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 2014/06/17 09:54:07 UTC
svn commit: r1603081 - in /webservices/axiom/trunk:
modules/axiom-api/src/test/resources/soap/soap11/
modules/axiom-api/src/test/resources/soap/soap12/
modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/
modules/axiom-testsuite/src/main/jav...
Author: veithen
Date: Tue Jun 17 07:54:07 2014
New Revision: 1603081
URL: http://svn.apache.org/r1603081
Log:
Add some infrastructure to manage SOAP test messages.
Added:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapter.java (with props)
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapterFactory.java (with props)
webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedTestMessage.java (with props)
webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SimpleTestMessage.java
- copied, changed from r1603080, webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/MessageTest.java
webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessage.java (with props)
webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageSet.java (with props)
webservices/axiom/trunk/testsuites/soap-testsuite/src/main/resources/
webservices/axiom/trunk/testsuites/soap-testsuite/src/main/resources/test-message/
webservices/axiom/trunk/testsuites/soap-testsuite/src/main/resources/test-message/set/
webservices/axiom/trunk/testsuites/soap-testsuite/src/main/resources/test-message/set/no-header.xml (contents, props changed)
- copied, changed from r1603080, webservices/axiom/trunk/modules/axiom-api/src/test/resources/soap/soap12/message_without_header.xml
Removed:
webservices/axiom/trunk/modules/axiom-api/src/test/resources/soap/soap11/message_without_header.xml
webservices/axiom/trunk/modules/axiom-api/src/test/resources/soap/soap12/message_without_header.xml
Modified:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/MessageTest.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestAddHeaderToIncompleteEnvelope.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetHeaderWithParserNoHeader.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeaderWithParserNoHeader.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestSerialize.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestSerialize.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/resources/META-INF/services/org.apache.axiom.ts.soap.AdapterFactory
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java?rev=1603081&r1=1603080&r2=1603081&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java Tue Jun 17 07:54:07 2014
@@ -34,7 +34,6 @@ import org.xml.sax.InputSource;
public abstract class SOAPTestCase extends AxiomTestCase {
protected static final String MESSAGE = "message.xml";
- protected static final String MESSAGE_WITHOUT_HEADER = "message_without_header.xml";
protected static final String SOAP_MESSAGE = "soapmessage.xml";
protected final SOAPSpec spec;
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1603081&r1=1603080&r2=1603081&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Tue Jun 17 07:54:07 2014
@@ -40,13 +40,23 @@ public class SOAPTestSuiteBuilder extend
"soap12/header-bad-case.xml", "soap12/header-no-namespace.xml", "soap12/processing-instruction.xml", "soap12/entity-reference.xml",
"soap12/additional-element-after-body.xml"};
- private static final String[] goodSOAPFiles = { TestConstants.WHITESPACE_MESSAGE,
- TestConstants.MINIMAL_MESSAGE, TestConstants.REALLY_BIG_MESSAGE,
- TestConstants.EMPTY_BODY_MESSAGE, "soap/soap11/soapfault.xml", "soap/soap11/soapfault2.xml", "soap/soap11/bodyNotQualified.xml",
- "soap/soap11/message.xml", "soap/soap12/message.xml",
- "soap/soap11/faultelements-with-comment.xml", "soap/soap11/additional-element-after-body.xml",
- "soap/soap11/message_without_header.xml", "soap/soap12/message_without_header.xml",
- "soap/soap11/empty-header.xml", "soap/soap12/empty-header.xml" };
+ private static final TestMessage[] goodSOAPFiles = {
+ new SimpleTestMessage(SOAPSpec.SOAP11, TestConstants.WHITESPACE_MESSAGE),
+ new SimpleTestMessage(SOAPSpec.SOAP11, TestConstants.MINIMAL_MESSAGE),
+ new SimpleTestMessage(SOAPSpec.SOAP11, TestConstants.REALLY_BIG_MESSAGE),
+ new SimpleTestMessage(SOAPSpec.SOAP11, TestConstants.EMPTY_BODY_MESSAGE),
+ new SimpleTestMessage(SOAPSpec.SOAP11, "soap/soap11/soapfault.xml"),
+ new SimpleTestMessage(SOAPSpec.SOAP11, "soap/soap11/soapfault2.xml"),
+ new SimpleTestMessage(SOAPSpec.SOAP11, "soap/soap11/bodyNotQualified.xml"),
+ new SimpleTestMessage(SOAPSpec.SOAP11, "soap/soap11/message.xml"),
+ new SimpleTestMessage(SOAPSpec.SOAP12, "soap/soap12/message.xml"),
+ new SimpleTestMessage(SOAPSpec.SOAP11, "soap/soap11/faultelements-with-comment.xml"),
+ new SimpleTestMessage(SOAPSpec.SOAP11, "soap/soap11/additional-element-after-body.xml"),
+ TestMessageSet.NO_HEADER.getMessage(SOAPSpec.SOAP11),
+ TestMessageSet.NO_HEADER.getMessage(SOAPSpec.SOAP12),
+ new SimpleTestMessage(SOAPSpec.SOAP11, "soap/soap11/empty-header.xml"),
+ new SimpleTestMessage(SOAPSpec.SOAP12, "soap/soap12/empty-header.xml"),
+ };
private static final QName[] generalQNames = {
new QName("root"),
Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapter.java?rev=1603081&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapter.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapter.java Tue Jun 17 07:54:07 2014
@@ -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.soap;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.util.StAXParserConfiguration;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPModelBuilder;
+import org.junit.Assert;
+import org.xml.sax.InputSource;
+
+/**
+ * {@link TestMessage} adapter that adds some Axiom specific methods to retrieve the content of the
+ * test message.
+ */
+public final class TestMessageAdapter {
+ private final TestMessage testMessage;
+
+ TestMessageAdapter(TestMessage testMessage) {
+ this.testMessage = testMessage;
+ }
+
+ public SOAPModelBuilder getBuilder(OMMetaFactory metaFactory) {
+ return metaFactory.createSOAPModelBuilder(StAXParserConfiguration.SOAP, new InputSource(testMessage.getInputStream()));
+ }
+
+ public SOAPEnvelope getSOAPEnvelope(OMMetaFactory metaFactory) {
+ SOAPEnvelope envelope = getBuilder(metaFactory).getSOAPEnvelope();
+ // TODO: this is not the right place to assert this
+ Assert.assertSame(testMessage.getSOAPSpec().getEnvelopeNamespaceURI(), ((SOAPFactory)envelope.getOMFactory()).getSoapVersionURI());
+ return envelope;
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapterFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapterFactory.java?rev=1603081&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapterFactory.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapterFactory.java Tue Jun 17 07:54:07 2014
@@ -0,0 +1,25 @@
+/*
+ * 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;
+
+public class TestMessageAdapterFactory implements AdapterFactory<TestMessage> {
+ public void createAdapters(TestMessage testMessage, Adapters adapters) {
+ adapters.add(TestMessageAdapter.class, new TestMessageAdapter(testMessage));
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapterFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/MessageTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/MessageTest.java?rev=1603081&r1=1603080&r2=1603081&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/MessageTest.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/MessageTest.java Tue Jun 17 07:54:07 2014
@@ -18,24 +18,24 @@
*/
package org.apache.axiom.ts.soap.builder;
-import org.apache.axiom.om.AbstractTestCase;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.ts.AxiomTestCase;
+import org.apache.axiom.ts.soap.TestMessage;
public class MessageTest extends AxiomTestCase {
- private final String file;
+ private final TestMessage message;
- public MessageTest(OMMetaFactory metaFactory, String file) {
+ public MessageTest(OMMetaFactory metaFactory, TestMessage message) {
super(metaFactory);
- this.file = file;
- addTestParameter("file", file);
+ this.message = message;
+ addTestParameter("message", message.getName());
}
protected void runTest() throws Throwable {
SOAPEnvelope soapEnvelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory,
- AbstractTestCase.getTestResource(file), null).getSOAPEnvelope();
+ message.getInputStream(), null).getSOAPEnvelope();
OMTestUtils.walkThrough(soapEnvelope);
soapEnvelope.close(false);
}
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestAddHeaderToIncompleteEnvelope.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestAddHeaderToIncompleteEnvelope.java?rev=1603081&r1=1603080&r2=1603081&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestAddHeaderToIncompleteEnvelope.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestAddHeaderToIncompleteEnvelope.java Tue Jun 17 07:54:07 2014
@@ -23,6 +23,8 @@ import org.apache.axiom.soap.SOAPEnvelop
import org.apache.axiom.soap.SOAPHeader;
import org.apache.axiom.ts.soap.SOAPSpec;
import org.apache.axiom.ts.soap.SOAPTestCase;
+import org.apache.axiom.ts.soap.TestMessageAdapter;
+import org.apache.axiom.ts.soap.TestMessageSet;
/**
* Test the behavior when adding a header to an envelope that has not yet been built completely.
@@ -34,7 +36,7 @@ public class TestAddHeaderToIncompleteEn
}
protected void runTest() throws Throwable {
- SOAPEnvelope envelope = getTestMessage(MESSAGE_WITHOUT_HEADER);
+ SOAPEnvelope envelope = TestMessageSet.NO_HEADER.getMessage(spec).getAdapter(TestMessageAdapter.class).getSOAPEnvelope(metaFactory);
assertNull(envelope.getHeader());
SOAPHeader header = soapFactory.createSOAPHeader(envelope);
assertSame(header, envelope.getHeader());
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetHeaderWithParserNoHeader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetHeaderWithParserNoHeader.java?rev=1603081&r1=1603080&r2=1603081&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetHeaderWithParserNoHeader.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetHeaderWithParserNoHeader.java Tue Jun 17 07:54:07 2014
@@ -23,6 +23,8 @@ import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.ts.soap.SOAPSpec;
import org.apache.axiom.ts.soap.SOAPTestCase;
+import org.apache.axiom.ts.soap.TestMessageAdapter;
+import org.apache.axiom.ts.soap.TestMessageSet;
/**
* Tests the behavior of {@link SOAPEnvelope#getHeader()} on a message that has no header. In
@@ -34,7 +36,7 @@ public class TestGetHeaderWithParserNoHe
}
protected void runTest() throws Throwable {
- SOAPEnvelope envelope = getTestMessage(MESSAGE_WITHOUT_HEADER);
+ SOAPEnvelope envelope = TestMessageSet.NO_HEADER.getMessage(spec).getAdapter(TestMessageAdapter.class).getSOAPEnvelope(metaFactory);
assertNull(envelope.getHeader());
assertFalse(envelope.getBody().isComplete());
}
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeaderWithParserNoHeader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeaderWithParserNoHeader.java?rev=1603081&r1=1603080&r2=1603081&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeaderWithParserNoHeader.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetOrCreateHeaderWithParserNoHeader.java Tue Jun 17 07:54:07 2014
@@ -24,6 +24,8 @@ import org.apache.axiom.soap.SOAPEnvelop
import org.apache.axiom.soap.SOAPHeader;
import org.apache.axiom.ts.soap.SOAPSpec;
import org.apache.axiom.ts.soap.SOAPTestCase;
+import org.apache.axiom.ts.soap.TestMessageAdapter;
+import org.apache.axiom.ts.soap.TestMessageSet;
/**
* Tests the behavior of {@link SOAPEnvelope#getOrCreateHeader()} on a message that has no header.
@@ -36,7 +38,7 @@ public class TestGetOrCreateHeaderWithPa
}
protected void runTest() throws Throwable {
- SOAPEnvelope envelope = getTestMessage(MESSAGE_WITHOUT_HEADER);
+ SOAPEnvelope envelope = TestMessageSet.NO_HEADER.getMessage(spec).getAdapter(TestMessageAdapter.class).getSOAPEnvelope(metaFactory);
SOAPHeader header = envelope.getOrCreateHeader();
assertNotNull(header);
assertSame(envelope.getFirstElement(), header);
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestSerialize.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestSerialize.java?rev=1603081&r1=1603080&r2=1603081&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestSerialize.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestSerialize.java Tue Jun 17 07:54:07 2014
@@ -18,39 +18,39 @@
*/
package org.apache.axiom.ts.soap.envelope;
-import org.apache.axiom.om.AbstractTestCase;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.ts.AxiomTestCase;
import org.apache.axiom.ts.dimension.ExpansionStrategy;
import org.apache.axiom.ts.dimension.serialization.SerializationStrategy;
+import org.apache.axiom.ts.soap.TestMessage;
import org.custommonkey.xmlunit.XMLAssert;
import org.custommonkey.xmlunit.XMLUnit;
import org.xml.sax.InputSource;
public class TestSerialize extends AxiomTestCase {
- private final String file;
+ private final TestMessage testMessage;
private final ExpansionStrategy expansionStrategy;
private final SerializationStrategy serializationStrategy;
- public TestSerialize(OMMetaFactory metaFactory, String file,
+ public TestSerialize(OMMetaFactory metaFactory, TestMessage testMessage,
ExpansionStrategy expansionStrategy, SerializationStrategy serializationStrategy) {
super(metaFactory);
- this.file = file;
+ this.testMessage = testMessage;
this.expansionStrategy = expansionStrategy;
this.serializationStrategy = serializationStrategy;
- addTestParameter("file", file);
+ addTestParameter("message", testMessage.getName());
expansionStrategy.addTestParameters(this);
serializationStrategy.addTestParameters(this);
}
protected void runTest() throws Throwable {
SOAPEnvelope soapEnvelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory,
- AbstractTestCase.getTestResource(file), null).getSOAPEnvelope();
+ testMessage.getInputStream(), null).getSOAPEnvelope();
expansionStrategy.apply(soapEnvelope);
XMLAssert.assertXMLIdentical(XMLUnit.compareXML(
- new InputSource(AbstractTestCase.getTestResource(file)),
+ new InputSource(testMessage.getInputStream()),
serializationStrategy.serialize(soapEnvelope).getInputSource()), true);
soapEnvelope.close(false);
}
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestSerialize.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestSerialize.java?rev=1603081&r1=1603080&r2=1603081&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestSerialize.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestSerialize.java Tue Jun 17 07:54:07 2014
@@ -18,39 +18,39 @@
*/
package org.apache.axiom.ts.soap.message;
-import org.apache.axiom.om.AbstractTestCase;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.soap.SOAPMessage;
import org.apache.axiom.ts.AxiomTestCase;
import org.apache.axiom.ts.dimension.ExpansionStrategy;
import org.apache.axiom.ts.dimension.serialization.SerializationStrategy;
+import org.apache.axiom.ts.soap.TestMessage;
import org.custommonkey.xmlunit.XMLAssert;
import org.custommonkey.xmlunit.XMLUnit;
import org.xml.sax.InputSource;
public class TestSerialize extends AxiomTestCase {
- private final String file;
+ private final TestMessage testMessage;
private final ExpansionStrategy expansionStrategy;
private final SerializationStrategy serializationStrategy;
- public TestSerialize(OMMetaFactory metaFactory, String file,
+ public TestSerialize(OMMetaFactory metaFactory, TestMessage testMessage,
ExpansionStrategy expansionStrategy, SerializationStrategy serializationStrategy) {
super(metaFactory);
- this.file = file;
+ this.testMessage = testMessage;
this.expansionStrategy = expansionStrategy;
this.serializationStrategy = serializationStrategy;
- addTestParameter("file", file);
+ addTestParameter("message", testMessage.getName());
expansionStrategy.addTestParameters(this);
serializationStrategy.addTestParameters(this);
}
protected void runTest() throws Throwable {
SOAPMessage message = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory,
- AbstractTestCase.getTestResource(file), null).getSOAPMessage();
+ testMessage.getInputStream(), null).getSOAPMessage();
expansionStrategy.apply(message);
XMLAssert.assertXMLIdentical(XMLUnit.compareXML(
- new InputSource(AbstractTestCase.getTestResource(file)),
+ new InputSource(testMessage.getInputStream()),
serializationStrategy.serialize(message).getInputSource()), true);
message.close(false);
}
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/resources/META-INF/services/org.apache.axiom.ts.soap.AdapterFactory
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/resources/META-INF/services/org.apache.axiom.ts.soap.AdapterFactory?rev=1603081&r1=1603080&r2=1603081&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/resources/META-INF/services/org.apache.axiom.ts.soap.AdapterFactory (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/resources/META-INF/services/org.apache.axiom.ts.soap.AdapterFactory Tue Jun 17 07:54:07 2014
@@ -1,2 +1,3 @@
org.apache.axiom.ts.soap.BooleanAttributeAdapterFactory
-org.apache.axiom.ts.soap.SOAPSpecAdapterFactory
\ No newline at end of file
+org.apache.axiom.ts.soap.SOAPSpecAdapterFactory
+org.apache.axiom.ts.soap.TestMessageAdapterFactory
\ No newline at end of file
Added: webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedTestMessage.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedTestMessage.java?rev=1603081&view=auto
==============================================================================
--- webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedTestMessage.java (added)
+++ webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedTestMessage.java Tue Jun 17 07:54:07 2014
@@ -0,0 +1,101 @@
+/*
+ * 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;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+final class ConvertedTestMessage extends TestMessage {
+ private final TestMessage soap12Message;
+ private byte[] content;
+
+ ConvertedTestMessage(TestMessage soap12Message, String name) {
+ super(SOAPSpec.SOAP11, name);
+ this.soap12Message = soap12Message;
+ }
+
+ @Override
+ public synchronized InputStream getInputStream() {
+ if (content == null) {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ Document document;
+ InputStream in = soap12Message.getInputStream();
+ try {
+ document = factory.newDocumentBuilder().parse(in);
+ } finally {
+ in.close();
+ }
+ processEnvelope(document.getDocumentElement());
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ TransformerFactory.newInstance().newTransformer().transform(
+ new DOMSource(document),
+ new StreamResult(baos));
+ content = baos.toByteArray();
+ } catch (Exception ex) {
+ throw new Error("Error converting SOAP message");
+ }
+ }
+ return new ByteArrayInputStream(content);
+ }
+
+ private static void processEnvelope(Element envelope) {
+ NodeList children = changeSOAPNamespace(envelope).getChildNodes();
+ for (int i=0; i<children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ Element childElement = (Element)child;
+ String localName = childElement.getLocalName();
+ if (localName.equals("Header")) {
+ processHeader(childElement);
+ } else if (localName.equals("Body")) {
+ processBody(childElement);
+ }
+ }
+ }
+ }
+
+ private static void processHeader(Element header) {
+ changeSOAPNamespace(header);
+ // TODO: need to transform mustUnderstand attributes
+ }
+
+ private static void processBody(Element body) {
+ changeSOAPNamespace(body);
+ }
+
+ private static Element changeSOAPNamespace(Element element) {
+ if (!SOAPSpec.SOAP12.getEnvelopeNamespaceURI().equals(element.getNamespaceURI())) {
+ throw new Error("Unexpected namespace");
+ }
+ return (Element)element.getOwnerDocument().renameNode(element, SOAPSpec.SOAP11.getEnvelopeNamespaceURI(), element.getTagName());
+ }
+}
Propchange: webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedTestMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SimpleTestMessage.java (from r1603080, webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/MessageTest.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SimpleTestMessage.java?p2=webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SimpleTestMessage.java&p1=webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/MessageTest.java&r1=1603080&r2=1603081&rev=1603081&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/builder/MessageTest.java (original)
+++ webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SimpleTestMessage.java Tue Jun 17 07:54:07 2014
@@ -16,27 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.axiom.ts.soap.builder;
+package org.apache.axiom.ts.soap;
-import org.apache.axiom.om.AbstractTestCase;
-import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMXMLBuilderFactory;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.ts.AxiomTestCase;
+import java.io.InputStream;
-public class MessageTest extends AxiomTestCase {
- private final String file;
+// TODO: this should eventually have package access
+public final class SimpleTestMessage extends TestMessage {
+ private final String resourceName;
- public MessageTest(OMMetaFactory metaFactory, String file) {
- super(metaFactory);
- this.file = file;
- addTestParameter("file", file);
+ public SimpleTestMessage(SOAPSpec spec, String resourceName) {
+ this(spec, resourceName, resourceName);
+ }
+
+ SimpleTestMessage(SOAPSpec spec, String resourceName, String name) {
+ super(spec, name);
+ this.resourceName = resourceName;
}
- protected void runTest() throws Throwable {
- SOAPEnvelope soapEnvelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory,
- AbstractTestCase.getTestResource(file), null).getSOAPEnvelope();
- OMTestUtils.walkThrough(soapEnvelope);
- soapEnvelope.close(false);
+ @Override
+ public InputStream getInputStream() {
+ return SimpleTestMessage.class.getClassLoader().getResourceAsStream(resourceName);
}
}
Added: webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessage.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessage.java?rev=1603081&view=auto
==============================================================================
--- webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessage.java (added)
+++ webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessage.java Tue Jun 17 07:54:07 2014
@@ -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;
+
+import java.io.InputStream;
+
+/**
+ * A SOAP test message.
+ */
+public abstract class TestMessage extends Adaptable {
+ private final SOAPSpec spec;
+ private final String name;
+
+ TestMessage(SOAPSpec spec, String name) {
+ this.spec = spec;
+ this.name = name;
+ }
+
+ /**
+ * Get the SOAP version of this message.
+ *
+ * @return the SOAP specification version
+ */
+ public final SOAPSpec getSOAPSpec() {
+ return spec;
+ }
+
+ /**
+ * Get the name of this message (for use in test case naming e.g.).
+ *
+ * @return the name of this test message
+ */
+ public final String getName() {
+ return name;
+ }
+
+ /**
+ * Get the content of this message.
+ *
+ * @return an input stream with the content of this message
+ */
+ public abstract InputStream getInputStream();
+}
Propchange: webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageSet.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageSet.java?rev=1603081&view=auto
==============================================================================
--- webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageSet.java (added)
+++ webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageSet.java Tue Jun 17 07:54:07 2014
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+/**
+ * A set of two equivalent SOAP messages, one for SOAP 1.1 and one for SOAP 1.2.
+ */
+public final class TestMessageSet extends Adaptable {
+ /**
+ * A simple SOAP message without header.
+ */
+ public static final TestMessageSet NO_HEADER = new TestMessageSet("no-header");
+
+ private final TestMessage soap11Message;
+ private final TestMessage soap12Message;
+
+ private TestMessageSet(String name) {
+ soap12Message = new SimpleTestMessage(SOAPSpec.SOAP12, "test-message/set/" + name + ".xml", "soap12/" + name);
+ soap11Message = new ConvertedTestMessage(soap12Message, "soap11/" + name);
+ }
+
+ /**
+ * Get the test message for the given SOAP version.
+ *
+ * @param spec
+ * the SOAP specification version
+ * @return the test message
+ */
+ public TestMessage getMessage(SOAPSpec spec) {
+ return spec == SOAPSpec.SOAP11 ? soap11Message : soap12Message;
+ }
+}
Propchange: webservices/axiom/trunk/testsuites/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageSet.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: webservices/axiom/trunk/testsuites/soap-testsuite/src/main/resources/test-message/set/no-header.xml (from r1603080, webservices/axiom/trunk/modules/axiom-api/src/test/resources/soap/soap12/message_without_header.xml)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testsuites/soap-testsuite/src/main/resources/test-message/set/no-header.xml?p2=webservices/axiom/trunk/testsuites/soap-testsuite/src/main/resources/test-message/set/no-header.xml&p1=webservices/axiom/trunk/modules/axiom-api/src/test/resources/soap/soap12/message_without_header.xml&r1=1603080&r2=1603081&rev=1603081&view=diff
==============================================================================
(empty)
Propchange: webservices/axiom/trunk/testsuites/soap-testsuite/src/main/resources/test-message/set/no-header.xml
------------------------------------------------------------------------------
svn:eol-style = native