PageRenderTime 28ms CodeModel.GetById 17ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 119 lines | 64 code | 26 blank | 29 comment | 0 complexity | 13c26eb849adf90a6b9c5f9336c110ba 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
 29
 30import org.mobicents.protocols.asn.AsnInputStream;
 31import org.mobicents.protocols.asn.AsnOutputStream;
 32import org.mobicents.protocols.ss7.map.MAPParameterFactoryImpl;
 33import org.mobicents.protocols.ss7.map.api.MAPParameterFactory;
 34import org.mobicents.protocols.ss7.map.api.primitives.AddressNature;
 35import org.mobicents.protocols.ss7.map.api.primitives.IMSI;
 36import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
 37import org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan;
 38import org.mobicents.protocols.ss7.map.api.primitives.SubscriberIdentity;
 39import org.mobicents.protocols.ss7.map.primitives.SubscriberIdentityImpl;
 40import org.mobicents.protocols.ss7.tcap.asn.TcapFactory;
 41import org.mobicents.protocols.ss7.tcap.asn.comp.Parameter;
 42
 43/**
 44 * @author amit bhayani
 45 * 
 46 */
 47public class SendRoutingInfoForLCSRequestIndicationTest {
 48	MAPParameterFactory MAPParameterFactory = new MAPParameterFactoryImpl();
 49
 50	@BeforeClass
 51	public static void setUpClass() throws Exception {
 52	}
 53
 54	@AfterClass
 55	public static void tearDownClass() throws Exception {
 56	}
 57
 58	@BeforeTest
 59	public void setUp() {
 60	}
 61
 62	@AfterTest
 63	public void tearDown() {
 64	}
 65
 66	@Test(groups = { "functional.decode","service.lsm"})
 67	public void testDecodeProvideSubscriberLocationRequestIndication() throws Exception {
 68		// The trace is from Brazilian operator
 69		byte[] data = new byte[] { 0x30, 0x13, (byte) 0x80, 0x05, (byte) 0x91, 0x55, 0x16, 0x09, 0x70, (byte) 0xa1, 0x0a, (byte) 0x80, 0x08, 0x27, (byte) 0x94,
 70				(byte) 0x99, 0x09, 0x00, 0x00, 0x00, (byte) 0xf7 };
 71
 72		AsnInputStream asn = new AsnInputStream(data);
 73		int tag = asn.readTag();
 74
 75		SendRoutingInfoForLCSRequestIndicationImpl rtgInfnoForLCSreqInd = new SendRoutingInfoForLCSRequestIndicationImpl();
 76		rtgInfnoForLCSreqInd.decodeAll(asn);
 77		
 78		ISDNAddressString mlcNum = rtgInfnoForLCSreqInd.getMLCNumber();
 79		assertNotNull(mlcNum);
 80		assertEquals( mlcNum.getAddressNature(),AddressNature.international_number);
 81		assertEquals( mlcNum.getNumberingPlan(),NumberingPlan.ISDN);
 82		assertEquals( mlcNum.getAddress(),"55619007");
 83		
 84		SubscriberIdentity subsIdent = rtgInfnoForLCSreqInd.getTargetMS();
 85		assertNotNull(subsIdent);
 86		
 87		IMSI imsi = subsIdent.getIMSI();
 88		ISDNAddressString msisdn  = subsIdent.getMSISDN();
 89		
 90		assertNotNull(imsi);
 91		assertNull(msisdn);
 92		
 93//		assertEquals( imsi.getMCC(),new Long(724l));
 94//		assertEquals( imsi.getMNC(),new Long(99l));
 95		assertEquals( imsi.getData(),"724999900000007");
 96
 97	}
 98
 99	@Test(groups = { "functional.encode","service.lsm"})
100	public void testEncode() throws Exception {
101		// The trace is from Brazilian operator
102		byte[] data = new byte[] { 0x30, 0x13, (byte) 0x80, 0x05, (byte) 0x91, 0x55, 0x16, 0x09, 0x70, (byte) 0xa1, 0x0a, (byte) 0x80, 0x08, 0x27, (byte) 0x94,
103				(byte) 0x99, 0x09, 0x00, 0x00, 0x00, (byte) 0xf7 };
104
105		IMSI imsi = this.MAPParameterFactory.createIMSI("724999900000007");
106		SubscriberIdentity subsIdent = new SubscriberIdentityImpl(imsi);
107
108		ISDNAddressString mlcNumber = this.MAPParameterFactory.createISDNAddressString(AddressNature.international_number, NumberingPlan.ISDN, "55619007");
109
110		SendRoutingInfoForLCSRequestIndicationImpl rtgInfnoForLCSreqInd = new SendRoutingInfoForLCSRequestIndicationImpl(mlcNumber, subsIdent);
111
112		AsnOutputStream asnOS = new AsnOutputStream();
113		rtgInfnoForLCSreqInd.encodeAll(asnOS);
114
115		byte[] encodedData = asnOS.toByteArray();
116
117		assertTrue( Arrays.equals(data,encodedData));
118	}
119}