ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1333644 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/test/java/org/apache/axiom/om/ axiom-api/src/test/resources/soap/ axiom-api/src/test/resources/soap/soap11/ axiom-api/src/test/resources/soap/soap12/ axiom-dom/sr...
Date Thu, 03 May 2012 21:51:13 GMT
Author: veithen
Date: Thu May  3 21:51:12 2012
New Revision: 1333644

URL: http://svn.apache.org/viewvc?rev=1333644&view=rev
Log:
Refactored the unit test for AXIOM-282 (r631309).

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap11/soapmessage.xml
      - copied unchanged from r1333572, webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soapmessage.xml
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap12/soapmessage.xml
  (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck.java
  (with props)
Removed:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soapmessage.xml
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/TestConstants.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/builder/CustomBuilderTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/OMElementHelperTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/TestConstants.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/TestConstants.java?rev=1333644&r1=1333643&r2=1333644&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/TestConstants.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/TestConstants.java
Thu May  3 21:51:12 2012
@@ -22,7 +22,7 @@ package org.apache.axiom.om;
 /** All the various files created 03-Nov-2005 12:02:12 */
 
 public class TestConstants {
-    public static final String SOAP_SOAPMESSAGE = "soap/soapmessage.xml";
+    public static final String SOAP_SOAPMESSAGE = "soap/soap11/soapmessage.xml";
     public static final String SOAP_SOAPMESSAGE1 = "soap/soapmessage1.xml";
     public static final String SAMPLE1 = "soap/sample1.xml";
     public static final String TEST = "soap/test.xml";

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap12/soapmessage.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap12/soapmessage.xml?rev=1333644&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap12/soapmessage.xml
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap12/soapmessage.xml
Thu May  3 21:51:12 2012
@@ -0,0 +1,39 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing">
+    <soapenv:Header>
+        <wsa:MessageID soapenv:mustUnderstand="0">
+            uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5</wsa:MessageID>
+        <wsa:To soapenv:mustUnderstand="0">
+            http://localhost:8081/axis/services/BankPort</wsa:To>
+        <wsa:From soapenv:mustUnderstand="0">
+            <Address xmlns="http://schemas.xmlsoap.org/ws/2004/03/addressing">
+                http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous
+            </Address>
+        </wsa:From>
+    </soapenv:Header>
+    <soapenv:Body>
+        <axis2:echoVoid xmlns:axis2="http://ws.apache.org/axis2">
+        </axis2:echoVoid>
+    </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap12/soapmessage.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java?rev=1333644&r1=1333643&r2=1333644&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java
Thu May  3 21:51:12 2012
@@ -31,7 +31,7 @@ import org.apache.axiom.ts.soap12.faultc
 
 public class SOAPImplementationTest extends TestCase {
     public static TestSuite suite() {
-        SOAPTestSuiteBuilder builder = new SOAPTestSuiteBuilder(new OMDOMMetaFactory(), false);
+        SOAPTestSuiteBuilder builder = new SOAPTestSuiteBuilder(new OMDOMMetaFactory(), false,
false);
         builder.exclude(TestWSCommons202.class);
         builder.exclude(TestGetDefaultFaultEnvelope.class);
         

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java?rev=1333644&r1=1333643&r2=1333644&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java
Thu May  3 21:51:12 2012
@@ -26,7 +26,7 @@ import org.apache.axiom.ts.soap.SOAPTest
 
 public class SOAPImplementationTest extends TestCase {
     public static TestSuite suite() {
-        SOAPTestSuiteBuilder builder = new SOAPTestSuiteBuilder(new OMLinkedListMetaFactory(),
true);
+        SOAPTestSuiteBuilder builder = new SOAPTestSuiteBuilder(new OMLinkedListMetaFactory(),
true, true);
         return builder.build();
     }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/builder/CustomBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/builder/CustomBuilderTest.java?rev=1333644&r1=1333643&r2=1333644&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/builder/CustomBuilderTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/builder/CustomBuilderTest.java
Thu May  3 21:51:12 2012
@@ -53,7 +53,7 @@ public class CustomBuilderTest extends A
     }
     
     public void testSample1() throws Exception {
-        copyAndCheck(createEnvelope(getTestResource(TestConstants.SAMPLE1), false), true);
+        copyAndCheck(createEnvelope(getTestResource(TestConstants.SAMPLE1)), true);
     }
     
     
@@ -80,29 +80,19 @@ public class CustomBuilderTest extends A
      * @throws Exception
      */
     public void testSOAPMESSAGE() throws Exception {
-        copyAndCheck(createEnvelope(getTestResource(TestConstants.SOAP_SOAPMESSAGE), false),
true);
-    }
-    
-    
-    /** 
-     * Same as testSOAPMessage, except that the a fault check is done too.
-     * (The fault check simulates what happens in the engine.)
-     * @throws Exception
-     */
-    public void testSOAPMESSAGE2() throws Exception {
-        copyAndCheck(createEnvelope(getTestResource(TestConstants.SOAP_SOAPMESSAGE), true),
true);
+        copyAndCheck(createEnvelope(getTestResource(TestConstants.SOAP_SOAPMESSAGE)), true);
     }
     
     public void testWHITESPACE_MESSAGE() throws Exception {
-        copyAndCheck(createEnvelope(getTestResource(TestConstants.WHITESPACE_MESSAGE), false),
true);
+        copyAndCheck(createEnvelope(getTestResource(TestConstants.WHITESPACE_MESSAGE)), true);
     }
     
     public void testREALLY_BIG_MESSAGE() throws Exception {
         // Ignore the serialization comparison
-        copyAndCheck(createEnvelope(getTestResource(TestConstants.REALLY_BIG_MESSAGE), false),
false);
+        copyAndCheck(createEnvelope(getTestResource(TestConstants.REALLY_BIG_MESSAGE)), false);
     }
     public void testOMSE() throws Exception {
-        SOAPEnvelope sourceEnv = createEnvelope(getTestResource(TestConstants.EMPTY_BODY_MESSAGE),
false);
+        SOAPEnvelope sourceEnv = createEnvelope(getTestResource(TestConstants.EMPTY_BODY_MESSAGE));
         SOAPBody body = sourceEnv.getBody();
         
         // Create a payload
@@ -116,7 +106,7 @@ public class CustomBuilderTest extends A
     }
     
     public void testOMSE2() throws Exception {
-        SOAPEnvelope sourceEnv = createEnvelope(getTestResource(TestConstants.EMPTY_BODY_MESSAGE),
false);
+        SOAPEnvelope sourceEnv = createEnvelope(getTestResource(TestConstants.EMPTY_BODY_MESSAGE));
         SOAPBody body = sourceEnv.getBody();
         SOAPHeader header = sourceEnv.getHeader();
         String encoding = "UTF-8";
@@ -151,22 +141,11 @@ public class CustomBuilderTest extends A
      * @return
      * @throws Exception
      */
-    protected SOAPEnvelope createEnvelope(InputStream in, boolean doFaultCheck) throws Exception
{
+    protected SOAPEnvelope createEnvelope(InputStream in) throws Exception {
         XMLStreamReader parser = StAXUtils.createXMLStreamReader(in);
         StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(parser, null);
-        
-        SOAPEnvelope sourceEnv = (SOAPEnvelope) builder.getDocumentElement();
-        
-        // Do a fault check.  This is normally done in the engine (Axiom) and should
-        // not cause inteference with the custom builder processing
-        if (doFaultCheck) {
-            sourceEnv.getBody().hasFault();
-        }
-        
-        // Do the registration here...this simulates when it could occure in the engine
-        // (After the fault check and during phase processing...probably dispatch phase)
         builder.registerCustomBuilderForPayload(new ByteArrayCustomBuilder("utf-8"));
-        return sourceEnv;
+        return (SOAPEnvelope) builder.getDocumentElement();
     }
     
     /**

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/OMElementHelperTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/OMElementHelperTest.java?rev=1333644&r1=1333643&r2=1333644&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/OMElementHelperTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/OMElementHelperTest.java
Thu May  3 21:51:12 2012
@@ -23,15 +23,12 @@ import org.apache.axiom.om.AbstractTestC
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.TestConstants;
 
 public class OMElementHelperTest extends AbstractTestCase {
-
-    private String testXMLFilePath = "soap/soapmessage.xml";
-
-
     public void testImportOMElement() throws Exception {
         OMElement documentElement =
-                OMXMLBuilderFactory.createOMBuilder(OMAbstractFactory.getOMFactory(), getTestResource(testXMLFilePath))
+                OMXMLBuilderFactory.createOMBuilder(OMAbstractFactory.getOMFactory(), getTestResource(TestConstants.SOAP_SOAPMESSAGE))
                         .getDocumentElement();
 
         // first lets try to import an element created from llom in to llom factory. This
should return the same element

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=1333644&r1=1333643&r2=1333644&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 21:51:12 2012
@@ -21,6 +21,7 @@ package org.apache.axiom.ts.soap;
 import javax.xml.namespace.QName;
 
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.TestConstants;
 import org.apache.axiom.testutils.suite.TestSuiteBuilder;
 
@@ -39,10 +40,22 @@ public class SOAPTestSuiteBuilder extend
     
     private final OMMetaFactory metaFactory;
     private final boolean supportsOMSourcedElement;
+    private final boolean supportsBodyElementNameOptimization;
     
-    public SOAPTestSuiteBuilder(OMMetaFactory metaFactory, boolean supportsOMSourcedElement)
{
+    /**
+     * Constructor.
+     * 
+     * @param metaFactory
+     * @param supportsOMSourcedElement
+     *            indicates whether the implementation supports {@link OMSourcedElement}
+     * @param supportsBodyElementNameOptimization
+     *            indicates whether the implementation supports the optimization described
by <a
+     *            href="https://issues.apache.org/jira/browse/AXIOM-282">AXIOM-282</a>
+     */
+    public SOAPTestSuiteBuilder(OMMetaFactory metaFactory, boolean supportsOMSourcedElement,
boolean supportsBodyElementNameOptimization) {
         this.metaFactory = metaFactory;
         this.supportsOMSourcedElement = supportsOMSourcedElement;
+        this.supportsBodyElementNameOptimization = supportsBodyElementNameOptimization;
     }
     
     private void addTests(SOAPSpec spec) {
@@ -52,6 +65,9 @@ public class SOAPTestSuiteBuilder extend
         addTest(new org.apache.axiom.ts.soap.body.TestGetFaultWithParser(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.body.TestHasFault(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.body.TestHasFaultWithParser(metaFactory, spec));
+        if (supportsBodyElementNameOptimization) {
+            addTest(new org.apache.axiom.ts.soap.builder.TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck(metaFactory,
spec));
+        }
         addTest(new org.apache.axiom.ts.soap.envelope.TestAddHeaderToIncompleteEnvelope(metaFactory,
spec));
         addTest(new org.apache.axiom.ts.soap.envelope.TestBodyHeaderOrder(metaFactory, spec));
         addTest(new org.apache.axiom.ts.soap.envelope.TestDetach(metaFactory, spec));

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck.java?rev=1333644&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck.java
Thu May  3 21:51:12 2012
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.soap.builder;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.ds.custombuilder.ByteArrayCustomBuilder;
+import org.apache.axiom.om.impl.builder.CustomBuilder;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+/**
+ * Tests that a custom builder registered with
+ * {@link StAXSOAPModelBuilder#registerCustomBuilderForPayload(CustomBuilder)} is still taken
into
+ * account after using {@link SOAPBody#hasFault()}. This assumes that the Axiom implementation
+ * supports the optimization described by <a
+ * href="https://issues.apache.org/jira/browse/AXIOM-282">AXIOM-282</a>.
+ */
+public class TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck extends SOAPTestCase
{
+    public TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck(OMMetaFactory metaFactory,
SOAPSpec spec) {
+        super(metaFactory, spec);
+    }
+
+    protected void runTest() throws Throwable {
+        SOAPEnvelope envelope = getTestMessage("soapmessage.xml");
+        StAXSOAPModelBuilder builder = (StAXSOAPModelBuilder)envelope.getBuilder();
+        
+        // Do a fault check.  This is normally done in the engine (Axiom) and should
+        // not cause inteference with the custom builder processing
+        envelope.getBody().hasFault();
+
+        // Do the registration here...this simulates when it could occure in the engine
+        // (After the fault check and during phase processing...probably dispatch phase)
+        builder.registerCustomBuilderForPayload(new ByteArrayCustomBuilder("utf-8"));
+        
+        OMElement bodyElement = envelope.getBody().getFirstElement();
+        assertTrue(bodyElement instanceof OMSourcedElement);
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message