diff --git a/test/src/main/java/org/springframework/ws/test/server/MockWebServiceClient.java b/test/src/main/java/org/springframework/ws/test/server/MockWebServiceClient.java index e131a4d3..e0ccc632 100644 --- a/test/src/main/java/org/springframework/ws/test/server/MockWebServiceClient.java +++ b/test/src/main/java/org/springframework/ws/test/server/MockWebServiceClient.java @@ -54,6 +54,47 @@ import static org.springframework.ws.test.support.AssertionErrors.fail; *

* For example: *

+ * import org.junit.*;
+ * import org.springframework.beans.factory.annotation.Autowired;
+ * import org.springframework.context.ApplicationContext;
+ * import org.springframework.test.context.ContextConfiguration;
+ * import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+ * import org.springframework.xml.transform.StringSource;
+ * import org.springframework.ws.test.server.MockWebServiceClient;
+ * import static org.springframework.ws.test.server.RequestCreators.*;
+ * import static org.springframework.ws.test.server.ResponseMatchers.*;
+ * 
+ * @RunWith(SpringJUnit4ClassRunner.class)
+ * @ContextConfiguration("applicationContext.xml")
+ * public class MyWebServiceIntegrationTest {
+ *
+ *   // a standard MessageDispatcherServlet application context, containing endpoints, mappings, etc.
+ *   @Autowired
+ *   private ApplicationContext applicationContext;
+ *
+ *   private MockWebServiceClient mockClient;
+ *
+ *   @Before
+ *   public void createClient() throws Exception {
+ *     mockClient = MockWebServiceClient.createClient(applicationContext);
+ *   }
+ *
+ *   // test the CustomerCountEndpoint, which is wired up in the application context above
+ *   // and handles <customerCount/> messages
+ *   @Test
+ *   public void customerCountEndpoint() throws Exception {
+ *     Source requestPayload = new StringSource(
+ *       "<customerCountRequest xmlns='http://springframework.org/spring-ws'>" +
+ *       "<customerName>John Doe</customerName>" +
+ *       "</customerCountRequest>");
+ *     Source expectedResponsePayload = new StringSource(
+ *       "<customerCountResponse xmlns='http://springframework.org/spring-ws'>" +
+ *       "<customerCount>42</customerCount>" +
+ *       "</customerCountResponse>");
+ *
+ *     mockClient.sendMessage(withPayload(requestPayload)).andExpect(payload(expectedResponsePayload));
+ *   }
+ * }
  * 
* * @author Arjen Poutsma diff --git a/test/src/test/java/org/springframework/ws/test/server/integration/ServerIntegrationTest.java b/test/src/test/java/org/springframework/ws/test/server/integration/ServerIntegrationTest.java index 43e96389..f9788ca5 100644 --- a/test/src/test/java/org/springframework/ws/test/server/integration/ServerIntegrationTest.java +++ b/test/src/test/java/org/springframework/ws/test/server/integration/ServerIntegrationTest.java @@ -30,7 +30,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import static org.springframework.ws.test.server.RequestCreators.withPayload; -import static org.springframework.ws.test.server.ResponseMatchers.noFault; import static org.springframework.ws.test.server.ResponseMatchers.payload; /** @@ -54,11 +53,11 @@ public class ServerIntegrationTest { public void basic() throws Exception { Source requestPayload = new StringSource("" + "John Doe" + ""); - Source responsePayload = new StringSource( + Source expectedResponsePayload = new StringSource( "" + "42" + ""); - mockClient.sendMessage(withPayload(requestPayload)).andExpect(payload(responsePayload)).andExpect(noFault()); + mockClient.sendMessage(withPayload(requestPayload)).andExpect(payload(expectedResponsePayload)); }