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

http://mobicents.googlecode.com/ · Java · 99 lines · 51 code · 12 blank · 36 comment · 0 complexity · 7cfc13afb7148e1a7252b597864c6aa8 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:36:27 2009-04-27<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:11:36:27 2009-04-27<br>
  38. * Project: mobicents-isup-stack<br>
  39. *
  40. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
  41. * </a>
  42. */
  43. public class UserTeleserviceInformationTest extends ParameterHarness {
  44. public UserTeleserviceInformationTest() {
  45. super();
  46. super.goodBodies.add(getBody(UserTeleserviceInformationImpl._PRESENTATION_METHOD_HLPP, UserTeleserviceInformationImpl._INTERPRETATION_FHGCI, UserTeleserviceInformationImpl._CODING_STANDARD_ISO_IEC,
  47. UserTeleserviceInformationImpl._HLCI_IVTI));
  48. super.goodBodies.add(getBody(UserTeleserviceInformationImpl._PRESENTATION_METHOD_HLPP, UserTeleserviceInformationImpl._INTERPRETATION_FHGCI, UserTeleserviceInformationImpl._CODING_STANDARD_ISO_IEC,
  49. UserTeleserviceInformationImpl._HLCI_AUDIO_VID_LOW_RANGE));
  50. super.goodBodies.add(getBody(UserTeleserviceInformationImpl._PRESENTATION_METHOD_HLPP, UserTeleserviceInformationImpl._INTERPRETATION_FHGCI, UserTeleserviceInformationImpl._CODING_STANDARD_ISO_IEC,
  51. UserTeleserviceInformationImpl._HLCI_AUDIO_VID_LOW_RANGE, UserTeleserviceInformationImpl._EACI_CSIC_AA_3_1_CALL));
  52. }
  53. @Test(groups = { "functional.encode","functional.decode","parameter"})
  54. public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException {
  55. UserTeleserviceInformationImpl bci = new UserTeleserviceInformationImpl(getBody(UserTeleserviceInformationImpl._PRESENTATION_METHOD_HLPP, UserTeleserviceInformationImpl._INTERPRETATION_FHGCI,
  56. UserTeleserviceInformationImpl._CODING_STANDARD_ISO_IEC, UserTeleserviceInformationImpl._HLCI_IVTI));
  57. String[] methodNames = { "getPresentationMethod", "getInterpretation", "getCodingStandard", "getHighLayerCharIdentification" };
  58. Object[] expectedValues = { UserTeleserviceInformationImpl._PRESENTATION_METHOD_HLPP, UserTeleserviceInformationImpl._INTERPRETATION_FHGCI, UserTeleserviceInformationImpl._CODING_STANDARD_ISO_IEC,
  59. UserTeleserviceInformationImpl._HLCI_IVTI };
  60. super.testValues(bci, methodNames, expectedValues);
  61. }
  62. @Test(groups = { "functional.encode","functional.decode","parameter"})
  63. public void testBody2EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException {
  64. UserTeleserviceInformationImpl bci = new UserTeleserviceInformationImpl(getBody(UserTeleserviceInformationImpl._PRESENTATION_METHOD_HLPP, UserTeleserviceInformationImpl._INTERPRETATION_FHGCI,
  65. UserTeleserviceInformationImpl._CODING_STANDARD_ISO_IEC, UserTeleserviceInformationImpl._HLCI_AUDIO_VID_LOW_RANGE, UserTeleserviceInformationImpl._EACI_CSIC_AA_3_1_CALL));
  66. String[] methodNames = { "getPresentationMethod", "getInterpretation", "getCodingStandard", "getHighLayerCharIdentification", "getEVidedoTelephonyCharIdentification" };
  67. Object[] expectedValues = { UserTeleserviceInformationImpl._PRESENTATION_METHOD_HLPP, UserTeleserviceInformationImpl._INTERPRETATION_FHGCI, UserTeleserviceInformationImpl._CODING_STANDARD_ISO_IEC,
  68. UserTeleserviceInformationImpl._HLCI_AUDIO_VID_LOW_RANGE, UserTeleserviceInformationImpl._EACI_CSIC_AA_3_1_CALL };
  69. super.testValues(bci, methodNames, expectedValues);
  70. }
  71. private byte[] getBody(int _PRESENTATION_METHOD, int _INTERPRETATION, int _CODING_STANDARD, int _HLCI) {
  72. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  73. bos.write(0x80 | (_CODING_STANDARD << 5) | (_INTERPRETATION << 2) | _PRESENTATION_METHOD);
  74. bos.write(0x80 | _HLCI);
  75. return bos.toByteArray();
  76. }
  77. private byte[] getBody(int _PRESENTATION_METHOD, int _INTERPRETATION, int _CODING_STANDARD, int _HLCI, int _EACI) {
  78. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  79. bos.write(0x80 | (_CODING_STANDARD << 5) | (_INTERPRETATION << 2) | _PRESENTATION_METHOD);
  80. bos.write(_HLCI);
  81. bos.write(0x80 | _EACI);
  82. return bos.toByteArray();
  83. }
  84. public AbstractISUPParameter getTestedComponent() {
  85. return new UserTeleserviceInformationImpl(1, 1, 1, 1);
  86. }
  87. }