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