axis-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1029034 - in /axis/axis2/java/core/trunk/modules/saaj: src/org/apache/axis2/saaj/SOAPElementImpl.java src/org/apache/axis2/saaj/TextImplEx.java test/org/apache/axis2/saaj/SOAPElementTest.java
Date Sat, 30 Oct 2010 11:53:39 GMT
Author: veithen
Date: Sat Oct 30 11:53:39 2010
New Revision: 1029034

URL: http://svn.apache.org/viewvc?rev=1029034&view=rev
Log:
AXIS2-4868: Fixed a couple of issues in SOAPElementImpl related to text nodes.

Modified:
    axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
    axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/TextImplEx.java
    axis/axis2/java/core/trunk/modules/saaj/test/org/apache/axis2/saaj/SOAPElementTest.java

Modified: axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java?rev=1029034&r1=1029033&r2=1029034&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
(original)
+++ axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
Sat Oct 30 11:53:39 2010
@@ -237,7 +237,7 @@ public class SOAPElementImpl extends Nod
         //TODO: May need to address the situation where the prev sibling of the textnode
itself is a textnode
         Text textNode = getOwnerDocument().createTextNode(text);
         NodeImpl node = ((NodeImpl)element.appendChild(textNode));
-        TextImplEx saajTextNode = new TextImplEx(text, this);
+        TextImplEx saajTextNode = new TextImplEx((TextImpl)textNode, this);
         node.setUserData(SAAJ_NODE, saajTextNode, null);
         return this;
     }
@@ -867,7 +867,7 @@ public class SOAPElementImpl extends Nod
         if (oldChild instanceof SOAPElementImpl) {
             oldChild = ((SOAPElementImpl)oldChild).getElement();
         } else if (oldChild instanceof TextImplEx) {
-            // TODO: handle text nodes somehow
+            oldChild = ((TextImplEx)oldChild).getTextNode();
         }
         return element.removeChild(oldChild);
     }

Modified: axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/TextImplEx.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/TextImplEx.java?rev=1029034&r1=1029033&r2=1029034&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/TextImplEx.java (original)
+++ axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/TextImplEx.java Sat
Oct 30 11:53:39 2010
@@ -44,6 +44,12 @@ public class TextImplEx extends NodeImpl
         this.parentElement = parent;
     }
 
+    public TextImplEx(TextImpl textNode, SOAPElement parent) {
+        super(((SOAPElementImpl)parent).getOMFactory());
+        this.textNode = textNode;
+        this.parentElement = parent;
+    }
+
     public TextImplEx(String data, SOAPElement parent,
                       org.w3c.dom.Node prevSibling, org.w3c.dom.Node nextSibling) {
         super(((SOAPElementImpl)parent).getOMFactory());
@@ -53,6 +59,10 @@ public class TextImplEx extends NodeImpl
         this.nextSibling = nextSibling;
     }
 
+    TextImpl getTextNode() {
+        return textNode;
+    }
+    
     public void setNextSibling(org.w3c.dom.Node nextSibling) {
         this.nextSibling = nextSibling;
     }

Modified: axis/axis2/java/core/trunk/modules/saaj/test/org/apache/axis2/saaj/SOAPElementTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/saaj/test/org/apache/axis2/saaj/SOAPElementTest.java?rev=1029034&r1=1029033&r2=1029034&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/saaj/test/org/apache/axis2/saaj/SOAPElementTest.java
(original)
+++ axis/axis2/java/core/trunk/modules/saaj/test/org/apache/axis2/saaj/SOAPElementTest.java
Sat Oct 30 11:53:39 2010
@@ -31,6 +31,7 @@ import javax.xml.soap.MessageFactory;
 import javax.xml.soap.Name;
 import javax.xml.soap.Node;
 import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
 import javax.xml.soap.SOAPConstants;
 import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPEnvelope;
@@ -781,4 +782,14 @@ public class SOAPElementTest extends Ass
         
         assertFalse(soapBody.getChildElements().hasNext());
     }
+    
+    @Validated @Test
+    public void testAddRemoveTextNode() throws Exception {
+        MessageFactory mf = MessageFactory.newInstance();
+        SOAPMessage msg = mf.createMessage();
+        SOAPBody body = msg.getSOAPBody();
+        SOAPBodyElement bodyChild = body.addBodyElement(new QName("TestChild"));
+        bodyChild.addTextNode("aaaaa");
+        bodyChild.removeChild(bodyChild.getFirstChild());
+    }
 }



Mime
View raw message