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

http://mobicents.googlecode.com/ · Java · 85 lines · 27 code · 15 blank · 43 comment · 0 complexity · af823a65d28cd08f7d780d4dc0abfe1d 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:13:20:04 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.IOException;
  32. import org.mobicents.protocols.ss7.isup.ParameterException;
  33. import org.testng.annotations.Test;
  34. /**
  35. * Start time:13:20:04 2009-04-26<br>
  36. * Project: mobicents-isup-stack<br>
  37. *
  38. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
  39. * </a>
  40. */
  41. public class NatureOfConnectionIndicatorsTest extends ParameterHarness {
  42. public NatureOfConnectionIndicatorsTest() {
  43. super();
  44. super.badBodies.add(new byte[2]);
  45. super.goodBodies.add(new byte[1]);
  46. super.goodBodies.add(new byte[] { 0x0E });
  47. }
  48. @Test(groups = { "functional.encode","functional.decode","parameter"})
  49. public void testBody1EncodedValues() throws IOException, ParameterException {
  50. NatureOfConnectionIndicatorsImpl eci = new NatureOfConnectionIndicatorsImpl(getBody(NatureOfConnectionIndicatorsImpl._SI_ONE_SATELLITE, NatureOfConnectionIndicatorsImpl._CCI_REQUIRED_ON_THIS_CIRCUIT,
  51. NatureOfConnectionIndicatorsImpl._ECDI_INCLUDED));
  52. String[] methodNames = { "getSatelliteIndicator", "getContinuityCheckIndicator", "isEchoControlDeviceIndicator" };
  53. Object[] expectedValues = { NatureOfConnectionIndicatorsImpl._SI_ONE_SATELLITE, NatureOfConnectionIndicatorsImpl._CCI_REQUIRED_ON_THIS_CIRCUIT, NatureOfConnectionIndicatorsImpl._ECDI_INCLUDED };
  54. super.testValues(eci, methodNames, expectedValues);
  55. }
  56. private byte[] getBody(int siOneSatellite, int cciRequiredOnThisCircuit, boolean ecdiIncluded) {
  57. byte b= (byte) (siOneSatellite | (cciRequiredOnThisCircuit<<2) | (ecdiIncluded? (0x01<<4):(0x00 << 4)));
  58. return new byte[]{b};
  59. }
  60. /*
  61. * (non-Javadoc)
  62. *
  63. * @see
  64. * org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent
  65. * ()
  66. */
  67. public AbstractISUPParameter getTestedComponent() throws ParameterException {
  68. return new NatureOfConnectionIndicatorsImpl(new byte[1]);
  69. }
  70. }