PageRenderTime 47ms CodeModel.GetById 17ms 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
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.sms;
  23. import java.util.Arrays;
  24. import org.mobicents.protocols.asn.AsnInputStream;
  25. import org.mobicents.protocols.asn.AsnOutputStream;
  26. import org.mobicents.protocols.asn.Tag;
  27. import org.mobicents.protocols.ss7.map.api.primitives.AddressNature;
  28. import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
  29. import org.mobicents.protocols.ss7.map.api.primitives.MAPExtensionContainer;
  30. import org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan;
  31. import org.mobicents.protocols.ss7.map.api.service.sms.MWStatus;
  32. import org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl;
  33. import org.mobicents.protocols.ss7.map.primitives.MAPExtensionContainerTest;
  34. import junit.framework.Assert;
  35. import static org.testng.Assert.*;import org.testng.*;import org.testng.annotations.*;
  36. /**
  37. *
  38. * @author sergey vetyutnev
  39. *
  40. */
  41. public class InformServiceCentreRequestIndicationTest {
  42. private byte[] getEncodedData() {
  43. return new byte[] { 48, 4, 3, 2, 2, 64 };
  44. }
  45. private byte[] getEncodedDataFull() {
  46. 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,
  47. 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 };
  48. }
  49. @Test(groups = { "functional.decode","service.sms"})
  50. public void testDecode() throws Exception {
  51. byte[] rawData = getEncodedData();
  52. AsnInputStream asn = new AsnInputStream(rawData);
  53. int tag = asn.readTag();
  54. InformServiceCentreRequestIndicationImpl isc = new InformServiceCentreRequestIndicationImpl();
  55. isc.decodeAll(asn);
  56. assertEquals( tag,Tag.SEQUENCE);
  57. assertEquals( asn.getTagClass(),Tag.CLASS_UNIVERSAL);
  58. MWStatus mwStatus = isc.getMwStatus();
  59. assertNotNull(mwStatus);
  60. assertFalse(mwStatus.getScAddressNotIncluded());
  61. assertTrue(mwStatus.getMnrfSet());
  62. assertFalse(mwStatus.getMcefSet());
  63. assertFalse(mwStatus.getMnrgSet());
  64. rawData = getEncodedDataFull();
  65. asn = new AsnInputStream(rawData);
  66. tag = asn.readTag();
  67. isc = new InformServiceCentreRequestIndicationImpl();
  68. isc.decodeAll(asn);
  69. assertEquals( tag,Tag.SEQUENCE);
  70. assertEquals( asn.getTagClass(),Tag.CLASS_UNIVERSAL);
  71. MAPExtensionContainer extensionContainer = isc.getExtensionContainer();
  72. ISDNAddressString storedMSISDN = isc.getStoredMSISDN();
  73. mwStatus = isc.getMwStatus();
  74. int absentSubscriberDiagnosticSM = isc.getAbsentSubscriberDiagnosticSM();
  75. int additionalAbsentSubscriberDiagnosticSM = isc.getAdditionalAbsentSubscriberDiagnosticSM();
  76. Assert.assertNotNull(storedMSISDN);
  77. Assert.assertEquals( AddressNature.international_number,storedMSISDN.getAddressNature());
  78. Assert.assertEquals( NumberingPlan.ISDN,storedMSISDN.getNumberingPlan());
  79. Assert.assertEquals( "111222333",storedMSISDN.getAddress());
  80. Assert.assertNotNull(mwStatus);
  81. Assert.assertFalse(mwStatus.getScAddressNotIncluded());
  82. Assert.assertTrue(mwStatus.getMnrfSet());
  83. Assert.assertFalse(mwStatus.getMcefSet());
  84. Assert.assertTrue(mwStatus.getMnrgSet());
  85. Assert.assertNotNull(absentSubscriberDiagnosticSM);
  86. Assert.assertEquals( 555,(int) absentSubscriberDiagnosticSM);
  87. Assert.assertNotNull(additionalAbsentSubscriberDiagnosticSM);
  88. Assert.assertEquals( 444,(int) additionalAbsentSubscriberDiagnosticSM);
  89. Assert.assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer));
  90. }
  91. @Test(groups = { "functional.encode","service.sms"})
  92. public void testEncode() throws Exception {
  93. MWStatus mwStatus = new MWStatusImpl(false, true, false, false);
  94. InformServiceCentreRequestIndicationImpl isc = new InformServiceCentreRequestIndicationImpl(null, mwStatus, null, null, null);
  95. AsnOutputStream asnOS = new AsnOutputStream();
  96. isc.encodeAll(asnOS);
  97. byte[] encodedData = asnOS.toByteArray();
  98. byte[] rawData = getEncodedData();
  99. assertTrue( Arrays.equals(rawData,encodedData));
  100. ISDNAddressString storedMSISDN = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "111222333");
  101. mwStatus = new MWStatusImpl(false, true, false, true);
  102. Integer absentSubscriberDiagnosticSM = 555;
  103. Integer additionalAbsentSubscriberDiagnosticSM = 444;
  104. isc = new InformServiceCentreRequestIndicationImpl(storedMSISDN, mwStatus, MAPExtensionContainerTest.GetTestExtensionContainer(),
  105. absentSubscriberDiagnosticSM, additionalAbsentSubscriberDiagnosticSM);
  106. asnOS.reset();
  107. isc.encodeAll(asnOS);
  108. encodedData = asnOS.toByteArray();
  109. rawData = getEncodedDataFull();
  110. assertTrue( Arrays.equals(rawData,encodedData));
  111. }
  112. }