PageRenderTime 37ms CodeModel.GetById 26ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 127 lines | 67 code | 19 blank | 41 comment | 4 complexity | 1805325deb7b75ab7fcd616ebb101356 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.CircuitGroupQueryResponseMessage;
 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.CircuitStateIndicator;
 37import org.mobicents.protocols.ss7.isup.message.parameter.RangeAndStatus;
 38
 39import static org.testng.Assert.*;
 40
 41import org.testng.*;
 42import org.testng.annotations.*;
 43/**
 44 * Start time:09:26:46 2009-04-22<br>
 45 * Project: mobicents-isup-stack<br>
 46 * Test for CQR
 47 * 
 48 * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a>
 49 */
 50public class CQRTest extends MessageHarness {
 51	
 52	
 53	@Test(groups = { "functional.encode","functional.decode","message"})
 54	public void testTwo_Params() throws Exception
 55	{
 56		byte[] message = getDefaultBody();
 57		//CircuitGroupQueryResponseMessage grs=new CircuitGroupQueryResponseMessageImpl(this,message);
 58		CircuitGroupQueryResponseMessage grs=super.messageFactory.createCQR();
 59		((AbstractISUPMessage)grs).decode(message,parameterFactory);
 60
 61		
 62		try{
 63			RangeAndStatus RS = (RangeAndStatus) grs.getParameter(RangeAndStatus._PARAMETER_CODE);
 64			assertNotNull(RS,"Range And Status retrun is null, it shoul not be");
 65			if(RS == null)
 66				return;
 67			byte range = RS.getRange();
 68			assertEquals(range,0x01,"Range is wrong,");
 69			byte[] b=RS.getStatus();
 70			assertNull(b,"RangeAndStatus.getRange() is not null");
 71		
 72			
 73		}catch(Exception e)
 74		{
 75			e.printStackTrace();
 76			fail("Failed on get parameter["+CallReference._PARAMETER_CODE+"]:"+e);
 77		}
 78		try{
 79			CircuitStateIndicator CSI = (CircuitStateIndicator) grs.getParameter(CircuitStateIndicator._PARAMETER_CODE);
 80			assertNotNull(CSI,"Circuit State Indicator return is null, it should not be");
 81			if(CSI == null)
 82				return;
 83			assertNotNull(CSI.getCircuitState(),"CircuitStateIndicator getCircuitState return is null, it should not be");
 84			byte[] circuitState = CSI.getCircuitState();
 85			assertEquals(circuitState.length,3, "CircuitStateIndicator.getCircuitState() length is nto correct");
 86			assertEquals( CSI.getMaintenanceBlockingState(circuitState[0]),1,"CircuitStateIndicator.getCircuitState()[0] value is not correct");
 87			assertEquals( CSI.getMaintenanceBlockingState(circuitState[1]),2,"CircuitStateIndicator.getCircuitState()[1] value is not correct");
 88			assertEquals( CSI.getMaintenanceBlockingState(circuitState[2]),3,"CircuitStateIndicator.getCircuitState()[2] value is not correct");
 89		}catch(Exception e)
 90		{
 91			e.printStackTrace();
 92			fail("Failed on get parameter["+CallReference._PARAMETER_CODE+"]:"+e);
 93		}
 94
 95	}
 96	
 97	protected byte[] getDefaultBody() {
 98		//FIXME: for now we strip MTP part
 99		byte[] message={
100
101				0x0C
102				,(byte) 0x0B
103				,CircuitGroupQueryResponseMessage.MESSAGE_CODE
104
105				,0x02 // ptr to variable part
106				,0x03
107				
108				//no optional, so no pointer
109				//RangeAndStatus._PARAMETER_CODE
110				,0x01
111				,0x01
112				//CircuitStateIndicator
113				,0x03
114				,0x01
115				,0x02
116				,0x03
117			
118				
119		};
120
121		return message;
122	}
123	
124	protected ISUPMessage getDefaultMessage() {
125		return super.messageFactory.createCQR();
126	}
127}