/protocols/ss7/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/errors/MAPErrorMessageTest.java
Java | 531 lines | 447 code | 55 blank | 29 comment | 0 complexity | d174fb71afada68db3b5f8108e1f6d74 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.errors; 24 25import java.util.Arrays; 26 27import static org.testng.Assert.*; 28 29import org.testng.*;import org.testng.annotations.*; 30 31import org.mobicents.protocols.asn.AsnInputStream; 32import org.mobicents.protocols.asn.AsnOutputStream; 33import org.mobicents.protocols.asn.Tag; 34import org.mobicents.protocols.ss7.map.api.errors.AbsentSubscriberReason; 35import org.mobicents.protocols.ss7.map.api.errors.AdditionalNetworkResource; 36import org.mobicents.protocols.ss7.map.api.errors.CallBarringCause; 37import org.mobicents.protocols.ss7.map.api.errors.MAPErrorCode; 38import org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageAbsentSubscriber; 39import org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageAbsentSubscriberSM; 40import org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageCallBarred; 41import org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageFacilityNotSup; 42import org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessagePositionMethodFailure; 43import org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSMDeliveryFailure; 44import org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSubscriberBusyForMtSms; 45import org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSystemFailure; 46import org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageUnauthorizedLCSClient; 47import org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageUnknownSubscriber; 48import org.mobicents.protocols.ss7.map.api.errors.NetworkResource; 49import org.mobicents.protocols.ss7.map.api.errors.PositionMethodFailureDiagnostic; 50import org.mobicents.protocols.ss7.map.api.errors.SMEnumeratedDeliveryFailureCause; 51import org.mobicents.protocols.ss7.map.api.errors.UnauthorizedLCSClientDiagnostic; 52import org.mobicents.protocols.ss7.map.api.errors.UnknownSubscriberDiagnostic; 53import org.mobicents.protocols.ss7.map.primitives.MAPExtensionContainerTest; 54import org.mobicents.protocols.ss7.tcap.asn.ParameterImpl; 55import org.mobicents.protocols.ss7.tcap.asn.comp.Parameter; 56 57/** 58 * 59 * @author sergey vetyutnev 60 * 61 */ 62public class MAPErrorMessageTest { 63 64 private Parameter getDataExtContainerFull() { 65 Parameter par = new ParameterImpl(); 66 par.setData(new byte[] { 48, 39, (byte) 160, 32, 48, 10, 6, 3, 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, 67 24, 25, 26, (byte) 161, 3, 31, 32, 33 }); 68 par.setPrimitive(false); 69 par.setTagClass(Tag.CLASS_UNIVERSAL); 70 par.setTag(Tag.SEQUENCE); 71 return par; 72 } 73 74 private Parameter getDataSmDeliveryFailure() { 75 Parameter par = new ParameterImpl(); 76 par.setData(new byte[] { 10, 1, 5 }); 77 par.setPrimitive(false); 78 par.setTagClass(Tag.CLASS_UNIVERSAL); 79 par.setTag(Tag.SEQUENCE); 80 return par; 81 // 10, 1, 0 82 } 83 84 private Parameter getDataSmDeliveryFailureFull() { 85 Parameter par = new ParameterImpl(); 86 par.setData(new byte[] { 10, 1, 4, 4, 5, 1, 3, 5, 7, 9, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 87 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }); 88 par.setPrimitive(false); 89 par.setTagClass(Tag.CLASS_UNIVERSAL); 90 par.setTag(Tag.SEQUENCE); 91 return par; 92 } 93 94 private Parameter getDataAbsentSubscriberSM() { 95 Parameter par = new ParameterImpl(); 96 par.setData(new byte[] { 2, 1, 1 }); 97 par.setPrimitive(false); 98 par.setTagClass(Tag.CLASS_UNIVERSAL); 99 par.setTag(Tag.SEQUENCE); 100 return par; 101 // 2, 1, 0 102 // 2, 1, 4 103 } 104 105 private Parameter getDataAbsentSubscriberSMFull() { 106 Parameter par = new ParameterImpl(); 107 par.setData(new byte[] { 2, 1, 11, 48, 39, (byte) 160, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 108 21, 22, 23, 24, 25, 26, (byte) 161, 3, 31, 32, 33, (byte) 128, 1, 22 }); 109 par.setPrimitive(false); 110 par.setTagClass(Tag.CLASS_UNIVERSAL); 111 par.setTag(Tag.SEQUENCE); 112 return par; 113 } 114 115 private Parameter getDataCallBarred() { 116 Parameter par = new ParameterImpl(); 117 par.setData(new byte[] { 10, 1, 1 }); 118 par.setPrimitive(false); 119 par.setTagClass(Tag.CLASS_UNIVERSAL); 120 par.setTag(Tag.SEQUENCE); 121 return par; 122 } 123 124 private Parameter getDataCallBarredFull() { 125 Parameter par = new ParameterImpl(); 126 par.setData(new byte[] { 10, 1, 1, 48, 39, (byte) 160, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 127 21, 22, 23, 24, 25, 26, (byte) 161, 3, 31, 32, 33, (byte) 129, 0 }); 128 par.setPrimitive(false); 129 par.setTagClass(Tag.CLASS_UNIVERSAL); 130 par.setTag(Tag.SEQUENCE); 131 return par; 132 } 133 134 private Parameter getDataSystemFailure() { 135 Parameter par = new ParameterImpl(); 136 par.setData(new byte[] { 0 }); 137 par.setPrimitive(true); 138 par.setTagClass(Tag.CLASS_UNIVERSAL); 139 par.setTag(Tag.ENUMERATED); 140 return par; 141 } 142 143 private Parameter getDataSystemFailureFull() { 144 Parameter par = new ParameterImpl(); 145 par.setData(new byte[] { 10, 1, 2, 48, 39, (byte) 160, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 146 21, 22, 23, 24, 25, 26, (byte) 161, 3, 31, 32, 33, (byte) 128, 1, 3 }); 147 par.setPrimitive(false); 148 par.setTagClass(Tag.CLASS_UNIVERSAL); 149 par.setTag(Tag.SEQUENCE); 150 return par; 151 } 152 153 private Parameter getDataFacilityNotSupFull() { 154 Parameter par = new ParameterImpl(); 155 par.setData(new byte[] { 48, 39, (byte) 160, 32, 48, 10, 6, 3, 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, 156 24, 25, 26, (byte) 161, 3, 31, 32, 33, (byte) 128, 0, (byte) 129, 0 }); 157 par.setPrimitive(false); 158 par.setTagClass(Tag.CLASS_UNIVERSAL); 159 par.setTag(Tag.SEQUENCE); 160 return par; 161 } 162 163 private Parameter getDataUnknownSubscriberFull() { 164 Parameter par = new ParameterImpl(); 165 par.setData(new byte[] { 48, 39, (byte) 160, 32, 48, 10, 6, 3, 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, 166 24, 25, 26, (byte) 161, 3, 31, 32, 33, 10, 1, 1 }); 167 par.setPrimitive(false); 168 par.setTagClass(Tag.CLASS_UNIVERSAL); 169 par.setTag(Tag.SEQUENCE); 170 return par; 171 } 172 173 private Parameter getDataSubscriberBusyForMTSMSFull() { 174 Parameter par = new ParameterImpl(); 175 par.setData(new byte[] { 48, 39, (byte) 160, 32, 48, 10, 6, 3, 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, 176 24, 25, 26, (byte) 161, 3, 31, 32, 33, 5, 0 }); 177 par.setPrimitive(false); 178 par.setTagClass(Tag.CLASS_UNIVERSAL); 179 par.setTag(Tag.SEQUENCE); 180 return par; 181 } 182 183 private Parameter getDataAbsentSubscriberFull() { 184 Parameter par = new ParameterImpl(); 185 par.setData(new byte[] { 48, 39, (byte) 160, 32, 48, 10, 6, 3, 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, 186 24, 25, 26, (byte) 161, 3, 31, 32, 33, (byte) 128, 1, 3 }); 187 par.setPrimitive(false); 188 par.setTagClass(Tag.CLASS_UNIVERSAL); 189 par.setTag(Tag.SEQUENCE); 190 return par; 191 } 192 193 private Parameter getDataUnauthorizedLCSClientFull() { 194 Parameter par = new ParameterImpl(); 195 par.setData(new byte[] { (byte) 128, 1, 2, (byte) 161, 39, (byte) 160, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 196 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, (byte) 161, 3, 31, 32, 33 }); 197 par.setPrimitive(false); 198 par.setTagClass(Tag.CLASS_UNIVERSAL); 199 par.setTag(Tag.SEQUENCE); 200 return par; 201 } 202 203 private Parameter getDataPositionMethodFailureFull() { 204 Parameter par = new ParameterImpl(); 205 par.setData(new byte[] { (byte) 128, 1, 4, (byte) 161, 39, (byte) 160, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 206 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, (byte) 161, 3, 31, 32, 33 }); 207 par.setPrimitive(false); 208 par.setTagClass(Tag.CLASS_UNIVERSAL); 209 par.setTag(Tag.SEQUENCE); 210 return par; 211 } 212 213 @Test(groups = { "functional.decode","dialog.message"}) 214 public void testDecode() throws Exception { 215 216 MAPErrorMessageFactoryImpl fact = new MAPErrorMessageFactoryImpl(); 217 218 Parameter p = getDataSmDeliveryFailure(); 219 MAPErrorMessageImpl em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.smDeliveryFailure); 220 AsnInputStream ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 221 em.decodeData(ais, p.getData().length); 222 assertTrue(em.isEmSMDeliveryFailure()); 223 MAPErrorMessageSMDeliveryFailure emSMDeliveryFailure = em.getEmSMDeliveryFailure(); 224 assertEquals( emSMDeliveryFailure.getSMEnumeratedDeliveryFailureCause(),SMEnumeratedDeliveryFailureCause.invalidSMEAddress); 225 assertNull(emSMDeliveryFailure.getSignalInfo()); 226 assertNull(emSMDeliveryFailure.getExtensionContainer()); 227 228 p = getDataSmDeliveryFailureFull(); 229 em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.smDeliveryFailure); 230 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 231 em.decodeData(ais, p.getData().length); 232 assertTrue(em.isEmSMDeliveryFailure()); 233 emSMDeliveryFailure = em.getEmSMDeliveryFailure(); 234 assertEquals( emSMDeliveryFailure.getSMEnumeratedDeliveryFailureCause(),SMEnumeratedDeliveryFailureCause.scCongestion); 235 assertNotNull(emSMDeliveryFailure.getSignalInfo()); 236 assertNotNull(emSMDeliveryFailure.getExtensionContainer()); 237 assertTrue(Arrays.equals(emSMDeliveryFailure.getSignalInfo(), new byte[] { 1, 3, 5, 7, 9 })); 238 assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(emSMDeliveryFailure.getExtensionContainer())); 239 240 p = getDataAbsentSubscriberSM(); 241 em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.absentSubscriberSM); 242 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 243 em.decodeData(ais, p.getData().length); 244 assertTrue(em.isEmAbsentSubscriberSM()); 245 MAPErrorMessageAbsentSubscriberSM emAbsentSubscriberSMImpl = em.getEmAbsentSubscriberSM(); 246 assertEquals( (int) emAbsentSubscriberSMImpl.getAbsentSubscriberDiagnosticSM(),1); 247 assertNull(emAbsentSubscriberSMImpl.getAdditionalAbsentSubscriberDiagnosticSM()); 248 assertNull(emAbsentSubscriberSMImpl.getExtensionContainer()); 249 250 p = getDataAbsentSubscriberSMFull(); 251 em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.absentSubscriberSM); 252 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 253 em.decodeData(ais, p.getData().length); 254 assertTrue(em.isEmAbsentSubscriberSM()); 255 emAbsentSubscriberSMImpl = em.getEmAbsentSubscriberSM(); 256 assertEquals( (int) emAbsentSubscriberSMImpl.getAbsentSubscriberDiagnosticSM(),11); 257 assertEquals( (int) emAbsentSubscriberSMImpl.getAdditionalAbsentSubscriberDiagnosticSM(),22); 258 assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(emAbsentSubscriberSMImpl.getExtensionContainer())); 259 260 p = getDataSystemFailure(); 261 em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.systemFailure); 262 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 263 em.decodeData(ais, p.getData().length); 264 assertTrue(em.isEmSystemFailure()); 265 MAPErrorMessageSystemFailure emSystemFailure = em.getEmSystemFailure(); 266 assertEquals( emSystemFailure.getMapProtocolVersion(),2); 267 assertEquals( emSystemFailure.getNetworkResource(),NetworkResource.plmn); 268 assertNull(emSystemFailure.getAdditionalNetworkResource()); 269 assertNull(emSystemFailure.getExtensionContainer()); 270 271 p = getDataSystemFailureFull(); 272 em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.systemFailure); 273 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 274 em.decodeData(ais, p.getData().length); 275 assertTrue(em.isEmSystemFailure()); 276 emSystemFailure = em.getEmSystemFailure(); 277 assertEquals( emSystemFailure.getMapProtocolVersion(),3); 278 assertEquals( emSystemFailure.getNetworkResource(),NetworkResource.vlr); 279 assertEquals( emSystemFailure.getAdditionalNetworkResource(),AdditionalNetworkResource.gsmSCF); 280 assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(emAbsentSubscriberSMImpl.getExtensionContainer())); 281 282 p = getDataCallBarred(); 283 em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.callBarred); 284 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 285 em.decodeData(ais, p.getData().length); 286 assertTrue(em.isEmCallBarred()); 287 MAPErrorMessageCallBarred emCallBarred = em.getEmCallBarred(); 288 assertEquals( emCallBarred.getMapProtocolVersion(),3); 289 assertEquals( emCallBarred.getCallBarringCause(),CallBarringCause.operatorBarring); 290 assertEquals( (boolean)emCallBarred.getUnauthorisedMessageOriginator(),false); 291 assertNull(emCallBarred.getExtensionContainer()); 292 293 p = getDataCallBarredFull(); 294 em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.callBarred); 295 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 296 em.decodeData(ais, p.getData().length); 297 assertTrue(em.isEmCallBarred()); 298 emCallBarred = em.getEmCallBarred(); 299 assertEquals( emCallBarred.getMapProtocolVersion(),3); 300 assertEquals( emCallBarred.getCallBarringCause(),CallBarringCause.operatorBarring); 301 assertEquals( (boolean)emCallBarred.getUnauthorisedMessageOriginator(),true); 302 assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(emCallBarred.getExtensionContainer())); 303 304 p = getDataFacilityNotSupFull(); 305 em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.facilityNotSupported); 306 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 307 em.decodeData(ais, p.getData().length); 308 assertTrue(em.isEmFacilityNotSup()); 309 MAPErrorMessageFacilityNotSup emFacilityNotSup = em.getEmFacilityNotSup(); 310 assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(emFacilityNotSup.getExtensionContainer())); 311 assertEquals( (boolean)emFacilityNotSup.getShapeOfLocationEstimateNotSupported(),true); 312 assertEquals( (boolean)emFacilityNotSup.getNeededLcsCapabilityNotSupportedInServingNode(),true); 313 314 p = getDataUnknownSubscriberFull(); 315 em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.unknownSubscriber); 316 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 317 em.decodeData(ais, p.getData().length); 318 assertTrue(em.isEmUnknownSubscriber()); 319 MAPErrorMessageUnknownSubscriber emUnknownSubscriber = em.getEmUnknownSubscriber(); 320 assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(emUnknownSubscriber.getExtensionContainer())); 321 assertEquals( emUnknownSubscriber.getUnknownSubscriberDiagnostic(),UnknownSubscriberDiagnostic.gprsSubscriptionUnknown); 322 323 p = getDataSubscriberBusyForMTSMSFull(); 324 em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.subscriberBusyForMTSMS); 325 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 326 em.decodeData(ais, p.getData().length); 327 assertTrue(em.isEmSubscriberBusyForMtSms()); 328 MAPErrorMessageSubscriberBusyForMtSms emSubscriberBusyForMtSms = em.getEmSubscriberBusyForMtSms(); 329 assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(emSubscriberBusyForMtSms.getExtensionContainer())); 330 assertEquals( (boolean)emSubscriberBusyForMtSms.getGprsConnectionSuspended(),true); 331 332 p = getDataAbsentSubscriberFull(); 333 em = (MAPErrorMessageImpl)fact.createMessageFromErrorCode((long) MAPErrorCode.absentSubscriber); 334 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 335 em.decodeData(ais, p.getData().length); 336 assertTrue(em.isEmAbsentSubscriber()); 337 MAPErrorMessageAbsentSubscriber emAbsentSubscriber = em.getEmAbsentSubscriber(); 338 assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(emAbsentSubscriber.getExtensionContainer())); 339 assertEquals( emAbsentSubscriber.getAbsentSubscriberReason(),AbsentSubscriberReason.purgedMS); 340 341 p = getDataUnauthorizedLCSClientFull(); 342 em = (MAPErrorMessageImpl) fact.createMessageFromErrorCode((long) MAPErrorCode.unauthorizedLCSClient); 343 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 344 em.decodeData(ais, p.getData().length); 345 assertTrue(em.isEmUnauthorizedLCSClient()); 346 MAPErrorMessageUnauthorizedLCSClient emUnauthorizedLCSClient = em.getEmUnauthorizedLCSClient(); 347 assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(emUnauthorizedLCSClient.getExtensionContainer())); 348 assertEquals( emUnauthorizedLCSClient.getUnauthorizedLCSClientDiagnostic(),UnauthorizedLCSClientDiagnostic.callToClientNotSetup); 349 350 p = getDataPositionMethodFailureFull(); 351 em = (MAPErrorMessageImpl) fact.createMessageFromErrorCode((long) MAPErrorCode.positionMethodFailure); 352 ais = new AsnInputStream(p.getData(), p.getTagClass(), p.isPrimitive(), p.getTag()); 353 em.decodeData(ais, p.getData().length); 354 assertTrue(em.isEmPositionMethodFailure()); 355 MAPErrorMessagePositionMethodFailure emPositionMethodFailure = em.getEmPositionMethodFailure(); 356 assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(emPositionMethodFailure.getExtensionContainer())); 357 assertEquals( emPositionMethodFailure.getPositionMethodFailureDiagnostic(),PositionMethodFailureDiagnostic.locationProcedureNotCompleted); 358 } 359 360 @Test(groups = { "functional.encode","dialog.message"}) 361 public void testEncode() throws Exception { 362 363 MAPErrorMessageFactoryImpl fact = new MAPErrorMessageFactoryImpl(); 364 365 MAPErrorMessageImpl em = (MAPErrorMessageImpl)fact.createMAPErrorMessageExtensionContainer(36L, MAPExtensionContainerTest.GetTestExtensionContainer()); 366 AsnOutputStream aos = new AsnOutputStream(); 367 em.encodeData(aos); 368 Parameter p = new ParameterImpl(); 369 p.setTagClass(em.getTagClass()); 370 p.setTag(em.getTag()); 371 p.setPrimitive(em.getIsPrimitive()); 372 p.setData(aos.toByteArray()); 373 assertParameter( getDataExtContainerFull(),p); 374 375 em = (MAPErrorMessageImpl)fact.createMAPErrorMessageSMDeliveryFailure(SMEnumeratedDeliveryFailureCause.invalidSMEAddress, null, null); 376 aos = new AsnOutputStream(); 377 em.encodeData(aos); 378 p = new ParameterImpl(); 379 p.setTagClass(em.getTagClass()); 380 p.setTag(em.getTag()); 381 p.setPrimitive(em.getIsPrimitive()); 382 p.setData(aos.toByteArray()); 383 assertParameter( getDataSmDeliveryFailure(),p); 384 385 em = (MAPErrorMessageImpl)fact.createMAPErrorMessageSMDeliveryFailure(SMEnumeratedDeliveryFailureCause.scCongestion, new byte[] { 1, 3, 5, 7, 9 }, 386 MAPExtensionContainerTest.GetTestExtensionContainer()); 387 aos = new AsnOutputStream(); 388 em.encodeData(aos); 389 p = new ParameterImpl(); 390 p.setTagClass(em.getTagClass()); 391 p.setTag(em.getTag()); 392 p.setPrimitive(em.getIsPrimitive()); 393 p.setData(aos.toByteArray()); 394 assertParameter( getDataSmDeliveryFailureFull(),p); 395 396 em = (MAPErrorMessageImpl)fact.createMAPErrorMessageAbsentSubscriberSM(1, null, null); 397 aos = new AsnOutputStream(); 398 em.encodeData(aos); 399 p = new ParameterImpl(); 400 p.setTagClass(em.getTagClass()); 401 p.setTag(em.getTag()); 402 p.setPrimitive(em.getIsPrimitive()); 403 p.setData(aos.toByteArray()); 404 assertParameter( getDataAbsentSubscriberSM(),p); 405 406 em = (MAPErrorMessageImpl)fact.createMAPErrorMessageAbsentSubscriberSM(11, MAPExtensionContainerTest.GetTestExtensionContainer(), 22); 407 aos = new AsnOutputStream(); 408 em.encodeData(aos); 409 p = new ParameterImpl(); 410 p.setTagClass(em.getTagClass()); 411 p.setTag(em.getTag()); 412 p.setPrimitive(em.getIsPrimitive()); 413 p.setData(aos.toByteArray()); 414 assertParameter( getDataAbsentSubscriberSMFull(),p); 415 416 em = (MAPErrorMessageImpl)fact.createMAPErrorMessageSystemFailure(2, NetworkResource.plmn, null, null); 417 aos = new AsnOutputStream(); 418 em.encodeData(aos); 419 p = new ParameterImpl(); 420 p.setTagClass(em.getTagClass()); 421 p.setTag(em.getTag()); 422 p.setPrimitive(em.getIsPrimitive()); 423 p.setData(aos.toByteArray()); 424 assertParameter( getDataSystemFailure(),p); 425 426 em = (MAPErrorMessageImpl)fact.createMAPErrorMessageSystemFailure(3, NetworkResource.vlr, AdditionalNetworkResource.gsmSCF, 427 MAPExtensionContainerTest.GetTestExtensionContainer()); 428 aos = new AsnOutputStream(); 429 em.encodeData(aos); 430 p = new ParameterImpl(); 431 p.setTagClass(em.getTagClass()); 432 p.setTag(em.getTag()); 433 p.setPrimitive(em.getIsPrimitive()); 434 p.setData(aos.toByteArray()); 435 assertParameter( getDataSystemFailureFull(),p); 436 437 em = (MAPErrorMessageImpl)fact.createMAPErrorMessageCallBarred(3L, CallBarringCause.operatorBarring, null, null); 438 aos = new AsnOutputStream(); 439 em.encodeData(aos); 440 p = new ParameterImpl(); 441 p.setTagClass(em.getTagClass()); 442 p.setTag(em.getTag()); 443 p.setPrimitive(em.getIsPrimitive()); 444 p.setData(aos.toByteArray()); 445 assertParameter( getDataCallBarred(),p); 446 447 em = (MAPErrorMessageImpl) fact.createMAPErrorMessageCallBarred(3L, CallBarringCause.operatorBarring, 448 MAPExtensionContainerTest.GetTestExtensionContainer(), true); 449 aos = new AsnOutputStream(); 450 em.encodeData(aos); 451 p = new ParameterImpl(); 452 p.setTagClass(em.getTagClass()); 453 p.setTag(em.getTag()); 454 p.setPrimitive(em.getIsPrimitive()); 455 p.setData(aos.toByteArray()); 456 assertParameter( getDataCallBarredFull(),p); 457 458 em = (MAPErrorMessageImpl) fact.createMAPErrorMessageFacilityNotSup(MAPExtensionContainerTest.GetTestExtensionContainer(), true, true); 459 aos = new AsnOutputStream(); 460 em.encodeData(aos); 461 p = new ParameterImpl(); 462 p.setTagClass(em.getTagClass()); 463 p.setTag(em.getTag()); 464 p.setPrimitive(em.getIsPrimitive()); 465 p.setData(aos.toByteArray()); 466 assertParameter( getDataFacilityNotSupFull(),p); 467 468 em = (MAPErrorMessageImpl) fact.createMAPErrorMessageUnknownSubscriber(MAPExtensionContainerTest.GetTestExtensionContainer(), 469 UnknownSubscriberDiagnostic.gprsSubscriptionUnknown); 470 aos = new AsnOutputStream(); 471 em.encodeData(aos); 472 p = new ParameterImpl(); 473 p.setTagClass(em.getTagClass()); 474 p.setTag(em.getTag()); 475 p.setPrimitive(em.getIsPrimitive()); 476 p.setData(aos.toByteArray()); 477 assertParameter( getDataUnknownSubscriberFull(),p); 478 479 em = (MAPErrorMessageImpl) fact.createMAPErrorMessageSubscriberBusyForMtSms(MAPExtensionContainerTest.GetTestExtensionContainer(), true); 480 aos = new AsnOutputStream(); 481 em.encodeData(aos); 482 p = new ParameterImpl(); 483 p.setTagClass(em.getTagClass()); 484 p.setTag(em.getTag()); 485 p.setPrimitive(em.getIsPrimitive()); 486 p.setData(aos.toByteArray()); 487 assertParameter( getDataSubscriberBusyForMTSMSFull(),p); 488 489 em = (MAPErrorMessageImpl) fact.createMAPErrorMessageAbsentSubscriber(MAPExtensionContainerTest.GetTestExtensionContainer(), 490 AbsentSubscriberReason.purgedMS); 491 aos = new AsnOutputStream(); 492 em.encodeData(aos); 493 p = new ParameterImpl(); 494 p.setTagClass(em.getTagClass()); 495 p.setTag(em.getTag()); 496 p.setPrimitive(em.getIsPrimitive()); 497 p.setData(aos.toByteArray()); 498 assertParameter( getDataAbsentSubscriberFull(),p); 499 500 em = (MAPErrorMessageImpl) fact.createMAPErrorMessageUnauthorizedLCSClient(UnauthorizedLCSClientDiagnostic.callToClientNotSetup, 501 MAPExtensionContainerTest.GetTestExtensionContainer()); 502 aos = new AsnOutputStream(); 503 em.encodeData(aos); 504 p = new ParameterImpl(); 505 p.setTagClass(em.getTagClass()); 506 p.setTag(em.getTag()); 507 p.setPrimitive(em.getIsPrimitive()); 508 p.setData(aos.toByteArray()); 509 assertParameter( getDataUnauthorizedLCSClientFull(),p); 510 511 em = (MAPErrorMessageImpl) fact.createMAPErrorMessagePositionMethodFailure(PositionMethodFailureDiagnostic.locationProcedureNotCompleted, 512 MAPExtensionContainerTest.GetTestExtensionContainer()); 513 aos = new AsnOutputStream(); 514 em.encodeData(aos); 515 p = new ParameterImpl(); 516 p.setTagClass(em.getTagClass()); 517 p.setTag(em.getTag()); 518 p.setPrimitive(em.getIsPrimitive()); 519 p.setData(aos.toByteArray()); 520 assertParameter( getDataPositionMethodFailureFull(),p); 521 } 522 523 private void assertParameter( Parameter p2,Parameter p1) { 524 assertNotNull(p1); 525 assertNotNull(p2); 526 assertEquals( p2.getTagClass(),p1.getTagClass()); 527 assertEquals( p2.getTag(),p1.getTag()); 528 assertEquals( p2.isPrimitive(),p1.isPrimitive()); 529 assertTrue(Arrays.equals(p1.getData(), p2.getData())); 530 } 531}