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 2014/07/19 19:01:40 UTC

svn commit: r1611920 - in /webservices/axiom/trunk: implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/ testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/

Author: veithen
Date: Sat Jul 19 17:01:40 2014
New Revision: 1611920

URL: http://svn.apache.org/r1611920
Log:
Fixed an issue with the splitText implementation.

Added:
    webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitTextWithoutParent.java   (with props)
Modified:
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
    webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java?rev=1611920&r1=1611919&r2=1611920&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java Sat Jul 19 17:01:40 2014
@@ -192,11 +192,9 @@ public abstract class TextNodeImpl exten
 
         ParentNode parentNode = (ParentNode)coreGetParent();
         if (parentNode != null) {
-            newText.coreSetParent(parentNode);
+            this.insertSiblingAfter(newText);
         }
 
-        this.insertSiblingAfter(newText);
-
         return newText;
     }
 

Modified: webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java?rev=1611920&r1=1611919&r2=1611920&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java Sat Jul 19 17:01:40 2014
@@ -192,6 +192,7 @@ public final class DOMTestSuiteBuilder e
         addTest(new org.apache.axiom.ts.dom.text.TestLookupNamespaceURIWithoutParent(dbf));
         addTest(new org.apache.axiom.ts.dom.text.TestSetPrefix(dbf));
         addTest(new org.apache.axiom.ts.dom.text.TestSplitText(dbf));
+        addTest(new org.apache.axiom.ts.dom.text.TestSplitTextWithoutParent(dbf));
         
         DOMTestDocumentBuilderFactory factory;
         try {

Added: webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitTextWithoutParent.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitTextWithoutParent.java?rev=1611920&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitTextWithoutParent.java (added)
+++ webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitTextWithoutParent.java Sat Jul 19 17:01:40 2014
@@ -0,0 +1,47 @@
+/*
+ * 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.dom.text;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Text;
+
+/**
+ * Tests the behavior of {@link Text#splitText(int)} when the node has no parent.
+ */
+public class TestSplitTextWithoutParent extends DOMTestCase {
+    public TestSplitTextWithoutParent(DocumentBuilderFactory dbf) {
+        super(dbf);
+    }
+
+    @Override
+    protected void runTest() throws Throwable {
+        Document document = dbf.newDocumentBuilder().newDocument();
+        Text text = document.createTextNode("ABCD");
+        Text newText = text.splitText(2);
+        assertThat(text.getData(), is(equalTo("AB")));
+        assertThat(newText.getData(), is(equalTo("CD")));
+    }
+}

Propchange: webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/text/TestSplitTextWithoutParent.java
------------------------------------------------------------------------------
    svn:eol-style = native