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 [1/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
Author: veithen
Date: Sat Jun 20 17:42:32 2009
New Revision: 786866

URL: http://svn.apache.org/viewvc?rev=786866&view=rev
Log:
Simplified the ADB tests (as far as I know, we are not paid by number of lines of code :-).

Added:
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/AbstractTestCase.java   (with props)
Modified:
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/all/AllTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/anytype/AnyTypeTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/attribute/AttributeTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/base64binary/Base64BinaryTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/booleantest/BooleanTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/choice/ChoiceTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/decimal/DecimalTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/enumeration/EnumerationTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/ComplexExtenstionTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/SimpleExtensionTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/group/GroupTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerChoice/InnerChoiceTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticleextension/TestInnerParticleExtension.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticles/InnerParticlesTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/list/ListTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/particalmaxoccurs/ParticalMaxOccursTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/rampart/RampartTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/ComplexRestrictionTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/SimpleRestrictionTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union/UnionTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union2/Union2Test.java

Added: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/AbstractTestCase.java?rev=786866&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/AbstractTestCase.java (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/AbstractTestCase.java Sat Jun 20 17:42:32 2009
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.schema;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axis2.databinding.ADBBean;
+import org.apache.axis2.databinding.ADBException;
+import org.apache.axis2.databinding.types.HexBinary;
+import org.apache.axis2.databinding.types.Language;
+import org.apache.axis2.databinding.types.URI;
+
+import junit.framework.TestCase;
+
+public abstract class AbstractTestCase extends TestCase {
+    // This is the set of property types that can be compared using Object#equals:
+    private static final Set<Class<?>> simpleJavaTypes = new HashSet<Class<?>>(Arrays.asList(new Class<?>[] {
+            String.class, Boolean.class, Boolean.TYPE, Integer.class, Integer.TYPE,
+            BigInteger.class, BigDecimal.class, Date.class, QName.class,
+            URI.class, Language.class, HexBinary.class
+    }));
+    
+    private static QName getADBBeanQName(Class<? extends ADBBean> beanClass) throws Exception {
+        return (QName)beanClass.getField("MY_QNAME").get(null);
+    }
+    
+    private static <T extends ADBBean> T parse(Class<T> beanClass, XMLStreamReader reader) throws Exception {
+        for (Class<?> clazz : beanClass.getDeclaredClasses()) {
+            if (clazz.getSimpleName().equals("Factory")) {
+                return beanClass.cast(clazz.getMethod("parse", XMLStreamReader.class).invoke(null, reader));
+            }
+        }
+        return null; // We should never get here
+    }
+    
+    private static boolean isEnum(Class<? extends ADBBean> beanClass) {
+        try {
+            beanClass.getDeclaredField("_table_");
+            return true;
+        } catch (NoSuchFieldException ex) {
+            return false;
+        }
+    }
+    
+    /**
+     * Assert that two ADB beans are equal. This method recursively compares properties
+     * in the bean. It supports comparison of various property types, including arrays
+     * and DataHandler.
+     * 
+     * @param expected
+     * @param actual
+     */
+    public static void assertBeanEquals(ADBBean expected, ADBBean actual) {
+        if (expected == null) {
+            assertNull(actual);
+            return;
+        }
+        Class<?> beanClass = expected.getClass();
+        assertEquals(beanClass, actual.getClass());
+        BeanInfo beanInfo;
+        try {
+            beanInfo = Introspector.getBeanInfo(beanClass, Object.class);
+        } catch (IntrospectionException ex) {
+            fail("Failed to introspect " + beanClass);
+            return; // Make compiler happy
+        }
+        for (PropertyDescriptor desc : beanInfo.getPropertyDescriptors()) {
+            String propertyName = desc.getName();
+//            System.out.println("Comparing property " + propertyName);
+            Method readMethod = desc.getReadMethod();
+            Object expectedValue;
+            Object actualValue;
+            try {
+                expectedValue = readMethod.invoke(expected);
+                actualValue = readMethod.invoke(actual);
+            } catch (Exception ex) {
+                fail("Failed to get property " + propertyName + " from " + beanClass);
+                return;
+            }
+            assertPropertyValueEquals("property " + propertyName + " in bean " + beanClass, expectedValue, actualValue);
+        }
+    }
+    
+    private static void assertPropertyValueEquals(String message, Object expected, Object actual) {
+        if (expected == null) {
+            assertNull(message, actual);
+        } else {
+            assertNotNull(message, actual);
+            Class<?> type = expected.getClass();
+            if (type.isArray()) {
+                int expectedLength = Array.getLength(expected);
+                int actualLength = Array.getLength(actual);
+                assertEquals("array length for " + message, expectedLength, actualLength);
+                for (int i=0; i<expectedLength; i++) {
+                    assertPropertyValueEquals(message, Array.get(expected, i), Array.get(actual, i));
+                }
+            } else if (simpleJavaTypes.contains(type)) {
+                assertEquals("value for " + message, expected, actual);
+            } else if (DataHandler.class.isAssignableFrom(type)) {
+                assertDataHandlerEquals((DataHandler)expected, (DataHandler)actual);
+            } else if (ADBBean.class.isAssignableFrom(type)) {
+                if (isEnum(((ADBBean)expected).getClass())) {
+                    assertSame("enum value for " + message, expected, actual);
+                } else {
+                    assertBeanEquals((ADBBean)expected, (ADBBean)actual);
+                }
+            } else {
+                fail("Don't know how to compare values of type " + type.getName() + " for " + message);
+            }
+        }
+    }
+    
+    private static void assertDataHandlerEquals(DataHandler expected, DataHandler actual) {
+        try {
+            InputStream in1 = expected.getInputStream();
+            InputStream in2 = actual.getInputStream();
+            int b;
+            do {
+                b = in1.read();
+                assertEquals(b, in2.read());
+            } while (b != -1);
+        } catch (IOException ex) {
+            fail("Failed to read data handler");
+        }
+    }
+    
+    /**
+     * Serialize a bean to XML and then deserialize the XML.
+     * 
+     * @param bean the bean to serialize
+     * @return the deserialized bean
+     * @throws Exception
+     */
+    public static ADBBean serializeDeserialize(ADBBean bean) throws Exception {
+        Class<? extends ADBBean> beanClass = bean.getClass();
+        OMElement omElement = bean.getOMElement(getADBBeanQName(beanClass), OMAbstractFactory.getOMFactory());
+        String omElementString = omElement.toStringWithConsume();
+//        System.out.println("om string ==> " + omElementString);
+        XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+        return parse(beanClass, xmlReader);
+    }
+    
+    /**
+     * Serialize a bean to XML, then deserialize the XML and compare the resulting bean to
+     * the original.
+     * 
+     * @param bean the bean to serialize
+     * @throws Exception
+     */
+    public static void testSerializeDeserialize(ADBBean bean) throws Exception {
+        assertBeanEquals(bean, serializeDeserialize(bean));
+    }
+    
+    /**
+     * Assert that serializing the given bean should result in an {@link ADBException}.
+     * 
+     * @param bean the bean to serialize
+     * @throws Exception
+     */
+    public static void assertSerializationFailure(ADBBean bean) throws Exception {
+        try {
+            OMElement omElement = bean.getOMElement(getADBBeanQName(bean.getClass()), OMAbstractFactory.getOMFactory());
+            omElement.toStringWithConsume();
+            fail("Expected ADBException");
+        } catch (ADBException ex) {
+            // OK: expected
+        }
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/AbstractTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/all/AllTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/all/AllTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/all/AllTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/all/AllTest.java Sat Jun 20 17:42:32 2009
@@ -19,37 +19,16 @@
 
 package org.apache.axis2.schema.all;
 
-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 org.tempuri.Update;
 
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
+public class AllTest extends AbstractTestCase {
 
-
-public class AllTest extends TestCase {
-
-    public void testAll(){
+    public void testAll() throws Exception {
         Update update = new Update();
         update.setArg0("test");
         update.setArg1(true);
         update.setId(2);
-
-
-        try {
-            OMElement omElement = update.getOMElement(Update.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("om string ==> " + omElementString);
-            omElementString = "<ns1:Update xmlns:ns1=\"http://tempuri.org/\"><ns1:arg1>true</ns1:arg1><ns1:id>2</ns1:id><ns1:arg0>test</ns1:arg0></ns1:Update>";
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            Update newUpdate = Update.Factory.parse(xmlReader);
-            assertEquals(update.getArg0(),newUpdate.getArg0());
-            assertEquals(update.getArg1(),newUpdate.getArg1());
-            assertEquals(update.getId(),newUpdate.getId());
-        } catch (Exception e) {
-            assertFalse(true);
-        }
+        testSerializeDeserialize(update);
     }
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/anytype/AnyTypeTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/anytype/AnyTypeTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/anytype/AnyTypeTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/anytype/AnyTypeTest.java Sat Jun 20 17:42:32 2009
@@ -19,348 +19,113 @@
 
 package org.apache.axis2.schema.anytype;
 
-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 test.adb.anytype.*;
 
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
 import java.io.StringReader;
 
+public class AnyTypeTest extends AbstractTestCase {
 
-
-public class AnyTypeTest extends TestCase {
-
-    public void testAnyTypeElement1() {
+    public void testAnyTypeElement1() throws Exception {
         TestAnyTypeElement1 testAnyTypeElement;
 
         testAnyTypeElement = new TestAnyTypeElement1();
         testAnyTypeElement.setTestAnyTypeElement1("test");
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement1.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement1 result = TestAnyTypeElement1.Factory.parse(xmlReader);
-            assertEquals(result.getTestAnyTypeElement1(),"test");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement1();
         testAnyTypeElement.setTestAnyTypeElement1(null);
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement1.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            fail();
-        } catch (ADBException e) {
-            assertTrue(true);
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
-
+        
+        assertSerializationFailure(testAnyTypeElement);
     }
 
-    public void testAnyTypeElement2() {
+    public void testAnyTypeElement2() throws Exception {
         TestAnyTypeElement2 testAnyTypeElement;
 
         testAnyTypeElement = new TestAnyTypeElement2();
         testAnyTypeElement.setTestAnyTypeElement2("test");
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement2.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement2 result = TestAnyTypeElement2.Factory.parse(xmlReader);
-            assertEquals(result.getTestAnyTypeElement2(),"test");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement2();
         testAnyTypeElement.setTestAnyTypeElement2(null);
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement1.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement2 result = TestAnyTypeElement2.Factory.parse(xmlReader);
-            assertEquals(result.getTestAnyTypeElement2(),null);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
     }
 
-    public void testAnyTypeElement3() {
+    public void testAnyTypeElement3() throws Exception {
         TestAnyTypeElement3 testAnyTypeElement;
         testAnyTypeElement = new TestAnyTypeElement3();
         testAnyTypeElement.setParam1(new Object[]{"test1","test2"});
 
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement3.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement3 result = TestAnyTypeElement3.Factory.parse(xmlReader);
-            assertEquals(result.getParam1()[0],"test1");
-            assertEquals(result.getParam1()[1],"test2");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement3();
         testAnyTypeElement.setParam1(null);
 
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement3.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement3 result = TestAnyTypeElement3.Factory.parse(xmlReader);
-            assertEquals(result.getParam1()[0],null);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        TestAnyTypeElement3 result = (TestAnyTypeElement3)serializeDeserialize(testAnyTypeElement);
+        assertEquals(result.getParam1()[0],null);
 
         testAnyTypeElement = new TestAnyTypeElement3();
         testAnyTypeElement.setParam1(new Object[]{"test",null});
 
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement3.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement3 result = TestAnyTypeElement3.Factory.parse(xmlReader);
-            assertEquals(result.getParam1()[0],"test");
-            assertEquals(result.getParam1()[1],null);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
     }
 
 
-     public void testAnyTypeElement4() {
+     public void testAnyTypeElement4() throws Exception {
         TestAnyTypeElement4 testAnyTypeElement;
         testAnyTypeElement = new TestAnyTypeElement4();
         testAnyTypeElement.setParam1(new Object[]{"test1","test2"});
-
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement4.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement4 result = TestAnyTypeElement4.Factory.parse(xmlReader);
-            assertEquals(result.getParam1()[0],"test1");
-            assertEquals(result.getParam1()[1],"test2");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement4();
         testAnyTypeElement.setParam1(null);
-
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement4.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement4 result = TestAnyTypeElement4.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(),null);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement4();
         testAnyTypeElement.setParam1(new Object[]{"test",null});
 
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement4.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement4 result = TestAnyTypeElement4.Factory.parse(xmlReader);
-            assertEquals(result.getParam1()[0],"test");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        TestAnyTypeElement4 result = (TestAnyTypeElement4)serializeDeserialize(testAnyTypeElement);
+        assertEquals(result.getParam1()[0],"test");
     }
 
 
-    public void testAnyTypeElement5() {
+    public void testAnyTypeElement5() throws Exception {
         TestAnyTypeElement5 testAnyTypeElement;
         testAnyTypeElement = new TestAnyTypeElement5();
         testAnyTypeElement.setParam1(new Object[]{"test1","test2"});
-
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement5.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement5 result = TestAnyTypeElement5.Factory.parse(xmlReader);
-            assertEquals(result.getParam1()[0],"test1");
-            assertEquals(result.getParam1()[1],"test2");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement5();
         testAnyTypeElement.setParam1(null);
 
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement5.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement5 result = TestAnyTypeElement5.Factory.parse(xmlReader);
-            assertEquals(result.getParam1()[0],null);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        TestAnyTypeElement5 result = (TestAnyTypeElement5)serializeDeserialize(testAnyTypeElement);
+        assertEquals(result.getParam1()[0],null);
 
         testAnyTypeElement = new TestAnyTypeElement5();
         testAnyTypeElement.setParam1(new Object[]{"test",null});
-
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement5.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement5 result = TestAnyTypeElement5.Factory.parse(xmlReader);
-            assertEquals(result.getParam1()[0],"test");
-            assertEquals(result.getParam1()[1],null);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
     }
 
 
-    public void testAnyTypeElement6() {
+    public void testAnyTypeElement6() throws Exception {
         TestAnyTypeElement6 testAnyTypeElement;
         testAnyTypeElement = new TestAnyTypeElement6();
         testAnyTypeElement.setParam1(new Object[]{"test1","test2"});
-
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement6.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement6 result = TestAnyTypeElement6.Factory.parse(xmlReader);
-            assertEquals(result.getParam1()[0],"test1");
-            assertEquals(result.getParam1()[1],"test2");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement6();
         testAnyTypeElement.setParam1(null);
-
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement6.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            fail();
-        } catch (ADBException e) {
-            assertTrue(true);
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        assertSerializationFailure(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement6();
         testAnyTypeElement.setParam1(new Object[]{"test",null});
-
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement6.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            fail();
-        } catch (ADBException e) {
-            assertTrue(true);
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        assertSerializationFailure(testAnyTypeElement);
     }
 
-    public void testAnyTypeElement61(){
+    public void testAnyTypeElement61() throws Exception {
         TestAnyTypeElement6 testAnyTypeElement6 = new TestAnyTypeElement6();
 
         TestComplexParent[] testComplexParents = new TestComplexParent[2];
@@ -374,258 +139,82 @@
 
         testAnyTypeElement6.setParam1(testComplexParents);
 
-        try {
-            OMElement omElement = testAnyTypeElement6.getOMElement(
-                    TestAnyTypeElement6.MY_QNAME,OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(
-                    new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement6 result = TestAnyTypeElement6.Factory.parse(xmlReader);
-            TestComplexParent resultParent = (TestComplexParent) result.getParam1()[0];
-            assertEquals(resultParent.getParam1(),"test param1");
-            TestComplexChild resultChild = (TestComplexChild) result.getParam1()[1];
-            assertEquals(resultChild.getParam1(), "test param1");
-            assertEquals(resultChild.getParam2(), 3);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement6);
     }
 
-    public void testAnyTypeElement7() {
+    public void testAnyTypeElement7() throws Exception {
         TestAnyTypeElement7 testAnyTypeElement;
 
         testAnyTypeElement = new TestAnyTypeElement7();
         testAnyTypeElement.setParam1("test");
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement7.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement7 result = TestAnyTypeElement7.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(),"test");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement7();
         testAnyTypeElement.setParam1(null);
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement7.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement7 result = TestAnyTypeElement7.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(),null);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
     }
 
-    public void testAnyTypeElement71(){
+    public void testAnyTypeElement71() throws Exception {
         TestAnyTypeElement7 testAnyTypeElement7 = new TestAnyTypeElement7();
         TestComplexParent testComplexParent = new TestComplexParent();
         testComplexParent.setParam1("test param1");
         testAnyTypeElement7.setParam1(testComplexParent);
-
-        try {
-            OMElement omElement = testAnyTypeElement7.getOMElement(
-                    TestAnyTypeElement7.MY_QNAME,OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(
-                    new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement7 result = TestAnyTypeElement7.Factory.parse(xmlReader);
-            TestComplexParent resultParent = (TestComplexParent) result.getParam1();
-            assertEquals(resultParent.getParam1(),"test param1");
-
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement7);
     }
 
-    public void testAnyTypeElement8() {
+    public void testAnyTypeElement8() throws Exception {
         TestAnyTypeElement8 testAnyTypeElement;
 
         testAnyTypeElement = new TestAnyTypeElement8();
         testAnyTypeElement.setParam1("test");
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement8.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement8 result = TestAnyTypeElement8.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(),"test");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement8();
         testAnyTypeElement.setParam1(null);
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement8.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement8 result = TestAnyTypeElement8.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(),null);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
     }
 
-    public void testAnyTypeElement9() {
+    public void testAnyTypeElement9() throws Exception {
         TestAnyTypeElement9 testAnyTypeElement;
 
         testAnyTypeElement = new TestAnyTypeElement9();
         testAnyTypeElement.setParam1("test");
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement9.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement9 result = TestAnyTypeElement9.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(),"test");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement9();
         testAnyTypeElement.setParam1(null);
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement9.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement9 result = TestAnyTypeElement9.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(),null);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
     }
 
-    public void testAnyTypeElement10() {
+    public void testAnyTypeElement10() throws Exception {
         TestAnyTypeElement10 testAnyTypeElement;
 
         testAnyTypeElement = new TestAnyTypeElement10();
         testAnyTypeElement.setParam1("test");
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement10.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement10 result = TestAnyTypeElement10.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(),"test");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
 
         testAnyTypeElement = new TestAnyTypeElement10();
         testAnyTypeElement.setParam1(null);
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement10.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            fail();
-        } catch (ADBException e) {
-            assertTrue(true);
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        assertSerializationFailure(testAnyTypeElement);
     }
 
-    public void testAnyElementInteger(){
+    public void testAnyElementInteger() throws Exception {
         // datatype tests
         TestAnyTypeElement1 testAnyTypeElement;
         testAnyTypeElement = new TestAnyTypeElement1();
         testAnyTypeElement.setTestAnyTypeElement1(new Integer(5));
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement1.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement1 result = TestAnyTypeElement1.Factory.parse(xmlReader);
-            assertEquals(result.getTestAnyTypeElement1(),new Integer(5));
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
     }
 
-    public void testAnyElementQName(){
+    public void testAnyElementQName() throws Exception {
         // datatype tests
         TestAnyTypeElement1 testAnyTypeElement;
         testAnyTypeElement = new TestAnyTypeElement1();
         testAnyTypeElement.setTestAnyTypeElement1(new QName("http://wso2.org","testElement"));
-        try {
-            OMElement omElement = testAnyTypeElement.getOMElement(TestAnyTypeElement1.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAnyTypeElement1 result = TestAnyTypeElement1.Factory.parse(xmlReader);
-            assertEquals(result.getTestAnyTypeElement1(),new QName("http://wso2.org","testElement"));
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAnyTypeElement);
     }
 
-    public void testTestElement(){
+    public void testTestElement() throws Exception {
         TestElement testElement = new TestElement();
 
         DynamicProperty[] dynamicProperties = new DynamicProperty[3];
@@ -650,29 +239,7 @@
 
         testElement.setParam1(dynamicProperties);
 
-        try {
-            OMElement omElement = testElement.getOMElement(
-                    TestElement.MY_QNAME,OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(
-                    new ByteArrayInputStream(omElementString.getBytes()));
-            TestElement result = TestElement.Factory.parse(xmlReader);
-            DynamicProperty[] resultProperties = result.getParam1();
-            assertEquals(resultProperties[0].getName(), "test name");
-            assertEquals(resultProperties[0].getVal(), new Integer(5));
-            assertEquals(resultProperties[1].getName(), "test name");
-            assertEquals(((TestComplexParent)resultProperties[1].getVal()).getParam1(), "test complext type");
-            assertEquals(resultProperties[2].getName(), "test name");
-            assertEquals(((TestSimpleType)resultProperties[2].getVal()).getTestSimpleType(),"test simple string");
-
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testElement);
     }
     
     // Regression test for AXIS2-4273

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/attribute/AttributeTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/attribute/AttributeTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/attribute/AttributeTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/attribute/AttributeTest.java Sat Jun 20 17:42:32 2009
@@ -19,155 +19,59 @@
 
 package org.apache.axis2.schema.attribute;
 
-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 org.tempuri.attribute.*;
 
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
+public class AttributeTest extends AbstractTestCase {
 
-public class AttributeTest extends TestCase {
-
-    public void testElement1(){
+    public void testElement1() throws Exception {
 
         TestElement1 testElement = new TestElement1();
         testElement.setAttribute1(1);
-        OMElement omElement;
-        try {
-            omElement = testElement.getOMElement(TestElement1.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMElement ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestElement1 result = TestElement1.Factory.parse(xmlReader);
-            assertEquals(result.getAttribute1(),1);
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testElement);
 
         testElement = new TestElement1();
         testElement.setAttribute1(Integer.MIN_VALUE);
-
-        try {
-            omElement = testElement.getOMElement(TestElement1.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMElement ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestElement1 result = TestElement1.Factory.parse(xmlReader);
-            assertEquals(result.getAttribute1(),Integer.MIN_VALUE);
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testElement);
     }
 
-    public void testElement2(){
+    public void testElement2() throws Exception {
         TestElement2 testElement = new TestElement2();
         testElement.setAttribute1(1);
-         OMElement omElement;
-         try {
-             omElement = testElement.getOMElement(TestElement2.MY_QNAME, OMAbstractFactory.getOMFactory());
-             String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMElement ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestElement2 result = TestElement2.Factory.parse(xmlReader);
-            assertEquals(result.getAttribute1(),1);
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testElement);
 
         testElement = new TestElement2();
         testElement.setAttribute1(Integer.MIN_VALUE);
-
-        try {
-            omElement = testElement.getOMElement(TestElement2.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMElement ==> " + omElementString);
-            fail();
-        } catch (Exception e) {
-            assertTrue(true);
-        }
+        assertSerializationFailure(testElement);
     }
 
-    public void testElement3(){
+    public void testElement3() throws Exception {
         TestElement3 testElement = new TestElement3();
         testElement.setAttribute1("test");
-         OMElement omElement;
-         try {
-             omElement = testElement.getOMElement(TestElement3.MY_QNAME, OMAbstractFactory.getOMFactory());
-             String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMElement ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestElement3 result = TestElement3.Factory.parse(xmlReader);
-            assertEquals(result.getAttribute1(),"test");
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testElement);
 
         testElement = new TestElement3();
-
-
-        try {
-            omElement = testElement.getOMElement(TestElement3.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMElement ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestElement3 result = TestElement3.Factory.parse(xmlReader);
-            assertEquals(result.getAttribute1(),null);
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testElement);
     }
 
-     public void testElement4(){
+    public void testElement4() throws Exception {
         TestElement4 testElement = new TestElement4();
         testElement.setAttribute1("test");
-        OMElement omElement;
-        try {
-            omElement = testElement.getOMElement(TestElement4.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMElement ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestElement4 result = TestElement4.Factory.parse(xmlReader);
-            assertEquals(result.getAttribute1(),"test");
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testElement);
 
         testElement = new TestElement4();
-
-
-        try {
-            omElement = testElement.getOMElement(TestElement4.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMElement ==> " + omElementString);
-            fail();
-        } catch (Exception e) {
-            assertTrue(true);
-        }
+        assertSerializationFailure(testElement);
     }
 
-    public void testAttributeSimpleType(){
+    public void testAttributeSimpleType() throws Exception {
         TestAttributeSimpleType testAttributeSimpleType = new TestAttributeSimpleType();
         Attribute1_type0 attribute1_type0 = new Attribute1_type0();
         attribute1_type0.setAttribute1_type0("test attribute");
         testAttributeSimpleType.setAttribute1(attribute1_type0);
-
-        try {
-            OMElement omElement = testAttributeSimpleType.getOMElement(TestAttributeSimpleType.MY_QNAME,
-                      OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OMString ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAttributeSimpleType result = TestAttributeSimpleType.Factory.parse(xmlReader);
-            assertEquals(result.getAttribute1().getAttribute1_type0(),"test attribute");
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAttributeSimpleType);
     }
 
-    public void testAttributeReferenceElement(){
+    public void testAttributeReferenceElement() throws Exception {
         TestAttributeReferenceElement testAttributeReferenceElement = new TestAttributeReferenceElement();
         TestAttributeReferenceType testAttributeReferenceType = new TestAttributeReferenceType();
         testAttributeReferenceType.setParam1("param1");
@@ -175,23 +79,6 @@
         testAttributeReferenceType.setTestAttribute1("attribute1");
 
         testAttributeReferenceElement.setTestAttributeReferenceElement(testAttributeReferenceType);
-
-        try {
-            OMElement omElement = testAttributeReferenceElement.getOMElement(TestAttributeReferenceElement.MY_QNAME,
-                         OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element ==> " + omElementString);
-            XMLStreamReader xmlReader =
-                    StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestAttributeReferenceElement result = TestAttributeReferenceElement.Factory.parse(xmlReader);
-
-            assertEquals(result.getTestAttributeReferenceElement().getParam1(),"param1");
-            assertEquals(result.getTestAttributeReferenceElement().getParam2(),"param2");
-            assertEquals(result.getTestAttributeReferenceElement().getTestAttribute1(),"attribute1");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testAttributeReferenceElement);
     }
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/base64binary/Base64BinaryTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/base64binary/Base64BinaryTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/base64binary/Base64BinaryTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/base64binary/Base64BinaryTest.java Sat Jun 20 17:42:32 2009
@@ -19,24 +19,15 @@
 
 package org.apache.axis2.schema.base64binary;
 
-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.databinding.types.HexBinary;
+import org.apache.axis2.schema.AbstractTestCase;
 import org.w3.www._2005._05.xmlmime.*;
 
 import javax.activation.DataHandler;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
 
+public class Base64BinaryTest extends AbstractTestCase {
 
-public class Base64BinaryTest extends TestCase {
-
-    public void testBase64Binary(){
+    public void testBase64Binary() throws Exception {
         TestBase64Binary testBase64Binary = new TestBase64Binary();
         Base64Binary base64Binary = new Base64Binary();
         testBase64Binary.setTestBase64Binary(base64Binary);
@@ -49,27 +40,10 @@
         contentType_type0.setContentType_type0("test content type");
         base64Binary.setContentType(contentType_type0);
 
-
-        try {
-            OMElement omElement = testBase64Binary.getOMElement(TestBase64Binary.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestBase64Binary result = TestBase64Binary.Factory.parse(xmlReader);
-            DataHandler resultDataHandler = result.getTestBase64Binary().getBase64Binary();
-            byte[] bytes = new byte[128];
-            int length = resultDataHandler.getInputStream().read(bytes);
-            String resultString = new String(bytes,0,length);
-            assertEquals(resultString,testString);
-            assertEquals(result.getTestBase64Binary().getContentType().getContentType_type0(),"test content type");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testBase64Binary);
     }
 
-    public void testHexBinary(){
+    public void testHexBinary() throws Exception {
         TestHexBinary testHexBinary = new TestHexBinary();
         org.w3.www._2005._05.xmlmime.HexBinary hexBinary = new org.w3.www._2005._05.xmlmime.HexBinary();
         testHexBinary.setTestHexBinary(hexBinary);
@@ -84,23 +58,10 @@
         contentType_type0.setContentType_type0("test content type");
         hexBinary.setContentType(contentType_type0);
 
-
-        try {
-            OMElement omElement = testHexBinary.getOMElement(TestBase64Binary.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestHexBinary result = TestHexBinary.Factory.parse(xmlReader);
-            assertEquals(result.getTestHexBinary().getHexBinary().toString(),testString);
-            assertEquals(result.getTestHexBinary().getContentType().getContentType_type0(),"test content type");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testHexBinary);
     }
 
-    public void testBase64MultiElement(){
+    public void testBase64MultiElement() throws Exception {
 
         TestBase64MultiElement testBase64MultiElement = new TestBase64MultiElement();
         String testString = "testing base 64 elements";
@@ -109,26 +70,6 @@
         testBase64MultiElement.setParam2("test string");
         testBase64MultiElement.setParam3(5);
 
-        try {
-            OMElement omElement = testBase64MultiElement.getOMElement(TestBase64MultiElement.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestBase64MultiElement result = TestBase64MultiElement.Factory.parse(xmlReader);
-            DataHandler resultDataHandler = result.getParam1();
-            byte[] buffer = new byte[128];
-            int length = resultDataHandler.getInputStream().read(buffer);
-            String resultString = new String(buffer,0,length);
-            assertEquals(testString,resultString);
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testBase64MultiElement);
     }
-
-
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/booleantest/BooleanTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/booleantest/BooleanTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/booleantest/BooleanTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/booleantest/BooleanTest.java Sat Jun 20 17:42:32 2009
@@ -19,51 +19,23 @@
 
 package org.apache.axis2.schema.booleantest;
 
-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 org.tempuri.boolean1.TestBoolean1;
 import org.tempuri.boolean1.TestBoolean2;
 
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
+public class BooleanTest extends AbstractTestCase {
 
-
-public class BooleanTest extends TestCase {
-
-    public void testBooleanTest1(){
+    public void testBooleanTest1() throws Exception {
         TestBoolean1 testBoolean = new TestBoolean1();
         testBoolean.setTestBoolean1(true);
-
-        try {
-            OMElement omElement = testBoolean.getOMElement(TestBoolean1.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestBoolean1 result = TestBoolean1.Factory.parse(xmlReader);
-            assertEquals(result.getTestBoolean1(),true);
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testBoolean);
     }
 
-    public void testBooleanTest2(){
+    public void testBooleanTest2() throws Exception {
         TestBoolean2 testBoolean = new TestBoolean2();
         testBoolean.setParam1(false);
         testBoolean.setAttribute1(true);
-
-         try {
-            OMElement omElement = testBoolean.getOMElement(TestBoolean2.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestBoolean2 result = TestBoolean2.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(),false);
-            assertEquals(result.getAttribute1(),true);
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testBoolean);
     }
 
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/choice/ChoiceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/choice/ChoiceTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/choice/ChoiceTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/choice/ChoiceTest.java Sat Jun 20 17:42:32 2009
@@ -19,32 +19,18 @@
 
 package org.apache.axis2.schema.choice;
 
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.StAXUtils;
-import test.axis2.apache.org.TestChoise;
-
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
+import org.apache.axis2.schema.AbstractTestCase;
 
+import test.axis2.apache.org.TestChoise;
 
-public class ChoiceTest extends TestCase {
+public class ChoiceTest extends AbstractTestCase {
 
-    public void testChoice(){
+    public void testChoice() throws Exception {
         TestChoise testChoise = new TestChoise();
         testChoise.setChoice1("test 2");
         testChoise.setChoice2(5);
-
-        try {
-            OMElement omElement = testChoise.getOMElement(TestChoise.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestChoise newTestChoice = TestChoise.Factory.parse(xmlReader);
-            assertEquals(5,newTestChoice.getChoice2());
-        } catch (Exception e) {
-            assertFalse(true);
-        }
+        
+        TestChoise newTestChoice = (TestChoise)serializeDeserialize(testChoise);
+        assertEquals(5, newTestChoice.getChoice2());
     }
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/decimal/DecimalTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/decimal/DecimalTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/decimal/DecimalTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/decimal/DecimalTest.java Sat Jun 20 17:42:32 2009
@@ -19,25 +19,17 @@
 
 package org.apache.axis2.schema.decimal;
 
-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.databinding.types.Duration;
+import org.apache.axis2.schema.AbstractTestCase;
 import org.tempuri.boolean1.ArrayOfDecimal;
 import org.tempuri.boolean1.GetHistoricNavResponse;
 
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
 import java.math.BigDecimal;
 import java.util.Calendar;
 
+public class DecimalTest extends AbstractTestCase {
 
-public class DecimalTest  extends TestCase {
-
-    public void testDecimal(){
+    public void testDecimal() throws Exception{
         GetHistoricNavResponse getHistoricNavResponse = new GetHistoricNavResponse();
         ArrayOfDecimal arrayOfDecimal = new ArrayOfDecimal();
         getHistoricNavResponse.setOut(arrayOfDecimal);
@@ -48,29 +40,10 @@
         arrayOfDecimal.addDecimal(new BigDecimal("111.38"));
         arrayOfDecimal.addDecimal(new BigDecimal("111.54"));
 
-        try {
-            OMElement omElement = getHistoricNavResponse.getOMElement(GetHistoricNavResponse.MY_QNAME,
-                    OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader =
-                    StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            GetHistoricNavResponse result = GetHistoricNavResponse.Factory.parse(xmlReader);
-            assertEquals(result.getOut().getDecimal()[0], null);
-            assertEquals(result.getOut().getDecimal()[1], null);
-            assertEquals(result.getOut().getDecimal()[2].toString(), "111.38");
-            assertEquals(result.getOut().getDecimal()[3].toString(), "111.38");
-            assertEquals(result.getOut().getDecimal()[4].toString(), "111.38");
-            assertEquals(result.getOut().getDecimal()[5].toString(), "111.54");
-        } catch (ADBException e) {
-            fail();
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(getHistoricNavResponse);
     }
 
+    // TODO: explain what this test has to do with "DecimalTest"???
     public void testDuration(){
         Calendar calendar = Calendar.getInstance();
         Duration duration = new Duration(false,0,0,23,12,24,23.45);

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/enumeration/EnumerationTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/enumeration/EnumerationTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/enumeration/EnumerationTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/enumeration/EnumerationTest.java Sat Jun 20 17:42:32 2009
@@ -19,35 +19,19 @@
 
 package org.apache.axis2.schema.enumeration;
 
-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 org.tempuri.CountPlacesInRect;
 import org.tempuri.PlaceType;
 
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
+public class EnumerationTest extends AbstractTestCase {
 
-
-public class EnumerationTest extends TestCase {
-
-    public void testEnumeration(){
+    public void testEnumeration() throws Exception {
 
         CountPlacesInRect countPlacesInRect = new CountPlacesInRect();
         countPlacesInRect.setLowerright("lowerright");
         countPlacesInRect.setUpperleft("upperleft");
         countPlacesInRect.setPtype(PlaceType.River);
 
-       try {
-            OMElement omElement = countPlacesInRect.getOMElement(CountPlacesInRect.MY_QNAME,OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            CountPlacesInRect newObject = CountPlacesInRect.Factory.parse(xmlReader);
-            assertEquals(countPlacesInRect.getPtype(),PlaceType.River);
-        } catch (Exception e) {
-            assertFalse(true);
-        }
+        testSerializeDeserialize(countPlacesInRect);
     }
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/ComplexExtenstionTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/ComplexExtenstionTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/ComplexExtenstionTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/ComplexExtenstionTest.java Sat Jun 20 17:42:32 2009
@@ -19,21 +19,14 @@
 
 package org.apache.axis2.schema.extension;
 
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.util.StAXUtils;
-import test.axis2.apache.org.BaseType;
+import org.apache.axis2.schema.AbstractTestCase;
+
 import test.axis2.apache.org.ExtendedComplexType;
-import test.axis2.apache.org.FullName;
 import test.axis2.apache.org.TestComplexElement;
 
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
-
-public class ComplexExtenstionTest extends TestCase {
+public class ComplexExtenstionTest extends AbstractTestCase {
 
-    public void testComplexExtension() {
+    public void testComplexExtension() throws Exception {
 
         TestComplexElement testComplexElement = new TestComplexElement();
         ExtendedComplexType extendedComplexType = new ExtendedComplexType();
@@ -44,35 +37,7 @@
         extendedComplexType.setParentElement1("test1");
         extendedComplexType.setParentElement2("test2");
 
-        try {
-            OMElement omElement = testComplexElement.getOMElement(TestComplexElement.MY_QNAME, OMAbstractFactory.getSOAP11Factory());
-            String omElementString;
-            XMLStreamReader xmlReader;
-            TestComplexElement result;
-
-            omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            result = TestComplexElement.Factory.parse(xmlReader);
-            assertEquals(result.getTestComplexElement().getFirst(),"Amila");
-            assertEquals(result.getTestComplexElement().getMiddle(),"Chinthaka");
-            assertEquals(result.getTestComplexElement().getLast(),"Suriarachchi");
-            assertEquals(result.getTestComplexElement().getParentElement1(),"test1");
-            assertEquals(result.getTestComplexElement().getParentElement2(),"test2");
-
-            omElementString = omElement.toString();
-            System.out.println("OM String ==> " + omElementString);
-            xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            result = TestComplexElement.Factory.parse(xmlReader);
-            assertEquals(result.getTestComplexElement().getFirst(),"Amila");
-            assertEquals(result.getTestComplexElement().getMiddle(),"Chinthaka");
-            assertEquals(result.getTestComplexElement().getLast(),"Suriarachchi");
-            assertEquals(result.getTestComplexElement().getParentElement1(),"test1");
-            assertEquals(result.getTestComplexElement().getParentElement2(),"test2");
-
-        } catch (Exception e) {
-            assertFalse(true);
-        }
+        testSerializeDeserialize(testComplexElement);
 
     }
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/SimpleExtensionTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/SimpleExtensionTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/SimpleExtensionTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/SimpleExtensionTest.java Sat Jun 20 17:42:32 2009
@@ -19,21 +19,16 @@
 
 package org.apache.axis2.schema.extension;
 
-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.types.Language;
+import org.apache.axis2.schema.AbstractTestCase;
+
 import test.axis2.apache.org.BaseType;
 import test.axis2.apache.org.FullName;
 import test.axis2.apache.org.SimpleType;
 
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
-
-public class SimpleExtensionTest extends TestCase {
+public class SimpleExtensionTest extends AbstractTestCase {
 
-    public void testSimpleTypeComplexExtension() {
+    public void testSimpleTypeComplexExtension() throws Exception {
         FullName fullName = new FullName();
         fullName.setFirst("amila");
         fullName.setMiddle("chinthaka");
@@ -43,36 +38,7 @@
 
         fullName.setAttribute2(SimpleType.Factory.fromString("ATTRIBUTE", ""));
 
-        try {
-            OMElement omElement = fullName.getOMElement(FullName.MY_QNAME, OMAbstractFactory.getSOAP11Factory());
-            String omElementString;
-            XMLStreamReader xmlReader;
-            FullName newFullName;
-
-            omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            newFullName = FullName.Factory.parse(xmlReader);
-            assertEquals(newFullName.getFirst(), "amila");
-            assertEquals(newFullName.getMiddle(), "chinthaka");
-            assertEquals(newFullName.getLast(), "suriarachchi");
-            assertEquals(newFullName.getLanguage().toString(), "singhala");
-            assertEquals(newFullName.getAttribute1().toString(), BaseType._s1);
-            assertEquals(newFullName.getAttribute2().toString(), "ATTRIBUTE");
-
-            omElementString = omElement.toString();
-            System.out.println("OM String ==> " + omElementString);
-            xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            newFullName = FullName.Factory.parse(xmlReader);
-            assertEquals(newFullName.getFirst(), "amila");
-            assertEquals(newFullName.getMiddle(), "chinthaka");
-            assertEquals(newFullName.getLast(), "suriarachchi");
-            assertEquals(newFullName.getLanguage().toString(), "singhala");
-            assertEquals(newFullName.getAttribute1().toString(), BaseType._s1);
-            assertEquals(newFullName.getAttribute2().toString(), "ATTRIBUTE");
-        } catch (Exception e) {
-            assertFalse(true);
-        }
+        testSerializeDeserialize(fullName);
     }
 
 

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/group/GroupTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/group/GroupTest.java?rev=786866&r1=786865&r2=786866&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/group/GroupTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/group/GroupTest.java Sat Jun 20 17:42:32 2009
@@ -20,21 +20,11 @@
 package org.apache.axis2.schema.group;
 
 import group.test.axis2.apache.org.*;
-import group.test.axis2.apache.org.TestAttributeGroupElement;
-import group.test.axis2.apache.org.TestNestedAttributeGroupElement;
-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 GroupTest extends AbstractTestCase {
 
-
-public class GroupTest extends TestCase {
-
-    public void testSequenceGroupElement(){
+    public void testSequenceGroupElement() throws Exception {
 
         TestSequenceGroupElement testGroupSequenceElement = new TestSequenceGroupElement();
         testGroupSequenceElement.setParam1("param1");
@@ -43,25 +33,10 @@
         testSequenceGroup.setSequenceParam2("sequenceParam2");
         testGroupSequenceElement.setTestSequenceGroup(testSequenceGroup);
 
-        try {
-            OMElement omElement =
-                    testGroupSequenceElement.getOMElement(TestSequenceGroupElement.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader =
-                    StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestSequenceGroupElement result = TestSequenceGroupElement.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(),"param1");
-            assertEquals(result.getTestSequenceGroup().getSequenceParam1(),"sequenceParam1");
-            assertEquals(result.getTestSequenceGroup().getSequenceParam2(),"sequenceParam2");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testGroupSequenceElement);
     }
 
-    public void testNestedSequenceGroupElement(){
+    public void testNestedSequenceGroupElement() throws Exception {
 
         TestSequenceNestedGroupElement testSequenceNestedGroupElement = new TestSequenceNestedGroupElement();
         testSequenceNestedGroupElement.setParam1("param1");
@@ -77,27 +52,10 @@
 
         testSequenceNestedGroupElement.setTestSequenceNestedGroup(testSequenceNestedGroup);
 
-       try {
-           OMElement omElement =
-                    testSequenceNestedGroupElement.getOMElement(TestSequenceNestedGroupElement.MY_QNAME, OMAbstractFactory.getOMFactory());
-
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader =
-                    StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestSequenceNestedGroupElement result = TestSequenceNestedGroupElement.Factory.parse(xmlReader);
-            assertEquals(result.getParam1(),"param1");
-            assertEquals(result.getTestSequenceNestedGroup().getNestedSequenceParam1(),"nestedSequenceParam1");
-            assertEquals(result.getTestSequenceNestedGroup().getTestSequenceGroup().getSequenceParam1(),"sequenceParam1");
-            assertEquals(result.getTestSequenceNestedGroup().getTestSequenceGroup().getSequenceParam2(),"sequenceParam2");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        testSerializeDeserialize(testSequenceNestedGroupElement);
     }
 
-    public void testChoiceGroupElement(){
+    public void testChoiceGroupElement() throws Exception {
 
         TestChoiceGroupElement testGroupChoiceElement = new TestChoiceGroupElement();
         testGroupChoiceElement.setParam1("param1");
@@ -105,23 +63,11 @@
         testChoiceGroup.setChoiceParam1("choiceParam1");
         testGroupChoiceElement.setTestChoiceGroup(testChoiceGroup);
 
-       try {
-           OMElement omElement =
-                   testGroupChoiceElement.getOMElement(TestChoiceGroupElement.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader =
-                    StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestChoiceGroupElement result = TestChoiceGroupElement.Factory.parse(xmlReader);
-            assertEquals(result.getTestChoiceGroup().getChoiceParam1(),"choiceParam1");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        TestChoiceGroupElement result = (TestChoiceGroupElement)serializeDeserialize(testGroupChoiceElement);
+        assertEquals(result.getTestChoiceGroup().getChoiceParam1(),"choiceParam1");
     }
 
-    public void testNestedChoiceGroupElement(){
+    public void testNestedChoiceGroupElement() throws Exception {
 
         TestChoiceNestedGroupElement testChoiceNestedGroupElement = new TestChoiceNestedGroupElement();
         testChoiceNestedGroupElement.setParam1("param1");
@@ -136,66 +82,25 @@
 
         testChoiceNestedGroupElement.setTestChoiceNestedGroup(testChoiceNestedGroup);
 
-       try {
-           OMElement omElement =
-                   testChoiceNestedGroupElement.getOMElement(testChoiceNestedGroupElement.MY_QNAME, OMAbstractFactory.getOMFactory());
-            String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM String ==> " + omElementString);
-            XMLStreamReader xmlReader =
-                    StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            TestChoiceNestedGroupElement result = TestChoiceNestedGroupElement.Factory.parse(xmlReader);
-            assertEquals(result.getTestChoiceNestedGroup().getTestChoiceGroup().getChoiceParam1(),"choiceParam1");
-        } catch (XMLStreamException e) {
-            fail();
-        } catch (Exception e) {
-            fail();
-        }
+        TestChoiceNestedGroupElement result = (TestChoiceNestedGroupElement)serializeDeserialize(testChoiceNestedGroupElement);
+        assertEquals(result.getTestChoiceNestedGroup().getTestChoiceGroup().getChoiceParam1(),"choiceParam1");
     }
 
-     public void testAttributeGroup(){
+     public void testAttributeGroup() throws Exception {
          TestAttributeGroupElement testAttributeGroup = new TestAttributeGroupElement();
          testAttributeGroup.setAttribute1("Attribute1");
          testAttributeGroup.setParam1("Param1");
 
-         try {
-             OMElement omElement =
-                       testAttributeGroup.getOMElement(TestAttributeGroupElement.MY_QNAME,OMAbstractFactory.getOMFactory());
-             String omElementString = omElement.toStringWithConsume();
-             System.out.println("OM Element ==> " + omElementString);
-             XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-             TestAttributeGroupElement result = TestAttributeGroupElement.Factory.parse(xmlReader);
-             assertEquals(result.getParam1(),"Param1");
-             assertEquals(result.getAttribute1(),"Attribute1");
-         } catch (XMLStreamException e) {
-             fail();
-         } catch (Exception e) {
-             fail();
-         }
-
+         testSerializeDeserialize(testAttributeGroup);
      }
 
-    public void testNestedAttributeGroup(){
+    public void testNestedAttributeGroup() throws Exception {
          TestNestedAttributeGroupElement testNestedAttributeGroupElement = new TestNestedAttributeGroupElement();
          testNestedAttributeGroupElement.setAttribute1("Attribute1");
          testNestedAttributeGroupElement.setAttribute2("Attribute2");
          testNestedAttributeGroupElement.setParam1("Param1");
 
-        try {
-            OMElement omElement =
-                    testNestedAttributeGroupElement.getOMElement(TestNestedAttributeGroupElement.MY_QNAME,OMAbstractFactory.getOMFactory());
-             String omElementString = omElement.toStringWithConsume();
-             System.out.println("OM Element ==> " + omElementString);
-             XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-             TestNestedAttributeGroupElement result = TestNestedAttributeGroupElement.Factory.parse(xmlReader);
-             assertEquals(result.getParam1(),"Param1");
-             assertEquals(result.getAttribute1(),"Attribute1");
-             assertEquals(result.getAttribute2(),"Attribute2");
-         } catch (XMLStreamException e) {
-             fail();
-         } catch (Exception e) {
-             fail();
-         }
-
+         testSerializeDeserialize(testNestedAttributeGroupElement);
      }
 
 



Mime
View raw message