/protocols/ss7/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/CallReferenceTest.java

http://mobicents.googlecode.com/ · Java · 112 lines · 44 code · 19 blank · 49 comment · 0 complexity · 142868c443dbe507ba4bb7c9f82a3cb8 MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. /**
  23. * Start time:14:11:03 2009-04-23<br>
  24. * Project: mobicents-isup-stack<br>
  25. *
  26. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
  27. * </a>
  28. *
  29. */
  30. package org.mobicents.protocols.ss7.isup.impl.message.parameter;
  31. import java.io.IOException;
  32. import java.lang.reflect.InvocationTargetException;
  33. import org.mobicents.protocols.ss7.isup.ParameterException;
  34. import org.testng.annotations.Test;
  35. /**
  36. * Start time:14:11:03 2009-04-23<br>
  37. * Project: mobicents-isup-stack<br>
  38. *
  39. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
  40. * </a>
  41. */
  42. public class CallReferenceTest extends ParameterHarness {
  43. /**
  44. * @throws IOException
  45. */
  46. public CallReferenceTest() throws IOException {
  47. super.badBodies.add(new byte[1]);
  48. super.badBodies.add(new byte[2]);
  49. super.badBodies.add(new byte[3]);
  50. super.badBodies.add(new byte[4]);
  51. super.badBodies.add(new byte[6]);
  52. super.goodBodies.add(getBody2());
  53. }
  54. private byte[] getBody1() throws IOException {
  55. // we will use odd number of digits, so we leave zero as MSB
  56. byte[] body = new byte[5];
  57. body[0]=12;
  58. body[1]=73;
  59. body[2]=120;
  60. body[3]=73;
  61. body[4]=120;
  62. return body;
  63. }
  64. private byte[] getBody2() throws IOException {
  65. // we will use odd number of digits, so we leave zero as MSB
  66. byte[] body = new byte[5];
  67. body[0]=12;
  68. body[1]=73;
  69. body[2]=120;
  70. body[3]=73;
  71. //one MSB will be ignored.
  72. body[4]=120 & 0x3F;
  73. return body;
  74. }
  75. @Test(groups = { "functional.encode","functional.decode","parameter"})
  76. public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException {
  77. CallReferenceImpl cr = new CallReferenceImpl();
  78. cr.decode(getBody1());
  79. String[] methodNames = { "getCallIdentity","getSignalingPointCode"};
  80. Object[] expectedValues = { 805240,14409};
  81. super.testValues(cr, methodNames, expectedValues);
  82. }
  83. /*
  84. * (non-Javadoc)
  85. *
  86. * @see
  87. * org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent
  88. * ()
  89. */
  90. public AbstractISUPParameter getTestedComponent() throws ParameterException {
  91. return new CallReferenceImpl();
  92. }
  93. }