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 2012/07/14 13:14:01 UTC
svn commit: r1361521 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/
axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/
axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/build...
Author: veithen
Date: Sat Jul 14 11:14:00 2012
New Revision: 1361521
URL: http://svn.apache.org/viewvc?rev=1361521&view=rev
Log:
* Consistently use SOAPProcessingException to report violations of the SOAP specs.
* Increased test coverage of StAXSOAPModelBuilder.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestDTD.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap11/processing-instruction.xml (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/processing-instruction.xml (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.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/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java?rev=1361521&r1=1361520&r2=1361521&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java Sat Jul 14 11:14:00 2012
@@ -376,12 +376,12 @@ public class StAXSOAPModelBuilder extend
/** Method createDTD. Overriding the default behaviour as a SOAPMessage should not have a DTD. */
protected OMNode createDTD() throws OMException {
- throw new OMException("SOAP message MUST NOT contain a Document Type Declaration(DTD)");
+ throw new SOAPProcessingException("SOAP message MUST NOT contain a Document Type Declaration(DTD)");
}
/** Method createPI. Overriding the default behaviour as a SOAP Message should not have a PI. */
protected OMNode createPI() throws OMException {
- throw new OMException("SOAP message MUST NOT contain Processing Instructions(PI)");
+ throw new SOAPProcessingException("SOAP message MUST NOT contain Processing Instructions(PI)");
}
// Necessary to allow SOAPBuilderHelper to access this method
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=1361521&r1=1361520&r2=1361521&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 Sat Jul 14 11:14:00 2012
@@ -31,7 +31,8 @@ import org.apache.axiom.testutils.suite.
public class SOAPTestSuiteBuilder extends TestSuiteBuilder {
private static final String[] badSOAPFiles = { "wrongSoapNs.xml", "notnamespaceQualified.xml", "soap11/twoheaders.xml", "soap11/twoBodymessage.xml",
"soap11/envelopeMissing.xml", "soap11/haederBodyWrongOrder.xml", "soap11/invalid-faultcode.xml", "soap11/invalid-faultstring.xml",
- "soap11/invalid-faultactor.xml", "soap12/header-bad-case.xml", "soap12/header-no-namespace.xml" };
+ "soap11/invalid-faultactor.xml", "soap11/processing-instruction.xml",
+ "soap12/header-bad-case.xml", "soap12/header-no-namespace.xml", "soap12/processing-instruction.xml" };
private static final String[] goodSOAPFiles = { TestConstants.WHITESPACE_MESSAGE,
TestConstants.MINIMAL_MESSAGE, TestConstants.REALLY_BIG_MESSAGE,
@@ -101,6 +102,7 @@ public class SOAPTestSuiteBuilder extend
addTest(new org.apache.axiom.ts.soap.body.TestHasFaultWithParser(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.builder.TestCommentInEpilog(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.builder.TestCommentInProlog(metaFactory, spec));
+ addTest(new org.apache.axiom.ts.soap.builder.TestDTD(metaFactory, spec));
if (supportsBodyElementNameOptimization) {
addTest(new org.apache.axiom.ts.soap.builder.TestRegisterCustomBuilderForPayloadAfterSOAPFaultCheck(metaFactory, spec));
}
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestDTD.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestDTD.java?rev=1361521&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestDTD.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestDTD.java Sat Jul 14 11:14:00 2012
@@ -0,0 +1,56 @@
+/*
+ * 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 java.io.StringReader;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.soap.SOAPModelBuilder;
+import org.apache.axiom.soap.SOAPProcessingException;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+/**
+ * Tests that the SOAP model builder rejects attempts to create a DTD. Note that this test is
+ * implemented using {@link OMXMLBuilderFactory#createStAXSOAPModelBuilder(XMLStreamReader)} because
+ * the methods taking a stream as input will generally reject DTDs at a much lower level.
+ */
+public class TestDTD extends SOAPTestCase {
+ public TestDTD(OMMetaFactory metaFactory, SOAPSpec spec) {
+ super(metaFactory, spec);
+ }
+
+ protected void runTest() throws Throwable {
+ String message = "<!DOCTYPE test []>" + soapFactory.getDefaultEnvelope();
+ XMLStreamReader parser = StAXUtils.createXMLStreamReader(new StringReader(message));
+ ;
+ try {
+ SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(metaFactory, parser);
+ // The processing must fail before we can get the SOAPEnvelope
+ builder.getSOAPEnvelope();
+ fail("Expected SOAPProcessingException");
+ } catch (SOAPProcessingException ex) {
+ // Expected
+ }
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestDTD.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap11/processing-instruction.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap11/processing-instruction.xml?rev=1361521&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap11/processing-instruction.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap11/processing-instruction.xml Sat Jul 14 11:14:00 2012
@@ -0,0 +1,7 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soapenv:Body>
+ <ns:echo xmlns:ns="urn:test">
+ <?pi some processing instruction?>
+ </ns:echo>
+ </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap11/processing-instruction.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/processing-instruction.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/processing-instruction.xml?rev=1361521&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/processing-instruction.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/processing-instruction.xml Sat Jul 14 11:14:00 2012
@@ -0,0 +1,7 @@
+<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
+ <soapenv:Body>
+ <ns:echo xmlns:ns="urn:test">
+ <?pi some processing instruction?>
+ </ns:echo>
+ </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/processing-instruction.xml
------------------------------------------------------------------------------
svn:eol-style = native