axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject cvs commit: xml-axis/java/test/message PackageTests.java TestMessageElement.java
Date Mon, 25 Mar 2002 16:12:16 GMT
glyn        02/03/25 08:12:16

  Modified:    java/src/org/apache/axis/client Call.java
               java/src/org/apache/axis/encoding
                        DeserializationContextImpl.java
               java/src/org/apache/axis/message MessageElement.java
  Added:       java/src/org/apache/axis/message PrefixedQName.java
               java/test/message PackageTests.java TestMessageElement.java
  Log:
  Complete plumbing-in of JAXM SOAPElement into Axis MessageElement:
    - replace Axis get/setParent methods with JAXM equivalents
    - implement JAXM Name with Axis PrefixedQName (extends JAX-RPC QName)
    - add test for parent/child JAXM methods.
  (The Axis get/setParent methods are private and may be rolled into the JAXM
  methods later.)
  
  Revision  Changes    Path
  1.105     +1 -1      xml-axis/java/src/org/apache/axis/client/Call.java
  
  Index: Call.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v
  retrieving revision 1.104
  retrieving revision 1.105
  diff -u -r1.104 -r1.105
  --- Call.java	23 Mar 2002 02:18:18 -0000	1.104
  +++ Call.java	25 Mar 2002 16:12:15 -0000	1.105
  @@ -1707,7 +1707,7 @@
               setRequestMessage(reqMsg);
   
               reqEnv.addBodyElement(body);
  -            body.setParent(reqEnv);
  +            body.setParentElement(reqEnv);
               reqEnv.setMessageType(Message.REQUEST);
   
               invoke();
  
  
  
  1.20      +2 -2      xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java
  
  Index: DeserializationContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DeserializationContextImpl.java	25 Mar 2002 04:44:01 -0000	1.19
  +++ DeserializationContextImpl.java	25 Mar 2002 16:12:16 -0000	1.20
  @@ -626,7 +626,7 @@
           }
           
           try {
  -            elem.setParent(curElement);
  +            elem.setParentElement(curElement);
           } catch (Exception e) {
               /*
                * The only checked exception that may be thrown from setParent
  @@ -878,7 +878,7 @@
               
           } finally {
               if (curElement != null)
  -                curElement = curElement.getParent();
  +                curElement = (MessageElement)curElement.getParentElement();
           }
       }
   
  
  
  
  1.91      +6 -32     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.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- MessageElement.java	25 Mar 2002 14:22:25 -0000	1.90
  +++ MessageElement.java	25 Mar 2002 16:12:16 -0000	1.91
  @@ -301,8 +301,8 @@
           }
       }
   
  -    public MessageElement getParent() { return parent; }
  -    public void setParent(MessageElement parent) throws SOAPException
  +    private MessageElement getParent() { return parent; }
  +    private void setParent(MessageElement parent) throws SOAPException
       { 
           this.parent = parent;
           if (parent != null) {
  @@ -813,39 +813,13 @@
                       prefix = q.substring(0, idx);
               }
   
  -            attrs.add(new NameImpl(attributes.getURI(i),
  -                                   attributes.getLocalName(i),
  -                                   prefix));
  +            attrs.add(new PrefixedQName(attributes.getURI(i),
  +                                        attributes.getLocalName(i),
  +                                        prefix));
           }
           return attrs.iterator();
       }
   
  -    protected static class NameImpl implements Name {
  -        private QName qName;
  -        private String prefix;
  -
  -        public NameImpl(String uri, String localName, String pre) {
  -            qName = new QName(uri, localName);
  -            prefix = pre;
  -        }
  -
  -        public String getLocalName() {
  -            return qName.getLocalPart();
  -        }
  -
  -        public String getQualifiedName() {
  -            return qName.toString();
  -        }
  -
  -        public String getURI() {
  -            return qName.getNamespaceURI();
  -        }
  -
  -        public String getPrefix() {
  -            return prefix;
  -        }
  -    }
  -
       // getNamespaceURI implemented above
   
       public Iterator getNamespacePrefixes() {
  @@ -858,7 +832,7 @@
       }
   
       public Name getElementName() {
  -        return new NameImpl(getNamespaceURI(), getName(), getPrefix());
  +        return new PrefixedQName(getNamespaceURI(), getName(), getPrefix());
       }
   
       public boolean removeAttribute(Name name) {
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/message/PrefixedQName.java
  
  Index: PrefixedQName.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.message;
  
  import javax.xml.soap.Name;
  import javax.xml.rpc.namespace.QName;
  
  public class PrefixedQName extends QName implements Name {
      private String prefix;
      
      public PrefixedQName(String uri, String localName, String pre) {
          super(uri, localName);
          prefix = pre;
      }
      
      public String getLocalName() {
          return super.getLocalPart();
      }
      
      public String getQualifiedName() {
          return super.toString();
      }
      
      public String getURI() {
          return super.getNamespaceURI();
      }
      
      public String getPrefix() {
          return prefix;
      }
  }
  
  
  
  1.1                  xml-axis/java/test/message/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package test.message;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * Test org.apache.axis.Message subsystem.
   *
   * @author Glyn Normington (glyn@apache.org)
   */
  public class PackageTests extends TestCase
  {
      public PackageTests(String name)
      {
          super(name);
      }
  
      public static Test suite() throws Exception
      {
          TestSuite suite = new TestSuite();
          
          suite.addTestSuite(TestMessageElement.class);
   
          return suite;
      }
  }
  
  
  
  1.1                  xml-axis/java/test/message/TestMessageElement.java
  
  Index: TestMessageElement.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    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,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package test.message;
  
  import junit.framework.TestCase;
  
  import javax.xml.soap.SOAPElement;
  import javax.xml.soap.Name;
  import org.apache.axis.soap.SOAPConstants;
  
  import org.apache.axis.message.MessageElement;
  import org.apache.axis.message.PrefixedQName;
  import org.apache.axis.message.EnvelopeBuilder;
  import org.apache.axis.Message;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializationContextImpl;
  
  import java.util.Iterator;
  
  /**
   * Test MessageElement class.
   *
   * @author Glyn Normington (glyn@apache.org)
   */
  public class TestMessageElement extends TestCase {
  
      public TestMessageElement(String name) {
          super(name);
      }
  
      // Test JAXM methods...
  
      public void testParentage() throws Exception {
          SOAPElement parent = new MessageElement();
          SOAPElement child = new MessageElement();
          child.setParentElement(parent);
          assertEquals("Parent is not as set", parent, child.getParentElement());
      }
  
      public void testAddChild() throws Exception {
          SOAPConstants sc = SOAPConstants.SOAP11_CONSTANTS;
          EnvelopeBuilder eb = new EnvelopeBuilder(Message.REQUEST, sc);
          DeserializationContext dc = new DeserializationContextImpl(null,
                                                                     eb); 
          SOAPElement parent = new MessageElement("parent.names",
                                                  "parent",
                                                  "parns:parent",
                                                  null,
                                                  dc);
          Name c1 = new PrefixedQName("child1.names", "child1" ,"c1ns");
          SOAPElement child1 = parent.addChildElement(c1);
          SOAPElement child2 = parent.addChildElement("child2");
          SOAPElement child3 = parent.addChildElement("child3.names", "parns");
          SOAPElement child4 = parent.addChildElement("child4",
                                                      "c4ns",
                                                      "child4.names");
          SOAPElement child5 = new MessageElement();
          parent.addChildElement(child5);
          SOAPElement c[] = {child1, child2, child3, child4, child5}; 
          
          Iterator children = parent.getChildElements();
          for (int i = 0; i < 5; i++) {
              assertEquals("Child " + (i+1) + " not found",
                           c[i],
                           children.next());
          }
          assertTrue("Unexpected child", !children.hasNext());
         
          Iterator c1only = parent.getChildElements(c1);
          assertEquals("Child 1 not found", child1, c1only.next());
          assertTrue("Unexpected child", !c1only.hasNext());
      }
  }
  
  
  

Mime
View raw message