PageRenderTime 29ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

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