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

/protocols/ss7/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/service/supplementary/ProcessUnstructuredSSResponseIndicationTest.java

http://mobicents.googlecode.com/
Java | 91 lines | 48 code | 18 blank | 25 comment | 0 complexity | cdff34d653cf5589d17cbceeefc0e079 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/or its affiliates, and individual
  4. * contributors as indicated by the @authors tag. All rights reserved.
  5. * See the copyright.txt in the distribution for a full listing
  6. * of individual contributors.
  7. *
  8. * This copyrighted material is made available to anyone wishing to use,
  9. * modify, copy, or redistribute it subject to the terms and conditions
  10. * of the GNU General Public License, v. 2.0.
  11. *
  12. * This program 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. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License,
  18. * v. 2.0 along with this distribution; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  20. * MA 02110-1301, USA.
  21. */
  22. package org.mobicents.protocols.ss7.map.service.supplementary;
  23. import static org.testng.Assert.*;
  24. import org.testng.*;
  25. import org.testng.annotations.*;
  26. import java.util.Arrays;
  27. import org.mobicents.protocols.asn.AsnInputStream;
  28. import org.mobicents.protocols.asn.AsnOutputStream;
  29. import org.mobicents.protocols.ss7.map.api.primitives.USSDString;
  30. import org.mobicents.protocols.ss7.map.primitives.USSDStringImpl;
  31. /**
  32. * @author abhayani
  33. *
  34. */
  35. public class ProcessUnstructuredSSResponseIndicationTest {
  36. @BeforeClass
  37. public static void setUpClass() throws Exception {
  38. }
  39. @AfterClass
  40. public static void tearDownClass() throws Exception {
  41. }
  42. @BeforeTest
  43. public void setUp() {
  44. }
  45. @AfterTest
  46. public void tearDown() {
  47. }
  48. @Test(groups = { "functional.decode","service.ussd"})
  49. public void testDecode() throws Exception {
  50. byte[] data = new byte[] { 0x30, 0x15, 0x04, 0x01, 0x0f, 0x04, 0x10, (byte) 0xd9, 0x77, 0x5d, 0x0e, 0x12, (byte) 0x87, (byte) 0xd9, 0x61, (byte) 0xf7,
  51. (byte) 0xb8, 0x0c, (byte) 0xea, (byte) 0x81, 0x66, 0x35, 0x18 };
  52. AsnInputStream asn = new AsnInputStream(data);
  53. int tag = asn.readTag();
  54. ProcessUnstructuredSSResponseIndicationImpl addNum = new ProcessUnstructuredSSResponseIndicationImpl();
  55. addNum.decodeAll(asn);
  56. byte dataCodingScheme = addNum.getUSSDDataCodingScheme();
  57. assertEquals( dataCodingScheme,(byte) 0x0f);
  58. USSDString ussdString = addNum.getUSSDString();
  59. assertNotNull(ussdString);
  60. assertEquals( ussdString.getString(),"Your balance = 350");
  61. }
  62. @Test(groups = { "functional.encode","service.ussd"})
  63. public void testEncode() throws Exception {
  64. byte[] data = new byte[] { 0x30, 0x15, 0x04, 0x01, 0x0f, 0x04, 0x10, (byte) 0xd9, 0x77, 0x5d, 0x0e, 0x12, (byte) 0x87, (byte) 0xd9, 0x61, (byte) 0xf7,
  65. (byte) 0xb8, 0x0c, (byte) 0xea, (byte) 0x81, 0x66, 0x35, 0x18 };
  66. USSDString ussdStr = new USSDStringImpl("Your balance = 350", null);
  67. ProcessUnstructuredSSResponseIndicationImpl addNum = new ProcessUnstructuredSSResponseIndicationImpl((byte) 0x0f, ussdStr);
  68. AsnOutputStream asnOS = new AsnOutputStream();
  69. addNum.encodeAll(asnOS);
  70. byte[] encodedData = asnOS.toByteArray();
  71. assertTrue( Arrays.equals(data,encodedData));
  72. }
  73. }