ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1333588 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/soap/ axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/ axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/ axiom-testsuite...
Date Thu, 03 May 2012 19:09:14 GMT
Author: veithen
Date: Thu May  3 19:09:13 2012
New Revision: 1333588

URL: http://svn.apache.org/viewvc?rev=1333588&view=rev
Log:
Fixed a couple of issues in SOAPEnvelope#getSOAPBodyFirstElementNS() and SOAPBody#getFirstElementNS():
* The return value should be normalized in the same way as for OMNamedInformationItem#getNamespace()
(see AXIOM-398).
* Don't return an OMNamespace instance with a null prefix.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPBody.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPEnvelope.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPBodyImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNS.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPBody.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPBody.java?rev=1333588&r1=1333587&r2=1333588&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPBody.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPBody.java
Thu May  3 19:09:13 2012
@@ -73,7 +73,9 @@ public interface SOAPBody extends OMElem
      * obtain this information from the builder/parser without building
      * the OMElement.  Use this method in the situations where you need
      * to know the OMNamespace, but don't necessarily need the OMElement.
-     * @return OMNamespace of first element in the body or null
+     * 
+     * @return the namespace of first element in the body, or <code>null</code>
if the element
+     * has no namespace or the body is empty
      */
     public OMNamespace getFirstElementNS();
     

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPEnvelope.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPEnvelope.java?rev=1333588&r1=1333587&r2=1333588&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPEnvelope.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPEnvelope.java
Thu May  3 19:09:13 2012
@@ -63,7 +63,9 @@ public interface SOAPEnvelope extends OM
      * obtain this information from the builder/parser without building
      * the OMElement.  Use this method in the situations where you need
      * to know the OMNamespace, but don't necessarily need the OMElement.
-     * @return OMNamespace of first element in the body or null
+     * 
+     * @return the namespace of first element in the body, or <code>null</code>
if the element
+     * has no namespace or the body is empty
      */
     public OMNamespace getSOAPBodyFirstElementNS();
     

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPBodyImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPBodyImpl.java?rev=1333588&r1=1333587&r2=1333588&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPBodyImpl.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPBodyImpl.java
Thu May  3 19:09:13 2012
@@ -192,9 +192,12 @@ public abstract class SOAPBodyImpl exten
             if (lookAheadSuccessful) {
                 this.lookAheadLocalName = soapBuilder.getName();
                 String ns = soapBuilder.getNamespace();
-                ns = (ns == null) ? "" : ns;
-                this.lookAheadNS = factory.createOMNamespace(ns, 
-                                                             soapBuilder.getPrefix());
+                if (ns == null) {
+                    lookAheadNS = null;
+                } else {
+                    String prefix = soapBuilder.getPrefix();
+                    lookAheadNS = factory.createOMNamespace(ns, prefix == null ? "" : prefix);
+                }
             }
         }
         return lookAheadSuccessful;

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1333588&r1=1333587&r2=1333588&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
Thu May  3 19:09:13 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.axiom.ts.soap;
 
+import javax.xml.namespace.QName;
+
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.TestConstants;
 import org.apache.axiom.testutils.suite.TestSuiteBuilder;
@@ -30,6 +32,11 @@ public class SOAPTestSuiteBuilder extend
         TestConstants.MINIMAL_MESSAGE, TestConstants.REALLY_BIG_MESSAGE,
         TestConstants.EMPTY_BODY_MESSAGE };
     
+    private static final QName[] qnames = {
+        new QName("root"),
+        new QName("urn:test", "root", "p"),
+        new QName("urn:test", "root") };
+    
     private final OMMetaFactory metaFactory;
     private final boolean supportsOMSourcedElement;
     
