PageRenderTime 22ms CodeModel.GetById 10ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/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/**
 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.CircuitGroupBlockingMessage;
 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 CGB
 46 * 
 47 * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a>
 48 */
 49public class CGBTest extends MessageHarness {
 50	
 51	
 52	@Test(groups = { "functional.encode","functional.decode","message"})
 53	public void testTwo_Params() throws Exception
 54	{
 55		//FIXME: for now we strip MTP part
 56		byte[] message={
 57				0x0C
 58				,(byte) 0x0B
 59				,CircuitGroupBlockingMessage.MESSAGE_CODE
 60				//Circuit group supervision message type
 61				,0x01 // hardware failure oriented
 62				,0x01 // ptr to variable part
 63				//no optional, so no pointer
 64				//RangeAndStatus._PARAMETER_CODE
 65				,0x03
 66				,0x0A
 67				,0x02
 68				,0x03
 69				
 70
 71		};
 72
 73		//CircuitGroupBlockingMessage cgb=new CircuitGroupBlockingMessageImpl(this,message);
 74		CircuitGroupBlockingMessage cgb=super.messageFactory.createCGB(0);
 75		((AbstractISUPMessage)cgb).decode(message,parameterFactory);
 76
 77		
 78		try{
 79			RangeAndStatus RS = (RangeAndStatus) cgb.getParameter(RangeAndStatus._PARAMETER_CODE);
 80			assertNotNull(RS,"Range And Status return is null, it should not be");
 81			if(RS == null)
 82				return;
 83			byte range = RS.getRange();
 84			assertEquals( range,0x0A,"Range is wrong");
 85			byte[] b=RS.getStatus();
 86			assertNotNull(b,"RangeAndStatus.getRange() is null");
 87			if(b == null)
 88			{
 89				return;
 90			}	
 91			assertEquals(b.length,2 ,"Length of param is wrong");
 92			if(b.length != 2)
 93				return;
 94			assertTrue( super.makeCompare(b, new byte[]{
 95					0x02
 96					,0x03
 97
 98					}),"RangeAndStatus.getRange() is wrong");
 99			
100		}catch(Exception e)
101		{
102			e.printStackTrace();
103			fail("Failed on get parameter["+CallReference._PARAMETER_CODE+"]:"+e);
104		}
105		
106	}
107	
108	protected byte[] getDefaultBody() {
109		//FIXME: for now we strip MTP part
110		byte[] message={
111				0x0C
112				,(byte) 0x0B
113				,CircuitGroupBlockingMessage.MESSAGE_CODE
114				//Circuit group supervision message type
115				,0x01 // hardware failure oriented
116				,0x01 // ptr to variable part
117				//no optional, so no pointer
118				//RangeAndStatus._PARAMETER_CODE
119				,0x02
120				,0x04
121				,0x02
122
123
124		};
125		return message;
126	}
127
128	
129	protected ISUPMessage getDefaultMessage() {
130		return super.messageFactory.createCGB(0);
131	}
132}