PageRenderTime 62ms CodeModel.GetById 30ms app.highlight 28ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 98 lines | 54 code | 19 blank | 25 comment | 0 complexity | ce3fc4b84405e697d86d20d97082fe6b MD5 | raw file
 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 */
22package org.mobicents.protocols.ss7.map.service.supplementary;
23
24import static org.testng.Assert.*;
25import org.testng.*;
26import org.testng.annotations.*;
27
28import java.util.Arrays;
29
30
31import org.mobicents.protocols.asn.AsnInputStream;
32import org.mobicents.protocols.asn.AsnOutputStream;
33import org.mobicents.protocols.ss7.map.api.primitives.USSDString;
34import org.mobicents.protocols.ss7.map.primitives.USSDStringImpl;
35
36/**
37 * @author amit bhayani
38 * 
39 */
40public class UnstructuredSSRequestIndicationTest {
41	@BeforeClass
42	public static void setUpClass() throws Exception {
43	}
44
45	@AfterClass
46	public static void tearDownClass() throws Exception {
47	}
48
49	@BeforeTest
50	public void setUp() {
51	}
52
53	@AfterTest
54	public void tearDown() {
55	}
56
57	@Test(groups = { "functional.decode","service.ussd"})
58	public void testDecode() throws Exception {
59		byte[] data = new byte[] { 0x30, 0x3e, 0x04, 0x01, 0x0f, 0x04, 0x39, (byte) 0xd5, (byte) 0xe9, (byte) 0x94, 0x08, (byte) 0x9a, (byte) 0xd2,
60				(byte) 0xe5, 0x69, (byte) 0xf7, 0x19, (byte) 0xa4, 0x03, 0x21, (byte) 0xcb, 0x6c, (byte) 0xf6, 0x1b, 0x74, 0x7d, (byte) 0xcb, (byte) 0xd9,
61				0x64, 0x10, 0x6f, 0x28, (byte) 0xf5, (byte) 0x81, 0x62, 0x2e, (byte) 0x90, 0x30, (byte) 0xcc, 0x0e, (byte) 0xbb, (byte) 0xc7, 0x65, 0x10, 0x6f,
62				0x28, (byte) 0xf5, (byte) 0x81, 0x64, 0x2e, 0x10, (byte) 0xb5, (byte) 0x8c, (byte) 0xa7, (byte) 0xcf, 0x41, (byte) 0xd2, 0x72, 0x3b,
63				(byte) 0x9c, 0x76, (byte) 0xa7, (byte) 0xdd, 0x67 };
64
65		AsnInputStream asn = new AsnInputStream(data);
66		int tag = asn.readTag();
67
68		UnstructuredSSRequestIndicationImpl addNum = new UnstructuredSSRequestIndicationImpl();
69		addNum.decodeAll(asn);
70		byte dataCodingScheme = addNum.getUSSDDataCodingScheme();
71		assertEquals( dataCodingScheme,(byte) 0x0f);
72
73		USSDString ussdString = addNum.getUSSDString();
74		assertNotNull(ussdString);
75
76		assertEquals( ussdString.getString(),"USSD String : Hello World <CR> 1. Balance <CR> 2. Texts Remaining");
77
78	}
79
80	@Test(groups = { "functional.encode","service.ussd"})
81	public void testEncode() throws Exception {
82		byte[] data = new byte[] { 0x30, 0x3e, 0x04, 0x01, 0x0f, 0x04, 0x39, (byte) 0xd5, (byte) 0xe9, (byte) 0x94, 0x08, (byte) 0x9a, (byte) 0xd2,
83				(byte) 0xe5, 0x69, (byte) 0xf7, 0x19, (byte) 0xa4, 0x03, 0x21, (byte) 0xcb, 0x6c, (byte) 0xf6, 0x1b, 0x74, 0x7d, (byte) 0xcb, (byte) 0xd9,
84				0x64, 0x10, 0x6f, 0x28, (byte) 0xf5, (byte) 0x81, 0x62, 0x2e, (byte) 0x90, 0x30, (byte) 0xcc, 0x0e, (byte) 0xbb, (byte) 0xc7, 0x65, 0x10, 0x6f,
85				0x28, (byte) 0xf5, (byte) 0x81, 0x64, 0x2e, 0x10, (byte) 0xb5, (byte) 0x8c, (byte) 0xa7, (byte) 0xcf, 0x41, (byte) 0xd2, 0x72, 0x3b,
86				(byte) 0x9c, 0x76, (byte) 0xa7, (byte) 0xdd, 0x67 };
87
88		USSDString ussdStr = new USSDStringImpl("USSD String : Hello World <CR> 1. Balance <CR> 2. Texts Remaining", null);
89		UnstructuredSSRequestIndicationImpl addNum = new UnstructuredSSRequestIndicationImpl((byte) 0x0f, ussdStr, null, null);
90
91		AsnOutputStream asnOS = new AsnOutputStream();
92		addNum.encodeAll(asnOS);
93
94		byte[] encodedData = asnOS.toByteArray();
95
96		assertTrue( Arrays.equals(data,encodedData));
97	}
98}