/protocols/ss7/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/service/sms/AlertServiceCentreRequestIndicationTest.java

http://mobicents.googlecode.com/ · Java · 89 lines · 47 code · 16 blank · 26 comment · 0 complexity · ac09de7261e083ae7357ec534f76cfc6 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. 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.MAPOperationCode;
  28. import org.mobicents.protocols.ss7.map.api.primitives.AddressNature;
  29. import org.mobicents.protocols.ss7.map.api.primitives.AddressString;
  30. import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
  31. import org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan;
  32. import org.mobicents.protocols.ss7.map.primitives.AddressStringImpl;
  33. import org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl;
  34. import static org.testng.Assert.*;import org.testng.*;import org.testng.annotations.*;
  35. /**
  36. *
  37. * @author sergey vetyutnev
  38. *
  39. */
  40. public class AlertServiceCentreRequestIndicationTest {
  41. private byte[] getEncodedData() {
  42. return new byte[] { 48, 18, 4, 7, -111, -110, 17, 19, 50, 19, -15, 4, 7, -111, -108, -120, 115, 0, -110, -14 };
  43. }
  44. @Test
  45. public void testDecode() throws Exception {
  46. byte[] rawData = getEncodedData();
  47. AsnInputStream asn = new AsnInputStream(rawData);
  48. int tag = asn.readTag();
  49. AlertServiceCentreRequestIndicationImpl asc = new AlertServiceCentreRequestIndicationImpl(MAPOperationCode.alertServiceCentre);
  50. asc.decodeAll(asn);
  51. assertEquals( tag,Tag.SEQUENCE);
  52. assertEquals( asn.getTagClass(),Tag.CLASS_UNIVERSAL);
  53. ISDNAddressString msisdn = asc.getMsisdn();
  54. assertEquals( msisdn.getAddressNature(),AddressNature.international_number);
  55. assertEquals( msisdn.getNumberingPlan(),NumberingPlan.ISDN);
  56. assertEquals( msisdn.getAddress(),"29113123311");
  57. AddressString sca = asc.getServiceCentreAddress();
  58. assertEquals( sca.getAddressNature(),AddressNature.international_number);
  59. assertEquals( sca.getNumberingPlan(),NumberingPlan.ISDN);
  60. assertEquals( sca.getAddress(),"49883700292");
  61. }
  62. @Test(groups = { "functional.encode"})
  63. public void testEncode() throws Exception {
  64. ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "29113123311");
  65. AddressString sca = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "49883700292");
  66. AlertServiceCentreRequestIndicationImpl asc = new AlertServiceCentreRequestIndicationImpl(msisdn, sca);
  67. AsnOutputStream asnOS = new AsnOutputStream();
  68. asc.encodeAll(asnOS);
  69. byte[] encodedData = asnOS.toByteArray();
  70. byte[] rawData = getEncodedData();
  71. assertTrue( Arrays.equals(rawData,encodedData));
  72. }
  73. }