PageRenderTime 32ms CodeModel.GetById 14ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/ss7/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/service/lsm/ProvideSubscriberLocationRequestIndicationTest.java

http://mobicents.googlecode.com/
Java | 168 lines | 107 code | 32 blank | 29 comment | 0 complexity | 45276699090aa632deaccce903011fab 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.lsm;
 24
 25import static org.testng.Assert.*;import org.testng.*;import org.testng.annotations.*;
 26
 27import java.util.Arrays;
 28
 29import org.mobicents.protocols.asn.AsnInputStream;
 30import org.mobicents.protocols.asn.AsnOutputStream;
 31import org.mobicents.protocols.ss7.map.MAPParameterFactoryImpl;
 32import org.mobicents.protocols.ss7.map.api.MAPParameterFactory;
 33import org.mobicents.protocols.ss7.map.api.primitives.AddressNature;
 34import org.mobicents.protocols.ss7.map.api.primitives.IMSI;
 35import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
 36import org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan;
 37import org.mobicents.protocols.ss7.map.api.primitives.USSDString;
 38import org.mobicents.protocols.ss7.map.api.service.lsm.LCSClientID;
 39import org.mobicents.protocols.ss7.map.api.service.lsm.LCSClientInternalID;
 40import org.mobicents.protocols.ss7.map.api.service.lsm.LCSClientName;
 41import org.mobicents.protocols.ss7.map.api.service.lsm.LCSClientType;
 42import org.mobicents.protocols.ss7.map.api.service.lsm.LCSQoS;
 43import org.mobicents.protocols.ss7.map.api.service.lsm.LocationEstimateType;
 44import org.mobicents.protocols.ss7.map.api.service.lsm.LocationType;
 45import org.mobicents.protocols.ss7.map.api.service.lsm.ResponseTime;
 46import org.mobicents.protocols.ss7.map.api.service.lsm.ResponseTimeCategory;
 47import org.mobicents.protocols.ss7.map.api.service.lsm.SupportedGADShapes;
 48import org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl;
 49
 50/**
 51 * @author amit bhayani
 52 * 
 53 */
 54public class ProvideSubscriberLocationRequestIndicationTest {
 55
 56	MAPParameterFactory MAPParameterFactory = new MAPParameterFactoryImpl();
 57
 58	@BeforeClass
 59	public static void setUpClass() throws Exception {
 60	}
 61
 62	@AfterClass
 63	public static void tearDownClass() throws Exception {
 64	}
 65
 66	@BeforeTest
 67	public void setUp() {
 68	}
 69
 70	@AfterTest
 71	public void tearDown() {
 72	}
 73
 74	@Test(groups = { "functional.decode","service.lsm"})
 75	public void testDecodeProvideSubscriberLocationRequestIndication() throws Exception {
 76		// The trace is from Brazilian operator
 77		byte[] rawData = new byte[] { 0x30, 0x41, 0x30, 0x03, (byte) 0x80, 0x01, 0x00, 0x04, 0x05, (byte) 0x91, 0x55, 0x16, 0x09, 0x70, (byte) 0xa0, 0x1b,
 78				(byte) 0x80, 0x01, 0x02, (byte) 0x83, 0x01, 0x00, (byte) 0xa4, 0x13, (byte) 0x80, 0x01, 0x0f, (byte) 0x82, 0x0e, 0x6e, 0x72, (byte) 0xfb, 0x1c,
 79				(byte) 0x86, (byte) 0xc3, 0x65, 0x6e, 0x72, (byte) 0xfb, 0x1c, (byte) 0x86, (byte) 0xc3, 0x65, (byte) 0x82, 0x08, 0x27, (byte) 0x94,
 80				(byte) 0x99, 0x09, 0x00, 0x00, 0x00, (byte) 0xf7, (byte) 0x86, 0x01, 0x01, (byte) 0xa7, 0x05, (byte) 0xa3, 0x03, 0x0a, 0x01, 0x00, (byte) 0x89,
 81				0x02, 0x01, (byte) 0xfe };
 82
 83		AsnInputStream asn = new AsnInputStream(rawData);
 84
 85		int tag = asn.readTag();
 86
 87		ProvideSubscriberLocationRequestIndicationImpl reqInd = new ProvideSubscriberLocationRequestIndicationImpl();
 88		reqInd.decodeAll(asn);
 89
 90		LocationType locationType = reqInd.getLocationType();
 91		assertNotNull(locationType);
 92		assertEquals( locationType.getLocationEstimateType(),LocationEstimateType.currentLocation);
 93
 94		ISDNAddressString mlcNumber = reqInd.getMlcNumber();
 95		assertNotNull(mlcNumber);
 96		assertEquals( mlcNumber.getAddressNature(),AddressNature.international_number);
 97		assertEquals( mlcNumber.getNumberingPlan(),NumberingPlan.ISDN);
 98		assertEquals( mlcNumber.getAddress(),"55619007");
 99
100		LCSClientID lcsClientId = reqInd.getLCSClientID();
101		assertNotNull(lcsClientId);
102		assertEquals( lcsClientId.getLCSClientType(),LCSClientType.plmnOperatorServices);
103		assertEquals( lcsClientId.getLCSClientInternalID(),LCSClientInternalID.broadcastService);
104		LCSClientName lcsClientName = lcsClientId.getLCSClientName();
105		assertNotNull(lcsClientName);
106		assertEquals( lcsClientName.getDataCodingScheme(),(byte) 0x0f);
107		assertEquals( lcsClientName.getNameString().getString(),"ndmgapp2ndmgapp2");
108
109		IMSI imsi = reqInd.getIMSI();
110		assertNotNull(imsi);
111//		assertEquals( imsi.getMCC(),new Long(724l));
112//		assertEquals( imsi.getMNC(),new Long(99l));
113		assertEquals( imsi.getData(),"724999900000007");
114
115		assertEquals( reqInd.getLCSPriority(),new Integer(1));
116
117		LCSQoS lcsQoS = reqInd.getLCSQoS();
118		assertNotNull(lcsQoS);
119		ResponseTime respTime = lcsQoS.getResponseTime();
120		assertNotNull(respTime);
121		assertEquals( respTime.getResponseTimeCategory(),ResponseTimeCategory.lowdelay);
122
123		SupportedGADShapes suppGadShapes = reqInd.getSupportedGADShapes();
124		assertNotNull(suppGadShapes);
125		assertTrue(suppGadShapes.getEllipsoidArc());
126		assertTrue(suppGadShapes.getEllipsoidPoint());
127		assertTrue(suppGadShapes.getEllipsoidPointWithAltitude());
128		assertTrue(suppGadShapes.getEllipsoidPointWithAltitudeAndUncertaintyElipsoid());
129
130		assertTrue(suppGadShapes.getEllipsoidPointWithUncertaintyCircle());
131		assertTrue(suppGadShapes.getEllipsoidPointWithUncertaintyEllipse());
132		assertTrue(suppGadShapes.getPolygon());
133	}
134
135	@Test(groups = { "functional.encode","service.lsm"})
136	public void testEncode() throws Exception {
137		// The trace is from Brazilian operator
138		byte[] data = new byte[] { 0x30, 0x41, 0x30, 0x03, (byte) 0x80, 0x01, 0x00, 0x04, 0x05, (byte) 0x91, 0x55, 0x16, 0x09, 0x70, (byte) 0xa0, 0x1b,
139				(byte) 0x80, 0x01, 0x02, (byte) 0x83, 0x01, 0x00, (byte) 0xa4, 0x13, (byte) 0x80, 0x01, 0x0f, (byte) 0x82, 0x0e, 0x6e, 0x72, (byte) 0xfb, 0x1c,
140				(byte) 0x86, (byte) 0xc3, 0x65, 0x6e, 0x72, (byte) 0xfb, 0x1c, (byte) 0x86, (byte) 0xc3, 0x65, (byte) 0x82, 0x08, 0x27, (byte) 0x94,
141				(byte) 0x99, 0x09, 0x00, 0x00, 0x00, (byte) 0xf7, (byte) 0x86, 0x01, 0x01, (byte) 0xa7, 0x05, (byte) 0xa3, 0x03, 0x0a, 0x01, 0x00, (byte) 0x89,
142				0x02, 0x01, (byte) 0xfe };
143
144		LocationType locationType = new LocationTypeImpl(LocationEstimateType.currentLocation, null);
145		ISDNAddressString mlcNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "55619007");
146
147		USSDString nameString = MAPParameterFactory.createUSSDString("ndmgapp2ndmgapp2");
148		LCSClientName lcsClientName = new LCSClientNameImpl((byte) 0x0f, nameString, null);
149
150		LCSClientID lcsClientID = new LCSClientIDImpl(LCSClientType.plmnOperatorServices, null, LCSClientInternalID.broadcastService, lcsClientName, null,
151				null, null);
152
153		IMSI imsi = MAPParameterFactory.createIMSI("724999900000007");
154
155		LCSQoS lcsQoS = new LCSQoSImpl(null, null, null, new ResponseTimeImpl(ResponseTimeCategory.lowdelay), null);
156
157		SupportedGADShapes supportedGADShapes = new SupportedGADShapesImpl(true, true, true, true, true, true, true);
158
159		ProvideSubscriberLocationRequestIndicationImpl reqInd = new ProvideSubscriberLocationRequestIndicationImpl(locationType, mlcNumber, lcsClientID, null,
160				imsi, null, null, null, 1, lcsQoS, null, supportedGADShapes, null, null, null, null, null, null);
161
162		AsnOutputStream asnOS = new AsnOutputStream();
163		reqInd.encodeAll(asnOS);
164
165		byte[] encodedData = asnOS.toByteArray();
166		assertTrue( Arrays.equals(data,encodedData));
167	}
168}