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

http://mobicents.googlecode.com/ · Java · 96 lines · 34 code · 13 blank · 49 comment · 0 complexity · 9a8615490fffc832231bee39c5fb9bca 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 org.mobicents.protocols.ss7.isup.ParameterException;
  34. import org.mobicents.protocols.ss7.isup.message.parameter.GVNSUserGroup;
  35. import org.mobicents.protocols.ss7.isup.message.parameter.OriginatingParticipatingServiceProvider;
  36. import org.mobicents.protocols.ss7.isup.message.parameter.TerminatingNetworkRoutingNumber;
  37. /**
  38. * Start time:14:11:03 2009-04-23<br>
  39. * Project: mobicents-isup-stack<br>
  40. *
  41. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
  42. * </a>
  43. */
  44. public class ForwardGVNSTest extends ParameterHarness {
  45. /**
  46. * @throws IOException
  47. * @throws ParameterException
  48. */
  49. public ForwardGVNSTest() throws IOException, ParameterException {
  50. super.goodBodies.add(getBody(getSixDigitsString(),getSixDigitsString(),getFiveDigitsString()));
  51. }
  52. private byte[] getBody(String bs, String bs2, String bs3) throws ParameterException, IOException
  53. {
  54. //those are tested in other junits.
  55. OriginatingParticipatingServiceProviderImpl ops = new OriginatingParticipatingServiceProviderImpl();
  56. ops.setAddress(bs);
  57. GVNSUserGroupImpl gvns = new GVNSUserGroupImpl();
  58. gvns.setAddress(bs2);
  59. TerminatingNetworkRoutingNumberImpl tnrn = new TerminatingNetworkRoutingNumberImpl();
  60. tnrn.setAddress(bs3);
  61. tnrn.setNumberingPlanIndicator(tnrn._NPI_TELEX);
  62. tnrn.setNatureOfAddressIndicator(tnrn._NAI_NATIONAL_SN);
  63. return getBody(ops,gvns,tnrn);
  64. }
  65. private byte[] getBody(OriginatingParticipatingServiceProvider ops,GVNSUserGroup gnvs,TerminatingNetworkRoutingNumber tnrn) throws ParameterException, IOException {
  66. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  67. //bit weird tests...
  68. bos.write( ((AbstractISUPParameter)ops).encode());
  69. bos.write( ((AbstractISUPParameter)gnvs).encode());
  70. bos.write( ((AbstractISUPParameter)tnrn).encode());
  71. return bos.toByteArray();
  72. }
  73. /*
  74. * (non-Javadoc)
  75. *
  76. * @see
  77. * org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent
  78. * ()
  79. */
  80. public AbstractISUPParameter getTestedComponent() {
  81. return new ForwardGVNSImpl();
  82. }
  83. }