PageRenderTime 7ms CodeModel.GetById 1ms 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/OptionalBackwardCallIndicatorsTest.java

http://mobicents.googlecode.com/
Java | 93 lines | 39 code | 11 blank | 43 comment | 0 complexity | b59950961ba86652cf38569aa63975d0 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:16:20:47 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.IOException;
34import java.lang.reflect.InvocationTargetException;
35
36import org.mobicents.protocols.ss7.isup.ParameterException;
37import org.testng.annotations.Test;
38
39/**
40 * Start time:16:20:47 2009-04-26<br>
41 * Project: mobicents-isup-stack<br>
42 * 
43 * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
44 *         </a>
45 */
46public class OptionalBackwardCallIndicatorsTest extends ParameterHarness {
47
48	private static final int _TURN_ON = 1;
49	private static final int _TURN_OFF = 0;
50	
51	public OptionalBackwardCallIndicatorsTest() {
52		super();
53		super.goodBodies.add(new byte[] { 8 });
54		super.badBodies.add(new byte[] { 8, 8 });
55	}
56	@Test(groups = { "functional.encode","functional.decode","parameter"})
57	public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException {
58		OptionalBackwardCallIndicatorsImpl bci = new OptionalBackwardCallIndicatorsImpl();
59
60		bci.decode(getBody(OptionalBackwardCallIndicatorsImpl._IBII_AVAILABLE, OptionalBackwardCallIndicatorsImpl._CDI_NO_INDICATION,
61				OptionalBackwardCallIndicatorsImpl._SSIR_NO_ADDITIONAL_INFO, OptionalBackwardCallIndicatorsImpl._MLLPUI_USER));
62		String[] methodNames = {    "isInbandInformationIndicator", 
63				                    "isCallDiversionMayOccurIndicator", 
64				                    "isSimpleSegmentationIndicator", 
65				                    "isMllpUserIndicator" };
66		Object[] expectedValues = { OptionalBackwardCallIndicatorsImpl._IBII_AVAILABLE, 
67									OptionalBackwardCallIndicatorsImpl._CDI_NO_INDICATION, 
68									OptionalBackwardCallIndicatorsImpl._SSIR_NO_ADDITIONAL_INFO,
69									OptionalBackwardCallIndicatorsImpl._MLLPUI_USER };
70		super.testValues(bci, methodNames, expectedValues);
71	}
72
73	private byte[] getBody(boolean ibiiAvailable, boolean cdiNoIndication, boolean ssirNoAdditionalInfo, boolean mllpuiUser) {
74		byte b = (byte) ((ibiiAvailable ? _TURN_ON : _TURN_OFF));
75		b |= ((cdiNoIndication ? _TURN_ON : _TURN_OFF) << 1);
76		b |= ((ssirNoAdditionalInfo ? _TURN_ON : _TURN_OFF) << 2);
77		b |= ((mllpuiUser ? _TURN_ON : _TURN_OFF) << 3);
78		return new byte[] { b };
79	}
80
81	/*
82	 * (non-Javadoc)
83	 * 
84	 * @see
85	 * org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent
86	 * ()
87	 */
88	
89	public AbstractISUPParameter getTestedComponent() throws ParameterException {
90		return new OptionalBackwardCallIndicatorsImpl();
91	}
92
93}