/protocols/ss7/isup/isup-impl/src/test/java/org/mobicents/protocols/ss7/isup/impl/message/CGUATest.java
Java | 115 lines | 59 code | 15 blank | 41 comment | 6 complexity | 5e01a7b341dd2244a7538a3b38bcd45c 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.CircuitGroupUnblockingAckMessage; 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 CGU 46 * 47 * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a> 48 */ 49public class CGUATest extends MessageHarness { 50 51 @Test(groups = { "functional.encode","functional.decode","message"}) 52 public void testTwo_Params() throws Exception 53 { 54 byte[] message = getDefaultBody(); 55 56 //CircuitGroupUnblockingAckMessage cgb=new CircuitGroupUnblockingAckMessageImpl(this,message); 57 CircuitGroupUnblockingAckMessage cgb=super.messageFactory.createCGUA(); 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 if(RS == null) 65 return; 66 byte range = RS.getRange(); 67 assertEquals( range,0x0A,"Range is wrong"); 68 byte[] b=RS.getStatus(); 69 assertNotNull(b,"RangeAndStatus.getRange() is null"); 70 if(b == null) 71 { 72 return; 73 } 74 assertEquals(b.length,2 ,"Length of param is wrong"); 75 if(b.length != 2) 76 return; 77 assertTrue(super.makeCompare(b, new byte[]{ 78 0x02 79 ,0x03 80 }),"RangeAndStatus.getRange() is wrong"); 81 82 }catch(Exception e) 83 { 84 e.printStackTrace(); 85 fail("Failed on get parameter["+CallReference._PARAMETER_CODE+"]:"+e); 86 } 87 88 } 89 90 protected byte[] getDefaultBody() { 91 //FIXME: for now we strip MTP part 92 byte[] message={ 93 94 0x0C 95 ,(byte) 0x0B 96 ,CircuitGroupUnblockingAckMessage.MESSAGE_CODE 97 //Circuit group supervision message type 98 ,0x01 // hardware failure oriented 99 ,0x01 // ptr to variable part 100 //no optional, so no pointer 101 //RangeAndStatus._PARAMETER_CODE 102 ,0x03 103 ,0x0A 104 ,0x02 105 ,0x03 106 107 }; 108 return message; 109 } 110 111 112 protected ISUPMessage getDefaultMessage() { 113 return super.messageFactory.createCGUA(); 114 } 115}