PageRenderTime 26ms CodeModel.GetById 1ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 1ms

/protocols/ss7/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/service/sms/ReportSMDeliveryStatusResponseIndicationTest.java

http://mobicents.googlecode.com/
Java | 86 lines | 43 code | 17 blank | 26 comment | 0 complexity | 2320a2d8a965a0b38e49eefec4adc411 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.AddressNature;
31import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
32import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer;
33import org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan;
34import org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl;
35import org.mobicents.protocols.ss7.map.primitives.MAPExtensionContainerTest;
36
37import static org.testng.Assert.*;import org.testng.*;import org.testng.annotations.*;
38
39/**
40 * 
41 * @author sergey vetyutnev
42 *
43 */
44public class ReportSMDeliveryStatusResponseIndicationTest  {
45	
46	private byte[] getEncodedData() {
47		return new byte[] { 48, 49, 4, 6, -111, -120, 120, 119, 102, -10, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6,
48				48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 };
49	}
50	
51	@Test(groups = { "functional.decode","service.sms"})
52	public void testDecode() throws Exception {
53		
54		byte[] rawData = getEncodedData();
55		AsnInputStream asn = new AsnInputStream(rawData);
56
57		int tag = asn.readTag();
58		ReportSMDeliveryStatusResponseIndicationImpl ind = new ReportSMDeliveryStatusResponseIndicationImpl();
59		ind.decodeAll(asn);
60
61		assertEquals( tag,Tag.SEQUENCE);
62		assertEquals( asn.getTagClass(),Tag.CLASS_UNIVERSAL);
63
64		assertEquals( ind.getStoredMSISDN().getAddressNature(),AddressNature.international_number);
65		assertEquals( ind.getStoredMSISDN().getNumberingPlan(),NumberingPlan.ISDN);
66		assertEquals( ind.getStoredMSISDN().getAddress(),"888777666");
67		assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ind.getExtensionContainer()));
68	}
69
70	@Test(groups = { "functional.encode","service.sms"})
71	public void testEncode() throws Exception {
72
73		ISDNAddressString storedMSISDN = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "888777666");
74		MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer();
75		ReportSMDeliveryStatusResponseIndicationImpl ind = new ReportSMDeliveryStatusResponseIndicationImpl(storedMSISDN, extensionContainer);
76		
77		AsnOutputStream asnOS = new AsnOutputStream();
78		ind.encodeAll(asnOS);
79		
80		byte[] encodedData = asnOS.toByteArray();
81		byte[] rawData = getEncodedData();		
82		assertTrue( Arrays.equals(rawData,encodedData));
83	}
84}
85
86