axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r786866 [2/3] - in /webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema: ./ all/ anytype/ attribute/ base64binary/ booleantest/ choice/ decimal/ enumeration/ extension/ group/ innerChoice/ innerparticleextension/ i...
Date Sat, 20 Jun 2009 17:42:33 GMT
Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerChoice/InnerChoiceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerChoice/InnerChoiceTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerChoice/InnerChoiceTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerChoice/InnerChoiceTest.java Sat Jun 20 17:42:32 2009
@@ -19,22 +19,19 @@
 
 package org.apache.axis2.schema.innerChoice;
 
-import com.mynamespace.testinnerparticle.TestInnerParticle1Sequence_type0;
-import junit.framework.TestCase;
 import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axis2.databinding.utils.writer.MTOMAwareXMLSerializer;
 import org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter;
+import org.apache.axis2.schema.AbstractTestCase;
+
 import test.axis2.apache.org.*;
 
-import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
-import java.io.ByteArrayInputStream;
 
-public class InnerChoiceTest extends TestCase {
+public class InnerChoiceTest extends AbstractTestCase {
 
-    public void testInnerChoice1() {
+    public void testInnerChoice1() throws Exception {
         TestInnerSequence1 testSequence = new TestInnerSequence1();
         testSequence.setSequence1("test sequence");
         testSequence.setSequence2(3);
@@ -44,30 +41,20 @@
         TestInnerSequence1Choice_type0.setChoice2(5);
         testSequence.setTestInnerSequence1Choice_type0(TestInnerSequence1Choice_type0);
 
-        try {
-            OMElement omElement = testSequence.getOMElement(TestInnerSequence1.MY_QNAME,
-                     OMAbstractFactory.getSOAP12Factory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMelement ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerSequence1 result = TestInnerSequence1.Factory.parse(xmlReader);
-            assertEquals(result.getSequence1(), "test sequence");
-            assertEquals(result.getSequence2(), 3);
-            assertEquals(result.getTestInnerSequence1Choice_type0().getChoice2(), 5);
-
-            // writtig result back
-            XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(System.out);
-            MTOMAwareXMLStreamWriter mtomAwareXMLStreamWriter = new MTOMAwareXMLSerializer(xmlStreamWriter);
-            result.serialize(new javax.xml.namespace.QName("org.apache.axis2.test", "TestInnerSequence1", "foo")
-                    , OMAbstractFactory.getSOAP11Factory(), mtomAwareXMLStreamWriter);
-            xmlStreamWriter.flush();
-
-        } catch (Exception e) {
-            fail();
-        }
+        TestInnerSequence1 result = (TestInnerSequence1)serializeDeserialize(testSequence);
+        assertEquals(result.getSequence1(), "test sequence");
+        assertEquals(result.getSequence2(), 3);
+        assertEquals(result.getTestInnerSequence1Choice_type0().getChoice2(), 5);
+
+        // writtig result back
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(System.out);
+        MTOMAwareXMLStreamWriter mtomAwareXMLStreamWriter = new MTOMAwareXMLSerializer(xmlStreamWriter);
+        result.serialize(new javax.xml.namespace.QName("org.apache.axis2.test", "TestInnerSequence1", "foo")
+                , OMAbstractFactory.getSOAP11Factory(), mtomAwareXMLStreamWriter);
+        xmlStreamWriter.flush();
     }
 
-    public void testInnerChoice21() {
+    public void testInnerChoice21() throws Exception {
         TestInnerSequence2 testSequence = new TestInnerSequence2();
         testSequence.setSequence1("sequence");
         testSequence.setSequence2(3);
@@ -75,22 +62,10 @@
         testInnerSequence2Choice_type1.setChoice1(new String[]{"choice1", "choice2"});
         testSequence.setTestInnerSequence2Choice_type0(testInnerSequence2Choice_type1);
 
-        try {
-            OMElement omElement = testSequence.getOMElement(TestInnerSequence2.MY_QNAME,
-                    OMAbstractFactory.getSOAP12Factory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMelement ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerSequence2 result = TestInnerSequence2.Factory.parse(xmlReader);
-            assertEquals(result.getSequence1(), "sequence");
-            assertEquals(result.getSequence2(), 3);
-            assertTrue(isEqual(result.getTestInnerSequence2Choice_type0().getChoice1(), new String[]{"choice1", "choice2"}));
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testSequence);
     }
 
-    public void testInnerChoice22() {
+    public void testInnerChoice22() throws Exception {
         TestInnerSequence2 testSequence = new TestInnerSequence2();
         testSequence.setSequence1("sequence");
         testSequence.setSequence2(3);
@@ -98,22 +73,10 @@
         testInnerSequence2Choice_type1.setChoice2(new int[]{2, 4});
         testSequence.setTestInnerSequence2Choice_type0(testInnerSequence2Choice_type1);
 
-         try {
-             OMElement omElement = testSequence.getOMElement(TestInnerSequence2.MY_QNAME,
-                      OMAbstractFactory.getSOAP12Factory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMelement ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerSequence2 result = TestInnerSequence2.Factory.parse(xmlReader);
-            assertEquals(result.getSequence1(), "sequence");
-            assertEquals(result.getSequence2(), 3);
-            assertTrue(isEqual(result.getTestInnerSequence2Choice_type0().getChoice2(), new int[]{2, 4}));
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testSequence);
     }
 
-    public void testInnerChoice31() {
+    public void testInnerChoice31() throws Exception {
         TestInnerSequence3 testSequence = new TestInnerSequence3();
         testSequence.setSequence1("sequence");
         testSequence.setSequence2(3);
@@ -121,22 +84,10 @@
         testInnerSequence3Choice_type0.setChoice1(new String[]{"choice1", null, "choice2"});
         testSequence.setTestInnerSequence3Choice_type0(testInnerSequence3Choice_type0);
 
-       try {
-           OMElement omElement = testSequence.getOMElement(TestInnerSequence3.MY_QNAME,
-                   OMAbstractFactory.getSOAP12Factory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMelement ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerSequence3 result = TestInnerSequence3.Factory.parse(xmlReader);
-            assertEquals(result.getSequence1(), "sequence");
-            assertEquals(result.getSequence2(), 3);
-            assertTrue(isEqual(result.getTestInnerSequence3Choice_type0().getChoice1(), new String[]{"choice1", null, "choice2"}));
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testSequence);
     }
 
-    public void testInnerChoice32() {
+    public void testInnerChoice32() throws Exception {
         TestInnerSequence3 testSequence = new TestInnerSequence3();
         testSequence.setSequence1("sequence");
         testSequence.setSequence2(3);
@@ -144,62 +95,6 @@
         testInnerSequence3Choice_type0.setChoice2(new int[]{2, Integer.MIN_VALUE, 6});
         testSequence.setTestInnerSequence3Choice_type0(testInnerSequence3Choice_type0);
 
-
-         try {
-             OMElement omElement = testSequence.getOMElement(TestInnerSequence3.MY_QNAME,
-                      OMAbstractFactory.getSOAP12Factory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMelement ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerSequence3 result = TestInnerSequence3.Factory.parse(xmlReader);
-            assertEquals(result.getSequence1(), "sequence");
-            assertEquals(result.getSequence2(), 3);
-            assertTrue(isEqual(result.getTestInnerSequence3Choice_type0().getChoice2(), new int[]{2, Integer.MIN_VALUE, 6}));
-        } catch (Exception e) {
-            fail();
-        }
-    }
-
-
-    private boolean isEqual(String[] test1, String[] test2) {
-        boolean isEqual = true;
-        if (test1.length != test2.length) {
-            isEqual = false;
-        } else {
-            for (int i = 0; i < test1.length; i++) {
-                if (test1[i] != null) {
-                    if (!test1[i].equals(test2[i])) {
-                        isEqual = false;
-                        break;
-                    }
-                } else {
-                    if (test2[i] != null) {
-                        isEqual = false;
-                        break;
-                    }
-                }
-
-            }
-        }
-
-        return isEqual;
-    }
-
-    private boolean isEqual(int[] test1, int[] test2) {
-        boolean isEqual = true;
-        if (test1.length != test2.length) {
-            isEqual = false;
-        } else {
-            for (int i = 0; i < test1.length; i++) {
-                if (test1[i] != test2[i]) {
-                    isEqual = false;
-                    break;
-                }
-            }
-        }
-
-        return isEqual;
+        testSerializeDeserialize(testSequence);
     }
-
-
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticleextension/TestInnerParticleExtension.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticleextension/TestInnerParticleExtension.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticleextension/TestInnerParticleExtension.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticleextension/TestInnerParticleExtension.java Sat Jun 20 17:42:32 2009
@@ -19,22 +19,14 @@
 
 package org.apache.axis2.schema.innerparticleextension;
 
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axis2.databinding.ADBException;
+import org.apache.axis2.schema.AbstractTestCase;
 import org.tempuri.innerparticalextension.ChildElement_type0;
 import org.tempuri.innerparticalextension.ParentTypeChoice;
 import org.tempuri.innerparticalextension.TestElement;
 
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
+public class TestInnerParticleExtension extends AbstractTestCase {
 
-public class TestInnerParticleExtension extends TestCase {
-
-    public void testTestElement(){
+    public void testTestElement() throws Exception {
         TestElement testElement = new TestElement();
 
         ChildElement_type0 childElement_type0[] = new ChildElement_type0[2];
@@ -62,29 +54,6 @@
 
         testElement.setChildElement(childElement_type0);
 
-        try {
-            OMElement omElement = testElement.getOMElement(TestElement.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element string ==> " + omElementString);
-            XMLStreamReader xmlReader =
-                    StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestElement result = TestElement.Factory.parse(xmlReader);
-            assertEquals(result.getChildElement()[0].getTestAttribute(),"Test Attribute");
-            assertEquals(result.getChildElement()[1].getTestAttribute(),"Test Attribute");
-
-            assertEquals(result.getChildElement()[0].getParentTypeChoice()[0].getParam1(),"param1");
-            assertEquals(result.getChildElement()[0].getParentTypeChoice()[1].getParam2(),"param2");
-            assertEquals(result.getChildElement()[1].getParentTypeChoice()[0].getParam1(),"param1");
-            assertEquals(result.getChildElement()[1].getParentTypeChoice()[1].getParam2(),"param2");
-
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
-
-
+        testSerializeDeserialize(testElement);
     }
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticles/InnerParticlesTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticles/InnerParticlesTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticles/InnerParticlesTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticles/InnerParticlesTest.java Sat Jun 20 17:42:32 2009
@@ -20,21 +20,11 @@
 package org.apache.axis2.schema.innerparticles;
 
 import com.mynamespace.testinnerparticle.*;
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axis2.databinding.ADBException;
+import org.apache.axis2.schema.AbstractTestCase;
 
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
+public class InnerParticlesTest extends AbstractTestCase {
 
-
-
-public class InnerParticlesTest extends TestCase {
-
-    public void testInnerParticle1() {
+    public void testInnerParticle1() throws Exception {
 
         TestInnerParticle1 testInnerParticle1 = new TestInnerParticle1();
         testInnerParticle1.setParam1("Param1");
@@ -44,25 +34,10 @@
         testInnerParticle1.setTestInnerParticle1Sequence_type0(testInnerParticle1Sequence_type0);
         testInnerParticle1.setParam4("Param4");
 
-         try {
-            OMElement omElement = testInnerParticle1.getOMElement(TestInnerParticle1.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerParticle1 result = TestInnerParticle1.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(), "Param1");
-            assertEquals(result.getTestInnerParticle1Sequence_type0().getParam2(), "Param2");
-            assertEquals(result.getTestInnerParticle1Sequence_type0().getParam3(), "Param3");
-            assertEquals(result.getParam4(), "Param4");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
-
+        testSerializeDeserialize(testInnerParticle1);
     }
 
-    public void testInnerParticle2() {
+    public void testInnerParticle2() throws Exception {
 
         TestInnerParticle2 testInnerParticle2 = new TestInnerParticle2();
         testInnerParticle2.setParam1("Param1");
@@ -72,46 +47,21 @@
         testInnerParticle2.setTestInnerParticle2Choice_type0(testInnerParticle2Choice_type1);
         testInnerParticle2.setParam4("Param4");
 
-       try {
-            OMElement omElement =
-                   testInnerParticle2.getOMElement(TestInnerParticle2.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerParticle2 result = TestInnerParticle2.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(), "Param1");
-            assertEquals(result.getTestInnerParticle2Choice_type0().getParam3(), "Param3");
-            assertEquals(result.getParam4(), "Param4");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
-
+        TestInnerParticle2 result = (TestInnerParticle2)serializeDeserialize(testInnerParticle2);
+        assertEquals(result.getParam1(), "Param1");
+        assertEquals(result.getTestInnerParticle2Choice_type0().getParam3(), "Param3");
+        assertEquals(result.getParam4(), "Param4");
     }
 
-    public void testInnerParticle31() {
+    public void testInnerParticle31() throws Exception {
 
         TestInnerParticle3 testInnerParticle3 = new TestInnerParticle3();
         testInnerParticle3.setParam1("Param1");
 
-        try {
-            OMElement omElement =
-                     testInnerParticle3.getOMElement(TestInnerParticle3.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerParticle3 result = TestInnerParticle3.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(), "Param1");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
-
+        testSerializeDeserialize(testInnerParticle3);
     }
 
-    public void testInnerParticle32() {
+    public void testInnerParticle32() throws Exception {
 
         TestInnerParticle3 testInnerParticle3 = new TestInnerParticle3();
         TestInnerParticle3Choice_type0 testInnerParticle3Choice_type1 = new TestInnerParticle3Choice_type0();
@@ -119,25 +69,11 @@
         testInnerParticle3Choice_type1.setParam3("Param3");
         testInnerParticle3.setTestInnerParticle3Choice_type0(testInnerParticle3Choice_type1);
 
-        try {
-            OMElement omElement =
-                    testInnerParticle3.getOMElement(TestInnerParticle3.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerParticle3 result = TestInnerParticle3.Factory.parse(xmlReader);
-            assertEquals(result.getTestInnerParticle3Choice_type0().getParam3(), "Param3");
-        } catch (XMLStreamException e) {
-            e.printStackTrace();
-            fail();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail();
-        }
-
+        TestInnerParticle3 result = (TestInnerParticle3)serializeDeserialize(testInnerParticle3);
+        assertEquals(result.getTestInnerParticle3Choice_type0().getParam3(), "Param3");
     }
 
-    public void testInnerParticle33() {
+    public void testInnerParticle33() throws Exception {
 
         TestInnerParticle3 testInnerParticle3 = new TestInnerParticle3();
         testInnerParticle3.setParam1("Param1");
@@ -147,46 +83,19 @@
         testInnerParticle3.setTestInnerParticle3Choice_type0(testInnerParticle3Choice_type1);
         testInnerParticle3.setParam4("Param4");
 
-         try {
-             OMElement omElement =
-                      testInnerParticle3.getOMElement(TestInnerParticle3.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerParticle3 result = TestInnerParticle3.Factory.parse(xmlReader);
-            assertEquals(result.getParam4(), "Param4");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
-
+        TestInnerParticle3 result = (TestInnerParticle3)serializeDeserialize(testInnerParticle3);
+        assertEquals(result.getParam4(), "Param4");
     }
 
-    public void testInnerParticle41() {
+    public void testInnerParticle41() throws Exception {
 
         TestInnerParticle4 testInnerParticle4 = new TestInnerParticle4();
         testInnerParticle4.setParam1("Param1");
 
-         try {
-             OMElement omElement =
-                      testInnerParticle4.getOMElement(TestInnerParticle4.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerParticle4 result = TestInnerParticle4.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(), "Param1");
-        } catch (XMLStreamException e) {
-            e.printStackTrace();
-            fail();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail();
-        }
-
+        testSerializeDeserialize(testInnerParticle4);
     }
 
-    public void testInnerParticle42() {
+    public void testInnerParticle42() throws Exception {
 
         TestInnerParticle4 testInnerParticle4 = new TestInnerParticle4();
         TestInnerParticle4Sequence_type0 TestInnerParticle4Sequence_type0 = new TestInnerParticle4Sequence_type0();
@@ -194,49 +103,18 @@
         TestInnerParticle4Sequence_type0.setParam3("Param3");
         testInnerParticle4.setTestInnerParticle4Sequence_type0(TestInnerParticle4Sequence_type0);
 
-        try {
-            OMElement omElement =
-                     testInnerParticle4.getOMElement(TestInnerParticle4.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerParticle4 result = TestInnerParticle4.Factory.parse(xmlReader);
-            assertEquals(result.getTestInnerParticle4Sequence_type0().getParam2(), "Param2");
-            assertEquals(result.getTestInnerParticle4Sequence_type0().getParam3(), "Param3");
-        } catch (XMLStreamException e) {
-            e.printStackTrace();
-            fail();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail();
-        }
-
+        testSerializeDeserialize(testInnerParticle4);
     }
 
-    public void testInnerParticle43() {
+    public void testInnerParticle43() throws Exception {
 
         TestInnerParticle4 testInnerParticle4 = new TestInnerParticle4();
         testInnerParticle4.setParam4("Param4");
 
-         try {
-            OMElement omElement =
-                      testInnerParticle4.getOMElement(TestInnerParticle4.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerParticle4 result = TestInnerParticle4.Factory.parse(xmlReader);
-            assertEquals(result.getParam4(), "Param4");
-        } catch (XMLStreamException e) {
-            e.printStackTrace();
-            fail();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail();
-        }
-
+        testSerializeDeserialize(testInnerParticle4);
     }
 
-    public void testInnerParticle5() {
+    public void testInnerParticle5() throws Exception {
 
         TestInnerParticle5 testInnerParticle5 = new TestInnerParticle5();
         testInnerParticle5.setParam1("Param1");
@@ -252,28 +130,10 @@
         testInnerParticle5.setTestInnerParticle5Sequence_type1(testInnerParticle2Choice_type1);
         testInnerParticle5.setParam6("Param6");
 
-        try {
-            OMElement omElement =
-                    testInnerParticle5.getOMElement(TestInnerParticle5.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerParticle5 result = TestInnerParticle5.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(), "Param1");
-            assertEquals(result.getTestInnerParticle5Sequence_type1().getParam2(), "Param2");
-            assertEquals(result.getTestInnerParticle5Sequence_type1().getParam3(), "Param3");
-            assertEquals(result.getTestInnerParticle5Sequence_type1().getTestInnerParticle5Sequence_type0().getParam4(), "Param4");
-            assertEquals(result.getTestInnerParticle5Sequence_type1().getTestInnerParticle5Sequence_type0().getParam5(), "Param5");
-            assertEquals(result.getParam6(), "Param6");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
-
+        testSerializeDeserialize(testInnerParticle5);
     }
 
-    public void testIntterParticalExtension(){
+    public void testIntterParticalExtension() throws Exception {
          TestInnterParticleExtension testInnterParticleExtension = new TestInnterParticleExtension();
 
         TestInnterParticleExtensionChildComplexType testInnterParticleExtensionChildComplexType =
@@ -287,27 +147,14 @@
         testInnterParticleExtensionParentComplexTypeChoice_type0.setParam1("param1");
         testInnterParticleExtensionParentComplexTypeChoice_type0.setParam2("param2");
 
-        try {
-            OMElement omElement = testInnterParticleExtension.getOMElement(TestInnterParticleExtension.MY_QNAME,
-                                                            OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnterParticleExtension result = TestInnterParticleExtension.Factory.parse(xmlReader);
-            assertTrue(result.getTestInnterParticleExtension() instanceof TestInnterParticleExtensionChildComplexType);
-            TestInnterParticleExtensionChildComplexType resultComplexType =
-                    (TestInnterParticleExtensionChildComplexType) result.getTestInnterParticleExtension();
-            assertEquals(resultComplexType.getTestInnterParticleExtensionParentComplexTypeChoice_type0().getParam2(),"param2");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        TestInnterParticleExtension result = (TestInnterParticleExtension)serializeDeserialize(testInnterParticleExtension);
+        assertTrue(result.getTestInnterParticleExtension() instanceof TestInnterParticleExtensionChildComplexType);
+        TestInnterParticleExtensionChildComplexType resultComplexType =
+                (TestInnterParticleExtensionChildComplexType) result.getTestInnterParticleExtension();
+        assertEquals(resultComplexType.getTestInnterParticleExtensionParentComplexTypeChoice_type0().getParam2(),"param2");
     }
 
-    public void testTestComplexTypeElement(){
+    public void testTestComplexTypeElement() throws Exception {
         TestComplexTypeElement testComplexTypeElement = new TestComplexTypeElement();
 
         TestComplexType testComplexType = new TestComplexType();
@@ -320,24 +167,7 @@
         TestComplexTypeSequence_type0 testComplexTypeSequence_type0 = new TestComplexTypeSequence_type0();
         testComplexType.setTestComplexTypeSequence_type0(testComplexTypeSequence_type0);
 
-        try {
-            OMElement omElement = testComplexTypeElement.getOMElement(
-                    TestComplexTypeElement.MY_QNAME,OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(
-                    new ByteArrayInputStream(omElementString.getBytes()));
-            TestComplexTypeElement result = TestComplexTypeElement.Factory.parse(xmlReader);
-            assertEquals(result.getTestComplexTypeElement().getTestElement().getParam(),"param");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail();
-        }
+        TestComplexTypeElement result = (TestComplexTypeElement)serializeDeserialize(testComplexTypeElement);
+        assertEquals(result.getTestComplexTypeElement().getTestElement().getParam(),"param");
     }
-
-
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/list/ListTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/list/ListTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/list/ListTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/list/ListTest.java Sat Jun 20 17:42:32 2009
@@ -19,42 +19,26 @@
 
 package org.apache.axis2.schema.list;
 
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axis2.schema.AbstractTestCase;
+
 import test.axis2.apache.org.*;
 
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
-
 
-public class ListTest extends TestCase {
+public class ListTest extends AbstractTestCase {
 
 
-    public void testListString(){
+    public void testListString() throws Exception {
 
         TestListStringElement testListStringElement = new TestListStringElement();
         TestListString testListString = new TestListString();
         testListStringElement.setTestListStringElement(testListString);
         testListString.setString(new String[]{"string1","string2"});
 
-       try {
-           OMElement omElement = testListStringElement.getOMElement(TestListStringElement.MY_QNAME,
-                       OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestListStringElement result = TestListStringElement.Factory.parse(xmlReader);
-            assertEquals(testListString.toString(),result.getTestListStringElement().toString());
-        } catch (Exception e) {
-            assertFalse(true);
-        }
-
+        testSerializeDeserialize(testListStringElement);
     }
 
-    public void testListQName(){
+    public void testListQName() throws Exception {
 
         TestListQNameElement testListQNameElement = new TestListQNameElement();
         TestListQName testListQName = new TestListQName();
@@ -63,21 +47,10 @@
                         new QName("http://www.google","test3")});
         testListQNameElement.setTestListQNameElement(testListQName);
 
-        try {
-            OMElement omElement = testListQNameElement.getOMElement(TestListQNameElement.MY_QNAME,OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestListQNameElement result = TestListQNameElement.Factory.parse(xmlReader);
-            assertEquals(result.getTestListQNameElement().getQName()[0],testListQName.getQName()[0]);
-            assertEquals(result.getTestListQNameElement().getQName()[1],testListQName.getQName()[1]);
-            assertEquals(result.getTestListQNameElement().getQName()[2],testListQName.getQName()[2]);
-        } catch (Exception e) {
-            assertFalse(true);
-        }
+        testSerializeDeserialize(testListQNameElement);
     }
 
-    public void testListOurs(){
+    public void testListOurs() throws Exception {
 
         TestListOursElement testListOursElement = new TestListOursElement();
         TestListOurs testListOurs = new TestListOurs();
@@ -90,41 +63,20 @@
         testString3.setTestString("test");
         testListOurs.setTestString(new TestString[]{testString1,testString2,testString3});
 
-        try {
-            OMElement omElement = testListOursElement.getOMElement(TestListOursElement.MY_QNAME,OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestListOursElement result = TestListOursElement.Factory.parse(xmlReader);
-            assertEquals(result.getTestListOursElement().getTestString()[0].getTestString(),testString1.getTestString());
-            assertEquals(result.getTestListOursElement().getTestString()[1].getTestString(),testString2.getTestString());
-            assertEquals(result.getTestListOursElement().getTestString()[2].getTestString(),testString3.getTestString());
-        } catch (Exception e) {
-            assertFalse(true);
-        }
+        testSerializeDeserialize(testListOursElement);
     }
 
-    public void testListSuper(){
+    public void testListSuper() throws Exception {
 
         SuperTestListStringElement superTestListStringElement = new SuperTestListStringElement();
         SuperTestListString superTestListString = new SuperTestListString();
         superTestListStringElement.setSuperTestListStringElement(superTestListString);
         superTestListString.setString(new String[]{"test1","test2","test3"});
 
-       try {
-           OMElement omElement = superTestListStringElement.getOMElement(SuperTestListStringElement.MY_QNAME,
-                   OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            SuperTestListStringElement result = SuperTestListStringElement.Factory.parse(xmlReader);
-            assertEquals(superTestListString.getString()[0],result.getSuperTestListStringElement().getString()[0]);
-        } catch (Exception e) {
-            assertTrue(false);
-        }
+        testSerializeDeserialize(superTestListStringElement);
     }
 
-    public void testInnerSimpleTypes(){
+    public void testInnerSimpleTypes() throws Exception {
         TestInnerListSimpleType testInnerListSimpleType = new TestInnerListSimpleType();
         InnerListSimpleType innerListSimpleType = new InnerListSimpleType();
         testInnerListSimpleType.setTestInnerListSimpleType(innerListSimpleType);
@@ -134,20 +86,6 @@
 
         innerListSimpleType.setInnerListSimpleType_type0(list);
 
-         try {
-             OMElement omElement = testInnerListSimpleType.getOMElement(TestInnerListSimpleType.MY_QNAME,
-                      OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestInnerListSimpleType result = TestInnerListSimpleType.Factory.parse(xmlReader);
-            assertEquals(result.getTestInnerListSimpleType().getInnerListSimpleType_type0()[0],InnerListSimpleType_type0.Access);
-            assertEquals(result.getTestInnerListSimpleType().getInnerListSimpleType_type0()[1],InnerListSimpleType_type0.Exist);
-        } catch (Exception e) {
-            assertTrue(false);
-        }
-
+        testSerializeDeserialize(testInnerListSimpleType);
     }
-
-
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/particalmaxoccurs/ParticalMaxOccursTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/particalmaxoccurs/ParticalMaxOccursTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/particalmaxoccurs/ParticalMaxOccursTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/particalmaxoccurs/ParticalMaxOccursTest.java Sat Jun 20 17:42:32 2009
@@ -20,21 +20,13 @@
 package org.apache.axis2.schema.particalmaxoccurs;
 
 import com.mynamespace.testparticlemaxoccurs.*;
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axis2.schema.AbstractTestCase;
 
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
-
-
-public class ParticalMaxOccursTest extends TestCase {
+public class ParticalMaxOccursTest extends AbstractTestCase {
 
     private int i = 0;
 
-    public void testParticalSequenceMaxOccursTest1() {
+    public void testParticalSequenceMaxOccursTest1() throws Exception {
         TestParticalSequenceMaxOccurs1 testParticalMaxOccures1 = new TestParticalSequenceMaxOccurs1();
         TestParticalSequenceMaxOccursType1 testParticalMaxOccursType1 = new TestParticalSequenceMaxOccursType1();
         testParticalMaxOccures1.setTestParticalSequenceMaxOccurs1(testParticalMaxOccursType1);
@@ -51,27 +43,10 @@
 
         testParticalMaxOccursType1.setTestParticalSequenceMaxOccursType1Sequence(testSequences);
 
-         try {
-             OMElement omElement = testParticalMaxOccures1.getOMElement(TestParticalSequenceMaxOccurs1.MY_QNAME,
-                       OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalSequenceMaxOccurs1 result = TestParticalSequenceMaxOccurs1.Factory.parse(xmlReader);
-            TestParticalSequenceMaxOccursType1Sequence[] resultSequences =
-                    result.getTestParticalSequenceMaxOccurs1().getTestParticalSequenceMaxOccursType1Sequence();
-            assertEquals(resultSequences[0].getParm1(), "Param11");
-            assertEquals(resultSequences[0].getParm2(), "Param12");
-            assertEquals(resultSequences[1].getParm1(), "Param21");
-            assertEquals(resultSequences[1].getParm2(), "Param22");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testParticalMaxOccures1);
     }
 
-    public void testParticleSequenceMaxOccurs2() {
+    public void testParticleSequenceMaxOccurs2() throws Exception {
         TestParticalSequenceMaxOccurs2 testParticalMaxOccures2 = new TestParticalSequenceMaxOccurs2();
         TestParticalSequenceMaxOccursType2 testParticalMaxOccursType2 = new TestParticalSequenceMaxOccursType2();
         testParticalMaxOccures2.setTestParticalSequenceMaxOccurs2(testParticalMaxOccursType2);
@@ -88,31 +63,10 @@
 
         testParticalMaxOccursType2.setTestParticalSequenceMaxOccursType2Sequence(testSequences);
 
-        try {
-            OMElement omElement = testParticalMaxOccures2.getOMElement(TestParticalSequenceMaxOccurs2.MY_QNAME,
-                     OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalSequenceMaxOccurs2 result = TestParticalSequenceMaxOccurs2.Factory.parse(xmlReader);
-            TestParticalSequenceMaxOccursType2Sequence[] resultSequences =
-                    result.getTestParticalSequenceMaxOccurs2().getTestParticalSequenceMaxOccursType2Sequence();
-            assertEquals(resultSequences[0].getParm1()[0], "Param111");
-            assertEquals(resultSequences[0].getParm1()[1], "Param112");
-            assertEquals(resultSequences[0].getParm1()[2], "Param113");
-            assertEquals(resultSequences[1].getParm2()[0], "Param121");
-            assertEquals(resultSequences[1].getParm2()[1], "Param122");
-            assertEquals(resultSequences[1].getParm2()[2], "Param123");
-        } catch (XMLStreamException e) {
-            e.printStackTrace();
-            fail();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail();
-        }
+        testSerializeDeserialize(testParticalMaxOccures2);
     }
 
-    public void testParticleSequenceMaxOccurs3() {
+    public void testParticleSequenceMaxOccurs3() throws Exception {
         TestParticalSequenceMaxOccurs3 testParticalMaxOccures3 = new TestParticalSequenceMaxOccurs3();
         TestParticalSequenceMaxOccursType3 testParticalMaxOccursType3 = new TestParticalSequenceMaxOccursType3();
         testParticalMaxOccures3.setTestParticalSequenceMaxOccurs3(testParticalMaxOccursType3);
@@ -127,29 +81,18 @@
 
         testParticalMaxOccursType3.setTestParticalSequenceMaxOccursType3Sequence(testSequences);
 
-        try {
-            OMElement omElement = testParticalMaxOccures3.getOMElement(TestParticalSequenceMaxOccurs3.MY_QNAME,
-                      OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalSequenceMaxOccurs3 result = TestParticalSequenceMaxOccurs3.Factory.parse(xmlReader);
-            TestParticalSequenceMaxOccursType3Sequence[] resultSequences =
-                    result.getTestParticalSequenceMaxOccurs3().getTestParticalSequenceMaxOccursType3Sequence();
-            assertEquals(resultSequences[0].getParm2()[0], "Param111");
-            assertEquals(resultSequences[0].getParm2()[1], null);
-            assertEquals(resultSequences[0].getParm2()[2], "Param113");
-            assertEquals(resultSequences[1].getParm1()[0], "Param121");
-            assertEquals(resultSequences[1].getParm1()[1], "Param122");
-            assertEquals(resultSequences[1].getParm1()[2], null);
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        TestParticalSequenceMaxOccurs3 result = (TestParticalSequenceMaxOccurs3)serializeDeserialize(testParticalMaxOccures3);
+        TestParticalSequenceMaxOccursType3Sequence[] resultSequences =
+                result.getTestParticalSequenceMaxOccurs3().getTestParticalSequenceMaxOccursType3Sequence();
+        assertEquals(resultSequences[0].getParm2()[0], "Param111");
+        assertEquals(resultSequences[0].getParm2()[1], null);
+        assertEquals(resultSequences[0].getParm2()[2], "Param113");
+        assertEquals(resultSequences[1].getParm1()[0], "Param121");
+        assertEquals(resultSequences[1].getParm1()[1], "Param122");
+        assertEquals(resultSequences[1].getParm1()[2], null);
     }
 
-    public void testParticleSequenceMaxOccurs4() {
+    public void testParticleSequenceMaxOccurs4() throws Exception {
 
         TestParticalSequenceMaxOccurs4 testParticalSequenceMaxOccurs4 = new TestParticalSequenceMaxOccurs4();
         TestParticalSequenceMaxOccursType4 testParticalSequenceMaxOccursType4 = new TestParticalSequenceMaxOccursType4();
@@ -168,37 +111,10 @@
         testParticalSequenceMaxOccursType4Sequence[2] = new TestParticalSequenceMaxOccursType4Sequence();
         testParticalSequenceMaxOccursType4Sequence[2].setParm3(getNewCustomType());
 
-        try {
-            OMElement omElement = testParticalSequenceMaxOccurs4.getOMElement(TestParticalSequenceMaxOccurs4.MY_QNAME,
-                     OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalSequenceMaxOccurs4 result = TestParticalSequenceMaxOccurs4.Factory.parse(xmlReader);
-            TestParticalSequenceMaxOccursType4Sequence[] resultSequences =
-                    result.getTestParticalSequenceMaxOccurs4().getTestParticalSequenceMaxOccursType4Sequence();
-            assertTrue(isEqual(resultSequences[0].getParm1(), testParticalSequenceMaxOccursType4Sequence[0].getParm1()));
-            assertTrue(isEqual(resultSequences[0].getParm2(), testParticalSequenceMaxOccursType4Sequence[0].getParm2()));
-            assertTrue(isEqual(resultSequences[0].getParm3(), testParticalSequenceMaxOccursType4Sequence[0].getParm3()));
-
-            assertTrue(isEqual(resultSequences[1].getParm1(), testParticalSequenceMaxOccursType4Sequence[1].getParm1()));
-            assertTrue(isEqual(resultSequences[1].getParm2(), testParticalSequenceMaxOccursType4Sequence[1].getParm2()));
-            assertTrue(isEqual(resultSequences[1].getParm3(), testParticalSequenceMaxOccursType4Sequence[1].getParm3()));
-
-            assertTrue(isEqual(resultSequences[2].getParm1(), testParticalSequenceMaxOccursType4Sequence[2].getParm1()));
-            assertTrue(isEqual(resultSequences[2].getParm2(), testParticalSequenceMaxOccursType4Sequence[2].getParm2()));
-            assertTrue(isEqual(resultSequences[2].getParm3(), testParticalSequenceMaxOccursType4Sequence[2].getParm3()));
-
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
-
-
+        testSerializeDeserialize(testParticalSequenceMaxOccurs4);
     }
 
-    public void testParticleSequenceMaxOccurs5() {
+    public void testParticleSequenceMaxOccurs5() throws Exception {
 
         TestParticalSequenceMaxOccurs5 testParticalSequenceMaxOccurs5 = new TestParticalSequenceMaxOccurs5();
         TestParticalSequenceMaxOccursType5 testParticalSequenceMaxOccursType5 = new TestParticalSequenceMaxOccursType5();
@@ -222,39 +138,10 @@
         testParticalSequenceMaxOccursType5Sequence[2].setParm1(new TestCustomType[]{getNewCustomType()});
         testParticalSequenceMaxOccursType5Sequence[2].setParm3(new TestCustomType[]{getNewCustomType()});
 
-        try {
-            OMElement omElement = testParticalSequenceMaxOccurs5.getOMElement(TestParticalSequenceMaxOccurs5.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalSequenceMaxOccurs5 result = TestParticalSequenceMaxOccurs5.Factory.parse(xmlReader);
-            TestParticalSequenceMaxOccursType5Sequence[] resultSequences =
-                    result.getTestParticalSequenceMaxOccurs5().getTestParticalSequenceMaxOccursType5Sequence();
-            assertTrue(isEqual(resultSequences[0].getParm1(), testParticalSequenceMaxOccursType5Sequence[0].getParm1()));
-            assertTrue(isEqual(resultSequences[0].getParm2(), testParticalSequenceMaxOccursType5Sequence[0].getParm2()));
-            assertTrue(isEqual(resultSequences[0].getParm3(), testParticalSequenceMaxOccursType5Sequence[0].getParm3()));
-
-            assertTrue(isEqual(resultSequences[1].getParm1(), testParticalSequenceMaxOccursType5Sequence[1].getParm1()));
-            assertTrue(isEqual(resultSequences[1].getParm2(), testParticalSequenceMaxOccursType5Sequence[1].getParm2()));
-            assertTrue(isEqual(resultSequences[1].getParm3(), testParticalSequenceMaxOccursType5Sequence[1].getParm3()));
-
-            assertTrue(isEqual(resultSequences[2].getParm1(), testParticalSequenceMaxOccursType5Sequence[2].getParm1()));
-            assertTrue(isEqual(resultSequences[2].getParm2(), testParticalSequenceMaxOccursType5Sequence[2].getParm2()));
-            assertTrue(isEqual(resultSequences[2].getParm3(), testParticalSequenceMaxOccursType5Sequence[2].getParm3()));
-
-        } catch (XMLStreamException e) {
-            e.printStackTrace();
-            fail();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail();
-        }
-
-
+        testSerializeDeserialize(testParticalSequenceMaxOccurs5);
     }
 
-    public void testParticalSequenceMaxOccursTest6() {
+    public void testParticalSequenceMaxOccursTest6() throws Exception {
         TestParticalSequenceMaxOccurs6 testParticalMaxOccures6 = new TestParticalSequenceMaxOccurs6();
         TestParticalSequenceMaxOccursType6 testParticalMaxOccursType6 = new TestParticalSequenceMaxOccursType6();
         testParticalMaxOccures6.setTestParticalSequenceMaxOccurs6(testParticalMaxOccursType6);
@@ -273,51 +160,20 @@
         testParticalMaxOccursType6.setAttribute1("Attribute1");
         testParticalMaxOccursType6.setAttribute2("Attribute2");
 
-        try {
-            OMElement omElement = testParticalMaxOccures6.getOMElement(TestParticalSequenceMaxOccurs6.MY_QNAME,
-                     OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalSequenceMaxOccurs6 result = TestParticalSequenceMaxOccurs6.Factory.parse(xmlReader);
-            TestParticalSequenceMaxOccursType6Sequence[] resultSequences =
-                    result.getTestParticalSequenceMaxOccurs6().getTestParticalSequenceMaxOccursType6Sequence();
-            assertEquals(resultSequences[0].getParm1(), "Param11");
-            assertEquals(resultSequences[0].getParm2(), "Param12");
-            assertEquals(resultSequences[1].getParm1(), "Param21");
-            assertEquals(resultSequences[1].getParm2(), "Param22");
-            assertEquals(result.getTestParticalSequenceMaxOccurs6().getAttribute1(), "Attribute1");
-            assertEquals(result.getTestParticalSequenceMaxOccurs6().getAttribute2(), "Attribute2");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testParticalMaxOccures6);
     }
 
-    public void testParticalMaxOccursTest() {
+    public void testParticalMaxOccursTest() throws Exception {
         TestParticalChoiceMaxOccurs testParticalChoiceMaxOccurs = new TestParticalChoiceMaxOccurs();
         TestParticalChoiceMaxOccursType testParticalChoiceMaxOccursType = new TestParticalChoiceMaxOccursType();
         testParticalChoiceMaxOccurs.setTestParticalChoiceMaxOccurs(testParticalChoiceMaxOccursType);
 
         testParticalChoiceMaxOccursType.setParm1("Param1");
 
-        try {
-            OMElement omElement =
-                     testParticalChoiceMaxOccurs.getOMElement(TestParticalChoiceMaxOccurs.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM string ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalChoiceMaxOccurs result = TestParticalChoiceMaxOccurs.Factory.parse(xmlReader);
-            assertEquals(result.getTestParticalChoiceMaxOccurs().getParm1(), "Param1");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testParticalChoiceMaxOccurs);
     }
 
-    public void testParticalChoiceMaxOccursTest1() {
+    public void testParticalChoiceMaxOccursTest1() throws Exception {
         TestParticalChoiceMaxOccurs1 testParticalMaxOccures1 = new TestParticalChoiceMaxOccurs1();
         TestParticalChoiceMaxOccursType1 testParticalMaxOccursType1 = new TestParticalChoiceMaxOccursType1();
         testParticalMaxOccures1.setTestParticalChoiceMaxOccurs1(testParticalMaxOccursType1);
@@ -332,27 +188,10 @@
 
         testParticalMaxOccursType1.setTestParticalChoiceMaxOccursType1Choice(testChoices);
 
-       try {
-            OMElement omElement = testParticalMaxOccures1.getOMElement(TestParticalChoiceMaxOccurs1.MY_QNAME,
-                   OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalChoiceMaxOccurs1 result = TestParticalChoiceMaxOccurs1.Factory.parse(xmlReader);
-            TestParticalChoiceMaxOccursType1Choice[] resultChoices =
-                    result.getTestParticalChoiceMaxOccurs1().getTestParticalChoiceMaxOccursType1Choice();
-            assertEquals(resultChoices[0].getParm1(), "Param11");
-            assertEquals(resultChoices[1].getParm2(), "Param12");
-        } catch (XMLStreamException e) {
-           e.printStackTrace();
-            fail();
-        } catch (Exception e) {
-           e.printStackTrace();
-            fail();
-        }
+        testSerializeDeserialize(testParticalMaxOccures1);
     }
 
-    public void testParticleChoiceMaxOccurs2() {
+    public void testParticleChoiceMaxOccurs2() throws Exception {
         TestParticalChoiceMaxOccurs2 testParticalMaxOccures2 = new TestParticalChoiceMaxOccurs2();
         TestParticalChoiceMaxOccursType2 testParticalMaxOccursType2 = new TestParticalChoiceMaxOccursType2();
         testParticalMaxOccures2.setTestParticalChoiceMaxOccurs2(testParticalMaxOccursType2);
@@ -367,29 +206,10 @@
 
         testParticalMaxOccursType2.setTestParticalChoiceMaxOccursType2Choice(testChoices);
 
-         try {
-             OMElement omElement = testParticalMaxOccures2.getOMElement(TestParticalChoiceMaxOccurs2.MY_QNAME,
-                      OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalChoiceMaxOccurs2 result = TestParticalChoiceMaxOccurs2.Factory.parse(xmlReader);
-            TestParticalChoiceMaxOccursType2Choice[] resultChoices =
-                    result.getTestParticalChoiceMaxOccurs2().getTestParticalChoiceMaxOccursType2Choice();
-            assertEquals(resultChoices[0].getParm1()[0], "Param111");
-            assertEquals(resultChoices[0].getParm1()[1], "Param112");
-            assertEquals(resultChoices[0].getParm1()[2], "Param113");
-            assertEquals(resultChoices[1].getParm2()[0], "Param121");
-            assertEquals(resultChoices[1].getParm2()[1], "Param122");
-            assertEquals(resultChoices[1].getParm2()[2], "Param123");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testParticalMaxOccures2);
     }
 
-    public void testParticleChoiceMaxOccurs3() {
+    public void testParticleChoiceMaxOccurs3() throws Exception {
         TestParticalChoiceMaxOccurs3 testParticalMaxOccures3 = new TestParticalChoiceMaxOccurs3();
         TestParticalChoiceMaxOccursType3 testParticalMaxOccursType3 = new TestParticalChoiceMaxOccursType3();
         testParticalMaxOccures3.setTestParticalChoiceMaxOccurs3(testParticalMaxOccursType3);
@@ -404,29 +224,10 @@
 
         testParticalMaxOccursType3.setTestParticalChoiceMaxOccursType3Choice(testChoices);
 
-        try {
-            OMElement omElement = testParticalMaxOccures3.getOMElement(TestParticalChoiceMaxOccurs3.MY_QNAME,
-                     OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalChoiceMaxOccurs3 result = TestParticalChoiceMaxOccurs3.Factory.parse(xmlReader);
-            TestParticalChoiceMaxOccursType3Choice[] resultChoices =
-                    result.getTestParticalChoiceMaxOccurs3().getTestParticalChoiceMaxOccursType3Choice();
-            assertEquals(resultChoices[0].getParm1()[0], "Param111");
-            assertEquals(resultChoices[0].getParm1()[1], null);
-            assertEquals(resultChoices[0].getParm1()[2], "Param113");
-            assertEquals(resultChoices[1].getParm2()[0], "Param121");
-            assertEquals(resultChoices[1].getParm2()[1], "Param122");
-            assertEquals(resultChoices[1].getParm2()[2], null);
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testParticalMaxOccures3);
     }
 
-    public void testParticleChoiceMaxOccurs4() {
+    public void testParticleChoiceMaxOccurs4() throws Exception {
 
         TestParticalChoiceMaxOccurs4 testParticalChoiceMaxOccurs4 = new TestParticalChoiceMaxOccurs4();
         TestParticalChoiceMaxOccursType4 testParticalChoiceMaxOccursType4 = new TestParticalChoiceMaxOccursType4();
@@ -445,37 +246,10 @@
         testParticalChoiceMaxOccursType4Choice[2] = new TestParticalChoiceMaxOccursType4Choice();
         testParticalChoiceMaxOccursType4Choice[2].setParm3(getNewCustomType());
 
-         try {
-             OMElement omElement = testParticalChoiceMaxOccurs4.getOMElement(TestParticalChoiceMaxOccurs4.MY_QNAME,
-                      OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalChoiceMaxOccurs4 result = TestParticalChoiceMaxOccurs4.Factory.parse(xmlReader);
-            TestParticalChoiceMaxOccursType4Choice[] resultChoices =
-                    result.getTestParticalChoiceMaxOccurs4().getTestParticalChoiceMaxOccursType4Choice();
-            assertTrue(isEqual(resultChoices[0].getParm1(), testParticalChoiceMaxOccursType4Choice[0].getParm1()));
-            assertTrue(isEqual(resultChoices[0].getParm2(), testParticalChoiceMaxOccursType4Choice[0].getParm2()));
-            assertTrue(isEqual(resultChoices[0].getParm3(), testParticalChoiceMaxOccursType4Choice[0].getParm3()));
-
-            assertTrue(isEqual(resultChoices[1].getParm1(), testParticalChoiceMaxOccursType4Choice[1].getParm1()));
-            assertTrue(isEqual(resultChoices[1].getParm2(), testParticalChoiceMaxOccursType4Choice[1].getParm2()));
-            assertTrue(isEqual(resultChoices[1].getParm3(), testParticalChoiceMaxOccursType4Choice[1].getParm3()));
-
-            assertTrue(isEqual(resultChoices[2].getParm1(), testParticalChoiceMaxOccursType4Choice[2].getParm1()));
-            assertTrue(isEqual(resultChoices[2].getParm2(), testParticalChoiceMaxOccursType4Choice[2].getParm2()));
-            assertTrue(isEqual(resultChoices[2].getParm3(), testParticalChoiceMaxOccursType4Choice[2].getParm3()));
-
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
-
-
+        testSerializeDeserialize(testParticalChoiceMaxOccurs4);
     }
 
-    public void testParticleChoiceMaxOccurs5() {
+    public void testParticleChoiceMaxOccurs5() throws Exception {
 
         TestParticalChoiceMaxOccurs5 testParticalChoiceMaxOccurs5 = new TestParticalChoiceMaxOccurs5();
         TestParticalChoiceMaxOccursType5 testParticalChoiceMaxOccursType5 = new TestParticalChoiceMaxOccursType5();
@@ -495,39 +269,10 @@
         testParticalChoiceMaxOccursType5Choice[2] = new TestParticalChoiceMaxOccursType5Choice();
         testParticalChoiceMaxOccursType5Choice[2].setParm3(new TestCustomType[]{getNewCustomType()});
 
-       try {
-            OMElement omElement = testParticalChoiceMaxOccurs5.getOMElement(TestParticalChoiceMaxOccurs5.MY_QNAME,
-                   OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalChoiceMaxOccurs5 result = TestParticalChoiceMaxOccurs5.Factory.parse(xmlReader);
-            TestParticalChoiceMaxOccursType5Choice[] resultChoices =
-                    result.getTestParticalChoiceMaxOccurs5().getTestParticalChoiceMaxOccursType5Choice();
-            assertTrue(isEqual(resultChoices[0].getParm1(), testParticalChoiceMaxOccursType5Choice[0].getParm1()));
-            assertTrue(isEqual(resultChoices[0].getParm2(), testParticalChoiceMaxOccursType5Choice[0].getParm2()));
-            assertTrue(isEqual(resultChoices[0].getParm3(), testParticalChoiceMaxOccursType5Choice[0].getParm3()));
-
-            assertTrue(isEqual(resultChoices[1].getParm1(), testParticalChoiceMaxOccursType5Choice[1].getParm1()));
-            assertTrue(isEqual(resultChoices[1].getParm2(), testParticalChoiceMaxOccursType5Choice[1].getParm2()));
-            assertTrue(isEqual(resultChoices[1].getParm3(), testParticalChoiceMaxOccursType5Choice[1].getParm3()));
-
-            assertTrue(isEqual(resultChoices[2].getParm1(), testParticalChoiceMaxOccursType5Choice[2].getParm1()));
-            assertTrue(isEqual(resultChoices[2].getParm2(), testParticalChoiceMaxOccursType5Choice[2].getParm2()));
-            assertTrue(isEqual(resultChoices[2].getParm3(), testParticalChoiceMaxOccursType5Choice[2].getParm3()));
-
-        } catch (XMLStreamException e) {
-            e.printStackTrace();
-            fail();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail();
-        }
-
-
+        testSerializeDeserialize(testParticalChoiceMaxOccurs5);
     }
 
-    public void testParticalChoiceMaxOccursTest6() {
+    public void testParticalChoiceMaxOccursTest6() throws Exception {
         TestParticalChoiceMaxOccurs6 testParticalMaxOccures6 = new TestParticalChoiceMaxOccurs6();
         TestParticalChoiceMaxOccursType6 testParticalMaxOccursType6 = new TestParticalChoiceMaxOccursType6();
         testParticalMaxOccures6.setTestParticalChoiceMaxOccurs6(testParticalMaxOccursType6);
@@ -544,24 +289,7 @@
         testParticalMaxOccursType6.setAttribute1("Attribute1");
         testParticalMaxOccursType6.setAttribute2("Attribute2");
 
-        try {
-            OMElement omElement = testParticalMaxOccures6.getOMElement(TestParticalChoiceMaxOccurs6.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestParticalChoiceMaxOccurs6 result = TestParticalChoiceMaxOccurs6.Factory.parse(xmlReader);
-            TestParticalChoiceMaxOccursType6Choice[] resultChoices =
-                    result.getTestParticalChoiceMaxOccurs6().getTestParticalChoiceMaxOccursType6Choice();
-            assertEquals(resultChoices[0].getParm1(), "Param11");
-            assertEquals(resultChoices[1].getParm2(), "Param12");
-            assertEquals(result.getTestParticalChoiceMaxOccurs6().getAttribute1(), "Attribute1");
-            assertEquals(result.getTestParticalChoiceMaxOccurs6().getAttribute2(), "Attribute2");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testParticalMaxOccures6);
     }
 
     private TestCustomType getNewCustomType() {
@@ -572,63 +300,4 @@
         testCustomType.setParam3("Param" + i + "3");
         return testCustomType;
     }
-
-    private boolean isEqual(TestCustomType object1, TestCustomType object2) {
-        boolean isEqual = false;
-        if ((object1 != null) && (object2 != null)) {
-            isEqual = isEqual(object1.getParam1(), object2.getParam1()) &&
-                    isEqual(object1.getParam2(), object2.getParam2()) &&
-                    isEqual(object1.getParam3(), object2.getParam3());
-        } else if ((object1 == null) && (object2 == null)) {
-            isEqual = true;
-        }
-        return isEqual;
-    }
-
-    private boolean isEqual(TestCustomType[] object1, TestCustomType[] object2) {
-        boolean isEqual = false;
-        if ((object1 != null) && (object2 != null)) {
-            if (object1.length == object2.length) {
-                isEqual = true;
-                for (int i = 0; i < object1.length; i++) {
-                    if (!isEqual(object1[i], object2[i])) {
-                        isEqual = false;
-                        break;
-                    }
-                }
-            }
-        } else if ((object1 == null) && (object2 == null)) {
-            isEqual = true;
-        }
-        return isEqual;
-    }
-
-    private boolean isEqual(String[] object1, String[] object2) {
-        boolean isEqual = false;
-        if ((object1 != null) && (object2 != null)) {
-            if (object1.length == object2.length) {
-                isEqual = true;
-                for (int i = 0; i < object1.length; i++) {
-                    if (!isEqual(object1[i], object2[i])) {
-                        isEqual = false;
-                        break;
-                    }
-                }
-            }
-        } else if ((object1 == null) && (object2 == null)) {
-            isEqual = true;
-        }
-        return isEqual;
-    }
-
-    private boolean isEqual(String object1, String object2) {
-        boolean isEqual = false;
-        if ((object1 != null) && (object2 != null)) {
-            isEqual = object1.equals(object2);
-        } else if ((object1 == null) && (object2 == null)) {
-            isEqual = true;
-        }
-        return isEqual;
-    }
-
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/rampart/RampartTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/rampart/RampartTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/rampart/RampartTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/rampart/RampartTest.java Sat Jun 20 17:42:32 2009
@@ -19,25 +19,17 @@
 
 package org.apache.axis2.schema.rampart;
 
-import junit.framework.TestCase;
 import org.apache.axiom.attachments.ByteArrayDataSource;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axis2.databinding.ADBException;
+import org.apache.axis2.schema.AbstractTestCase;
 import org.w3.www._2005._05.xmlmime.Base64Binary;
 import org.w3.www._2005._05.xmlmime.ContentType_type0;
 import org.w3.www._2005._05.xmlmime.TestExtension;
 
 import javax.activation.DataHandler;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
 
+public class RampartTest extends AbstractTestCase {
 
-public class RampartTest extends TestCase {
-
-    public void testExtension(){
+    public void testExtension() throws Exception {
         TestExtension testExtension = new TestExtension();
 
         Base64Binary base64Binary = new Base64Binary();
@@ -51,19 +43,6 @@
         contentType_type0.setContentType_type0("test string");
         base64Binary.setContentType(contentType_type0);
 
-        try {
-            OMElement omElement = testExtension.getOMElement(TestExtension.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestExtension result = TestExtension.Factory.parse(xmlReader);
-            
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        TestExtension result = (TestExtension)serializeDeserialize(testExtension);
     }
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java Sat Jun 20 17:42:32 2009
@@ -20,20 +20,11 @@
 package org.apache.axis2.schema.references;
 
 import com.americanexpress.www.wsdl.ctn.utilities.atb.*;
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axis2.databinding.ADBException;
+import org.apache.axis2.schema.AbstractTestCase;
 
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
+public class ElementReferenceTest extends AbstractTestCase {
 
-
-public class ElementReferenceTest extends TestCase {
-
-    public void testSingleElementReference() {
+    public void testSingleElementReference() throws Exception {
         CheckEligibility1 echCheckEligibility1 = new CheckEligibility1();
         AtbRequestCheckEligibility_type0 atbRequestCheckEligibility = new AtbRequestCheckEligibility_type0();
         echCheckEligibility1.setAtbRequestCheckEligibility(atbRequestCheckEligibility);
@@ -42,24 +33,10 @@
         atbRequestCheckEligibility.setExpirationDate("date");
         atbRequestCheckEligibility.setNameAsOnCard("cardname");
         atbRequestCheckEligibility.setYearOfRedemption(2);
-
-
-        try {
-            OMElement omElement = echCheckEligibility1.getOMElement(CheckEligibility1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
-            String omElementString = omElement.toStringWithConsume();
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            CheckEligibility1 result = CheckEligibility1.Factory.parse(xmlReader);
-            assertEquals(result.getAtbRequestCheckEligibility().getCardNumber(), "carnumber");
-            assertEquals(result.getAtbRequestCheckEligibility().getClientId(), "clientid");
-            assertEquals(result.getAtbRequestCheckEligibility().getExpirationDate(), "date");
-            assertEquals(result.getAtbRequestCheckEligibility().getNameAsOnCard(), "cardname");
-            assertEquals(result.getAtbRequestCheckEligibility().getYearOfRedemption(), 2);
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(echCheckEligibility1);
     }
 
-    public void testMultipleElementReference() {
+    public void testMultipleElementReference() throws Exception {
         CheckEligibility2 echCheckEligibility2 = new CheckEligibility2();
         AtbRequestCheckEligibility_type0[] atbRequestCheckEligibility = new AtbRequestCheckEligibility_type0[2];
         echCheckEligibility2.setAtbRequestCheckEligibility(atbRequestCheckEligibility);
@@ -78,51 +55,18 @@
         atbRequestCheckEligibility[1].setNameAsOnCard("cardname");
         atbRequestCheckEligibility[1].setYearOfRedemption(2);
 
-
-        try {
-            OMElement omElement = echCheckEligibility2.getOMElement(CheckEligibility2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
-            String omElementString = omElement.toStringWithConsume();
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            CheckEligibility2 result = CheckEligibility2.Factory.parse(xmlReader);
-            assertEquals(result.getAtbRequestCheckEligibility()[0].getCardNumber(), "carnumber");
-            assertEquals(result.getAtbRequestCheckEligibility()[0].getClientId(), "clientid");
-            assertEquals(result.getAtbRequestCheckEligibility()[0].getExpirationDate(), "date");
-            assertEquals(result.getAtbRequestCheckEligibility()[0].getNameAsOnCard(), "cardname");
-            assertEquals(result.getAtbRequestCheckEligibility()[0].getYearOfRedemption(), 2);
-
-            assertEquals(result.getAtbRequestCheckEligibility()[1].getCardNumber(), "carnumber");
-            assertEquals(result.getAtbRequestCheckEligibility()[1].getClientId(), "clientid");
-            assertEquals(result.getAtbRequestCheckEligibility()[1].getExpirationDate(), "date");
-            assertEquals(result.getAtbRequestCheckEligibility()[1].getNameAsOnCard(), "cardname");
-            assertEquals(result.getAtbRequestCheckEligibility()[1].getYearOfRedemption(), 2);
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(echCheckEligibility2);
     }
 
-    public void testElement11(){
+    public void testElement11() throws Exception {
 
         Element1 element1 = new Element1();
         ComplexType1 complexType1 = new ComplexType1();
         element1.setElement1(complexType1);
-
-        try {
-            OMElement omElement = element1.getOMElement(Element1.MY_QNAME,OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            Element1 result = Element1.Factory.parse(xmlReader);
-            assertNotNull(result);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(element1);
     }
 
-    public void testElement12(){
+    public void testElement12() throws Exception {
 
         Element1 element1 = new Element1();
         ComplexType1 complexType1 = new ComplexType1();
@@ -131,27 +75,10 @@
         complexType1.setElement1(complexType2);
         ComplexType1 complexType3 = new ComplexType1();
         complexType2.setElement1(complexType3);
-
-
-        try {
-            OMElement omElement = element1.getOMElement(Element1.MY_QNAME,OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            Element1 result = Element1.Factory.parse(xmlReader);
-            assertNotNull(result);
-            assertNotNull(result.getElement1());
-            assertNotNull(result.getElement1().getElement1());
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(element1);
     }
 
-    public void testElement21(){
+    public void testElement21() throws Exception {
         Element2 element2 = new Element2();
         Element2_type0 element2_type0 = new Element2_type0();
         element2.setElement2(element2_type0);
@@ -161,24 +88,10 @@
         element2_type1.setParam1("test string2");
         element2_type0.setElement2(element2_type1);
 
-        try {
-            OMElement omElement = element2.getOMElement(Element2.MY_QNAME,OMAbstractFactory.getOMFactory());
-            String omElmentString = omElement.toStringWithConsume();
-            System.out.println("OM element ==>" + omElmentString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElmentString.getBytes()));
-            Element2 result = Element2.Factory.parse(xmlReader);
-            assertEquals(result.getElement2().getParam1(),"test string1");
-            assertEquals(result.getElement2().getElement2().getParam1(), "test string2");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(element2);
     }
 
-    public void testSimpleReference() {
+    public void testSimpleReference() throws Exception {
         TestSimpleReference testSimpleReference = new TestSimpleReference();
         Discard_transferToken discard_transferToken = new Discard_transferToken();
 // FIXME: Breaks in IBM JDK 1.5 - the generated code there is looking for AuthInfo_type0 instead of AuthInfo_type1
@@ -188,26 +101,6 @@
         discard_transferToken.setParam1("New parm");
         testSimpleReference.setTestSimpleReference(discard_transferToken);
 
-        try {
-            OMElement omElement = testSimpleReference.getOMElement(TestSimpleReference.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElmentString = omElement.toStringWithConsume();
-            System.out.println("OM element ==>" + omElmentString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElmentString.getBytes()));
-            TestSimpleReference result = TestSimpleReference.Factory.parse(xmlReader);
-            assertEquals(result.getTestSimpleReference().getParam1(),"New parm");
-// See FIXME above:
-//            assertEquals(result.getTestSimpleReference().getAuthInfo().getAuthInfo_type1(),"Simple param");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
-
-
+        testSerializeDeserialize(testSimpleReference);
     }
-
-
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/ComplexRestrictionTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/ComplexRestrictionTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/ComplexRestrictionTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/ComplexRestrictionTest.java Sat Jun 20 17:42:32 2009
@@ -19,22 +19,15 @@
 
 package org.apache.axis2.schema.restriction;
 
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axis2.databinding.ADBException;
+import org.apache.axis2.schema.AbstractTestCase;
 import org.tempuri.GetExemplarResponseType;
 import org.tempuri.GetExemplarResponseTypeElement;
 
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
 import java.math.BigInteger;
 
-public class ComplexRestrictionTest extends TestCase {
+public class ComplexRestrictionTest extends AbstractTestCase {
 
-    public void testGetExemplarResponseTypeElement(){
+    public void testGetExemplarResponseTypeElement() throws Exception {
         GetExemplarResponseTypeElement getExemplarResponseTypeElement = new GetExemplarResponseTypeElement();
         GetExemplarResponseType getExemplarResponseType = new GetExemplarResponseType();
         getExemplarResponseType.setExemplar("test string1");
@@ -44,25 +37,7 @@
 
         getExemplarResponseTypeElement.setGetExemplarResponseTypeElement(getExemplarResponseType);
 
-        try {
-            OMElement omElement =
-                    getExemplarResponseTypeElement.getOMElement(GetExemplarResponseTypeElement.MY_QNAME,
-                            OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMElement string ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            GetExemplarResponseTypeElement result = GetExemplarResponseTypeElement.Factory.parse(xmlReader);
-            GetExemplarResponseType resultType = result.getGetExemplarResponseTypeElement();
-            assertEquals(resultType.getExemplar(),"test string1");
-            assertEquals(resultType.getResponseMessage(),"test string2");
-            assertEquals(resultType.getSupportedMethods(),"test string3");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(getExemplarResponseTypeElement);
     }
 
 }



Mime
View raw message