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 2011/07/25 23:27:03 UTC

svn commit: r1150920 - in /webservices/commons/trunk/modules/axiom/modules: axiom-tests/src/test/java/org/apache/axiom/om/ axiom-testsuite/src/main/java/org/apache/axiom/ts/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/

Author: veithen
Date: Mon Jul 25 21:27:02 2011
New Revision: 1150920

URL: http://svn.apache.org/viewvc?rev=1150920&view=rev
Log:
AXIOM-311: Refactored another test case.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestDetachFirstChild.java   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMTest.java?rev=1150920&r1=1150919&r2=1150920&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMTest.java Mon Jul 25 21:27:02 2011
@@ -87,22 +87,6 @@ public class OMTest extends AbstractTest
         assertFalse("Root should not be complete", envelope.isComplete());
     }
 
-    /**
-     * Assumption - The fed XML has at least two children under the root element
-     *
-     * @throws Exception
-     */
-    public void testFirstChildDetach() throws Exception {
-        OMElement root = envelope;
-        assertFalse("Root should not be complete", root.isComplete());
-        OMNode oldFirstChild = root.getFirstOMChild();
-        assertNotNull(oldFirstChild);
-        oldFirstChild.detach();
-        OMNode newFirstChild = root.getFirstOMChild();
-        assertNotNull(newFirstChild);
-        assertNotSame(oldFirstChild, newFirstChild);
-    }
-
     //todo this is wrong correct this
     public void testAdditionOfaCompletelyNewElement() throws Exception {
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java?rev=1150920&r1=1150919&r2=1150920&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java Mon Jul 25 21:27:02 2011
@@ -190,6 +190,8 @@ public class OMTestSuiteBuilder extends 
         addTest(new org.apache.axiom.ts.om.namespace.TestObjectEqualsWithDifferentURIs(metaFactory));
         addTest(new org.apache.axiom.ts.om.node.TestDetach(metaFactory, true));
         addTest(new org.apache.axiom.ts.om.node.TestDetach(metaFactory, false));
+        addTest(new org.apache.axiom.ts.om.node.TestDetachFirstChild(metaFactory, true));
+        addTest(new org.apache.axiom.ts.om.node.TestDetachFirstChild(metaFactory, false));
         addTest(new org.apache.axiom.ts.om.node.TestInsertSiblingAfter(metaFactory));
         addTest(new org.apache.axiom.ts.om.node.TestInsertSiblingAfterLastChild(metaFactory));
         addTest(new org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild(metaFactory));

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestDetachFirstChild.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestDetachFirstChild.java?rev=1150920&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestDetachFirstChild.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/node/TestDetachFirstChild.java Mon Jul 25 21:27:02 2011
@@ -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.om.node;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axiom.ts.AxiomTestCase;
+
+/**
+ * Tests the behavior of {@link OMNode#detach()}.
+ */
+public class TestDetachFirstChild extends AxiomTestCase {
+    private final boolean build;
+    
+    public TestDetachFirstChild(OMMetaFactory metaFactory, boolean build) {
+        super(metaFactory);
+        this.build = build;
+        addTestProperty("build", Boolean.toString(build));
+    }
+
+    protected void runTest() throws Throwable {
+        OMElement root = AXIOMUtil.stringToOM(metaFactory.getOMFactory(), "<root><a/><b/></root>");
+        if (build) {
+            root.build();
+        } else {
+            assertFalse(root.isComplete());
+        }
+        OMNode oldFirstChild = root.getFirstOMChild();
+        assertNotNull(oldFirstChild);
+        oldFirstChild.detach();
+        OMNode newFirstChild = root.getFirstOMChild();
+        assertNotNull(newFirstChild);
+        assertNotSame(oldFirstChild, newFirstChild);
+    }
+}

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