axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-axis/java/test/saaj TestEnvelope.java
Date Wed, 10 Jul 2002 15:39:14 GMT
dims        2002/07/10 08:39:14

  Modified:    java/src/org/apache/axis/message MessageElement.java
                        SOAPEnvelope.java Text.java
               java/test/saaj TestEnvelope.java
  Log:
  - Add Text support for SAAJ compliance.
  - Add testcase.
  
  Revision  Changes    Path
  1.111     +2 -2      xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.110
  retrieving revision 1.111
  diff -u -r1.110 -r1.111
  --- MessageElement.java	3 Jul 2002 17:50:28 -0000	1.110
  +++ MessageElement.java	10 Jul 2002 15:39:14 -0000	1.111
  @@ -788,7 +788,7 @@
   
       public void setParentElement(SOAPElement parent) throws SOAPException {
           if(parent == null)
  -            throw new IllegalArgumentException(JavaUtils.getMessage("nullParent00")); 
  +            throw new IllegalArgumentException(JavaUtils.getMessage("nullParent00"));
           try {
               setParent((MessageElement)parent);
           } catch (Throwable t) {
  @@ -873,7 +873,7 @@
           org.apache.axis.message.Text text = new org.apache.axis.message.Text(s);
           try {
               addChild((MessageElement)text);
  -            return text;
  +            return this;
           } catch (ClassCastException e) {
               throw new SOAPException(e);
           }
  
  
  
  1.76      +46 -36    xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java
  
  Index: SOAPEnvelope.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- SOAPEnvelope.java	3 Jul 2002 17:50:28 -0000	1.75
  +++ SOAPEnvelope.java	10 Jul 2002 15:39:14 -0000	1.76
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "Axis" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -92,7 +92,7 @@
   
       private SOAPHeader header;
       private SOAPBody body;
  -    
  +
       public Vector trailers = new Vector();
       private SOAPConstants soapConstants;
   
  @@ -101,9 +101,9 @@
       // or anything else your particular service descripton requires.
       //
       // This gets passed back into the service description during
  -    // deserialization 
  +    // deserialization
       public String messageType;
  -    
  +
       public SOAPEnvelope()
       {
           this(true, SOAPConstants.SOAP11_CONSTANTS);
  @@ -131,7 +131,7 @@
               namespaces.add(new Mapping(Constants.URI_DEFAULT_SCHEMA_XSI,
                                          Constants.NS_PREFIX_SCHEMA_XSI));
           }
  -        
  +
           setDirty(true);
       }
   
  @@ -145,17 +145,17 @@
                                                 Message.REQUEST, this );
           dser.parse();
       }
  -    
  +
       public String getMessageType()
       {
           return messageType;
       }
  -    
  +
       public void setMessageType(String messageType)
       {
           this.messageType = messageType;
       }
  -    
  +
       public Vector getBodyElements() throws AxisFault
       {
           if (body != null) {
  @@ -164,12 +164,12 @@
               return new Vector();
           }
       }
  -    
  +
       public Vector getTrailers()
       {
           return trailers;
       }
  -    
  +
       public SOAPBodyElement getFirstBody() throws AxisFault
       {
           if (body == null) {
  @@ -178,7 +178,7 @@
               return body.getFirstBody();
           }
       }
  -    
  +
       public Vector getHeaders() throws AxisFault
       {
           if (header != null) {
  @@ -187,10 +187,10 @@
               return new Vector();
           }
       }
  -    
  +
       /**
        * Get all the headers targeted at a list of actors.
  -     */ 
  +     */
       public Vector getHeadersByActor(ArrayList actors)
       {
           if (header != null) {
  @@ -199,7 +199,7 @@
               return new Vector();
           }
       }
  -    
  +
       public void addHeader(SOAPHeaderElement hdr)
       {
           if (header == null) {
  @@ -209,7 +209,7 @@
           header.addHeader(hdr);
           _isDirty = true;
       }
  -    
  +
       public void addBodyElement(SOAPBodyElement element)
       {
           if (body == null) {
  @@ -242,7 +242,7 @@
               _isDirty = true;
           }
       }
  -    
  +
       public void removeBody() {
           body = null;
       }
  @@ -264,7 +264,7 @@
               _isDirty = true;
           }
       }
  -    
  +
       public void removeTrailer(MessageElement element)
       {
           if (log.isDebugEnabled())
  @@ -272,7 +272,7 @@
           trailers.removeElement(element);
           _isDirty = true;
       }
  -    
  +
       public void clearBody()
       {
           if (body != null) {
  @@ -280,7 +280,7 @@
               _isDirty = true;
           }
       }
  -    
  +
       public void addTrailer(MessageElement element)
       {
           if (log.isDebugEnabled())
  @@ -293,18 +293,18 @@
       /**
        * Get a header by name (always respecting the currently in-scope
        * actors list)
  -     */ 
  +     */
       public SOAPHeaderElement getHeaderByName(String namespace,
                                                String localPart)
           throws AxisFault
       {
           return getHeaderByName(namespace, localPart, false);
       }
  -    
  +
       /**
        * Get a header by name, filtering for headers targeted at this
        * engine depending on the accessAllHeaders parameter.
  -     */ 
  +     */
       public SOAPHeaderElement getHeaderByName(String namespace,
                                                String localPart,
                                                boolean accessAllHeaders)
  @@ -318,7 +318,7 @@
               return null;
           }
       }
  -    
  +
       public SOAPBodyElement getBodyByName(String namespace, String localPart)
           throws AxisFault
       {
  @@ -328,7 +328,7 @@
               return body.getBodyByName(namespace, localPart);
           }
       }
  -    
  +
       public Enumeration getHeadersByName(String namespace, String localPart)
           throws AxisFault
       {
  @@ -340,11 +340,11 @@
        * and localPart.  Depending on the value of the accessAllHeaders
        * parameter, we will attempt to filter on the current engine's list
        * of actors.
  -     * 
  +     *
        * !!! NOTE THAT RIGHT NOW WE ALWAYS ASSUME WE'RE THE "ULTIMATE
        * DESTINATION" (i.e. we match on null actor).  IF WE WANT TO FULLY SUPPORT
        * INTERMEDIARIES WE'LL NEED TO FIX THIS.
  -     */ 
  +     */
       public Enumeration getHeadersByName(String namespace, String localPart,
                                           boolean accessAllHeaders)
           throws AxisFault
  @@ -357,7 +357,7 @@
               return new Vector().elements();
           }
       }
  -    
  +
       /** Should make SOAPSerializationException?
        */
       public void outputImpl(SerializationContext context)
  @@ -374,14 +374,24 @@
                                                mapping.getNamespaceURI());
               }
           }
  -        
  +
           Enumeration enum;
  -        
  +
           // Output <SOAP-ENV:Envelope>
           context.startElement(new QName(soapConstants.getEnvelopeURI(),
                                          Constants.ELEM_ENVELOPE), attributes);
   
  -        // Output headers        
  +        // Output non-SOAPHeader and non-SOAPBody stuff.
  +        Iterator i = getChildElements();
  +        while (i.hasNext()) {
  +            MessageElement element = (MessageElement)i.next();
  +            if(element instanceof SOAPHeader ||
  +               element instanceof SOAPBody)
  +                continue;
  +            element.output(context);
  +        }
  +
  +        // Output headers
           if (header != null) {
               header.outputImpl(context);
           }
  @@ -398,7 +408,7 @@
               element.output(context);
               // Output this independent element
           }
  -        
  +
           // Output </SOAP-ENV:Envelope>
           context.endElement();
   
  @@ -434,14 +444,14 @@
           // Ok to use the SOAP envelope's namespace URI and prefix?
           return new PrefixedQName(namespaceURI, localName, prefix);
       }
  -    
  +
       public javax.xml.soap.Name createName(String localName,
                                             String prefix,
                                             String uri)
           throws SOAPException {
           return new PrefixedQName(uri, localName, prefix);
       }
  -    
  +
       public javax.xml.soap.SOAPBody getBody() throws SOAPException {
           return body;
       }
  
  
  
  1.3       +3 -1      xml-axis/java/src/org/apache/axis/message/Text.java
  
  Index: Text.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/Text.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Text.java	30 May 2002 16:40:42 -0000	1.2
  +++ Text.java	10 Jul 2002 15:39:14 -0000	1.3
  @@ -76,7 +76,9 @@
        *     a comment; <CODE>false</CODE> otherwise
        */
       public boolean isComment() {
  -        //TODO: Flesh this out.
  +        String temp = textRep.getNodeValue().trim();
  +        if(temp.startsWith("<!--") && temp.endsWith("-->"))
  +            return true;
           return false;
       }
   }
  
  
  
  1.3       +49 -0     xml-axis/java/test/saaj/TestEnvelope.java
  
  Index: TestEnvelope.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/saaj/TestEnvelope.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestEnvelope.java	29 Jun 2002 20:44:53 -0000	1.2
  +++ TestEnvelope.java	10 Jul 2002 15:39:14 -0000	1.3
  @@ -5,11 +5,15 @@
   import javax.xml.soap.SOAPBody;
   import javax.xml.soap.SOAPConnection;
   import javax.xml.soap.SOAPConnectionFactory;
  +import javax.xml.soap.SOAPElement;
   import javax.xml.soap.SOAPEnvelope;
   import javax.xml.soap.SOAPFault;
   import javax.xml.soap.SOAPHeader;
   import javax.xml.soap.SOAPHeaderElement;
   import javax.xml.soap.SOAPMessage;
  +import javax.xml.soap.Node;
  +import javax.xml.soap.Text;
  +import java.util.Iterator;
   
   public class TestEnvelope extends junit.framework.TestCase {
   
  @@ -86,6 +90,48 @@
           assertTrue(!iterator.hasNext());
       }
   
  +    public void testText1() throws Exception {
  +        SOAPEnvelope envelope = getSOAPEnvelope();
  +        Iterator iStart = envelope.getChildElements();
  +        int countStart = getIteratorCount(iStart);
  +        SOAPElement se = envelope.addTextNode("<txt>This is text</txt>");
  +        assertTrue(se != null);
  +        assertTrue(envelope.getValue().equals("<txt>This is text</txt>"));
  +        Iterator i = envelope.getChildElements();
  +        int count = getIteratorCount(i);
  +        assertTrue(count == countStart + 1);
  +    }
  +
  +    public void testText2() throws Exception {
  +        SOAPEnvelope envelope = getSOAPEnvelope();
  +	    SOAPElement se = envelope.addTextNode("This is text");
  +	    Iterator iterator = se.getChildElements();
  +	    Node n = null;
  +	    while (iterator.hasNext()) {
  +            n = (Node)iterator.next();
  +            if (n instanceof Text)
  +                break;
  +	    }
  +	    assertTrue(n instanceof Text);
  +		Text t = (Text)n;
  +		assertTrue(!t.isComment());
  +    }
  +
  +    public void testText3() throws Exception {
  +        SOAPEnvelope envelope = getSOAPEnvelope();
  +	    SOAPElement se = envelope.addTextNode("<!-- This is a comment -->");
  +	    Iterator iterator = se.getChildElements();
  +	    Node n = null;
  +	    while (iterator.hasNext()) {
  +            n = (Node)iterator.next();
  +            if (n instanceof Text)
  +                break;
  +	    }
  +	    assertTrue(n instanceof Text);
  +		Text t = (Text)n;
  +		assertTrue(t.isComment());
  +    }
  +
       private int getIteratorCount(java.util.Iterator i) {
           int count = 0;
           while (i.hasNext()) {
  @@ -97,6 +143,9 @@
   
       public static void main(String[] args) throws Exception {
           test.saaj.TestEnvelope tester = new test.saaj.TestEnvelope("TestEnvelope");
  +        tester.testText3();
  +        tester.testText2();
  +        tester.testText1();
           tester.testHeaderElements();
           tester.testFaults();
           tester.testAttributes();
  
  
  

Mime
View raw message