PageRenderTime 18ms CodeModel.GetById 2ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 103 lines | 37 code | 26 blank | 40 comment | 0 complexity | e2a846161d735cb5e22aa81c72de6c36 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:17:14:12 2009-04-24<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;
 35
 36import org.mobicents.protocols.ss7.isup.ParameterException;
 37import org.testng.annotations.Test;
 38
 39/**
 40 * Start time:17:14:12 2009-04-24<br>
 41 * Project: mobicents-isup-stack<br>
 42 * 
 43 * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski
 44 *         </a>
 45 */
 46public class MLPPPrecedenceTest extends ParameterHarness {
 47
 48
 49	
 50	
 51	public MLPPPrecedenceTest() {
 52		super();
 53		super.goodBodies.add(new byte[6]);
 54		
 55		super.badBodies.add(new byte[5]);
 56		super.badBodies.add(new byte[7]);
 57		
 58	}
 59
 60	
 61	@Test(groups = { "functional.encode","functional.decode","parameter"})
 62	public void testBody1EncodedValues() throws IOException, ParameterException {
 63		//FIXME: This one fails....
 64		int serDomain = 15;
 65		MLPPPrecedenceImpl eci = new MLPPPrecedenceImpl(getBody(MLPPPrecedenceImpl._LFB_INDICATOR_ALLOWED,MLPPPrecedenceImpl._PLI_PRIORITY,new byte[]{3,4}, serDomain));
 66		
 67		String[] methodNames = { "getLfb", "getPrecedenceLevel","getMllpServiceDomain" };
 68		Object[] expectedValues = { (byte)MLPPPrecedenceImpl._LFB_INDICATOR_ALLOWED,(byte)MLPPPrecedenceImpl._PLI_PRIORITY, serDomain };
 69	
 70		super.testValues(eci, methodNames, expectedValues);
 71	}
 72	
 73	
 74	
 75	
 76	private byte[] getBody(int lfbIndicatorAllowed, int precedenceLevel, byte[] bs, int mllpServiceDomain) throws IOException {
 77		ByteArrayOutputStream bos = new ByteArrayOutputStream();
 78		byte b = (byte) ((lfbIndicatorAllowed & 0x03) << 5);
 79		b |= precedenceLevel & 0x0F;
 80		bos.write(b);
 81		bos.write(bs);
 82		
 83		
 84		bos.write(mllpServiceDomain >> 16);
 85		bos.write(mllpServiceDomain >> 8);
 86		bos.write( mllpServiceDomain);
 87		byte[] bb =bos.toByteArray();
 88		return bb;
 89		
 90	}
 91
 92
 93
 94	/* (non-Javadoc)
 95	 * @see org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent()
 96	 */
 97	
 98	public AbstractISUPParameter getTestedComponent() throws ParameterException {
 99		MLPPPrecedenceImpl component = new MLPPPrecedenceImpl(new byte[6]);
100		return component;
101	}
102
103}