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

http://mobicents.googlecode.com/ · Java · 133 lines · 46 code · 17 blank · 70 comment · 0 complexity · d542c4f6830548d9904270b232a15280 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:12:21:06 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.lang.reflect.InvocationTargetException;
  32. import org.mobicents.protocols.ss7.isup.ParameterException;
  33. import org.testng.annotations.Test;
  34. /**
  35. * Start time:12:21:06 2009-04-23<br>
  36. * Project: mobicents-isup-stack<br>
  37. * Class to test BCI
  38. *
  39. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
  40. * </a>
  41. */
  42. public class BackwardCallIndicatorsTest extends ParameterHarness {
  43. public BackwardCallIndicatorsTest() {
  44. super();
  45. super.badBodies.add(new byte[1]);
  46. super.badBodies.add(new byte[3]);
  47. super.goodBodies.add(getBody1());
  48. super.goodBodies.add(getBody2());
  49. }
  50. private byte[] getBody1() {
  51. byte[] body = new byte[2];
  52. // Chardi IND : 10 - charge
  53. // Called part status ind: 01 - sub free
  54. // Called part category ind: 10 - pay phone
  55. // e2emethod ind: 10 - sccp
  56. // whole: 10100110
  57. body[0] = (byte) 0xA6;
  58. // Interworking : 1 - encoutnered
  59. // e2einfo ind : 0 - no info
  60. // ISUP ind : 1 - all the way
  61. // hold ind : 1 - requested
  62. // ISDN acc ind : 1 - terminating acc isdn
  63. // echo ctrl dev: 0 - not included
  64. // SCCP m ind : 10 - connection oriented only
  65. // whole : 10011101
  66. body[1] = (byte) 0x9D;
  67. return body;
  68. }
  69. @Test(groups = { "functional.encode","functional.decode","parameter"})
  70. public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, ParameterException {
  71. BackwardCallIndicatorsImpl bci = new BackwardCallIndicatorsImpl(getBody1());
  72. String[] methodNames = { "getChargeIndicator", "getCalledPartysStatusIndicator", "getCalledPartysCategoryIndicator", "getEndToEndMethodIndicator", "isInterworkingIndicator",
  73. "isEndToEndInformationIndicator", "isIsdnUserPartIndicator", "isHoldingIndicator", "isIsdnAccessIndicator", "isEchoControlDeviceIndicator", "getSccpMethodIndicator" };
  74. Object[] expectedValues = { bci._CHARGE_INDICATOR_CHARGE, bci._CPSI_SUBSCRIBER_FREE, bci._CPCI_PAYPHONE, bci._ETEMI_SCCP,
  75. bci._II_IE, bci._ETEII_NO_IA, bci._ISDN_UPI_UATW, bci._HI_REQUESTED,bci._ISDN_AI_TA_ISDN, bci._ECDI_IECD_NOT_INCLUDED, bci._SCCP_MI_CONNECTION_ORIENTED };
  76. super.testValues(bci, methodNames, expectedValues);
  77. }
  78. private byte[] getBody2() {
  79. byte[] body = new byte[2];
  80. // Chardi IND : 01 - no charge
  81. // Called part status ind: 10 - conn when free
  82. // Called part category ind: 10 - pay phone
  83. // e2emethod ind: 11 - pass alond and sccp
  84. // whole: 11101001
  85. body[0] = (byte) 0xE9;
  86. // Interworking : 1 - encoutnered
  87. // e2einfo ind : 0 - no info
  88. // ISUP ind : 1 - all the way
  89. // hold ind : 1 - requested
  90. // ISDN acc ind : 1 - terminating acc isdn
  91. // echo ctrl dev: 1 - not included
  92. // SCCP m ind : 10 - connection oriented only
  93. // whole : 10111101
  94. body[1] = (byte) 0xBD;
  95. return body;
  96. }
  97. @Test(groups = { "functional.encode","functional.decode","parameter"})
  98. public void testBody2EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, ParameterException {
  99. BackwardCallIndicatorsImpl bci = new BackwardCallIndicatorsImpl(getBody2());
  100. String[] methodNames = { "getChargeIndicator", "getCalledPartysStatusIndicator", "getCalledPartysCategoryIndicator", "getEndToEndMethodIndicator", "isInterworkingIndicator",
  101. "isEndToEndInformationIndicator", "isIsdnUserPartIndicator", "isHoldingIndicator", "isIsdnAccessIndicator", "isEchoControlDeviceIndicator", "getSccpMethodIndicator" };
  102. Object[] expectedValues = { bci._CHARGE_INDICATOR_NOCHARGE, bci._CPSI_CONNECT_WHEN_FREE, bci._CPCI_PAYPHONE, bci._ETEMI_SCCP_AND_PASSALONG,
  103. bci._II_IE, bci._ETEII_NO_IA, bci._ISDN_UPI_UATW, bci._HI_REQUESTED,bci._ISDN_AI_TA_ISDN, bci._ECDI_IECD_INCLUDED, bci._SCCP_MI_CONNECTION_ORIENTED };
  104. super.testValues(bci, methodNames, expectedValues);
  105. }
  106. /*
  107. * (non-Javadoc)
  108. *
  109. * @see
  110. * org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent
  111. * ()
  112. */
  113. public AbstractISUPParameter getTestedComponent() throws ParameterException {
  114. return new org.mobicents.protocols.ss7.isup.impl.message.parameter.BackwardCallIndicatorsImpl(new byte[2]);
  115. }
  116. }