/protocols/ss7/map/map-impl/src/test/java/org/mobicents/protocols/ss7/map/errors/MAPErrorMessageTest.java

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