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

http://mobicents.googlecode.com/ · Java · 103 lines · 37 code · 26 blank · 40 comment · 0 complexity · e2a846161d735cb5e22aa81c72de6c36 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:17:14:12 2009-04-24<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.parameter;
  31. import java.io.ByteArrayOutputStream;
  32. import java.io.IOException;
  33. import org.mobicents.protocols.ss7.isup.ParameterException;
  34. import org.testng.annotations.Test;
  35. /**
  36. * Start time:17:14:12 2009-04-24<br>
  37. * Project: mobicents-isup-stack<br>
  38. *
  39. * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
  40. * </a>
  41. */
  42. public class MLPPPrecedenceTest extends ParameterHarness {
  43. public MLPPPrecedenceTest() {
  44. super();
  45. super.goodBodies.add(new byte[6]);
  46. super.badBodies.add(new byte[5]);
  47. super.badBodies.add(new byte[7]);
  48. }
  49. @Test(groups = { "functional.encode","functional.decode","parameter"})
  50. public void testBody1EncodedValues() throws IOException, ParameterException {
  51. //FIXME: This one fails....
  52. int serDomain = 15;
  53. MLPPPrecedenceImpl eci = new MLPPPrecedenceImpl(getBody(MLPPPrecedenceImpl._LFB_INDICATOR_ALLOWED,MLPPPrecedenceImpl._PLI_PRIORITY,new byte[]{3,4}, serDomain));
  54. String[] methodNames = { "getLfb", "getPrecedenceLevel","getMllpServiceDomain" };
  55. Object[] expectedValues = { (byte)MLPPPrecedenceImpl._LFB_INDICATOR_ALLOWED,(byte)MLPPPrecedenceImpl._PLI_PRIORITY, serDomain };
  56. super.testValues(eci, methodNames, expectedValues);
  57. }
  58. private byte[] getBody(int lfbIndicatorAllowed, int precedenceLevel, byte[] bs, int mllpServiceDomain) throws IOException {
  59. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  60. byte b = (byte) ((lfbIndicatorAllowed & 0x03) << 5);
  61. b |= precedenceLevel & 0x0F;
  62. bos.write(b);
  63. bos.write(bs);
  64. bos.write(mllpServiceDomain >> 16);
  65. bos.write(mllpServiceDomain >> 8);
  66. bos.write( mllpServiceDomain);
  67. byte[] bb =bos.toByteArray();
  68. return bb;
  69. }
  70. /* (non-Javadoc)
  71. * @see org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent()
  72. */
  73. public AbstractISUPParameter getTestedComponent() throws ParameterException {
  74. MLPPPrecedenceImpl component = new MLPPPrecedenceImpl(new byte[6]);
  75. return component;
  76. }
  77. }