Revision: 21461
Author:   [email protected]
Date:     Fri Jan  6 23:27:54 2012
Log:      INAP & CAP update: ISUP depended parameters implementation
http://code.google.com/p/mobicents/source/detail?r=21461

Added:
/trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/AdditionalCallingPartyNumberCapTest.java /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/BearerCapTest.java /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CalledPartyNumberCapTest.java /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CallingPartyNumberCapTest.java /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/GenericNumberCapTest.java /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/LocationNumberCapTest.java /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/OriginalCalledNumberCapTest.java /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/RedirectingPartyIDCapTest.java /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/primitive/BearerCapabilityTest.java

=======================================
--- /dev/null
+++ /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/AdditionalCallingPartyNumberCapTest.java Fri Jan 6 23:27:54 2012
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.cap.isup;
+
+import static org.testng.Assert.*;
+
+import java.util.Arrays;
+
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.asn.Tag;
+import org.mobicents.protocols.ss7.isup.impl.message.parameter.GenericNumberImpl;
+import org.mobicents.protocols.ss7.isup.message.parameter.GenericNumber;
+import org.testng.*;import org.testng.annotations.*;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class AdditionalCallingPartyNumberCapTest {
+
+       public byte[] getData() {
+               return new byte[] {  };
+       }
+
+       public byte[] getIntData() {
+               return new byte[] {  };
+       }
+
+       @Test(groups = { "functional.decode","isup"})
+       public void testDecode() throws Exception {
+
+//             byte[] data = this.getData();
+//             AsnInputStream ais = new AsnInputStream(data);
+// AdditionalCallingPartyNumberCapImpl elem = new AdditionalCallingPartyNumberCapImpl();
+//             int tag = ais.readTag();
+//             elem.decodeAll(ais);
+//             GenericNumber gn = elem.getGenericNumber();
+//             assertTrue(Arrays.equals(elem.getData(), this.getIntData()));
+//             assertEquals(gn.getNatureOfAddressIndicator(), 3);
+//             assertTrue(gn.getAddress().equals("7010900"));
+//             assertEquals(gn.getNumberingPlanIndicator(), 1);
+//             assertEquals(gn.getAddressRepresentationRestrictedIndicator(), 
1);
+//             assertEquals(gn.getNumberQualifierIndicator(), 1);
+//             assertEquals(gn.getScreeningIndicator(), 0);
+
+               // TODO: implement decoding test after getting encoded data
+       }
+
+       @Test(groups = { "functional.encode","isup"})
+       public void testEncode() throws Exception {
+
+// AdditionalCallingPartyNumberCapImpl elem = new AdditionalCallingPartyNumberCapImpl(this.getIntData());
+//             AsnOutputStream aos = new AsnOutputStream();
+//             elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 29);
+//             assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+// GenericNumber rn = new GenericNumberImpl(3, "7010900", 1, 1, 1, false, 0);
+//             elem = new AdditionalCallingPartyNumberCapImpl(rn);
+//             aos = new AsnOutputStream();
+//             elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 29);
+//             assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+ // int natureOfAddresIndicator, String address, int numberQualifierIndicator, int numberingPlanIndicator, int addressRepresentationREstrictedIndicator,
+               // boolean numberIncomplete, int screeningIndicator
+
+               // TODO: resolve ISUP GenericNumber encoding failure
+       }
+}
+
=======================================
--- /dev/null
+++ /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/BearerCapTest.java Fri Jan 6 23:27:54 2012
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.cap.isup;
+
+import static org.testng.Assert.*;
+
+import java.util.Arrays;
+
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.asn.Tag;
+import org.mobicents.protocols.ss7.isup.message.parameter.UserServiceInformation;
+import org.testng.*;import org.testng.annotations.*;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class BearerCapTest {
+
+       public byte[] getData() {
+               return new byte[] { (byte) 128, 3, (byte) 128, (byte) 144, 
(byte) 163 };
+       }
+
+       public byte[] getIntData() {
+               return new byte[] { (byte) 128, (byte) 144, (byte) 163 };
+       }
+
+       @Test(groups = { "functional.decode","isup"})
+       public void testDecode() throws Exception {
+
+               byte[] data = this.getData();
+               AsnInputStream ais = new AsnInputStream(data);
+               BearerCapImpl elem = new BearerCapImpl();
+               int tag = ais.readTag();
+               elem.decodeAll(ais);
+               assertTrue(Arrays.equals(elem.getData(), this.getIntData()));
+               UserServiceInformation usi = elem.getUserServiceInformation();
+
+ // TODO: implement UserServiceInformation (ISUP) and then implement CAP unit tests for UserServiceInformation usi
+
+//             assertEquals(ci.getCodingStandard(), 0);
+       }
+
+       @Test(groups = { "functional.encode","isup"})
+       public void testEncode() throws Exception {
+
+               BearerCapImpl elem = new BearerCapImpl(this.getIntData());
+               AsnOutputStream aos = new AsnOutputStream();
+               elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 0);
+               assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+ // TODO: implement UserServiceInformation (ISUP) and then implement CAP unit tests for UserServiceInformation usi
+
+//             UserServiceInformation usi = new 
UserServiceInformationImpl(cdata);
+//             elem = new BearerCapImpl(usi);
+//             aos = new AsnOutputStream();
+//             elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 0);
+//             assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+       }
+}
+
=======================================
--- /dev/null
+++ /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CalledPartyNumberCapTest.java Fri Jan 6 23:27:54 2012
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.cap.isup;
+
+import static org.testng.Assert.*;
+
+import java.util.Arrays;
+
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.asn.Tag;
+import org.mobicents.protocols.ss7.isup.impl.message.parameter.CalledPartyNumberImpl; +import org.mobicents.protocols.ss7.isup.message.parameter.CalledPartyNumber;
+import org.testng.*;import org.testng.annotations.*;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class CalledPartyNumberCapTest {
+
+       public byte[] getData() {
+ return new byte[] { (byte) 130, 7, 3, (byte) 144, 33, 114, 16, (byte) 144, 0 };
+       }
+
+       public byte[] getIntData() {
+               return new byte[] { 3, (byte) 144, 33, 114, 16, (byte) 144, 0 };
+       }
+
+       @Test(groups = { "functional.decode","isup"})
+       public void testDecode() throws Exception {
+
+               byte[] data = this.getData();
+               AsnInputStream ais = new AsnInputStream(data);
+               CalledPartyNumberCapImpl elem = new CalledPartyNumberCapImpl();
+               int tag = ais.readTag();
+               elem.decodeAll(ais);
+               CalledPartyNumber cpn = elem.getCalledPartyNumber();
+               assertTrue(Arrays.equals(elem.getData(), this.getIntData()));
+               assertFalse(cpn.isOddFlag());
+               assertEquals(cpn.getNumberingPlanIndicator(), 1);
+               assertEquals(cpn.getInternalNetworkNumberIndicator(), 1);
+               assertEquals(cpn.getNatureOfAddressIndicator(), 3);
+               assertTrue(cpn.getAddress().equals("1227010900"));
+       }
+
+       @Test(groups = { "functional.encode","isup"})
+       public void testEncode() throws Exception {
+
+ CalledPartyNumberCapImpl elem = new CalledPartyNumberCapImpl(this.getIntData());
+               AsnOutputStream aos = new AsnOutputStream();
+               elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 2);
+               assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+               CalledPartyNumber cpn = new CalledPartyNumberImpl(3, 
"1227010900", 1, 1);
+               elem = new CalledPartyNumberCapImpl(cpn);
+               aos = new AsnOutputStream();
+               elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 2);
+               assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+ // int natureOfAddresIndicator, String address, int numberingPlanIndicator, int internalNetworkNumberIndicator
+       }
+}
+
=======================================
--- /dev/null
+++ /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/CallingPartyNumberCapTest.java Fri Jan 6 23:27:54 2012
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.cap.isup;
+
+import static org.testng.Assert.*;
+
+import java.util.Arrays;
+
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.asn.Tag;
+import org.mobicents.protocols.ss7.isup.impl.message.parameter.CallingPartyNumberImpl; +import org.mobicents.protocols.ss7.isup.message.parameter.CallingPartyNumber;
+import org.testng.*;import org.testng.annotations.*;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class CallingPartyNumberCapTest {
+
+       public byte[] getData() {
+ return new byte[] { (byte) 131, 8, (byte) 132, 17, 20, (byte) 135, 9, 80, 64, (byte) 7 }; // 247
+       }
+
+       public byte[] getIntData() {
+ return new byte[] { (byte) 132, 17, 20, (byte) 135, 9, 80, 64, (byte) 7 }; // 247
+       }
+
+       @Test(groups = { "functional.decode","isup"})
+       public void testDecode() throws Exception {
+
+               byte[] data = this.getData();
+               AsnInputStream ais = new AsnInputStream(data);
+               CallingPartyNumberCapImpl elem = new 
CallingPartyNumberCapImpl();
+               int tag = ais.readTag();
+               elem.decodeAll(ais);
+               CallingPartyNumber cpn = elem.getCallingPartyNumber();
+               assertTrue(Arrays.equals(elem.getData(), this.getIntData()));
+               assertTrue(cpn.isOddFlag());
+               assertEquals(cpn.getNumberingPlanIndicator(), 1);
+               assertEquals(cpn.getScreeningIndicator(), 1);
+               assertEquals(cpn.getAddressRepresentationREstrictedIndicator(), 
0);
+               assertEquals(cpn.getNumberIncompleteIndicator(), 0);
+               assertEquals(cpn.getNatureOfAddressIndicator(), 4);
+               assertTrue(cpn.getAddress().equals("41789005047"));
+       }
+
+       @Test(groups = { "functional.encode","isup"})
+       public void testEncode() throws Exception {
+
+ CallingPartyNumberCapImpl elem = new CallingPartyNumberCapImpl(this.getIntData());
+               AsnOutputStream aos = new AsnOutputStream();
+               elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 3);
+               assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+ CallingPartyNumber cpn = new CallingPartyNumberImpl(4, "41789005047", 1, 0, 0, 1);
+               elem = new CallingPartyNumberCapImpl(cpn);
+               aos = new AsnOutputStream();
+               elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 3);
+               assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+// int natureOfAddresIndicator, String address, int numberingPlanIndicator, int numberIncompleteIndicator, int addressRepresentationREstrictedIndicator,
+//             int screeningIndicator
+       }
+}
+
+
=======================================
--- /dev/null
+++ /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/GenericNumberCapTest.java Fri Jan 6 23:27:54 2012
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.cap.isup;
+
+import static org.testng.Assert.*;
+
+import java.util.Arrays;
+
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.asn.Tag;
+import org.mobicents.protocols.ss7.isup.impl.message.parameter.GenericNumberImpl;
+import org.mobicents.protocols.ss7.isup.message.parameter.GenericNumber;
+import org.testng.*;import org.testng.annotations.*;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class GenericNumberCapTest {
+
+       public byte[] getData() {
+               return new byte[] {  };
+       }
+
+       public byte[] getIntData() {
+               return new byte[] {  };
+       }
+
+       @Test(groups = { "functional.decode","isup"})
+       public void testDecode() throws Exception {
+
+//             byte[] data = this.getData();
+//             AsnInputStream ais = new AsnInputStream(data);
+//             GenericNumberCapImpl elem = new GenericNumberCapImpl();
+//             int tag = ais.readTag();
+//             elem.decodeAll(ais);
+//             GenericNumber gn = elem.getGenericNumber();
+//             assertTrue(Arrays.equals(elem.getData(), this.getIntData()));
+//             assertEquals(gn.getNatureOfAddressIndicator(), 3);
+//             assertTrue(gn.getAddress().equals("7010900"));
+//             assertEquals(gn.getNumberingPlanIndicator(), 1);
+//             assertEquals(gn.getAddressRepresentationRestrictedIndicator(), 
1);
+//             assertEquals(gn.getNumberQualifierIndicator(), 1);
+//             assertEquals(gn.getScreeningIndicator(), 0);
+
+               // TODO: implement decoding test after getting encoded data
+       }
+
+       @Test(groups = { "functional.encode","isup"})
+       public void testEncode() throws Exception {
+
+// GenericNumberCapImpl elem = new GenericNumberCapImpl(this.getIntData());
+//             AsnOutputStream aos = new AsnOutputStream();
+//             elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 29);
+//             assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+//
+// GenericNumber rn = new GenericNumberImpl(3, "7010900", 1, 1, 1, false, 0);
+//             elem = new GenericNumberCapImpl(rn);
+//             aos = new AsnOutputStream();
+//             elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 29);
+//             assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+ // int natureOfAddresIndicator, String address, int numberQualifierIndicator, int numberingPlanIndicator, int addressRepresentationREstrictedIndicator,
+               // boolean numberIncomplete, int screeningIndicator
+
+               // TODO: resolve ISUP GenericNumber encoding failure
+       }
+}
=======================================
--- /dev/null
+++ /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/LocationNumberCapTest.java Fri Jan 6 23:27:54 2012
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.cap.isup;
+
+import static org.testng.Assert.*;
+
+import java.util.Arrays;
+
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.asn.Tag;
+import org.mobicents.protocols.ss7.isup.impl.message.parameter.LocationNumberImpl;
+import org.mobicents.protocols.ss7.isup.message.parameter.LocationNumber;
+import org.testng.*;import org.testng.annotations.*;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class LocationNumberCapTest {
+
+       public byte[] getData() {
+ return new byte[] { (byte) 138, 8, (byte) 132, (byte) 151, 8, 2, (byte) 151, 1, 32, (byte) 144 };
+       }
+
+       public byte[] getIntData() {
+ return new byte[] { (byte) 132, (byte) 151, 8, 2, (byte) 151, 1, 32, (byte) 144 };
+       }
+
+       @Test(groups = { "functional.decode","isup"})
+       public void testDecode() throws Exception {
+
+               byte[] data = this.getData();
+               AsnInputStream ais = new AsnInputStream(data);
+               LocationNumberCapImpl elem = new LocationNumberCapImpl();
+               int tag = ais.readTag();
+               elem.decodeAll(ais);
+               LocationNumber ln = elem.getLocationNumber();
+               assertTrue(Arrays.equals(elem.getData(), this.getIntData()));
+               assertEquals(ln.getNatureOfAddressIndicator(), 4);
+               assertTrue(ln.getAddress().equals("80207910020"));
+               assertEquals(ln.getNumberingPlanIndicator(), 1);
+               assertEquals(ln.getInternalNetworkNumberIndicator(), 1);
+               assertEquals(ln.getAddressRepresentationRestrictedIndicator(), 
1);
+               assertEquals(ln.getScreeningIndicator(), 3);
+       }
+
+       @Test(groups = { "functional.encode","isup"})
+       public void testEncode() throws Exception {
+
+ LocationNumberCapImpl elem = new LocationNumberCapImpl(this.getIntData());
+               AsnOutputStream aos = new AsnOutputStream();
+               elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 10);
+               assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+ LocationNumber cpn = new LocationNumberImpl(4, "80207910020", 1, 1, 1, 3);
+               elem = new LocationNumberCapImpl(cpn);
+               aos = new AsnOutputStream();
+               elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 10);
+//             assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+               // TODO: fix ISUP.LocationNumber encoding problem
+
+// int natureOfAddresIndicator, String address, int numberingPlanIndicator, int internalNetworkNumberIndicator, int addressRepresentationREstrictedIndicator,
+//             int screeningIndicator
+       }
+}
+
=======================================
--- /dev/null
+++ /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/OriginalCalledNumberCapTest.java Fri Jan 6 23:27:54 2012
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.cap.isup;
+
+import static org.testng.Assert.*;
+
+import java.util.Arrays;
+
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.asn.Tag;
+import org.mobicents.protocols.ss7.isup.impl.message.parameter.OriginalCalledNumberImpl; +import org.mobicents.protocols.ss7.isup.message.parameter.OriginalCalledNumber;
+import org.testng.*;import org.testng.annotations.*;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class OriginalCalledNumberCapTest {
+
+       public byte[] getData() {
+               return new byte[] { (byte) 140, 6, (byte) 131, 20, 7, 1, 9, 0 };
+       }
+
+       public byte[] getIntData() {
+               return new byte[] { (byte) 131, 20, 7, 1, 9, 0 };
+       }
+
+       @Test(groups = { "functional.decode","isup"})
+       public void testDecode() throws Exception {
+
+               byte[] data = this.getData();
+               AsnInputStream ais = new AsnInputStream(data);
+               OriginalCalledNumberCapImpl elem = new 
OriginalCalledNumberCapImpl();
+               int tag = ais.readTag();
+               elem.decodeAll(ais);
+               OriginalCalledNumber ocn = elem.getOriginalCalledNumber();
+               assertTrue(Arrays.equals(elem.getData(), this.getIntData()));
+               assertEquals(ocn.getNatureOfAddressIndicator(), 3);
+               assertTrue(ocn.getAddress().equals("7010900"));
+               assertEquals(ocn.getNumberingPlanIndicator(), 1);
+               assertEquals(ocn.getAddressRepresentationRestrictedIndicator(), 
1);
+       }
+
+       @Test(groups = { "functional.encode","isup"})
+       public void testEncode() throws Exception {
+
+ OriginalCalledNumberCapImpl elem = new OriginalCalledNumberCapImpl(this.getIntData());
+               AsnOutputStream aos = new AsnOutputStream();
+               elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 12);
+               assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+ OriginalCalledNumber cpn = new OriginalCalledNumberImpl(3, "7010900", 1, 1);
+               elem = new OriginalCalledNumberCapImpl(cpn);
+               aos = new AsnOutputStream();
+               elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 12);
+               assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+// int natureOfAddresIndicator, String address, int numberingPlanIndicator, int addressRepresentationREstrictedIndicator
+       }
+}
=======================================
--- /dev/null
+++ /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/isup/RedirectingPartyIDCapTest.java Fri Jan 6 23:27:54 2012
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.cap.isup;
+
+import static org.testng.Assert.*;
+
+import java.util.Arrays;
+
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.asn.Tag;
+import org.mobicents.protocols.ss7.isup.impl.message.parameter.RedirectingNumberImpl; +import org.mobicents.protocols.ss7.isup.message.parameter.RedirectingNumber;
+import org.testng.*;import org.testng.annotations.*;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class RedirectingPartyIDCapTest {
+
+       public byte[] getData() {
+               return new byte[] { (byte) 157, 6, (byte) 131, 20, 7, 1, 9, 0 };
+       }
+
+       public byte[] getIntData() {
+               return new byte[] { (byte) 131, 20, 7, 1, 9, 0 };
+       }
+
+       @Test(groups = { "functional.decode","isup"})
+       public void testDecode() throws Exception {
+
+               byte[] data = this.getData();
+               AsnInputStream ais = new AsnInputStream(data);
+               RedirectingPartyIDCapImpl elem = new 
RedirectingPartyIDCapImpl();
+               int tag = ais.readTag();
+               elem.decodeAll(ais);
+               RedirectingNumber rn = elem.getRedirectingNumber();
+               assertTrue(Arrays.equals(elem.getData(), this.getIntData()));
+               assertEquals(rn.getNatureOfAddressIndicator(), 3);
+               assertTrue(rn.getAddress().equals("7010900"));
+               assertEquals(rn.getNumberingPlanIndicator(), 1);
+               assertEquals(rn.getAddressRepresentationRestrictedIndicator(), 
1);
+       }
+
+       @Test(groups = { "functional.encode","isup"})
+       public void testEncode() throws Exception {
+
+ RedirectingPartyIDCapImpl elem = new RedirectingPartyIDCapImpl(this.getIntData());
+               AsnOutputStream aos = new AsnOutputStream();
+               elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 29);
+               assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+               RedirectingNumber rn = new RedirectingNumberImpl(3, "7010900", 
1, 1);
+               elem = new RedirectingPartyIDCapImpl(rn);
+               aos = new AsnOutputStream();
+               elem.encodeAll(aos, Tag.CLASS_CONTEXT_SPECIFIC, 29);
+//             assertTrue(Arrays.equals(aos.toByteArray(), this.getData()));
+
+ // TODO: fix ISUP.RedirectingNumber encoding problem: encoded data does not correspond to the original trace data
+
+// int natureOfAddresIndicator, String address, int numberingPlanIndicator, int addressRepresentationRestrictedIndicator
+       }
+}
=======================================
--- /dev/null
+++ /trunk/protocols/ss7/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/service/circuitSwitchedCall/primitive/BearerCapabilityTest.java Fri Jan 6 23:27:54 2012
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.protocols.ss7.cap.service.circuitSwitchedCall.primitive;
+
+import static org.testng.Assert.*;
+
+import java.util.Arrays;
+
+import org.mobicents.protocols.asn.AsnInputStream;
+import org.mobicents.protocols.asn.AsnOutputStream;
+import org.mobicents.protocols.ss7.cap.isup.BearerCapImpl;
+import org.testng.*;import org.testng.annotations.*;
+
+/**
+ *
+ * @author sergey vetyutnev
+ *
+ */
+public class BearerCapabilityTest {
+
+       public byte[] getData1() {
+               return new byte[] { (byte) 128, 3, (byte) 128, (byte) 144, 
(byte) 163 };
+       }
+
+       public byte[] getIntData1() {
+               return new byte[] { (byte) 128, (byte) 144, (byte) 163 };
+       }
+
+       @Test(groups = { "functional.decode","circuitSwitchedCall.primitive"})
+       public void testDecode() throws Exception {
+
+               byte[] data = this.getData1();
+               AsnInputStream ais = new AsnInputStream(data);
+               BearerCapabilityImpl elem = new BearerCapabilityImpl();
+               int tag = ais.readTag();
+               elem.decodeAll(ais);
+ assertTrue(Arrays.equals(elem.getBearerCap().getData(), this.getIntData1()));
+       }
+
+       @Test(groups = { "functional.encode","circuitSwitchedCall.primitive"})
+       public void testEncode() throws Exception {
+
+               BearerCapImpl bc = new BearerCapImpl(this.getIntData1());
+               BearerCapabilityImpl elem = new BearerCapabilityImpl(bc);
+               AsnOutputStream aos = new AsnOutputStream();
+               elem.encodeAll(aos);
+               assertTrue(Arrays.equals(aos.toByteArray(), this.getData1()));
+       }
+}
+

Reply via email to