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

http://mobicents.googlecode.com/ · Java · 94 lines · 35 code · 13 blank · 46 comment · 0 complexity · a37ad83e06edcfa4c4331b5f45598e32 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:11:34:01 2009-04-24<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 org.mobicents.protocols.ss7.isup.ParameterException;
  32. import org.testng.annotations.Test;
  33. /**
  34. * Start time:11:34:01 2009-04-24<br>
  35. * Project: mobicents-isup-stack<br>
  36. *
  37. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
  38. * </a>
  39. */
  40. public class InformationRequestIndicatorsTest extends ParameterHarness {
  41. private final static int _TURN_ON = 1;
  42. private final static int _TURN_OFF = 0;
  43. public InformationRequestIndicatorsTest() {
  44. super();
  45. //super.goodBodies.add(new byte[] { 67, 12 });
  46. //super.badBodies.add(new byte[3]);
  47. //super.badBodies.add(new byte[1]);
  48. }
  49. private byte[] getBody(boolean callingPartAddressRequestIndicator, boolean holdingIndicator, boolean callingpartysCategoryRequestIndicator, boolean chargeInformationRequestIndicator,
  50. boolean maliciousCallIdentificationRequestIndicator, int reserved) {
  51. int b0 = 0;
  52. int b1 = 0;
  53. b0 |= callingPartAddressRequestIndicator ? _TURN_ON : _TURN_OFF;
  54. b0 |= (holdingIndicator ? _TURN_ON : _TURN_OFF) << 1;
  55. b0 |= (callingpartysCategoryRequestIndicator ? _TURN_ON : _TURN_OFF) << 3;
  56. b0 |= (chargeInformationRequestIndicator ? _TURN_ON : _TURN_OFF) << 4;
  57. b0 |= (maliciousCallIdentificationRequestIndicator ? _TURN_ON : _TURN_OFF) << 7;
  58. b1 |= (reserved & 0x0F) << 4;
  59. return new byte[] { (byte) b0, (byte) b1 };
  60. }
  61. @Test(groups = { "functional.encode","functional.decode","parameter"})
  62. public void testBody1EncodedValues() throws ParameterException {
  63. InformationRequestIndicatorsImpl eci = new InformationRequestIndicatorsImpl(getBody(InformationRequestIndicatorsImpl._INDICATOR_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED,
  64. InformationRequestIndicatorsImpl._INDICATOR_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED, 10));
  65. String[] methodNames = { "isCallingPartAddressRequestIndicator", "isHoldingIndicator", "isCallingpartysCategoryRequestIndicator", "isChargeInformationRequestIndicator",
  66. "isMaliciousCallIdentificationRequestIndicator", "getReserved" };
  67. Object[] expectedValues = { InformationRequestIndicatorsImpl._INDICATOR_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_REQUESTED,
  68. InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED, 10 };
  69. super.testValues(eci, methodNames, expectedValues);
  70. }
  71. /*
  72. * (non-Javadoc)
  73. *
  74. * @see
  75. * org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent
  76. * ()
  77. */
  78. public AbstractISUPParameter getTestedComponent() throws ParameterException {
  79. return new InformationRequestIndicatorsImpl(new byte[2]);
  80. }
  81. }