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

http://mobicents.googlecode.com/ · Java · 98 lines · 38 code · 13 blank · 47 comment · 1 complexity · c6bd40044232a256dac70d4657c2ed56 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.ByteArrayOutputStream;
  32. import java.io.IOException;
  33. import java.lang.reflect.InvocationTargetException;
  34. import org.mobicents.protocols.ss7.isup.ParameterException;
  35. import org.testng.annotations.Test;
  36. /**
  37. * Start time:14:11:03 2009-04-23<br>
  38. * Project: mobicents-isup-stack<br>
  39. *
  40. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
  41. * </a>
  42. */
  43. public class GVNSUserGroupTest extends ParameterHarness {
  44. /**
  45. * @throws IOException
  46. */
  47. public GVNSUserGroupTest() throws IOException {
  48. super.goodBodies.add(getBody(getSixDigits(), false));
  49. }
  50. private byte[] getBody(byte[] digits, boolean isODD) throws IOException {
  51. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  52. // we will use odd number of digits, so we leave zero as MSB
  53. int header = digits.length;
  54. if (isODD) {
  55. header |= 0x01 << 7;
  56. }
  57. bos.write(header);
  58. bos.write(digits);
  59. return bos.toByteArray();
  60. }
  61. @Test(groups = { "functional.encode","functional.decode","parameter"})
  62. public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException {
  63. GVNSUserGroupImpl bci = new GVNSUserGroupImpl(getBody(getSixDigits(), false));
  64. String[] methodNames = { "getAddress", "getGugLengthIndicator" };
  65. Object[] expectedValues = { getSixDigitsString(), 3 };
  66. super.testValues(bci, methodNames, expectedValues);
  67. }
  68. @Test(groups = { "functional.encode","functional.decode","parameter"})
  69. public void testBody2EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException {
  70. GVNSUserGroupImpl bci = new GVNSUserGroupImpl(getBody(getFiveDigits(), true));
  71. String[] methodNames = { "getAddress", "getGugLengthIndicator" };
  72. Object[] expectedValues = { getFiveDigitsString(), 3 };
  73. super.testValues(bci, methodNames, expectedValues);
  74. }
  75. /*
  76. * (non-Javadoc)
  77. *
  78. * @see
  79. * org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent
  80. * ()
  81. */
  82. public AbstractISUPParameter getTestedComponent() {
  83. return new GVNSUserGroupImpl("12");
  84. }
  85. }