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/02/02 00:25:53 UTC
svn commit: r1728022 - in
/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap:
SOAPTestSuiteBuilder.java
builder/TestCreateSOAPModelBuilderMTOMContentTypeMismatch.java
Author: veithen
Date: Mon Feb 1 23:25:53 2016
New Revision: 1728022
URL: http://svn.apache.org/viewvc?rev=1728022&view=rev
Log:
Increase test coverage for StAXSOAPModelBuilder.
Added:
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestCreateSOAPModelBuilderMTOMContentTypeMismatch.java (with props)
Modified:
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1728022&r1=1728021&r2=1728022&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Mon Feb 1 23:25:53 2016
@@ -130,6 +130,7 @@ public class SOAPTestSuiteBuilder extend
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.TestCreateSOAPModelBuilderFromDOMSource(metaFactory, spec));
+ addTest(new org.apache.axiom.ts.soap.builder.TestCreateSOAPModelBuilderMTOMContentTypeMismatch(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.builder.TestDTD(metaFactory, spec));
if (supportsOMSourcedElement) {
addTest(new org.apache.axiom.ts.soap.builder.TestRegisterCustomBuilder(metaFactory, spec));
Added: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestCreateSOAPModelBuilderMTOMContentTypeMismatch.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestCreateSOAPModelBuilderMTOMContentTypeMismatch.java?rev=1728022&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestCreateSOAPModelBuilderMTOMContentTypeMismatch.java (added)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestCreateSOAPModelBuilderMTOMContentTypeMismatch.java Mon Feb 1 23:25:53 2016
@@ -0,0 +1,105 @@
+/*
+ * 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.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.mail.Session;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.blob.Blobs;
+import org.apache.axiom.blob.MemoryBlob;
+import org.apache.axiom.mime.ContentTypeBuilder;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.soap.SOAPProcessingException;
+import org.apache.axiom.ts.soap.SOAPSample;
+import org.apache.axiom.ts.soap.SOAPSampleSet;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+import org.apache.axiom.util.UIDGenerator;
+
+/**
+ * Tests that {@link OMXMLBuilderFactory#createSOAPModelBuilder(OMMetaFactory, Attachments)}
+ * produces an error if the SOAP version used in the root part doesn't match the Content-Type of the
+ * message.
+ */
+public class TestCreateSOAPModelBuilderMTOMContentTypeMismatch extends SOAPTestCase {
+ public TestCreateSOAPModelBuilderMTOMContentTypeMismatch(OMMetaFactory metaFactory, SOAPSpec spec) {
+ super(metaFactory, spec);
+ }
+
+ @Override
+ protected void runTest() throws Throwable {
+ final SOAPSample sample = SOAPSampleSet.NO_HEADER.getMessage(spec);
+ // Generate an MTOM message with the wrong content type
+ MimeMessage message = new MimeMessage((Session)null);
+ MimeMultipart mp = new MimeMultipart("related");
+ MimeBodyPart bp = new MimeBodyPart();
+ String contentID = "<" + UIDGenerator.generateContentId() + ">";
+ bp.setDataHandler(new DataHandler(new DataSource() {
+ @Override
+ public String getContentType() {
+ return "application/xop+xml; charset=\"" + sample.getEncoding() + "\"; type=\"" + spec.getAltSpec().getContentType() + "\"";
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return sample.getInputStream();
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public OutputStream getOutputStream() {
+ throw new UnsupportedOperationException();
+ }
+ }));
+ bp.addHeader("Content-Transfer-Encoding", "binary");
+ bp.addHeader("Content-ID", contentID);
+ mp.addBodyPart(bp);
+ message.setContent(mp);
+ message.saveChanges();
+ ContentTypeBuilder contentType = new ContentTypeBuilder(message.getContentType());
+ contentType.setParameter("type", "application/xop+xml");
+ contentType.setParameter("start", contentID);
+ contentType.setParameter("start-info", spec.getAltSpec().getContentType());
+ MemoryBlob blob = Blobs.createMemoryBlob();
+ OutputStream out = blob.getOutputStream();
+ mp.writeTo(out);
+ out.close();
+ // Now attempt to create an Axiom builder
+ try {
+ OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new Attachments(blob.getInputStream(), contentType.toString()));
+ fail("Expected SOAPProcessingException");
+ } catch (SOAPProcessingException ex) {
+ // Expected
+ }
+ }
+}
Propchange: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/TestCreateSOAPModelBuilderMTOMContentTypeMismatch.java
------------------------------------------------------------------------------
svn:eol-style = native