PageRenderTime 37ms CodeModel.GetById 10ms app.highlight 21ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 198 lines | 98 code | 35 blank | 65 comment | 2 complexity | ac0b2097bfe49799bec77bebfe758408 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:17:28:44 2009-04-26<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.parameter;
 32
 33import java.io.ByteArrayOutputStream;
 34import java.io.IOException;
 35import java.lang.reflect.InvocationTargetException;
 36
 37import org.mobicents.protocols.ss7.isup.ParameterException;
 38import org.mobicents.protocols.ss7.isup.message.parameter.InstructionIndicators;
 39import org.testng.annotations.Test;
 40import static org.testng.Assert.*;
 41import org.testng.*;
 42import org.testng.annotations.*;
 43/**
 44 * Start time:17:28:44 2009-04-26<br>
 45 * Project: mobicents-isup-stack<br>
 46 * 
 47 * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
 48 *         </a>
 49 */
 50public class ParameterCompatibilityInformationTest extends ParameterHarness{
 51
 52	private static final boolean[][] flags = new boolean[4][5];
 53	private static final int[][] intFlags = new int[4][2];
 54	private static final int _TRANSIT_EXCHANGE_INDEX = 0;
 55	private static final int _RLEASE_CALL_INDEX = 1;
 56	private static final int _SEND_NOTIFICATION_INDEX = 2;
 57	private static final int _DICARD_MESSAGE_INDEX = 3;
 58	private static final int _DISCARD_PARAMETER_INDEX = 4;
 59	private static final int _PASS_NOT_POSSIBLE_INDEX = 0;
 60	private static final int _BAND_INTERWORKING_INDEX = 1;
 61	
 62	static
 63	{
 64		intFlags[0][_BAND_INTERWORKING_INDEX] = 3;
 65		//1
 66		intFlags[0][_PASS_NOT_POSSIBLE_INDEX]=1;
 67		//0
 68		flags[0][_DISCARD_PARAMETER_INDEX]=false;
 69		//1
 70		flags[0][_DICARD_MESSAGE_INDEX]=true;
 71		//0
 72		flags[0][_SEND_NOTIFICATION_INDEX]=false;
 73		//1
 74		flags[0][_RLEASE_CALL_INDEX]=true;
 75		//1
 76		flags[0][_TRANSIT_EXCHANGE_INDEX]=true;
 77		
 78		//index = 1, its raw, we dont include
 79		
 80		//101111
 81		intFlags[2][_BAND_INTERWORKING_INDEX] = 1;
 82		//1
 83		intFlags[2][_PASS_NOT_POSSIBLE_INDEX]=1;
 84		//0
 85		flags[2][_DISCARD_PARAMETER_INDEX]=false;
 86		//1
 87		flags[2][_DICARD_MESSAGE_INDEX]=true;
 88		//1
 89		flags[2][_SEND_NOTIFICATION_INDEX]=true;
 90		//1
 91		flags[2][_RLEASE_CALL_INDEX]=true;
 92		//1
 93		flags[2][_TRANSIT_EXCHANGE_INDEX]=true;
 94		
 95		//111011
 96		intFlags[3][_BAND_INTERWORKING_INDEX] = 2;
 97		//1
 98		intFlags[3][_PASS_NOT_POSSIBLE_INDEX]=1;
 99		//1
100		flags[3][_DISCARD_PARAMETER_INDEX]=true;
101		//1
102		flags[3][_DICARD_MESSAGE_INDEX]=true;
103		//0
104		flags[3][_SEND_NOTIFICATION_INDEX]=false;
105		//1
106		flags[3][_RLEASE_CALL_INDEX]=true;
107		//1
108		flags[3][_TRANSIT_EXCHANGE_INDEX]=true;
109		
110		
111	}
112	
113	public ParameterCompatibilityInformationTest() {
114		super();
115		super.goodBodies.add(getBody1());
116	}
117
118	@Test(groups = { "functional.encode","functional.decode","parameter"})
119	public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException {
120		ParameterCompatibilityInformationImpl bci = new ParameterCompatibilityInformationImpl(getBody1());
121	
122		assertEquals(bci.size(),4, "Wrong number of instructions. ");
123		
124		//Yeah this is different
125		
126		for(int index = 0 ; index< bci.size() ; index++)
127		{
128			//this is raw, we dotn validate
129			if(index ==1)
130				continue;
131			
132			InstructionIndicators ii = bci.getInstructionIndicators(index);
133			
134			String[] methodNames = { "getBandInterworkingIndicator", 
135									 "getPassOnNotPossibleIndicator", 
136									 "isDiscardParameterIndicator", 
137									 "isDiscardMessageIndicator", 
138									 "isSendNotificationIndicator",
139									 "isReleaseCallindicator",
140									 "isTransitAtIntermediateExchangeIndicator"};
141		
142			Object[] expectedValues = { 
143			intFlags[index][_BAND_INTERWORKING_INDEX] ,
144			//1
145			intFlags[index][_PASS_NOT_POSSIBLE_INDEX],
146			//0
147			flags[index][_DISCARD_PARAMETER_INDEX],
148			//1
149			flags[index][_DICARD_MESSAGE_INDEX],
150			//0
151			flags[index][_SEND_NOTIFICATION_INDEX],
152			//1
153			flags[index][_RLEASE_CALL_INDEX],
154			//1
155			flags[index][_TRANSIT_EXCHANGE_INDEX]};
156			super.testValues((AbstractISUPParameter)ii, methodNames, expectedValues);
157			
158		}
159		
160		
161		
162		byte parameterCode = bci.getParameterCode(0);
163		assertEquals( parameterCode,1,"Wrong parameter code");
164		
165		
166		
167	}
168	
169	
170	private byte[] getBody1() {
171		ByteArrayOutputStream bos = new ByteArrayOutputStream();
172		
173		bos.write(1);
174		bos.write(0x80 | 0x2B);
175		bos.write(3);
176		
177		bos.write(2);
178		bos.write(0x80 | 0x2B);
179		bos.write(0x80 | 3);
180		bos.write(12);
181		
182		bos.write(3);
183		bos.write(0x80 | 0x2F);
184		bos.write(1);
185		
186		bos.write(4);
187		bos.write(0x80 | 0x3B);
188		bos.write(2);
189		return bos.toByteArray();
190	}
191
192
193	
194	public AbstractISUPParameter getTestedComponent() {
195		return new ParameterCompatibilityInformationImpl();
196	}
197
198}