PageRenderTime 26ms CodeModel.GetById 20ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 118 lines | 61 code | 16 blank | 41 comment | 6 complexity | 859fa4d13091580fa110dde6f3a0fe3f 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.CircuitGroupUnblockingMessage;
 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 CGUTest 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		//CircuitGroupUnblockingMessage cgb=new CircuitGroupUnblockingMessageImpl(this,message);
 58		CircuitGroupUnblockingMessage cgb=super.messageFactory.createCGU(0);
 59		((AbstractISUPMessage)cgb).decode(message,parameterFactory);
 60
 61		
 62		try{
 63			RangeAndStatus RS = (RangeAndStatus) cgb.getParameter(RangeAndStatus._PARAMETER_CODE);
 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		//FIXME: for now we strip MTP part
 94		byte[] message={
 95
 96				0x0C
 97				,(byte) 0x0B
 98				,CircuitGroupUnblockingMessage.MESSAGE_CODE
 99				//Circuit group supervision message type
100				,0x01 // hardware failure oriented
101				,0x01 // ptr to variable part
102				//no optional, so no pointer
103				//RangeAndStatus._PARAMETER_CODE
104				,0x04
105				,0x11
106				,0x02
107				,0x03
108				,0x04
109
110		};
111		return message;
112	}
113
114	
115	protected ISUPMessage getDefaultMessage() {
116		return super.messageFactory.createCGU(0);
117	}
118}