diff --git a/spring-integration-samples/pom.xml b/spring-integration-samples/pom.xml index 199f424b55..d4d2f8caf3 100644 --- a/spring-integration-samples/pom.xml +++ b/spring-integration-samples/pom.xml @@ -10,6 +10,7 @@ Spring Integration Samples 2.0.0.BUILD-SNAPSHOT + 3.0.0.RELEASE cafe @@ -102,6 +103,7 @@ **/*.xml **/*.xsl + **/*.dtd @@ -175,4 +177,4 @@ - \ No newline at end of file + diff --git a/spring-integration-samples/ws-inbound-gateway/.classpath b/spring-integration-samples/ws-inbound-gateway/.classpath new file mode 100644 index 0000000000..830cc9bd58 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/.classpath @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/spring-integration-samples/ws-inbound-gateway/.project b/spring-integration-samples/ws-inbound-gateway/.project new file mode 100644 index 0000000000..23cd58e05e --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/.project @@ -0,0 +1,48 @@ + + + ws-inbound-gateway + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/spring-integration-samples/ws-inbound-gateway/.settings/.jsdtscope b/spring-integration-samples/ws-inbound-gateway/.settings/.jsdtscope new file mode 100644 index 0000000000..bbb8e68be8 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/.settings/.jsdtscope @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.jdt.core.prefs b/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..f11f831818 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Thu Feb 25 18:31:06 PST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.common.component b/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000000..759db87c8f --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.common.component @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.common.project.facet.core.xml b/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000000..3ca4f04559 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.jsdt.ui.superType.container b/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000000..3bd5d0a480 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.jsdt.ui.superType.name b/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000000..05bd71b6ec --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/spring-integration-samples/ws-inbound-gateway/.settings/org.maven.ide.eclipse.prefs b/spring-integration-samples/ws-inbound-gateway/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 0000000000..36f3af1cf1 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Thu Feb 25 18:31:04 PST 2010 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +includeModules=false +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/spring-integration-samples/ws-inbound-gateway/.settings/org.springframework.ide.eclipse.beans.core.prefs b/spring-integration-samples/ws-inbound-gateway/.settings/org.springframework.ide.eclipse.beans.core.prefs new file mode 100644 index 0000000000..f53abcb235 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/.settings/org.springframework.ide.eclipse.beans.core.prefs @@ -0,0 +1,4 @@ +#Fri Feb 26 15:19:13 PST 2010 +eclipse.preferences.version=1 +org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false +org.springframework.ide.eclipse.beans.core.loadNamespaceHandlerFromClasspath=false diff --git a/spring-integration-samples/ws-inbound-gateway/.springBeans b/spring-integration-samples/ws-inbound-gateway/.springBeans new file mode 100644 index 0000000000..1340640109 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/.springBeans @@ -0,0 +1,15 @@ + + + 1 + + + + + + + src/main/webapp/WEB-INF/spring-ws-config.xml + src/main/java/org/springframework/integration/samples/ws/inbound-gateway-config.xml + + + + diff --git a/spring-integration-samples/ws-inbound-gateway/pom.xml b/spring-integration-samples/ws-inbound-gateway/pom.xml new file mode 100644 index 0000000000..3708f2a3e3 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/pom.xml @@ -0,0 +1,65 @@ + + + + spring-integration-samples + org.springframework.integration + 2.0.0.BUILD-SNAPSHOT + + 4.0.0 + ws-inbound-gateway + ws-inbound-gateway + 2.0.0.BUILD-SNAPSHOT + war + + + javax.xml.soap + saaj-api + 1.3 + runtime + + + com.sun.xml.messaging.saaj + saaj-impl + 1.3 + runtime + + + org.springframework + spring-test + ${spring.framework.version} + test + + + junit + junit + 4.7 + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*Tests.java + + + + **/InContainerTests.java + + + + + + diff --git a/spring-integration-samples/ws-inbound-gateway/src/main/java/log4j.dtd b/spring-integration-samples/ws-inbound-gateway/src/main/java/log4j.dtd new file mode 100644 index 0000000000..d92a6e7bc6 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/src/main/java/log4j.dtd @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-integration-samples/ws-inbound-gateway/src/main/java/log4j.xml b/spring-integration-samples/ws-inbound-gateway/src/main/java/log4j.xml new file mode 100644 index 0000000000..cf78c080e5 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/src/main/java/log4j.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-integration-samples/ws-inbound-gateway/src/main/java/org/springframework/integration/samples/ws/SimpleEchoResponder.java b/spring-integration-samples/ws-inbound-gateway/src/main/java/org/springframework/integration/samples/ws/SimpleEchoResponder.java new file mode 100644 index 0000000000..e5f383283a --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/src/main/java/org/springframework/integration/samples/ws/SimpleEchoResponder.java @@ -0,0 +1,28 @@ +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed 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.springframework.integration.samples.ws; + +import javax.xml.transform.dom.DOMSource; + +import org.springframework.integration.xml.source.DomSourceFactory; + +public class SimpleEchoResponder { + public DOMSource issueResponseFor(Object request) { + return (DOMSource) new DomSourceFactory().createSource( + "hello"); + } +} diff --git a/spring-integration-samples/ws-inbound-gateway/src/main/java/org/springframework/integration/samples/ws/inbound-gateway-config.xml b/spring-integration-samples/ws-inbound-gateway/src/main/java/org/springframework/integration/samples/ws/inbound-gateway-config.xml new file mode 100644 index 0000000000..8c0644df92 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/src/main/java/org/springframework/integration/samples/ws/inbound-gateway-config.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-integration-samples/ws-inbound-gateway/src/main/webapp/WEB-INF/spring-ws-config.xml b/spring-integration-samples/ws-inbound-gateway/src/main/webapp/WEB-INF/spring-ws-config.xml new file mode 100644 index 0000000000..05dea19637 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/src/main/webapp/WEB-INF/spring-ws-config.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/spring-integration-samples/ws-inbound-gateway/src/main/webapp/WEB-INF/web.xml b/spring-integration-samples/ws-inbound-gateway/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..fdb72cf724 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,23 @@ + + + ws:inbound-gateway sample + + + spring-ws + org.springframework.ws.transport.http.MessageDispatcherServlet + + contextConfigLocation + WEB-INF/spring-ws-config.xml + + + + + spring-ws + /echoservice + + + + index.html + + + diff --git a/spring-integration-samples/ws-inbound-gateway/src/main/webapp/index.html b/spring-integration-samples/ws-inbound-gateway/src/main/webapp/index.html new file mode 100644 index 0000000000..54436ec8a2 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/src/main/webapp/index.html @@ -0,0 +1 @@ +The web service has been successfully deployed. You may now issue SOAP requests. See included JUnit tests for examples. \ No newline at end of file diff --git a/spring-integration-samples/ws-inbound-gateway/src/test/java/org/springframework/integration/samples/ws/InContainerTests.java b/spring-integration-samples/ws-inbound-gateway/src/test/java/org/springframework/integration/samples/ws/InContainerTests.java new file mode 100644 index 0000000000..ee22cbbf5d --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/src/test/java/org/springframework/integration/samples/ws/InContainerTests.java @@ -0,0 +1,56 @@ +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed 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.springframework.integration.samples.ws; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +import javax.xml.transform.Source; + +import org.junit.Test; +import org.springframework.ws.client.core.WebServiceTemplate; +import org.springframework.xml.transform.StringResult; +import org.springframework.xml.transform.StringSource; + +/** + * System tests ensuring the Spring WS MessageDispatcherServlet is correctly + * set up and configured to delegate incoming requests to our ws:inbound-gateway. + * + * Use 'mvn package' to create a war file for this project, then deploy before + * attempting to run this test. + * + * @author Chris Beams + */ +public class InContainerTests { + + private static final String WS_URI = "http://localhost:8080/ws-inbound-gateway/echoservice"; + private final WebServiceTemplate template = new WebServiceTemplate(); + + @Test + public void testWebServiceRequestAndResponse() { + StringResult result = new StringResult(); + Source payload = new StringSource( + "" + + "hello"); + + template.sendSourceAndReceiveToResult(WS_URI, payload, result); + + assertThat(result.toString(), equalTo( + "" + + "hello")); + } +} diff --git a/spring-integration-samples/ws-inbound-gateway/src/test/java/org/springframework/integration/samples/ws/InboundGatewayTests.java b/spring-integration-samples/ws-inbound-gateway/src/test/java/org/springframework/integration/samples/ws/InboundGatewayTests.java new file mode 100644 index 0000000000..411a2b82a5 --- /dev/null +++ b/spring-integration-samples/ws-inbound-gateway/src/test/java/org/springframework/integration/samples/ws/InboundGatewayTests.java @@ -0,0 +1,68 @@ +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed 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.springframework.integration.samples.ws; + +import static org.hamcrest.CoreMatchers.equalTo; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.integration.core.Message; +import org.springframework.integration.message.MessageBuilder; +import org.springframework.integration.ws.SimpleWebServiceInboundGateway; +import org.springframework.integration.xml.source.DomSourceFactory; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * Out-of-container tests for ws:inbound-gateway message processing. + * + * @author Chris Beams + */ +@ContextConfiguration("inbound-gateway-config.xml") +@RunWith(SpringJUnit4ClassRunner.class) +public class InboundGatewayTests { + + @Autowired + private SimpleWebServiceInboundGateway gateway; + + /** + * Emulate the Spring WS MessageDispatcherServlet by calling the gateway + * with a DOMSource object representing the payload of the original SOAP + * 'echoRequest' message. Expect an 'echoResponse' DOMSource object + * to be returned in synchronous fashion, which the MessageDispatcherServlet + * would in turn wrap in a SOAP envelope and return to the client. + */ + @Test + public void testSendAndReceive() { + Source source = new DomSourceFactory().createSource( + "hello"); + + Message msg = MessageBuilder.withPayload(source).build(); + + Object reply = gateway.sendAndReceive(msg); + + assertThat(reply, is(DOMSource.class)); + assertThat(((DOMSource)reply).getNode().getNodeName(), equalTo("echoResponse")); + } +} diff --git a/spring-integration-samples/ws-inbound-gateway/target/test-classes/org/springframework/integration/samples/ws/InContainerTests.class b/spring-integration-samples/ws-inbound-gateway/target/test-classes/org/springframework/integration/samples/ws/InContainerTests.class new file mode 100644 index 0000000000..8a87939aac Binary files /dev/null and b/spring-integration-samples/ws-inbound-gateway/target/test-classes/org/springframework/integration/samples/ws/InContainerTests.class differ diff --git a/spring-integration-samples/ws-inbound-gateway/target/test-classes/org/springframework/integration/samples/ws/InboundGatewayTests.class b/spring-integration-samples/ws-inbound-gateway/target/test-classes/org/springframework/integration/samples/ws/InboundGatewayTests.class new file mode 100644 index 0000000000..c85c6be192 Binary files /dev/null and b/spring-integration-samples/ws-inbound-gateway/target/test-classes/org/springframework/integration/samples/ws/InboundGatewayTests.class differ