/protocols/ss7/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/service/sms/MtForwardShortMessageResponseIndicationTest.java

http://mobicents.googlecode.com/ · Java · 80 lines · 39 code · 15 blank · 26 comment · 0 complexity · 79682da4d4009b1cc9cd77e91a5f6d3e 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. package org.mobicents.protocols.ss7.map.service.sms;
  23. import java.util.Arrays;
  24. import org.mobicents.protocols.asn.AsnInputStream;
  25. import org.mobicents.protocols.asn.AsnOutputStream;
  26. import org.mobicents.protocols.asn.Tag;
  27. import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer;
  28. import org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo;
  29. import org.mobicents.protocols.ss7.map.primitives.MAPExtensionContainerTest;
  30. import static org.testng.Assert.*;
  31. import org.testng.*;import org.testng.annotations.*;
  32. /**
  33. *
  34. * @author sergey vetyutnev
  35. *
  36. */
  37. public class MtForwardShortMessageResponseIndicationTest {
  38. private byte[] getEncodedData() {
  39. return new byte[] { 48, 48, 4, 5, 11, 22, 33, 44, 55, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3,
  40. 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 };
  41. }
  42. @Test(groups = { "functional.decode","service.sms"})
  43. public void testDecode() throws Exception {
  44. byte[] rawData = getEncodedData();
  45. AsnInputStream asn = new AsnInputStream(rawData);
  46. int tag = asn.readTag();
  47. MtForwardShortMessageResponseIndicationImpl ind = new MtForwardShortMessageResponseIndicationImpl();
  48. ind.decodeAll(asn);
  49. assertEquals( tag,Tag.SEQUENCE);
  50. assertEquals( asn.getTagClass(),Tag.CLASS_UNIVERSAL);
  51. assertTrue(Arrays.equals(new byte[] { 11, 22, 33, 44, 55 }, ind.getSM_RP_UI().getData()));
  52. assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ind.getExtensionContainer()));
  53. }
  54. @Test(groups = { "functional.encode","service.sms"})
  55. public void testEncode() throws Exception {
  56. SmsSignalInfo ui = new SmsSignalInfoImpl(new byte[] { 11, 22, 33, 44, 55 }, null);
  57. MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer();
  58. MtForwardShortMessageResponseIndicationImpl ind = new MtForwardShortMessageResponseIndicationImpl(ui, extensionContainer);
  59. AsnOutputStream asnOS = new AsnOutputStream();
  60. ind.encodeAll(asnOS);
  61. byte[] encodedData = asnOS.toByteArray();
  62. byte[] rawData = getEncodedData();
  63. assertTrue( Arrays.equals(rawData,encodedData));
  64. }
  65. }