PageRenderTime 79ms CodeModel.GetById 70ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 140 lines | 84 code | 23 blank | 33 comment | 8 complexity | 84f6e06ac0bc10edc3465cc237a8cab2 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
 23package org.mobicents.protocols.ss7.isup.impl.message;
 24
 25import org.mobicents.protocols.ss7.isup.message.AnswerMessage;
 26import org.mobicents.protocols.ss7.isup.message.ISUPMessage;
 27import org.mobicents.protocols.ss7.isup.message.parameter.CallReference;
 28import org.mobicents.protocols.ss7.isup.message.parameter.ServiceActivation;
 29import static org.testng.Assert.*;
 30import org.testng.*;
 31import org.testng.annotations.*;
 32/**
 33 * Start time:09:26:46 2009-04-22<br>
 34 * Project: mobicents-isup-stack<br>
 35 * Test for ANM
 36 * 
 37 * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a>
 38 */
 39public class ANMTest extends MessageHarness {
 40
 41	
 42
 43	@Test(groups = { "functional.encode","functional.decode","message"})
 44	public void testTwo_Params() throws Exception
 45	{
 46		byte[] message = getDefaultBody();
 47
 48		//AnswerMessageImpl ANM=new AnswerMessageImpl(this,message);
 49		AnswerMessage ANM=super.messageFactory.createANM();
 50		((AbstractISUPMessage)ANM).decode(message,parameterFactory);
 51		try{
 52			CallReference cr = (CallReference) ANM.getParameter(CallReference._PARAMETER_CODE);
 53			assertNotNull(cr,"Call Reference return is null, it should not be");
 54			if(cr == null)
 55				return;
 56			assertEquals(cr.getCallIdentity(),65793, "CallIdentity missmatch");
 57			assertEquals(cr.getSignalingPointCode(),478, "SignalingPointCode missmatch");
 58			
 59		}catch(Exception e)
 60		{
 61			e.printStackTrace();
 62			fail("Failed on get parameter["+CallReference._PARAMETER_CODE+"]:"+e);
 63		}
 64		try{
 65			ServiceActivation sa = (ServiceActivation) ANM.getParameter(ServiceActivation._PARAMETER_CODE);
 66			assertNotNull(sa,"Service Activation return is null, it should not be");
 67			if(sa == null)
 68				return;
 69			
 70			byte[] b=sa.getFeatureCodes();
 71			assertNotNull(b,"ServerActivation.getFeatureCodes() is null");
 72			if(b == null)
 73			{
 74				return;
 75			}	
 76			assertEquals(b.length,7 ,"Length of param is wrong");
 77			if(b.length != 7)
 78				return;
 79			assertTrue(super.makeCompare(b, new byte[]{0x01
 80					,0x02
 81					,0x03
 82					,0x04
 83					,0x05
 84					,0x06
 85					,0x07}),"Content of ServiceActivation.getFeatureCodes is wrong");
 86			
 87		}catch(Exception e)
 88		{
 89			e.printStackTrace();
 90			fail("Failed on get parameter["+CallReference._PARAMETER_CODE+"]:"+e);
 91		}
 92
 93	}
 94	
 95	protected byte[] getDefaultBody() {
 96		byte[] message={
 97
 98				0x0C
 99				,(byte) 0x0B
100				,AnswerMessage.MESSAGE_CODE
101				//No mandatory varaible part, no ptr
102				,0x01 // ptr to optional part
103				
104				
105				//Call reference
106				,0x01
107				,0x05
108				,0x01
109				,0x01
110				,0x01
111				,(byte)0xDE
112				,0x01
113				//ServiceActivation
114				,0x33
115				,0x07
116				,0x01
117				,0x02
118				,0x03
119				,0x04
120				,0x05
121				,0x06
122				,0x07
123				
124				
125				
126				
127				//End of optional part
128				,0x0
129
130				
131
132		};
133		return message;
134	}
135
136	
137	protected ISUPMessage getDefaultMessage() {
138		return super.messageFactory.createANM();
139	}
140}