diff --git a/samples/echo/client/saaj/src/org/springframework/ws/samples/echo/client/saaj/EchoClient.java b/samples/echo/client/saaj/src/main/java/org/springframework/ws/samples/echo/client/saaj/EchoClient.java similarity index 96% rename from samples/echo/client/saaj/src/org/springframework/ws/samples/echo/client/saaj/EchoClient.java rename to samples/echo/client/saaj/src/main/java/org/springframework/ws/samples/echo/client/saaj/EchoClient.java index 5761a569..a8ee4f25 100644 --- a/samples/echo/client/saaj/src/org/springframework/ws/samples/echo/client/saaj/EchoClient.java +++ b/samples/echo/client/saaj/src/main/java/org/springframework/ws/samples/echo/client/saaj/EchoClient.java @@ -87,11 +87,13 @@ public class EchoClient { SOAPBodyElement echoResponseElement = (SOAPBodyElement) message .getSOAPBody().getChildElements(echoResponseName).next(); String echoValue = echoResponseElement.getTextContent(); + System.out.println(); System.out.println("Echo Response [" + echoValue + "]"); + System.out.println(); } public static void main(String[] args) throws Exception { - String url = "http://localhost:8080/echo/services"; + String url = "http://localhost:8080/echo-server/services"; if (args.length > 0) { url = args[0]; } diff --git a/samples/echo/client/spring-ws/src/org/springframework/ws/samples/echo/client/sws/EchoClient.java b/samples/echo/client/spring-ws/src/main/java/org/springframework/ws/samples/echo/client/sws/EchoClient.java similarity index 96% rename from samples/echo/client/spring-ws/src/org/springframework/ws/samples/echo/client/sws/EchoClient.java rename to samples/echo/client/spring-ws/src/main/java/org/springframework/ws/samples/echo/client/sws/EchoClient.java index 1d8e5de7..6eb79a92 100644 --- a/samples/echo/client/spring-ws/src/org/springframework/ws/samples/echo/client/sws/EchoClient.java +++ b/samples/echo/client/spring-ws/src/main/java/org/springframework/ws/samples/echo/client/sws/EchoClient.java @@ -38,7 +38,9 @@ public class EchoClient extends WebServiceGatewaySupport { Source requestSource = new ResourceSource(request); StringResult result = new StringResult(); getWebServiceTemplate().sendSourceAndReceiveToResult(requestSource, result); + System.out.println(); System.out.println(result); + System.out.println(); } public static void main(String[] args) throws IOException { diff --git a/samples/echo/client/spring-ws/src/log4j.properties b/samples/echo/client/spring-ws/src/main/resources/log4j.properties similarity index 100% rename from samples/echo/client/spring-ws/src/log4j.properties rename to samples/echo/client/spring-ws/src/main/resources/log4j.properties diff --git a/samples/echo/client/spring-ws/src/org/springframework/ws/samples/echo/client/sws/applicationContext.xml b/samples/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/applicationContext.xml similarity index 84% rename from samples/echo/client/spring-ws/src/org/springframework/ws/samples/echo/client/sws/applicationContext.xml rename to samples/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/applicationContext.xml index 699494da..21376fc1 100644 --- a/samples/echo/client/spring-ws/src/org/springframework/ws/samples/echo/client/sws/applicationContext.xml +++ b/samples/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/applicationContext.xml @@ -1,9 +1,9 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/samples/echo/client/spring-ws/src/org/springframework/ws/samples/echo/client/sws/echoRequest.xml b/samples/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/echoRequest.xml similarity index 100% rename from samples/echo/client/spring-ws/src/org/springframework/ws/samples/echo/client/sws/echoRequest.xml rename to samples/echo/client/spring-ws/src/main/resources/org/springframework/ws/samples/echo/client/sws/echoRequest.xml diff --git a/samples/echo/pom.xml b/samples/echo/server/pom.xml similarity index 51% rename from samples/echo/pom.xml rename to samples/echo/server/pom.xml index 8044d861..32c3fefd 100644 --- a/samples/echo/pom.xml +++ b/samples/echo/server/pom.xml @@ -1,14 +1,14 @@ - spring-ws-samples + echo org.springframework.ws 2.0.0-M1-SNAPSHOT - ../samples/pom.xml + ../pom.xml 4.0.0 - echo + echo-server war - Spring WS Echo Sample + Spring WS Echo Sample - Server A minimal Spring-WS sample that uses W3C DOM to echo back an incoming string. @@ -21,41 +21,18 @@ javax.xml.stream stax-api + + javax.xml.soap + saaj-api + - - - - maven-javadoc-plugin - - ${basedir}/../../src/main/javadoc/javadoc.css - - - - org.springframework.ws spring-ws-core - - - easymock - easymock - 1.2_Java1.3 - test - - - xerces - xercesImpl - 2.8.1 - - - xalan - xalan - 2.7.0 - \ No newline at end of file diff --git a/samples/echo/src/main/java/org/springframework/ws/samples/echo/service/EchoService.java b/samples/echo/server/src/main/java/org/springframework/ws/samples/echo/service/EchoService.java similarity index 100% rename from samples/echo/src/main/java/org/springframework/ws/samples/echo/service/EchoService.java rename to samples/echo/server/src/main/java/org/springframework/ws/samples/echo/service/EchoService.java diff --git a/samples/echo/src/main/java/org/springframework/ws/samples/echo/service/impl/EchoServiceImpl.java b/samples/echo/server/src/main/java/org/springframework/ws/samples/echo/service/impl/EchoServiceImpl.java similarity index 100% rename from samples/echo/src/main/java/org/springframework/ws/samples/echo/service/impl/EchoServiceImpl.java rename to samples/echo/server/src/main/java/org/springframework/ws/samples/echo/service/impl/EchoServiceImpl.java diff --git a/samples/echo/src/main/java/org/springframework/ws/samples/echo/ws/EchoEndpoint.java b/samples/echo/server/src/main/java/org/springframework/ws/samples/echo/ws/EchoEndpoint.java similarity index 96% rename from samples/echo/src/main/java/org/springframework/ws/samples/echo/ws/EchoEndpoint.java rename to samples/echo/server/src/main/java/org/springframework/ws/samples/echo/ws/EchoEndpoint.java index 0f91fd4e..781fe8e5 100755 --- a/samples/echo/src/main/java/org/springframework/ws/samples/echo/ws/EchoEndpoint.java +++ b/samples/echo/server/src/main/java/org/springframework/ws/samples/echo/ws/EchoEndpoint.java @@ -64,6 +64,7 @@ public class EchoEndpoint extends AbstractDomPayloadEndpoint { * @param document a DOM document to be used for constructing Nodes * @return the response element */ + @Override protected Element invokeInternal(Element requestElement, Document document) throws Exception { Assert.isTrue(NAMESPACE_URI.equals(requestElement.getNamespaceURI()), "Invalid namespace"); Assert.isTrue(ECHO_REQUEST_LOCAL_NAME.equals(requestElement.getLocalName()), "Invalid local name"); diff --git a/samples/echo/src/main/resources/log4j.properties b/samples/echo/server/src/main/resources/log4j.properties similarity index 100% rename from samples/echo/src/main/resources/log4j.properties rename to samples/echo/server/src/main/resources/log4j.properties diff --git a/samples/echo/src/main/webapp/WEB-INF/echo.xsd b/samples/echo/server/src/main/webapp/WEB-INF/echo.xsd similarity index 100% rename from samples/echo/src/main/webapp/WEB-INF/echo.xsd rename to samples/echo/server/src/main/webapp/WEB-INF/echo.xsd diff --git a/samples/echo/src/main/webapp/WEB-INF/spring-ws-servlet.xml b/samples/echo/server/src/main/webapp/WEB-INF/spring-ws-servlet.xml similarity index 100% rename from samples/echo/src/main/webapp/WEB-INF/spring-ws-servlet.xml rename to samples/echo/server/src/main/webapp/WEB-INF/spring-ws-servlet.xml diff --git a/samples/echo/src/main/webapp/WEB-INF/web.xml b/samples/echo/server/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from samples/echo/src/main/webapp/WEB-INF/web.xml rename to samples/echo/server/src/main/webapp/WEB-INF/web.xml diff --git a/samples/echo/src/test/java/org/springframework/ws/samples/echo/ws/EchoEndpointTest.java b/samples/echo/server/src/test/java/org/springframework/ws/samples/echo/ws/EchoEndpointTest.java similarity index 73% rename from samples/echo/src/test/java/org/springframework/ws/samples/echo/ws/EchoEndpointTest.java rename to samples/echo/server/src/test/java/org/springframework/ws/samples/echo/ws/EchoEndpointTest.java index c75e3bb8..afadfd87 100644 --- a/samples/echo/src/test/java/org/springframework/ws/samples/echo/ws/EchoEndpointTest.java +++ b/samples/echo/server/src/test/java/org/springframework/ws/samples/echo/ws/EchoEndpointTest.java @@ -19,15 +19,18 @@ package org.springframework.ws.samples.echo.ws; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import org.custommonkey.xmlunit.XMLTestCase; -import org.easymock.MockControl; +import org.springframework.ws.samples.echo.service.EchoService; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; -import org.springframework.ws.samples.echo.service.EchoService; +import static org.easymock.EasyMock.*; -public class EchoEndpointTest extends XMLTestCase { +public class EchoEndpointTest { private EchoEndpoint endpoint; @@ -35,23 +38,21 @@ public class EchoEndpointTest extends XMLTestCase { private Document responseDocument; - private MockControl control; - private EchoService mock; - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { endpoint = new EchoEndpoint(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); requestDocument = documentBuilder.newDocument(); responseDocument = documentBuilder.newDocument(); - control = MockControl.createControl(EchoService.class); - mock = (EchoService) control.getMock(); + mock = createMock(EchoService.class); endpoint.setEchoService(mock); } + @Test public void testInvokeInternal() throws Exception { Element echoRequest = requestDocument.createElementNS(EchoEndpoint.NAMESPACE_URI, EchoEndpoint.ECHO_REQUEST_LOCAL_NAME); @@ -59,14 +60,17 @@ public class EchoEndpointTest extends XMLTestCase { Text requestText = requestDocument.createTextNode(content); echoRequest.appendChild(requestText); String result = "DEF"; - control.expectAndReturn(mock.echo(content), result); - control.replay(); + expect(mock.echo(content)).andReturn(result); + + replay(mock); + Element echoResponse = endpoint.invokeInternal(echoRequest, responseDocument); - assertEquals("Invalid namespace", EchoEndpoint.NAMESPACE_URI, echoResponse.getNamespaceURI()); - assertEquals("Invalid namespace", EchoEndpoint.ECHO_RESPONSE_LOCAL_NAME, echoResponse.getLocalName()); + Assert.assertEquals("Invalid namespace", EchoEndpoint.NAMESPACE_URI, echoResponse.getNamespaceURI()); + Assert.assertEquals("Invalid namespace", EchoEndpoint.ECHO_RESPONSE_LOCAL_NAME, echoResponse.getLocalName()); Text responseText = (Text) echoResponse.getChildNodes().item(0); - assertEquals("Invalid content", result, responseText.getNodeValue()); - control.verify(); + Assert.assertEquals("Invalid content", result, responseText.getNodeValue()); + + verify(mock); } } \ No newline at end of file diff --git a/samples/echo/src/test/resources/log4j.properties b/samples/echo/server/src/test/resources/log4j.properties similarity index 100% rename from samples/echo/src/test/resources/log4j.properties rename to samples/echo/server/src/test/resources/log4j.properties diff --git a/samples/pom.xml b/samples/pom.xml index ea8f86ec..602f6cc5 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -18,50 +18,6 @@ stockquote airline - - - spring-milestone - Spring Milestone Repository - http://s3.amazonaws.com/maven.springframework.org/milestone - - - - - jdk15 - - !1.6 - - - - javax.xml.bind - jaxb-api - provided - true - 2.1 - - - javax.xml.stream - stax-api - - - javax.activation - activation - - - - - com.sun.xml.bind - jaxb-impl - 2.1.5 - provided - - - javax.activation - activation - - - - @@ -78,7 +34,7 @@ - + log4j log4j diff --git a/samples/readme.txt b/samples/readme.txt index 7c1f6eb6..8d542f99 100644 --- a/samples/readme.txt +++ b/samples/readme.txt @@ -10,6 +10,7 @@ Sample table of contents * stock - Shows how to use WS-Addressing and the Java 6 HTTP Server * tutorial - Contains the code from the Spring-WS tutorial -Most of these samples can be run by using the Jetty Web container. Simply issue -the "mvn jetty:run" command in one of the sample directories. Alternatively, -you can build deployable war archives using "mvn package". +Except the tutorial, all of these samples consist of a separate 'server' and 'client' project. +The server projects can be run using the "mvn jetty:run" command, or by using "mvn package" and deploying the resulting +war archives to a Web Container. +The client projects are typically command-line projects, and can by started by issuing the 'mvn exec:java' command. \ No newline at end of file