You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2012/05/13 14:43:33 UTC

svn commit: r1337858 - in /webservices/commons/trunk/modules/axiom/modules: axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/ axiom-tests/src/test/java/org/apache/axiom/om/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/ axiom-testsuite/src/m...

Author: veithen
Date: Sun May 13 12:43:32 2012
New Revision: 1337858

URL: http://svn.apache.org/viewvc?rev=1337858&view=rev
Log:
Refactored OMElementCloneTest. This also reveals some issues in DOOM.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestCloneOMElement.java
      - copied, changed from r1337853, webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementCloneTest.java
Removed:
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementCloneTest.java
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1337858&r1=1337857&r2=1337858&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java Sun May 13 12:43:32 2012
@@ -26,6 +26,7 @@ import org.apache.axiom.ts.om.OMTestSuit
 import org.apache.axiom.ts.om.builder.TestCreateOMBuilderFromDOMSource;
 import org.apache.axiom.ts.om.container.TestSerialize;
 import org.apache.axiom.ts.om.document.TestDigest;
+import org.apache.axiom.ts.om.element.TestCloneOMElement;
 import org.apache.axiom.ts.om.element.TestGetChildrenWithName4;
 import org.apache.axiom.ts.om.factory.TestCreateOMElementWithGeneratedPrefix;
 import org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope1;
@@ -64,6 +65,9 @@ public class OMImplementationTest extend
         // TODO: if there is a comment node surrounded by text, then these text nodes need to be merged
         builder.exclude(TestDigest.class, "(|(file=digest3.xml)(file=digest4.xml))");
         
+        // TODO: there seems to be an issue in the builder
+        builder.exclude(TestCloneOMElement.class);
+        
         return builder.build();
     }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1337858&r1=1337857&r2=1337858&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java Sun May 13 12:43:32 2012
@@ -133,6 +133,7 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.element.TestAddChildWithSameParent(metaFactory, false));
         addTest(new org.apache.axiom.ts.om.element.TestChildReDeclaringGrandParentsDefaultNSWithPrefix(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestChildReDeclaringParentsDefaultNSWithPrefix(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestCloneOMElement(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestDeclareDefaultNamespace1(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestDeclareDefaultNamespace2(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestDeclareDefaultNamespaceConflict1(metaFactory));

Copied: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestCloneOMElement.java (from r1337853, webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementCloneTest.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestCloneOMElement.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestCloneOMElement.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementCloneTest.java&r1=1337853&r2=1337858&rev=1337858&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMElementCloneTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestCloneOMElement.java Sun May 13 12:43:32 2012
@@ -16,56 +16,38 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.axiom.ts.om.element;
 
-package org.apache.axiom.om;
-
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.TestConstants;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.custommonkey.xmlunit.XMLAssert;
 
-public class OMElementCloneTest extends AbstractTestCase {
-
-    public void testElementCloningWithoutUsingOMElementMethod() throws Exception {
-        SOAPEnvelope soapEnvelope = OMXMLBuilderFactory.createSOAPModelBuilder(getTestResource(
-                TestConstants.SOAP_SOAPMESSAGE), null).getSOAPEnvelope();
-        SOAPBody body = soapEnvelope.getBody();
-
-        OMElement firstClonedBodyElement =
-                OMXMLBuilderFactory.createStAXOMBuilder(body.getXMLStreamReader()).getDocumentElement();
-        OMElement secondClonedBodyElement =
-                OMXMLBuilderFactory.createStAXOMBuilder(body.getXMLStreamReader()).getDocumentElement();
-
-        // first check whether both have the same information
-        String firstClonedBodyElementText = firstClonedBodyElement.toString();
-        String secondClonedBodyElementText = secondClonedBodyElement.toString();
-        String bodyText = body.toString();
-        assertXMLEqual(bodyText, firstClonedBodyElementText);
-        assertXMLEqual(bodyText, secondClonedBodyElementText);
-        assertXMLEqual(firstClonedBodyElementText,
-                       secondClonedBodyElementText);
-
-        // lets check some links. They must not be equal
-        assertNotSame(body.getParent(), firstClonedBodyElement.getParent());
-        assertNotSame(body.getParent(), secondClonedBodyElement.getParent());
-        assertNotSame(firstClonedBodyElement.getParent(), secondClonedBodyElement.getParent());
-
-        soapEnvelope.close(false);
+public class TestCloneOMElement extends AxiomTestCase {
+    public TestCloneOMElement(OMMetaFactory metaFactory) {
+        super(metaFactory);
     }
 
-    public void testElementCloningUsingOMElementMethod() throws Exception {
-        SOAPEnvelope soapEnvelope = OMXMLBuilderFactory.createSOAPModelBuilder(getTestResource(
-                TestConstants.SOAP_SOAPMESSAGE), null).getSOAPEnvelope();
+    protected void runTest() throws Throwable {
+        SOAPEnvelope soapEnvelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory,
+                AbstractTestCase.getTestResource(TestConstants.SOAP_SOAPMESSAGE), null).getSOAPEnvelope();
         SOAPBody body = soapEnvelope.getBody();
 
         OMElement firstClonedBodyElement = body.cloneOMElement();
         OMElement secondClonedBodyElement = body.cloneOMElement();
 
         // first check whether both have the same information
-        assertXMLEqual(body.toString(),
-                       firstClonedBodyElement.toString());
-        assertXMLEqual(body.toString(),
-                       secondClonedBodyElement.toString());
-        assertXMLEqual(firstClonedBodyElement.toString(),
-                       secondClonedBodyElement.toString());
+        XMLAssert.assertXMLEqual(body.toString(),
+                                 firstClonedBodyElement.toString());
+        XMLAssert.assertXMLEqual(body.toString(),
+                                 secondClonedBodyElement.toString());
+        XMLAssert.assertXMLEqual(firstClonedBodyElement.toString(),
+                                 secondClonedBodyElement.toString());
 
         // lets check some links. They must not be equal
         assertNotSame(body.getParent(), firstClonedBodyElement.getParent());