PageRenderTime 71ms CodeModel.GetById 61ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 115 lines | 56 code | 19 blank | 40 comment | 6 complexity | 869e2c0f36c9053cab250cc76a34c616 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.CircuitGroupResetAckMessage;
 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 GRA
 46 * 
 47 * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a>
 48 */
 49public class GRATest 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		//CircuitGroupResetAckMessage grs=new CircuitGroupResetAckMessageImpl(this,message);
 58		CircuitGroupResetAckMessage grs=super.messageFactory.createGRA();
 59		((AbstractISUPMessage)grs).decode(message,parameterFactory);
 60		
 61		try{
 62			RangeAndStatus RS = (RangeAndStatus) grs.getParameter(RangeAndStatus._PARAMETER_CODE);
 63			assertNotNull(RS,"Range And Status retrun is null, it shoul not be");
 64			if(RS == null)
 65				return;
 66			byte range = RS.getRange();
 67			assertEquals(range,0x01,"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,1 ,"Length of param is wrong");
 75			if(b.length != 1)
 76				return;
 77			assertTrue(super.makeCompare(b, new byte[]{
 78					0x02
 79					}),"RangeAndStatus.getRange() is wrong");
 80		
 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				,CircuitGroupResetAckMessage.MESSAGE_CODE
 97
 98				,0x01 // ptr to variable part
 99				//no optional, so no pointer
100				//RangeAndStatus._PARAMETER_CODE
101				,0x02
102				,0x01
103				,0x02
104
105				
106		};
107
108		return message;
109	}
110	
111	protected ISUPMessage getDefaultMessage() {
112		return super.messageFactory.createGRA();
113	}
114	
115}