You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ve...@apache.org on 2009/06/21 11:45:34 UTC
svn commit: r786971 - in /webservices/axis2/trunk/java/modules:
adb-codegen/test/org/apache/axis2/schema/AbstractTestCase.java parent/pom.xml
Author: veithen
Date: Sun Jun 21 09:45:33 2009
New Revision: 786971
URL: http://svn.apache.org/viewvc?rev=786971&view=rev
Log:
* Modified the ADB test cases such that serialization/deserialization is tested using several approaches, in particular by taking the XMLStreamReader from an Axiom tree with caching (i.e. using StAXOMWrapper). This increases the test coverage.
* Changed the Axiom dependency to 1.2.9-SNAPSHOT since this fails with 1.2.8.
Modified:
webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/AbstractTestCase.java
webservices/axis2/trunk/java/modules/parent/pom.xml
Modified: 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=786971&r1=786970&r2=786971&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/AbstractTestCase.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/AbstractTestCase.java Sun Jun 21 09:45:33 2009
@@ -26,6 +26,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.StringReader;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.math.BigDecimal;
@@ -41,6 +42,7 @@
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axis2.databinding.ADBBean;
import org.apache.axis2.databinding.ADBException;
@@ -180,13 +182,33 @@
/**
* Serialize a bean to XML, then deserialize the XML and compare the resulting bean to
- * the original.
+ * the original. This will actually do the serialization and deserialization several times
+ * using different approaches in order to increase the test coverage.
*
* @param bean the bean to serialize
* @throws Exception
*/
public static void testSerializeDeserialize(ADBBean bean) throws Exception {
- assertBeanEquals(bean, serializeDeserialize(bean));
+ Class<? extends ADBBean> beanClass = bean.getClass();
+ QName qname = getADBBeanQName(beanClass);
+
+ OMElement omElement = bean.getOMElement(qname, OMAbstractFactory.getOMFactory());
+ String omElementString = omElement.toStringWithConsume();
+
+ // Deserialization approach 1: use an XMLStreamReader produced by the StAX parser.
+ assertBeanEquals(bean, parse(beanClass,
+ StAXUtils.createXMLStreamReader(new StringReader(omElementString))));
+
+ // Deserialization approach 2: use an Axiom tree with caching. In this case the
+ // XMLStreamReader implementation is OMStAXWrapper and we test interoperability
+ // between ADB and Axiom's OMStAXWrapper.
+ OMElement omElement2 = new StAXOMBuilder(StAXUtils.createXMLStreamReader(
+ new StringReader(omElementString))).getDocumentElement();
+ assertBeanEquals(bean, parse(beanClass, omElement2.getXMLStreamReader()));
+
+ // Deserialization approach 3: use the pull parser produced by ADB.
+ // TODO: this badly fails for many of the test cases => there are still issues to solve!!!
+// assertBeanEquals(bean, parse(beanClass, bean.getPullParser(qname)));
}
/**
Modified: webservices/axis2/trunk/java/modules/parent/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/parent/pom.xml?rev=786971&r1=786970&r2=786971&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/parent/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/parent/pom.xml Sun Jun 21 09:45:33 2009
@@ -84,7 +84,7 @@
<ant.version>1.7.0</ant.version>
<antlr.version>2.7.7</antlr.version>
- <axiom.version>1.2.8</axiom.version>
+ <axiom.version>1.2.9-SNAPSHOT</axiom.version>
<bcel.version>5.2</bcel.version>
<bsf.version>2.4.0</bsf.version>
<commons.codec.version>1.3</commons.codec.version>