PageRenderTime 31ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 118 lines | 50 code | 20 blank | 48 comment | 0 complexity | 7a384596cc748f2e41606649401b8087 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  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 </a>
  41. */
  42. public class OriginatingParticipatingServiceProviderTest extends ParameterHarness {
  43. /**
  44. * @throws IOException
  45. */
  46. public OriginatingParticipatingServiceProviderTest() throws IOException {
  47. super.badBodies.add(getBody3());
  48. super.goodBodies.add(new byte[1]);
  49. super.goodBodies.add(getBody1());
  50. }
  51. @Test(groups = { "functional.encode","functional.decode","parameter"})
  52. public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
  53. InvocationTargetException, IOException, ParameterException {
  54. OriginatingParticipatingServiceProviderImpl bci = new OriginatingParticipatingServiceProviderImpl(getBody1());
  55. String[] methodNames = { "isOddFlag", "getAddress", "getOpspLengthIndicator" };
  56. Object[] expectedValues = { false, super.getSixDigitsString(), 3 };
  57. super.testValues(bci, methodNames, expectedValues);
  58. }
  59. @Test(groups = { "functional.encode","functional.decode","parameter"})
  60. public void testBody2EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
  61. InvocationTargetException, IOException, ParameterException {
  62. OriginatingParticipatingServiceProviderImpl bci = new OriginatingParticipatingServiceProviderImpl(getBody2());
  63. String[] methodNames = { "isOddFlag", "getAddress", "getOpspLengthIndicator" };
  64. Object[] expectedValues = { true, super.getFiveDigitsString(), 3 };
  65. super.testValues(bci, methodNames, expectedValues);
  66. }
  67. private byte[] getBody1() throws IOException {
  68. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  69. // we will use odd number of digits, so we leave zero as MSB
  70. bos.write(3);
  71. bos.write(super.getSixDigits());
  72. return bos.toByteArray();
  73. }
  74. private byte[] getBody2() throws IOException {
  75. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  76. // we will use odd number of digits, so we leave zero as MSB
  77. bos.write(3 | 0x80);
  78. bos.write(super.getFiveDigits());
  79. return bos.toByteArray();
  80. }
  81. private byte[] getBody3() throws IOException {
  82. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  83. // we will use odd number of digits, so we leave zero as MSB
  84. bos.write(4);
  85. bos.write(super.getEightDigits());
  86. return bos.toByteArray();
  87. }
  88. /*
  89. * (non-Javadoc)
  90. *
  91. * @see
  92. * org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent
  93. * ()
  94. */
  95. public AbstractISUPParameter getTestedComponent() {
  96. return new OriginatingParticipatingServiceProviderImpl("1234");
  97. }
  98. }