PageRenderTime 32ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 198 lines | 98 code | 35 blank | 65 comment | 2 complexity | ac0b2097bfe49799bec77bebfe758408 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  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:17:28:44 2009-04-26<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.ByteArrayOutputStream;
  32. import java.io.IOException;
  33. import java.lang.reflect.InvocationTargetException;
  34. import org.mobicents.protocols.ss7.isup.ParameterException;
  35. import org.mobicents.protocols.ss7.isup.message.parameter.InstructionIndicators;
  36. import org.testng.annotations.Test;
  37. import static org.testng.Assert.*;
  38. import org.testng.*;
  39. import org.testng.annotations.*;
  40. /**
  41. * Start time:17:28:44 2009-04-26<br>
  42. * Project: mobicents-isup-stack<br>
  43. *
  44. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
  45. * </a>
  46. */
  47. public class ParameterCompatibilityInformationTest extends ParameterHarness{
  48. private static final boolean[][] flags = new boolean[4][5];
  49. private static final int[][] intFlags = new int[4][2];
  50. private static final int _TRANSIT_EXCHANGE_INDEX = 0;
  51. private static final int _RLEASE_CALL_INDEX = 1;
  52. private static final int _SEND_NOTIFICATION_INDEX = 2;
  53. private static final int _DICARD_MESSAGE_INDEX = 3;
  54. private static final int _DISCARD_PARAMETER_INDEX = 4;
  55. private static final int _PASS_NOT_POSSIBLE_INDEX = 0;
  56. private static final int _BAND_INTERWORKING_INDEX = 1;
  57. static
  58. {
  59. intFlags[0][_BAND_INTERWORKING_INDEX] = 3;
  60. //1
  61. intFlags[0][_PASS_NOT_POSSIBLE_INDEX]=1;
  62. //0
  63. flags[0][_DISCARD_PARAMETER_INDEX]=false;
  64. //1
  65. flags[0][_DICARD_MESSAGE_INDEX]=true;
  66. //0
  67. flags[0][_SEND_NOTIFICATION_INDEX]=false;
  68. //1
  69. flags[0][_RLEASE_CALL_INDEX]=true;
  70. //1
  71. flags[0][_TRANSIT_EXCHANGE_INDEX]=true;
  72. //index = 1, its raw, we dont include
  73. //101111
  74. intFlags[2][_BAND_INTERWORKING_INDEX] = 1;
  75. //1
  76. intFlags[2][_PASS_NOT_POSSIBLE_INDEX]=1;
  77. //0
  78. flags[2][_DISCARD_PARAMETER_INDEX]=false;
  79. //1
  80. flags[2][_DICARD_MESSAGE_INDEX]=true;
  81. //1
  82. flags[2][_SEND_NOTIFICATION_INDEX]=true;
  83. //1
  84. flags[2][_RLEASE_CALL_INDEX]=true;
  85. //1
  86. flags[2][_TRANSIT_EXCHANGE_INDEX]=true;
  87. //111011
  88. intFlags[3][_BAND_INTERWORKING_INDEX] = 2;
  89. //1
  90. intFlags[3][_PASS_NOT_POSSIBLE_INDEX]=1;
  91. //1
  92. flags[3][_DISCARD_PARAMETER_INDEX]=true;
  93. //1
  94. flags[3][_DICARD_MESSAGE_INDEX]=true;
  95. //0
  96. flags[3][_SEND_NOTIFICATION_INDEX]=false;
  97. //1
  98. flags[3][_RLEASE_CALL_INDEX]=true;
  99. //1
  100. flags[3][_TRANSIT_EXCHANGE_INDEX]=true;
  101. }
  102. public ParameterCompatibilityInformationTest() {
  103. super();
  104. super.goodBodies.add(getBody1());
  105. }
  106. @Test(groups = { "functional.encode","functional.decode","parameter"})
  107. public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException {
  108. ParameterCompatibilityInformationImpl bci = new ParameterCompatibilityInformationImpl(getBody1());
  109. assertEquals(bci.size(),4, "Wrong number of instructions. ");
  110. //Yeah this is different
  111. for(int index = 0 ; index< bci.size() ; index++)
  112. {
  113. //this is raw, we dotn validate
  114. if(index ==1)
  115. continue;
  116. InstructionIndicators ii = bci.getInstructionIndicators(index);
  117. String[] methodNames = { "getBandInterworkingIndicator",
  118. "getPassOnNotPossibleIndicator",
  119. "isDiscardParameterIndicator",
  120. "isDiscardMessageIndicator",
  121. "isSendNotificationIndicator",
  122. "isReleaseCallindicator",
  123. "isTransitAtIntermediateExchangeIndicator"};
  124. Object[] expectedValues = {
  125. intFlags[index][_BAND_INTERWORKING_INDEX] ,
  126. //1
  127. intFlags[index][_PASS_NOT_POSSIBLE_INDEX],
  128. //0
  129. flags[index][_DISCARD_PARAMETER_INDEX],
  130. //1
  131. flags[index][_DICARD_MESSAGE_INDEX],
  132. //0
  133. flags[index][_SEND_NOTIFICATION_INDEX],
  134. //1
  135. flags[index][_RLEASE_CALL_INDEX],
  136. //1
  137. flags[index][_TRANSIT_EXCHANGE_INDEX]};
  138. super.testValues((AbstractISUPParameter)ii, methodNames, expectedValues);
  139. }
  140. byte parameterCode = bci.getParameterCode(0);
  141. assertEquals( parameterCode,1,"Wrong parameter code");
  142. }
  143. private byte[] getBody1() {
  144. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  145. bos.write(1);
  146. bos.write(0x80 | 0x2B);
  147. bos.write(3);
  148. bos.write(2);
  149. bos.write(0x80 | 0x2B);
  150. bos.write(0x80 | 3);
  151. bos.write(12);
  152. bos.write(3);
  153. bos.write(0x80 | 0x2F);
  154. bos.write(1);
  155. bos.write(4);
  156. bos.write(0x80 | 0x3B);
  157. bos.write(2);
  158. return bos.toByteArray();
  159. }
  160. public AbstractISUPParameter getTestedComponent() {
  161. return new ParameterCompatibilityInformationImpl();
  162. }
  163. }