axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ven...@apache.org
Subject cvs commit: ws-axis/java/test/message TestSOAPBody.java
Date Thu, 09 Jun 2005 16:36:27 GMT
venkat      2005/06/09 09:36:27

  Modified:    java/src/org/apache/axis/message MessageElement.java
                        NodeImpl.java
               java/test/message TestSOAPBody.java
  Log:
  Fix for AXIS-1960:
  - Added a new test case for TestSOAPBody.java to test for this bug.
  - added a call to setDirty(true) inside a few methods in NodeImpl
  - added setDirty(false) in getAsString() to fix ant all-tests errors.
  
  Revision  Changes    Path
  1.198     +1 -0      ws-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.197
  retrieving revision 1.198
  diff -u -r1.197 -r1.198
  --- MessageElement.java	25 Apr 2005 14:44:06 -0000	1.197
  +++ MessageElement.java	9 Jun 2005 16:36:27 -0000	1.198
  @@ -1107,6 +1107,7 @@
           }
           serializeContext = new SerializationContext(writer, msgContext);
           serializeContext.setSendDecl(false);
  +        setDirty(false);
           output(serializeContext);
           writer.close();
   
  
  
  
  1.15      +3 -0      ws-axis/java/src/org/apache/axis/message/NodeImpl.java
  
  Index: NodeImpl.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/NodeImpl.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- NodeImpl.java	27 May 2005 10:20:12 -0000	1.14
  +++ NodeImpl.java	9 Jun 2005 16:36:27 -0000	1.15
  @@ -493,6 +493,7 @@
           ((NodeImpl) newChild).detachNode();
           children.add(newChild);
           ((NodeImpl) newChild).parent = this;
  +        setDirty(true);
           return newChild;
       }
   
  @@ -560,6 +561,7 @@
               position = 0;
           }
           children.add(position, newChild);
  +        setDirty(true);
           return newChild;
       }
   
  @@ -595,6 +597,7 @@
           }
           children.remove(position);
           children.add(position, newChild);
  +        setDirty(true);
           return oldChild;
       }
   
  
  
  
  1.4       +47 -2     ws-axis/java/test/message/TestSOAPBody.java
  
  Index: TestSOAPBody.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/message/TestSOAPBody.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestSOAPBody.java	25 Feb 2004 14:02:57 -0000	1.3
  +++ TestSOAPBody.java	9 Jun 2005 16:36:27 -0000	1.4
  @@ -23,11 +23,18 @@
   import javax.xml.soap.MimeHeaders;
   import javax.xml.soap.Name;
   import javax.xml.soap.SOAPBody;
  +import javax.xml.soap.SOAPEnvelope;
  +import javax.xml.soap.SOAPHeader;
   import javax.xml.soap.SOAPBodyElement;
   import javax.xml.soap.SOAPMessage;
   import javax.xml.soap.SOAPPart;
   import java.io.ByteArrayInputStream;
   import java.util.Iterator;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.Element;
  +import org.apache.axis.Message;
  +import org.apache.axis.utils.XMLUtils;
  +
   
   /**
    * @author john.gregg@techarch.com
  @@ -118,4 +125,42 @@
           }
           assertTrue(count == 1);
       }
  +    /**
  +     * Method testSaveChanges
  +     *
  +     * @throws Exception
  +     */
  +    public void testSaveChanges() throws Exception {
  +        MimeHeaders mimeheaders = new MimeHeaders();
  +
  +        mimeheaders.addHeader("Content-Type", "text/xml");
  +        ByteArrayInputStream instream = new ByteArrayInputStream(xmlString.getBytes());
  +        MessageFactory factory =
  +                MessageFactory.newInstance();
  +        SOAPMessage msg =
  +                factory.createMessage(mimeheaders, instream);
  +        org.apache.axis.client.AxisClient axisengine =
  +                new org.apache.axis.client.AxisClient();
  +
  +        ((Message) msg).setMessageContext(
  +                new org.apache.axis.MessageContext(axisengine));
  +        SOAPPart sp = msg.getSOAPPart();
  +        SOAPEnvelope se = (org.apache.axis.message.SOAPEnvelope) sp.getEnvelope();
  +        SOAPHeader sh = (org.apache.axis.message.SOAPHeader)se.getHeader();
  +        SOAPBody sb = (org.apache.axis.message.SOAPBody)se.getBody();
  +
  +        Node myNode = (Element) sb.getElementsByTagName("City").item(0);
  +
  +        myNode.replaceChild( myNode.getOwnerDocument().createTextNode("NY"), myNode.getFirstChild());
  +        System.out.println(XMLUtils.ElementToString(sb));
  +
  +        msg.saveChanges();
  +        
  +        sp = msg.getSOAPPart();
  +        se = (org.apache.axis.message.SOAPEnvelope) sp.getEnvelope();
  +        javax.xml.soap.SOAPBody sb2 = se.getBody();
  +        myNode = (Element) sb.getElementsByTagName("City").item(0);
  +        Node city = myNode.getFirstChild();
  +        assertEquals("City name did not change to NY", city.toString(), "NY");
  +    }
   }
  
  
  

Mime
View raw message