PageRenderTime 22ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 133 lines | 46 code | 17 blank | 70 comment | 0 complexity | d542c4f6830548d9904270b232a15280 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:12:21:06 2009-04-23<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.lang.reflect.InvocationTargetException;
 34
 35import org.mobicents.protocols.ss7.isup.ParameterException;
 36import org.testng.annotations.Test;
 37
 38/**
 39 * Start time:12:21:06 2009-04-23<br>
 40 * Project: mobicents-isup-stack<br>
 41 * Class to test BCI
 42 * 
 43 * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
 44 *         </a>
 45 */
 46public class BackwardCallIndicatorsTest extends ParameterHarness {
 47
 48	public BackwardCallIndicatorsTest() {
 49		super();
 50		
 51		super.badBodies.add(new byte[1]);
 52		super.badBodies.add(new byte[3]);
 53
 54		super.goodBodies.add(getBody1());
 55		super.goodBodies.add(getBody2());
 56	}
 57
 58	private byte[] getBody1() {
 59
 60		byte[] body = new byte[2];
 61		// Chardi IND : 10 - charge
 62		// Called part status ind: 01 - sub free
 63		// Called part category ind: 10 - pay phone
 64		// e2emethod ind: 10 - sccp
 65		// whole: 10100110
 66		body[0] = (byte) 0xA6;
 67
 68		// Interworking : 1 - encoutnered
 69		// e2einfo ind : 0 - no info
 70		// ISUP ind : 1 - all the way
 71		// hold ind : 1 - requested
 72		// ISDN acc ind : 1 - terminating acc isdn
 73		// echo ctrl dev: 0 - not included
 74		// SCCP m ind : 10 - connection oriented only
 75		// whole : 10011101
 76		body[1] = (byte) 0x9D;
 77		return body;
 78	}
 79	@Test(groups = { "functional.encode","functional.decode","parameter"})
 80	public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, ParameterException {
 81		BackwardCallIndicatorsImpl bci = new BackwardCallIndicatorsImpl(getBody1());
 82
 83		String[] methodNames = { "getChargeIndicator", "getCalledPartysStatusIndicator", "getCalledPartysCategoryIndicator", "getEndToEndMethodIndicator", "isInterworkingIndicator",
 84				"isEndToEndInformationIndicator", "isIsdnUserPartIndicator", "isHoldingIndicator", "isIsdnAccessIndicator", "isEchoControlDeviceIndicator", "getSccpMethodIndicator" };
 85		Object[] expectedValues = { bci._CHARGE_INDICATOR_CHARGE, bci._CPSI_SUBSCRIBER_FREE, bci._CPCI_PAYPHONE, bci._ETEMI_SCCP, 
 86				bci._II_IE, bci._ETEII_NO_IA, bci._ISDN_UPI_UATW, bci._HI_REQUESTED,bci._ISDN_AI_TA_ISDN, bci._ECDI_IECD_NOT_INCLUDED, bci._SCCP_MI_CONNECTION_ORIENTED };
 87		super.testValues(bci, methodNames, expectedValues);
 88	}
 89
 90	private byte[] getBody2() {
 91		byte[] body = new byte[2];
 92		// Chardi IND : 01 - no charge
 93		// Called part status ind: 10 - conn when free
 94		// Called part category ind: 10 - pay phone
 95		// e2emethod ind: 11 - pass alond and sccp
 96		// whole: 11101001
 97		body[0] = (byte) 0xE9;
 98
 99		// Interworking : 1 - encoutnered
100		// e2einfo ind : 0 - no info
101		// ISUP ind : 1 - all the way
102		// hold ind : 1 - requested
103		// ISDN acc ind : 1 - terminating acc isdn
104		// echo ctrl dev: 1 - not included
105		// SCCP m ind : 10 - connection oriented only
106		// whole : 10111101
107		body[1] = (byte) 0xBD;
108		return body;
109	}
110	
111	@Test(groups = { "functional.encode","functional.decode","parameter"})
112	public void testBody2EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, ParameterException {
113		BackwardCallIndicatorsImpl bci = new BackwardCallIndicatorsImpl(getBody2());
114
115		String[] methodNames = { "getChargeIndicator", "getCalledPartysStatusIndicator", "getCalledPartysCategoryIndicator", "getEndToEndMethodIndicator", "isInterworkingIndicator",
116				"isEndToEndInformationIndicator", "isIsdnUserPartIndicator", "isHoldingIndicator", "isIsdnAccessIndicator", "isEchoControlDeviceIndicator", "getSccpMethodIndicator" };
117		Object[] expectedValues = { bci._CHARGE_INDICATOR_NOCHARGE, bci._CPSI_CONNECT_WHEN_FREE, bci._CPCI_PAYPHONE, bci._ETEMI_SCCP_AND_PASSALONG, 
118				bci._II_IE, bci._ETEII_NO_IA, bci._ISDN_UPI_UATW, bci._HI_REQUESTED,bci._ISDN_AI_TA_ISDN, bci._ECDI_IECD_INCLUDED, bci._SCCP_MI_CONNECTION_ORIENTED };
119		super.testValues(bci, methodNames, expectedValues);
120	}
121	/*
122	 * (non-Javadoc)
123	 * 
124	 * @see
125	 * org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent
126	 * ()
127	 */
128	
129	public AbstractISUPParameter getTestedComponent() throws ParameterException {
130		return new org.mobicents.protocols.ss7.isup.impl.message.parameter.BackwardCallIndicatorsImpl(new byte[2]);
131	}
132
133}