1 package de.spring.webservices.endpoints;
3 import static org.springframework.ws.test.server.RequestCreators.withPayload;
4 import static org.springframework.ws.test.server.ResponseMatchers.payload;
6 import javax.xml.transform.Source;
8 import org.junit.Before;
10 import org.junit.runner.RunWith;
11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.context.ApplicationContext;
13 import org.springframework.test.context.ContextConfiguration;
14 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
15 import org.springframework.ws.test.server.MockWebServiceClient;
16 import org.springframework.xml.transform.StringSource;
19 @RunWith(SpringJUnit4ClassRunner.class)
20 @ContextConfiguration("/spring-configuration.xml")
21 public class ExampleEndPointIntegrationTest {
24 private ApplicationContext applicationContext;
26 private MockWebServiceClient mockClient;
29 public void createClient() {
30 mockClient = MockWebServiceClient.createClient(applicationContext);
34 public void exampleEndpoint() throws Exception {
35 final Source requestPayload = new StringSource(
36 "<ExampleRequest xmlns='http://gumartinm.name/spring-ws/example'>" +
37 "<data>SCARLETT</data>" +
39 final Source responsePayload = new StringSource(
40 "<ns2:ExampleResponse xmlns:ns2='http://gumartinm.name/spring-ws/example'>" +
41 "<ns2:data>SNAKE EYES AND SCARLETT</ns2:data>" +
42 "</ns2:ExampleResponse>");
43 mockClient.sendRequest(withPayload(requestPayload)).andExpect(
44 payload(responsePayload));