PageRenderTime 24ms CodeModel.GetById 12ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/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
23package org.mobicents.protocols.ss7.map.service.sms;
24
25import java.util.Arrays;
26
27import org.mobicents.protocols.asn.AsnInputStream;
28import org.mobicents.protocols.asn.AsnOutputStream;
29import org.mobicents.protocols.asn.Tag;
30import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer;
31import org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo;
32import org.mobicents.protocols.ss7.map.primitives.MAPExtensionContainerTest;
33
34import static org.testng.Assert.*;
35import org.testng.*;import org.testng.annotations.*;
36
37/**
38 * 
39 * @author sergey vetyutnev
40 *
41 */
42public class MtForwardShortMessageResponseIndicationTest  {
43	
44	private byte[] getEncodedData() {
45		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,
46				42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 };
47	}
48	
49	@Test(groups = { "functional.decode","service.sms"})
50	public void testDecode() throws Exception {
51		
52		byte[] rawData = getEncodedData();
53		AsnInputStream asn = new AsnInputStream(rawData);
54
55		int tag = asn.readTag();
56		MtForwardShortMessageResponseIndicationImpl ind = new MtForwardShortMessageResponseIndicationImpl();
57		ind.decodeAll(asn);
58
59		assertEquals( tag,Tag.SEQUENCE);
60		assertEquals( asn.getTagClass(),Tag.CLASS_UNIVERSAL);
61
62		assertTrue(Arrays.equals(new byte[] { 11, 22, 33, 44, 55 }, ind.getSM_RP_UI().getData()));
63		assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ind.getExtensionContainer()));
64	}
65
66	@Test(groups = { "functional.encode","service.sms"})
67	public void testEncode() throws Exception {
68
69		SmsSignalInfo ui = new SmsSignalInfoImpl(new byte[] { 11, 22, 33, 44, 55 }, null);
70		MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer();
71		MtForwardShortMessageResponseIndicationImpl ind = new MtForwardShortMessageResponseIndicationImpl(ui, extensionContainer);
72		
73		AsnOutputStream asnOS = new AsnOutputStream();
74		ind.encodeAll(asnOS);
75		
76		byte[] encodedData = asnOS.toByteArray();
77		byte[] rawData = getEncodedData();		
78		assertTrue( Arrays.equals(rawData,encodedData));
79	}
80}