You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2016/01/29 12:07:29 UTC

svn commit: r1727529 - in /webservices/axiom/trunk: axiom-compat/src/main/java/org/apache/axiom/soap/impl/builder/ testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/ testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/spr...

Author: veithen
Date: Fri Jan 29 11:07:28 2016
New Revision: 1727529

URL: http://svn.apache.org/viewvc?rev=1727529&view=rev
Log:
Emulate the original StAXSOAPModelBuilder behavior for SOAP version mismatches.

Added:
    webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/soap/messagefactory/TestCreateWebServiceMessageFromInputStreamVersionMismatch.java   (with props)
Modified:
    webservices/axiom/trunk/axiom-compat/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java
    webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SpringWSTestSuiteBuilder.java

Modified: webservices/axiom/trunk/axiom-compat/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-compat/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java?rev=1727529&r1=1727528&r2=1727529&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-compat/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java (original)
+++ webservices/axiom/trunk/axiom-compat/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java Fri Jan 29 11:07:28 2016
@@ -29,6 +29,7 @@ import org.apache.axiom.soap.SOAPEnvelop
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPMessage;
 import org.apache.axiom.soap.SOAPModelBuilder;
+import org.apache.axiom.soap.SOAPProcessingException;
 
 /**
  * @deprecated Please use the {@link OMXMLBuilderFactory} API to create builders.
@@ -51,7 +52,11 @@ public class StAXSOAPModelBuilder implem
     }
     
     protected final void validateSOAPVersion(SOAPFactory factory, String soapVersion) {
-        // TODO
+        SOAPFactory actualFactory = (SOAPFactory)getSOAPMessage().getOMFactory();
+        if (factory != null && actualFactory != factory ||
+                soapVersion != null && !actualFactory.getSOAPVersion().getEnvelopeURI().equals(soapVersion)) {
+            throw new SOAPProcessingException("SOAP version mismatch");
+        }
     }
     
     public SOAPEnvelope getSOAPEnvelope() {

Modified: webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SpringWSTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SpringWSTestSuiteBuilder.java?rev=1727529&r1=1727528&r2=1727529&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SpringWSTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SpringWSTestSuiteBuilder.java Fri Jan 29 11:07:28 2016
@@ -32,6 +32,7 @@ import org.apache.axiom.ts.springws.scen
 import org.apache.axiom.ts.springws.soap.messagefactory.TestCreateWebServiceMessage;
 import org.apache.axiom.ts.springws.soap.messagefactory.TestCreateWebServiceMessageFromInputStream;
 import org.apache.axiom.ts.springws.soap.messagefactory.TestCreateWebServiceMessageFromInputStreamMTOM;
+import org.apache.axiom.ts.springws.soap.messagefactory.TestCreateWebServiceMessageFromInputStreamVersionMismatch;
 
 public class SpringWSTestSuiteBuilder extends MatrixTestSuiteBuilder {
     private final MessageFactoryConfigurator messageFactoryConfigurator;
@@ -59,6 +60,7 @@ public class SpringWSTestSuiteBuilder ex
     private void addSimpleTests(MessageFactoryConfigurator mfc, SOAPSpec spec) {
         addTest(new TestCreateWebServiceMessage(mfc, spec));
         addTest(new TestCreateWebServiceMessageFromInputStream(mfc, spec));
+        addTest(new TestCreateWebServiceMessageFromInputStreamVersionMismatch(mfc, spec));
     }
     
     private void addScenarioTests(ScenarioConfig config, SOAPSpec spec) {

Added: webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/soap/messagefactory/TestCreateWebServiceMessageFromInputStreamVersionMismatch.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/soap/messagefactory/TestCreateWebServiceMessageFromInputStreamVersionMismatch.java?rev=1727529&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/soap/messagefactory/TestCreateWebServiceMessageFromInputStreamVersionMismatch.java (added)
+++ webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/soap/messagefactory/TestCreateWebServiceMessageFromInputStreamVersionMismatch.java Fri Jan 29 11:07:28 2016
@@ -0,0 +1,50 @@
+/*
+ * 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.springws.soap.messagefactory;
+
+import java.io.InputStream;
+
+import org.apache.axiom.ts.soap.SOAPSampleSet;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.springws.MessageFactoryConfigurator;
+import org.apache.axiom.ts.springws.SimpleTestCase;
+import org.springframework.ws.soap.SoapMessageCreationException;
+import org.springframework.ws.soap.SoapMessageFactory;
+
+/**
+ * Tests that {@link SoapMessageFactory#createWebServiceMessage(InputStream)} throws
+ * {@link SoapMessageCreationException} if there is a mismatch between the SOAP version implied by
+ * the content type and the actual SOAP version used by the message.
+ */
+public class TestCreateWebServiceMessageFromInputStreamVersionMismatch extends SimpleTestCase {
+    public TestCreateWebServiceMessageFromInputStreamVersionMismatch(MessageFactoryConfigurator mfc, SOAPSpec spec) {
+        super(mfc, spec);
+    }
+
+    @Override
+    protected void runTest(SoapMessageFactory messageFactory) throws Throwable {
+        try {
+            messageFactory.createWebServiceMessage(
+                    new TransportInputStreamImpl(SOAPSampleSet.NO_HEADER.getMessage(spec.getAltSpec())));
+            fail("Expected SoapMessageCreationException");
+        } catch (SoapMessageCreationException ex) {
+            // Expected
+        }
+    }
+}

Propchange: webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/soap/messagefactory/TestCreateWebServiceMessageFromInputStreamVersionMismatch.java
------------------------------------------------------------------------------
    svn:eol-style = native