/protocols/ss7/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/dialog/MAPSimpleDialogTest.java

http://mobicents.googlecode.com/ · Java · 97 lines · 48 code · 23 blank · 26 comment · 0 complexity · 8da773b5ede0f838563c2f76409bfde4 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.dialog;
  23. import java.util.Arrays;
  24. import static org.testng.Assert.*;import org.testng.*;import org.testng.annotations.*;
  25. import org.mobicents.protocols.asn.AsnInputStream;
  26. import org.mobicents.protocols.asn.AsnOutputStream;
  27. import org.mobicents.protocols.ss7.map.primitives.MAPExtensionContainerTest;
  28. /**
  29. *
  30. * @author sergey vetyutnev
  31. *
  32. */
  33. public class MAPSimpleDialogTest {
  34. private byte[] getDataAcceptInfo() {
  35. return new byte[] { -95, 41, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23,
  36. 24, 25, 26, -95, 3, 31, 32, 33 };
  37. }
  38. private byte[] getDataCloseInfo() {
  39. return new byte[] { -94, 41, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23,
  40. 24, 25, 26, -95, 3, 31, 32, 33 };
  41. }
  42. @Test(groups = { "functional.decode","dialog"})
  43. public void testDecode() throws Exception {
  44. AsnInputStream asnIs = new AsnInputStream(this.getDataAcceptInfo());
  45. int tag = asnIs.readTag();
  46. assertEquals( tag,1);
  47. MAPAcceptInfoImpl accInfo = new MAPAcceptInfoImpl();
  48. accInfo.decodeAll(asnIs);
  49. assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(accInfo.getExtensionContainer()));
  50. asnIs = new AsnInputStream(this.getDataCloseInfo());
  51. tag = asnIs.readTag();
  52. assertEquals( tag,2);
  53. MAPCloseInfoImpl closeInfo = new MAPCloseInfoImpl();
  54. closeInfo.decodeAll(asnIs);
  55. assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(closeInfo.getExtensionContainer()));
  56. }
  57. @Test(groups = { "functional.encode","dialog"})
  58. public void testEncode() throws Exception {
  59. byte[] b = this.getDataAcceptInfo();
  60. MAPAcceptInfoImpl accInfo = new MAPAcceptInfoImpl();
  61. accInfo.setExtensionContainer(MAPExtensionContainerTest.GetTestExtensionContainer());
  62. AsnOutputStream asnOS = new AsnOutputStream();
  63. accInfo.encodeAll(asnOS);
  64. byte[] data = asnOS.toByteArray();
  65. assertTrue( Arrays.equals(b,data));
  66. b = this.getDataCloseInfo();
  67. MAPCloseInfoImpl closeInfo = new MAPCloseInfoImpl();
  68. closeInfo.setExtensionContainer(MAPExtensionContainerTest.GetTestExtensionContainer());
  69. asnOS = new AsnOutputStream();
  70. closeInfo.encodeAll(asnOS);
  71. data = asnOS.toByteArray();
  72. assertTrue( Arrays.equals(b,data));
  73. }
  74. }