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/07/07 12:17:03 UTC

svn commit: r1358534 - in /webservices/commons/trunk/modules/axiom/modules: axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/ axiom-...

Author: veithen
Date: Sat Jul  7 10:17:03 2012
New Revision: 1358534

URL: http://svn.apache.org/viewvc?rev=1358534&view=rev
Log:
Increased test coverage for OMNode#discard() and fixed an issue in DOOM.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscardIncomplete.java
      - copied, changed from r1358519, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscard.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscardPartiallyBuilt.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/header/TestDiscardIncomplete.java
      - copied, changed from r1358519, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestDiscardHeader.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/header/TestDiscardPartiallyBuilt.java   (with props)
Removed:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscard.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestDiscardHeader.java
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?rev=1358534&r1=1358533&r2=1358534&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java Sat Jul  7 10:17:03 2012
@@ -148,11 +148,11 @@ public abstract class ParentNode extends
         return (OMNode)lastChild;
     }
 
-    public void setFirstChild(OMNode omNode) {
+    public void setFirstChild(OMNode firstChild) {
         if (firstChild != null) {
-            ((OMNodeEx) omNode).setParent((OMContainer)this);
+            ((OMNodeEx) firstChild).setParent((OMContainer)this);
         }
-        this.firstChild = (NodeImpl) omNode;
+        this.firstChild = (NodeImpl) firstChild;
     }
 
     /**

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=1358534&r1=1358533&r2=1358534&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 Sat Jul  7 10:17:03 2012
@@ -152,7 +152,8 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.element.TestDeclareNamespaceWithGeneratedPrefix3(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestDigestWithNamespace(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestDigestWithoutNamespace(metaFactory));
-        addTest(new org.apache.axiom.ts.om.element.TestDiscard(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestDiscardIncomplete(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestDiscardPartiallyBuilt(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestFindNamespaceByNamespaceURIMasked(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestFindNamespaceByPrefix(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestFindNamespaceCaseSensitivity(metaFactory));

Copied: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscardIncomplete.java (from r1358519, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscard.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscardIncomplete.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscardIncomplete.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscard.java&r1=1358519&r2=1358534&rev=1358534&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscard.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscardIncomplete.java Sat Jul  7 10:17:03 2012
@@ -29,8 +29,8 @@ import org.apache.axiom.ts.AxiomTestCase
 /**
  *Test the discard method
  */
-public class TestDiscard extends AxiomTestCase {
-    public TestDiscard(OMMetaFactory metaFactory) {
+public class TestDiscardIncomplete extends AxiomTestCase {
+    public TestDiscardIncomplete(OMMetaFactory metaFactory) {
         super(metaFactory);
     }
 

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscardPartiallyBuilt.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscardPartiallyBuilt.java?rev=1358534&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscardPartiallyBuilt.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscardPartiallyBuilt.java Sat Jul  7 10:17:03 2012
@@ -0,0 +1,56 @@
+/*
+ * 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.axiom.ts.om.element;
+
+import java.io.StringReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.custommonkey.xmlunit.XMLAssert;
+
+/**
+ * Tests the behavior of {@link OMNode#discard()} on an element that is partially built, more
+ * precisely in a situation where the builder is building a descendant that is not an immediate
+ * child of the element.
+ */
+public class TestDiscardPartiallyBuilt extends AxiomTestCase {
+    public TestDiscardPartiallyBuilt(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMElement root = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader(
+                "<root><element><a><b>text</b></a><c/></element><sibling/></root>")).getDocumentElement();;
+        OMElement element = root.getFirstElement();
+        
+        // Navigate to the text node so that the element is partially built
+        OMElement b = element.getFirstElement().getFirstElement();
+        OMText text = (OMText)b.getFirstOMChild();
+        assertEquals("text", text.getText());
+        
+        element.discard();
+        XMLAssert.assertXMLEqual("<root><sibling/></root>", root.toString());
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestDiscardPartiallyBuilt.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java?rev=1358534&r1=1358533&r2=1358534&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java Sat Jul  7 10:17:03 2012
@@ -34,6 +34,7 @@ import org.xml.sax.InputSource;
 public abstract class SOAPTestCase extends AxiomTestCase {
     protected static final String MESSAGE = "message.xml";
     protected static final String MESSAGE_WITHOUT_HEADER = "message_without_header.xml";
+    protected static final String SOAP_MESSAGE = "soapmessage.xml";
     
     protected final SOAPSpec spec;
     protected SOAPFactory soapFactory;

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1358534&r1=1358533&r2=1358534&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Sat Jul  7 10:17:03 2012
@@ -109,7 +109,6 @@ public class SOAPTestSuiteBuilder extend
             addTest(new org.apache.axiom.ts.soap.envelope.TestCloneOMElementWithSourcedElement2(metaFactory, spec));
         }
         addTest(new org.apache.axiom.ts.soap.envelope.TestDetach(metaFactory, spec));
-        addTest(new org.apache.axiom.ts.soap.envelope.TestDiscardHeader(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.envelope.TestGetBody(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.envelope.TestGetBodyOnEmptyEnvelope(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.envelope.TestGetBodyOnEnvelopeWithHeaderOnly(metaFactory, spec));
@@ -163,6 +162,8 @@ public class SOAPTestSuiteBuilder extend
         addTest(new org.apache.axiom.ts.soap.header.TestAddHeaderBlock(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.header.TestAddHeaderBlockWithoutNamespace1(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.header.TestAddHeaderBlockWithoutNamespace2(metaFactory, spec));
+        addTest(new org.apache.axiom.ts.soap.header.TestDiscardIncomplete(metaFactory, spec));
+        addTest(new org.apache.axiom.ts.soap.header.TestDiscardPartiallyBuilt(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.header.TestExamineAllHeaderBlocks(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.header.TestExamineAllHeaderBlocksWithParser(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.header.TestExamineHeaderBlocks(metaFactory, spec));

Copied: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/header/TestDiscardIncomplete.java (from r1358519, webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestDiscardHeader.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/header/TestDiscardIncomplete.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/header/TestDiscardIncomplete.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestDiscardHeader.java&r1=1358519&r2=1358534&rev=1358534&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestDiscardHeader.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/header/TestDiscardIncomplete.java Sat Jul  7 10:17:03 2012
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.axiom.ts.soap.envelope;
+package org.apache.axiom.ts.soap.header;
 
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.soap.SOAPEnvelope;
@@ -24,8 +24,8 @@ import org.apache.axiom.ts.soap.SOAPSpec
 import org.apache.axiom.ts.soap.SOAPTestCase;
 
 // Regression test for AXIOM-223 (see r567512)
-public class TestDiscardHeader extends SOAPTestCase {
-    public TestDiscardHeader(OMMetaFactory metaFactory, SOAPSpec spec) {
+public class TestDiscardIncomplete extends SOAPTestCase {
+    public TestDiscardIncomplete(OMMetaFactory metaFactory, SOAPSpec spec) {
         super(metaFactory, spec);
     }
 

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/header/TestDiscardPartiallyBuilt.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/header/TestDiscardPartiallyBuilt.java?rev=1358534&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/header/TestDiscardPartiallyBuilt.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/header/TestDiscardPartiallyBuilt.java Sat Jul  7 10:17:03 2012
@@ -0,0 +1,53 @@
+/*
+ * 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.axiom.ts.soap.header;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+/**
+ * Tests the behavior of {@link OMNode#discard()} on a {@link SOAPHeader} that is partially built,
+ * more precisely in a situation where the builder is building a descendant that is not an immediate
+ * child of the header.
+ */
+public class TestDiscardPartiallyBuilt extends SOAPTestCase {
+    public TestDiscardPartiallyBuilt(OMMetaFactory metaFactory, SOAPSpec spec) {
+        super(metaFactory, spec);
+    }
+
+    protected void runTest() throws Throwable {
+        SOAPEnvelope envelope = getTestMessage(SOAP_MESSAGE);
+        SOAPHeader header = envelope.getHeader();
+        OMElement from = header.getFirstChildWithName(new QName("http://schemas.xmlsoap.org/ws/2004/03/addressing", "From"));
+        from.getFirstElement().getFirstOMChild();
+        assertFalse(from.isComplete()); // Just in case getFirstChildWithName or getFirstElement did stupid things
+        
+        header.discard();
+        OMElement body = envelope.getFirstElement();
+        assertTrue(body instanceof SOAPBody);
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/header/TestDiscardPartiallyBuilt.java
------------------------------------------------------------------------------
    svn:eol-style = native