PageRenderTime 100ms CodeModel.GetById 83ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/ss7/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/dialog/MAPSimpleDialogTest.java

http://mobicents.googlecode.com/
Java | 97 lines | 48 code | 23 blank | 26 comment | 0 complexity | 8da773b5ede0f838563c2f76409bfde4 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.dialog;
24
25import java.util.Arrays;
26
27import static org.testng.Assert.*;import org.testng.*;import org.testng.annotations.*;
28
29import org.mobicents.protocols.asn.AsnInputStream;
30import org.mobicents.protocols.asn.AsnOutputStream;
31import org.mobicents.protocols.ss7.map.primitives.MAPExtensionContainerTest;
32
33/**
34 * 
35 * @author sergey vetyutnev
36 * 
37 */
38public class MAPSimpleDialogTest   {
39
40	private byte[] getDataAcceptInfo() {
41		return new byte[] { -95, 41, 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, 42, 3, 5, 21, 22, 23,
42				24, 25, 26, -95, 3, 31, 32, 33 };
43	}
44
45	private byte[] getDataCloseInfo() {
46		return new byte[] { -94, 41, 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, 42, 3, 5, 21, 22, 23,
47				24, 25, 26, -95, 3, 31, 32, 33 };
48	}
49	
50	@Test(groups = { "functional.decode","dialog"})
51	public void testDecode() throws Exception {
52
53		AsnInputStream asnIs = new AsnInputStream(this.getDataAcceptInfo());
54
55		int tag = asnIs.readTag();
56		assertEquals( tag,1);
57
58		MAPAcceptInfoImpl accInfo = new MAPAcceptInfoImpl();
59		accInfo.decodeAll(asnIs);
60		assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(accInfo.getExtensionContainer()));
61
62		
63		asnIs = new AsnInputStream(this.getDataCloseInfo());
64
65		tag = asnIs.readTag();
66		assertEquals( tag,2);
67
68		MAPCloseInfoImpl closeInfo = new MAPCloseInfoImpl();
69		closeInfo.decodeAll(asnIs);
70		assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(closeInfo.getExtensionContainer()));
71		
72	}
73
74	@Test(groups = { "functional.encode","dialog"})
75	public void testEncode() throws Exception {
76
77		byte[] b = this.getDataAcceptInfo();
78		MAPAcceptInfoImpl accInfo = new MAPAcceptInfoImpl();
79		accInfo.setExtensionContainer(MAPExtensionContainerTest.GetTestExtensionContainer());
80
81		AsnOutputStream asnOS = new AsnOutputStream();
82		accInfo.encodeAll(asnOS);
83		byte[] data = asnOS.toByteArray();
84		assertTrue( Arrays.equals(b,data));
85
86		
87		b = this.getDataCloseInfo();
88		MAPCloseInfoImpl closeInfo = new MAPCloseInfoImpl();
89		closeInfo.setExtensionContainer(MAPExtensionContainerTest.GetTestExtensionContainer());
90
91		asnOS = new AsnOutputStream();
92		closeInfo.encodeAll(asnOS);
93		data = asnOS.toByteArray();
94		assertTrue( Arrays.equals(b,data));
95	}
96	
97}