/protocols/ss7/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/CGBTest.java

http://mobicents.googlecode.com/ · Java · 132 lines · 68 code · 19 blank · 45 comment · 6 complexity · 789327b4be7bbfee7e0279a7c5a88c13 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. /**
  23. * Start time:09:26:46 2009-04-22<br>
  24. * Project: mobicents-isup-stack<br>
  25. *
  26. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
  27. * </a>
  28. *
  29. */
  30. package org.mobicents.protocols.ss7.isup.impl.message;
  31. import org.mobicents.protocols.ss7.isup.message.CircuitGroupBlockingMessage;
  32. import org.mobicents.protocols.ss7.isup.message.ISUPMessage;
  33. import org.mobicents.protocols.ss7.isup.message.parameter.CallReference;
  34. import org.mobicents.protocols.ss7.isup.message.parameter.RangeAndStatus;
  35. import static org.testng.Assert.*;
  36. import org.testng.*;
  37. import org.testng.annotations.*;
  38. /**
  39. * Start time:09:26:46 2009-04-22<br>
  40. * Project: mobicents-isup-stack<br>
  41. * Test for CGB
  42. *
  43. * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a>
  44. */
  45. public class CGBTest extends MessageHarness {
  46. @Test(groups = { "functional.encode","functional.decode","message"})
  47. public void testTwo_Params() throws Exception
  48. {
  49. //FIXME: for now we strip MTP part
  50. byte[] message={
  51. 0x0C
  52. ,(byte) 0x0B
  53. ,CircuitGroupBlockingMessage.MESSAGE_CODE
  54. //Circuit group supervision message type
  55. ,0x01 // hardware failure oriented
  56. ,0x01 // ptr to variable part
  57. //no optional, so no pointer
  58. //RangeAndStatus._PARAMETER_CODE
  59. ,0x03
  60. ,0x0A
  61. ,0x02
  62. ,0x03
  63. };
  64. //CircuitGroupBlockingMessage cgb=new CircuitGroupBlockingMessageImpl(this,message);
  65. CircuitGroupBlockingMessage cgb=super.messageFactory.createCGB(0);
  66. ((AbstractISUPMessage)cgb).decode(message,parameterFactory);
  67. try{
  68. RangeAndStatus RS = (RangeAndStatus) cgb.getParameter(RangeAndStatus._PARAMETER_CODE);
  69. assertNotNull(RS,"Range And Status return is null, it should not be");
  70. if(RS == null)
  71. return;
  72. byte range = RS.getRange();
  73. assertEquals( range,0x0A,"Range is wrong");
  74. byte[] b=RS.getStatus();
  75. assertNotNull(b,"RangeAndStatus.getRange() is null");
  76. if(b == null)
  77. {
  78. return;
  79. }
  80. assertEquals(b.length,2 ,"Length of param is wrong");
  81. if(b.length != 2)
  82. return;
  83. assertTrue( super.makeCompare(b, new byte[]{
  84. 0x02
  85. ,0x03
  86. }),"RangeAndStatus.getRange() is wrong");
  87. }catch(Exception e)
  88. {
  89. e.printStackTrace();
  90. fail("Failed on get parameter["+CallReference._PARAMETER_CODE+"]:"+e);
  91. }
  92. }
  93. protected byte[] getDefaultBody() {
  94. //FIXME: for now we strip MTP part
  95. byte[] message={
  96. 0x0C
  97. ,(byte) 0x0B
  98. ,CircuitGroupBlockingMessage.MESSAGE_CODE
  99. //Circuit group supervision message type
  100. ,0x01 // hardware failure oriented
  101. ,0x01 // ptr to variable part
  102. //no optional, so no pointer
  103. //RangeAndStatus._PARAMETER_CODE
  104. ,0x02
  105. ,0x04
  106. ,0x02
  107. };
  108. return message;
  109. }
  110. protected ISUPMessage getDefaultMessage() {
  111. return super.messageFactory.createCGB(0);
  112. }
  113. }