PageRenderTime 25ms CodeModel.GetById 14ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

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

http://mobicents.googlecode.com/
Java | 91 lines | 31 code | 13 blank | 47 comment | 2 complexity | ef57d7de99ad940ba754756c8e3a18e5 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:14:11:03 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.io.ByteArrayOutputStream;
34import java.io.IOException;
35import java.lang.reflect.InvocationTargetException;
36
37import org.mobicents.protocols.ss7.isup.ParameterException;
38import org.testng.annotations.Test;
39
40/**
41 * Start time:14:11:03 2009-04-23<br>
42 * Project: mobicents-isup-stack<br>
43 * 
44 * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
45 *         </a>
46 */
47public class TransitNetworkSelectionTest extends ParameterHarness {
48
49	/**
50	 * @throws IOException
51	 */
52	public TransitNetworkSelectionTest() throws IOException {
53		super.badBodies.add(new byte[1]);
54
55	}
56	@Test(groups = { "functional.encode","functional.decode","parameter"})
57	public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException {
58		TransitNetworkSelectionImpl bci = new TransitNetworkSelectionImpl(getBody(false, TransitNetworkSelectionImpl._NIP_PDNIC, TransitNetworkSelectionImpl._TONI_ITU_T, getSixDigits()));
59
60		String[] methodNames = { "isOddFlag", "getNetworkIdentificationPlan", "getTypeOfNetworkIdentification",  "getAddress" };
61		Object[] expectedValues = { false, TransitNetworkSelectionImpl._NIP_PDNIC, TransitNetworkSelectionImpl._TONI_ITU_T, getSixDigitsString()};
62		super.testValues(bci, methodNames, expectedValues);
63	}
64
65	private byte[] getBody(boolean isODD, int _NIP, int _TONI, byte[] digits) throws IOException {
66		ByteArrayOutputStream bos = new ByteArrayOutputStream();
67		// we will use odd number of digits, so we leave zero as MSB
68
69		if (isODD) {
70			bos.write(0x80 | (_TONI << 4) | _NIP);
71		} else {
72			bos.write((_TONI << 4) | _NIP);
73		}
74
75		bos.write(digits);
76		return bos.toByteArray();
77	}
78
79	/*
80	 * (non-Javadoc)
81	 * 
82	 * @see
83	 * org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent
84	 * ()
85	 */
86	
87	public AbstractISUPParameter getTestedComponent() {
88		return new TransitNetworkSelectionImpl("11", 1, 1);
89	}
90
91}