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