PageRenderTime 57ms CodeModel.GetById 51ms 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/NetworkManagementControlsTest.java

http://mobicents.googlecode.com/
Java | 98 lines | 43 code | 12 blank | 43 comment | 8 complexity | 378b808957266d9eabfebe5687389fb6 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:13:20:04 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;
34
35import org.mobicents.protocols.ss7.isup.ParameterException;
36import org.testng.annotations.Test;
37import static org.testng.Assert.*;
38import org.testng.*;
39import org.testng.annotations.*;
40/**
41 * Start time:13:20:04 2009-04-26<br>
42 * Project: mobicents-isup-stack<br>
43 * 
44 * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
45 *         </a>
46 */
47public class NetworkManagementControlsTest extends ParameterHarness {
48
49	public NetworkManagementControlsTest() {
50		super();
51
52		super.goodBodies.add(new byte[1]);
53		super.goodBodies.add(new byte[] { 0x0E });
54		super.goodBodies.add(new byte[] { 0x0E, 32, 45, 0x0A });
55	}
56	@Test(groups = { "functional.encode","functional.decode","parameter"})
57	public void testBody1EncodedValues() throws IOException, ParameterException {
58
59		boolean[] bools = new boolean[] { true, true, false, true, false, true, true };
60		NetworkManagementControlsImpl eci = new NetworkManagementControlsImpl(getBody1(bools));
61		byte[] encoded = eci.encode();
62		for (int index = 0; index < encoded.length; index++) {
63			if (bools[index] != eci.isTARControlEnabled(encoded[index])) {
64				fail("Failed to get TAR bits, at index: " + index);
65			}
66
67			if (index == encoded.length - 1) {
68				if (((encoded[index] >> 7) & 0x01) != 1) {
69					fail("Last byte must have MSB turned on to indicate last byte, this one does not.");
70				}
71			}
72		}
73
74	}
75
76	private byte[] getBody1(boolean[] tarEnabled) {
77		boolean[] bools = new boolean[] { true, true, false, true, false, true, true };
78		NetworkManagementControlsImpl eci = new NetworkManagementControlsImpl();
79		byte[] b = new byte[tarEnabled.length];
80		for (int index = 0; index < tarEnabled.length; index++) {
81			b[index] = eci.createTAREnabledByte(tarEnabled[index]);
82		}
83		return b;
84	}
85
86	/*
87	 * (non-Javadoc)
88	 * 
89	 * @see
90	 * org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent
91	 * ()
92	 */
93	
94	public AbstractISUPParameter getTestedComponent() throws ParameterException {
95		return new NetworkManagementControlsImpl(new byte[1]);
96	}
97
98}