PageRenderTime 40ms CodeModel.GetById 33ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/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
 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
30import org.mobicents.protocols.asn.AsnInputStream;
31import org.mobicents.protocols.asn.AsnOutputStream;
32import org.mobicents.protocols.ss7.map.api.primitives.USSDString;
33import org.mobicents.protocols.ss7.map.primitives.USSDStringImpl;
34
35/**
36 * @author abhayani
37 * 
38 */
39public class ProcessUnstructuredSSResponseIndicationTest {
40	@BeforeClass
41	public static void setUpClass() throws Exception {
42	}
43
44	@AfterClass
45	public static void tearDownClass() throws Exception {
46	}
47
48	@BeforeTest
49	public void setUp() {
50	}
51
52	@AfterTest
53	public void tearDown() {
54	}
55
56	@Test(groups = { "functional.decode","service.ussd"})
57	public void testDecode() throws Exception {
58		byte[] data = new byte[] { 0x30, 0x15, 0x04, 0x01, 0x0f, 0x04, 0x10, (byte) 0xd9, 0x77, 0x5d, 0x0e, 0x12, (byte) 0x87, (byte) 0xd9, 0x61, (byte) 0xf7,
59				(byte) 0xb8, 0x0c, (byte) 0xea, (byte) 0x81, 0x66, 0x35, 0x18 };
60
61		AsnInputStream asn = new AsnInputStream(data);
62		int tag = asn.readTag();
63
64		ProcessUnstructuredSSResponseIndicationImpl addNum = new ProcessUnstructuredSSResponseIndicationImpl();
65		addNum.decodeAll(asn);
66		byte dataCodingScheme = addNum.getUSSDDataCodingScheme();
67		assertEquals( dataCodingScheme,(byte) 0x0f);
68
69		USSDString ussdString = addNum.getUSSDString();
70		assertNotNull(ussdString);
71
72		assertEquals( ussdString.getString(),"Your balance = 350");
73
74	}
75
76	@Test(groups = { "functional.encode","service.ussd"})
77	public void testEncode() throws Exception {
78		byte[] data = new byte[] { 0x30, 0x15, 0x04, 0x01, 0x0f, 0x04, 0x10, (byte) 0xd9, 0x77, 0x5d, 0x0e, 0x12, (byte) 0x87, (byte) 0xd9, 0x61, (byte) 0xf7,
79				(byte) 0xb8, 0x0c, (byte) 0xea, (byte) 0x81, 0x66, 0x35, 0x18 };
80
81		USSDString ussdStr = new USSDStringImpl("Your balance = 350", null);
82		ProcessUnstructuredSSResponseIndicationImpl addNum = new ProcessUnstructuredSSResponseIndicationImpl((byte) 0x0f, ussdStr);
83
84		AsnOutputStream asnOS = new AsnOutputStream();
85		addNum.encodeAll(asnOS);
86
87		byte[] encodedData = asnOS.toByteArray();
88
89		assertTrue( Arrays.equals(data,encodedData));
90	}
91}