@@ -55,8 +62,11 @@ public class SOAPTestSuiteBuilder extend
         addTest(new org.apache.axiom.ts.soap.envelope.TestGetBodyWithParser(metaFactory,
spec));
         addTest(new org.apache.axiom.ts.soap.envelope.TestGetHeader(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.envelope.TestGetHeaderWithParser(metaFactory,
spec));
-        addTest(new org.apache.axiom.ts.soap.envelope.TestGetSOAPBodyFirstElementLocalNameAndNS(metaFactory,
spec));
-        addTest(new org.apache.axiom.ts.soap.envelope.TestGetSOAPBodyFirstElementLocalNameAndNSWithParser(metaFactory,
spec));
+        for (int i=0; i<qnames.length; i++) {
+            QName qname = qnames[i];
+            addTest(new org.apache.axiom.ts.soap.envelope.TestGetSOAPBodyFirstElementLocalNameAndNS(metaFactory,
spec, qname));
+            addTest(new org.apache.axiom.ts.soap.envelope.TestGetSOAPBodyFirstElementLocalNameAndNSWithParser(metaFactory,
spec, qname));
+        }
         addTest(new org.apache.axiom.ts.soap.envelope.TestHasFault(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.envelope.TestHasFaultWithParser(metaFactory,
spec));
         addTest(new org.apache.axiom.ts.soap.factory.TestCreateSOAPEnvelope(metaFactory,
spec));

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNS.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNS.java?rev=1333588&r1=1333587&r2=1333588&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNS.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNS.java
Thu May  3 19:09:13 2012
@@ -18,22 +18,36 @@
  */
 package org.apache.axiom.ts.soap.envelope;
 
+import javax.xml.namespace.QName;
+
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.ts.soap.SOAPSpec;
 import org.apache.axiom.ts.soap.SOAPTestCase;
 
 public class TestGetSOAPBodyFirstElementLocalNameAndNS extends SOAPTestCase {
-    public TestGetSOAPBodyFirstElementLocalNameAndNS(OMMetaFactory metaFactory, SOAPSpec
spec) {
+    private final QName qname;
+    
+    public TestGetSOAPBodyFirstElementLocalNameAndNS(OMMetaFactory metaFactory, SOAPSpec
spec, QName qname) {
         super(metaFactory, spec);
+        this.qname = qname;
+        addTestProperty("prefix", qname.getPrefix());
+        addTestProperty("uri", qname.getNamespaceURI());
     }
 
     protected void runTest() throws Throwable {
         SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
-        OMElement bodyElement = soapFactory.createOMElement("myOperation", "urn:ns", "ns");
+        OMElement bodyElement = soapFactory.createOMElement(qname.getLocalPart(), qname.getNamespaceURI(),
qname.getPrefix());
         envelope.getBody().addChild(bodyElement);
-        assertEquals(bodyElement.getLocalName(), envelope.getSOAPBodyFirstElementLocalName());
-        assertEquals(bodyElement.getNamespace(), envelope.getSOAPBodyFirstElementNS());
+        assertEquals(qname.getLocalPart(), envelope.getSOAPBodyFirstElementLocalName());
+        OMNamespace ns = envelope.getSOAPBodyFirstElementNS();
+        if (qname.getNamespaceURI().length() == 0) {
+            assertNull(ns);
+        } else {
+            assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
+            assertEquals(qname.getPrefix(), ns.getPrefix());
+        }
     }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java?rev=1333588&r1=1333587&r2=1333588&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java
Thu May  3 19:09:13 2012
@@ -20,6 +20,7 @@ package org.apache.axiom.ts.soap.envelop
 
 import java.io.StringReader;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.axiom.om.OMElement;
@@ -38,8 +39,13 @@ import org.apache.axiom.ts.soap.SOAPTest
  * the name of the element without actually instantiating the corresponding {@link OMElement}.
  */
 public class TestGetSOAPBodyFirstElementLocalNameAndNSWithParser extends SOAPTestCase {
-    public TestGetSOAPBodyFirstElementLocalNameAndNSWithParser(OMMetaFactory metaFactory,
SOAPSpec spec) {
+    private final QName qname;
+    
+    public TestGetSOAPBodyFirstElementLocalNameAndNSWithParser(OMMetaFactory metaFactory,
SOAPSpec spec, QName qname) {
         super(metaFactory, spec);
+        this.qname = qname;
+        addTestProperty("prefix", qname.getPrefix());
+        addTestProperty("uri", qname.getNamespaceURI());
     }
 
     protected void runTest() throws Throwable {
@@ -47,13 +53,18 @@ public class TestGetSOAPBodyFirstElement
         // doesn't contain any unwanted whitespace.
         SOAPFactory factory = spec.getFactory(metaFactory);
         SOAPEnvelope orgEnvelope = factory.getDefaultEnvelope();
-        OMNamespace ns = factory.createOMNamespace("urn:test", "ns");
-        factory.createOMElement("echo", ns, orgEnvelope.getBody());
+        orgEnvelope.getBody().addChild(soapFactory.createOMElement(qname.getLocalPart(),
qname.getNamespaceURI(), qname.getPrefix()));
         String message = orgEnvelope.toString();
         
         SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new
StringReader(message)).getSOAPEnvelope();
-        assertEquals("echo", envelope.getSOAPBodyFirstElementLocalName());
-        assertEquals(ns, envelope.getSOAPBodyFirstElementNS());
+        assertEquals(qname.getLocalPart(), envelope.getSOAPBodyFirstElementLocalName());
+        OMNamespace ns = envelope.getSOAPBodyFirstElementNS();
+        if (qname.getNamespaceURI().length() == 0) {
+            assertNull(ns);
+        } else {
+            assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
+            assertEquals(qname.getPrefix(), ns.getPrefix());
+        }
         
         // Also request an XMLStreamReader. The LLOM implementation triggers some special
processing
         // in this case (because the getSOAPBodyFirstElementXXX calls put the builder in
lookahead
@@ -64,8 +75,16 @@ public class TestGetSOAPBodyFirstElement
         assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
         assertEquals("Body", reader.getLocalName());
         assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
-        assertEquals("echo", reader.getLocalName());
-        assertEquals("ns", reader.getPrefix());
-        assertEquals("urn:test", reader.getNamespaceURI());
+        assertEquals(qname.getLocalPart(), reader.getLocalName());
+        if (qname.getNamespaceURI().length() == 0) {
+            assertNull(reader.getNamespaceURI());
+        } else {
+            assertEquals(qname.getNamespaceURI(), reader.getNamespaceURI());
+        }
+        if (qname.getPrefix().length() == 0) {
+            assertNull(reader.getPrefix());
+        } else {
+            assertEquals(qname.getPrefix(), reader.getPrefix());
+        }
     }
 }



Mime
View raw message