PageRenderTime 59ms CodeModel.GetById 39ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 138 lines | 86 code | 26 blank | 26 comment | 0 complexity | 3134c8cc4ad37e9397a629bd336de562 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.api.service.sms.MWStatus;
 35import org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl;
 36import org.mobicents.protocols.ss7.map.primitives.MAPExtensionContainerTest;
 37
 38import junit.framework.Assert;
 39import static org.testng.Assert.*;import org.testng.*;import org.testng.annotations.*;
 40
 41/**
 42 * 
 43 * @author sergey vetyutnev
 44 *
 45 */
 46public class InformServiceCentreRequestIndicationTest  {
 47	
 48	private byte[] getEncodedData() {
 49		return new byte[] { 48, 4, 3, 2, 2, 64 };
 50	}
 51	
 52	private byte[] getEncodedDataFull() {
 53		return new byte[] { 48, 61, 4, 6, -111, 17, 33, 34, 51, -13, 3, 2, 2, 80, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42,
 54				3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 2, 2, 2, 43, -128, 2, 1, -68 };
 55	}
 56	
 57	@Test(groups = { "functional.decode","service.sms"})
 58	public void testDecode() throws Exception {
 59		
 60		byte[] rawData = getEncodedData();
 61		AsnInputStream asn = new AsnInputStream(rawData);
 62
 63		int tag = asn.readTag();
 64		InformServiceCentreRequestIndicationImpl isc = new InformServiceCentreRequestIndicationImpl();
 65		isc.decodeAll(asn);
 66
 67		assertEquals( tag,Tag.SEQUENCE);
 68		assertEquals( asn.getTagClass(),Tag.CLASS_UNIVERSAL);
 69		
 70		MWStatus mwStatus = isc.getMwStatus();
 71		assertNotNull(mwStatus);
 72		assertFalse(mwStatus.getScAddressNotIncluded());
 73		assertTrue(mwStatus.getMnrfSet());
 74		assertFalse(mwStatus.getMcefSet());
 75		assertFalse(mwStatus.getMnrgSet());
 76		
 77		rawData = getEncodedDataFull();
 78		asn = new AsnInputStream(rawData);
 79
 80		tag = asn.readTag();
 81		isc = new InformServiceCentreRequestIndicationImpl();
 82		isc.decodeAll(asn);
 83
 84		assertEquals( tag,Tag.SEQUENCE);
 85		assertEquals( asn.getTagClass(),Tag.CLASS_UNIVERSAL);
 86		
 87		MAPExtensionContainer extensionContainer = isc.getExtensionContainer();
 88		ISDNAddressString storedMSISDN = isc.getStoredMSISDN();
 89		mwStatus = isc.getMwStatus();
 90		int absentSubscriberDiagnosticSM = isc.getAbsentSubscriberDiagnosticSM();
 91		int additionalAbsentSubscriberDiagnosticSM = isc.getAdditionalAbsentSubscriberDiagnosticSM();
 92
 93		Assert.assertNotNull(storedMSISDN);
 94		Assert.assertEquals( AddressNature.international_number,storedMSISDN.getAddressNature());
 95		Assert.assertEquals( NumberingPlan.ISDN,storedMSISDN.getNumberingPlan());
 96		Assert.assertEquals( "111222333",storedMSISDN.getAddress());
 97		Assert.assertNotNull(mwStatus);
 98		Assert.assertFalse(mwStatus.getScAddressNotIncluded());
 99		Assert.assertTrue(mwStatus.getMnrfSet());
100		Assert.assertFalse(mwStatus.getMcefSet());
101		Assert.assertTrue(mwStatus.getMnrgSet());
102		Assert.assertNotNull(absentSubscriberDiagnosticSM);
103		Assert.assertEquals( 555,(int) absentSubscriberDiagnosticSM);
104		Assert.assertNotNull(additionalAbsentSubscriberDiagnosticSM);
105		Assert.assertEquals( 444,(int) additionalAbsentSubscriberDiagnosticSM);
106		Assert.assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer));
107	}
108
109	@Test(groups = { "functional.encode","service.sms"})
110	public void testEncode() throws Exception {
111		
112		MWStatus mwStatus = new MWStatusImpl(false, true, false, false);
113		InformServiceCentreRequestIndicationImpl isc = new InformServiceCentreRequestIndicationImpl(null, mwStatus, null, null, null);
114		
115		AsnOutputStream asnOS = new AsnOutputStream();
116		isc.encodeAll(asnOS);
117		
118		byte[] encodedData = asnOS.toByteArray();
119		byte[] rawData = getEncodedData();		
120		assertTrue( Arrays.equals(rawData,encodedData));
121
122		
123		ISDNAddressString storedMSISDN = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "111222333");
124		mwStatus = new MWStatusImpl(false, true, false, true);
125		Integer absentSubscriberDiagnosticSM = 555;
126		Integer additionalAbsentSubscriberDiagnosticSM = 444;
127		isc = new InformServiceCentreRequestIndicationImpl(storedMSISDN, mwStatus, MAPExtensionContainerTest.GetTestExtensionContainer(),
128				absentSubscriberDiagnosticSM, additionalAbsentSubscriberDiagnosticSM);
129		
130		asnOS.reset();
131		isc.encodeAll(asnOS);
132		
133		encodedData = asnOS.toByteArray();
134		rawData = getEncodedDataFull();		
135		assertTrue( Arrays.equals(rawData,encodedData));
136	}
137
138}