PageRenderTime 37ms CodeModel.GetById 25ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/ss7/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/service/sms/ReportSMDeliveryStatusRequestIndicationTest.java

http://mobicents.googlecode.com/
Java | 140 lines | 86 code | 28 blank | 26 comment | 0 complexity | b7f48a07b8fa3f356a8ed4f85b7be2f8 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
 23package org.mobicents.protocols.ss7.map.service.sms;
 24
 25import java.util.Arrays;
 26
 27import static org.testng.Assert.*;import org.testng.*;import org.testng.annotations.*;
 28
 29import org.mobicents.protocols.asn.AsnInputStream;
 30import org.mobicents.protocols.asn.AsnOutputStream;
 31import org.mobicents.protocols.asn.Tag;
 32import org.mobicents.protocols.ss7.map.api.primitives.AddressNature;
 33import org.mobicents.protocols.ss7.map.api.primitives.AddressString;
 34import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
 35import org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan;
 36import org.mobicents.protocols.ss7.map.api.service.sms.SMDeliveryOutcome;
 37import org.mobicents.protocols.ss7.map.primitives.AddressStringImpl;
 38import org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl;
 39import org.mobicents.protocols.ss7.map.primitives.MAPExtensionContainerTest;
 40
 41/**
 42 * 
 43 * @author sergey vetyutnev
 44 *
 45 */
 46public class ReportSMDeliveryStatusRequestIndicationTest  {
 47	
 48	private byte[] getEncodedData() {
 49		return new byte[] { 48, 19, 4, 6, -111, 39, 34, 51, 19, 17, 4, 6, -111, 1, -112, 115, 84, -13, 10, 1, 1 };
 50	}
 51	
 52	private byte[] getEncodedDataFull() {
 53		return new byte[] { 48, 73, 4, 6, -72, 17, 33, 34, 51, -13, 4, 6, -111, 51, 35, 34, 17, -15, 10, 1, 2, -128, 2, 1, -68, -95, 39, -96, 32, 48, 10, 6, 3,
 54				42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -126, 0, -124, 1, 0,
 55				-123, 2, 2, 43 };
 56	}
 57	
 58	@Test(groups = { "functional.decode","service.sms"})
 59	public void testDecode() throws Exception {
 60		
 61		byte[] rawData = getEncodedData();
 62		AsnInputStream asn = new AsnInputStream(rawData);
 63
 64		int tag = asn.readTag();
 65		ReportSMDeliveryStatusRequestIndicationImpl ind = new ReportSMDeliveryStatusRequestIndicationImpl(3);
 66		ind.decodeAll(asn);
 67
 68		assertEquals( tag,Tag.SEQUENCE);
 69		assertEquals( asn.getTagClass(),Tag.CLASS_UNIVERSAL);
 70
 71		ISDNAddressString msisdn = ind.getMsisdn();
 72		assertEquals( msisdn.getAddressNature(),AddressNature.international_number);
 73		assertEquals( msisdn.getNumberingPlan(),NumberingPlan.ISDN);
 74		assertEquals( msisdn.getAddress(),"7222333111");
 75		AddressString sca = ind.getServiceCentreAddress();
 76		assertEquals( sca.getAddressNature(),AddressNature.international_number);
 77		assertEquals( sca.getNumberingPlan(),NumberingPlan.ISDN);
 78		assertEquals( sca.getAddress(),"100937453");
 79		assertEquals( ind.getSMDeliveryOutcome(),SMDeliveryOutcome.absentSubscriber);
 80
 81		
 82		rawData = getEncodedDataFull();
 83		asn = new AsnInputStream(rawData);
 84
 85		tag = asn.readTag();
 86		ind = new ReportSMDeliveryStatusRequestIndicationImpl(3);
 87		ind.decodeAll(asn);
 88
 89		assertEquals( tag,Tag.SEQUENCE);
 90		assertEquals( asn.getTagClass(),Tag.CLASS_UNIVERSAL);
 91
 92		msisdn = ind.getMsisdn();
 93		assertEquals( msisdn.getAddressNature(),AddressNature.network_specific_number);
 94		assertEquals( msisdn.getNumberingPlan(),NumberingPlan.national);
 95		assertEquals( msisdn.getAddress(),"111222333");
 96		sca = ind.getServiceCentreAddress();
 97		assertEquals( sca.getAddressNature(),AddressNature.international_number);
 98		assertEquals( sca.getNumberingPlan(),NumberingPlan.ISDN);
 99		assertEquals( sca.getAddress(),"333222111");
100		assertEquals( ind.getSMDeliveryOutcome(),SMDeliveryOutcome.successfulTransfer);
101		assertEquals( (int) ind.getAbsentSubscriberDiagnosticSM(),444);		
102		assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ind.getExtensionContainer()));
103		assertEquals( (boolean)ind.getGprsSupportIndicator(),true);		
104		assertEquals( (boolean)ind.getDeliveryOutcomeIndicator(),false);		
105		assertEquals( ind.getAdditionalSMDeliveryOutcome(),SMDeliveryOutcome.memoryCapacityExceeded);
106		assertEquals( (int) ind.getAdditionalAbsentSubscriberDiagnosticSM(),555);		
107	}
108
109	@Test(groups = { "functional.encode","service.sms"})
110	public void testEncode() throws Exception {
111
112		ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "7222333111");
113		AddressString sca = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "100937453");
114		ReportSMDeliveryStatusRequestIndicationImpl ind = new ReportSMDeliveryStatusRequestIndicationImpl(3, msisdn, sca, SMDeliveryOutcome.absentSubscriber,
115				null, null, false, false, null, null);
116		
117		AsnOutputStream asnOS = new AsnOutputStream();
118		ind.encodeAll(asnOS);
119		
120		byte[] encodedData = asnOS.toByteArray();
121		byte[] rawData = getEncodedData();		
122		assertTrue( Arrays.equals(rawData,encodedData));
123
124		
125		msisdn = new ISDNAddressStringImpl(AddressNature.network_specific_number, NumberingPlan.national, "111222333");
126		sca = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "333222111");
127		ind = new ReportSMDeliveryStatusRequestIndicationImpl(3, msisdn, sca, SMDeliveryOutcome.successfulTransfer, 444,
128				MAPExtensionContainerTest.GetTestExtensionContainer(), true, false, SMDeliveryOutcome.memoryCapacityExceeded, 555);
129		
130		asnOS = new AsnOutputStream();
131		ind.encodeAll(asnOS);
132		
133		encodedData = asnOS.toByteArray();
134		rawData = getEncodedDataFull();		
135		assertTrue( Arrays.equals(rawData,encodedData));
136		
137		
138	}
139
140}