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(locations = { "classpath*:spring-configuration/ws/soap-ws.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));
47 final Source customRequestPayload = new StringSource(
48 "<CustomBindingExampleRequest xmlns='http://gumartinm.name/spring-ws/example'>" +
49 "<data>SCARLETT</data>" +
50 "<exampleDate>2015-06-03T10:20:30Z</exampleDate>" +
51 "<parentEnum>FIRST</parentEnum>" +
52 "</CustomBindingExampleRequest>");
53 final Source customResponsePayload = new StringSource(
54 "<ns2:CustomBindingExampleResponse xmlns:ns2='http://gumartinm.name/spring-ws/example'>" +
55 "<ns2:data>CUSTOM BINDING SNAKE EYES AND SCARLETT</ns2:data>" +
56 "<ns2:parentEnum>FIRST</ns2:parentEnum>" +
57 "</ns2:CustomBindingExampleResponse>");
58 mockClient.sendRequest(withPayload(customRequestPayload)).andExpect(
59 payload(customResponsePayload));