PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

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

http://mobicents.googlecode.com/
Java | 101 lines | 38 code | 24 blank | 39 comment | 0 complexity | a23e1c145b696aaac2bb721bb64c6d45 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:20:07:45 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:20:07:45 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 RedirectionInformationTest extends ParameterHarness {
 47
 48	
 49	
 50	
 51	
 52	public RedirectionInformationTest() {
 53		super();
 54		super.goodBodies.add(new byte[]{(byte) 0xC5,(byte) 0x03});
 55		
 56		
 57		
 58		super.badBodies.add(new byte[]{(byte) 0xC5,(byte) 0x0F});
 59		super.badBodies.add(new byte[1]);
 60		super.badBodies.add(new byte[3]);
 61	}
 62
 63	@Test(groups = { "functional.encode","functional.decode","parameter"})
 64	public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException {
 65		RedirectionInformationImpl bci = new RedirectionInformationImpl(getBody(RedirectionInformationImpl._RI_CALL_D_RNPR,RedirectionInformationImpl._ORR_UNA,1,RedirectionInformationImpl._RR_DEFLECTION_IE));
 66	
 67		String[] methodNames = { "getRedirectingIndicator", 
 68								 "getOriginalRedirectionReason", 
 69								 "getRedirectionCounter", 
 70								 "getRedirectionReason" };
 71		Object[] expectedValues = { RedirectionInformationImpl._RI_CALL_D_RNPR,
 72								    RedirectionInformationImpl._ORR_UNA,
 73								    1,
 74								    RedirectionInformationImpl._RR_DEFLECTION_IE };
 75		super.testValues(bci, methodNames, expectedValues);
 76	}
 77	
 78	
 79	
 80	private byte[] getBody(int riCallDRnpr, int orrUna, int counter, int rrDeflectionIe) {
 81		byte[] b = new byte[2];
 82		
 83		b[0] = (byte) riCallDRnpr;
 84		b[0]|= orrUna <<4;
 85		
 86		
 87		b[1] = (byte) counter;
 88		b[1]|= rrDeflectionIe <<4;
 89		return b;
 90	}
 91
 92
 93	/* (non-Javadoc)
 94	 * @see org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent()
 95	 */
 96	
 97	public AbstractISUPParameter getTestedComponent() throws IllegalArgumentException, ParameterException {
 98		return new RedirectionInformationImpl(new byte[]{0,1});
 99	}
100
101}