7832cb169ea89fcab7acc5d3a81f689593da466e
[SpringWebServicesForFun/.git] /
1 package de.spring.webservices.endpoints;
2
3 import static org.springframework.ws.test.server.RequestCreators.withPayload;
4 import static org.springframework.ws.test.server.ResponseMatchers.payload;
5
6 import javax.xml.transform.Source;
7
8 import org.junit.Before;
9 import org.junit.Test;
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;
17
18
19 @RunWith(SpringJUnit4ClassRunner.class)
20 @ContextConfiguration("/spring-configuration.xml")
21 public class ExampleEndPointIntegrationTest {
22
23     @Autowired
24     private ApplicationContext applicationContext;
25
26     private MockWebServiceClient mockClient;
27
28     @Before
29     public void createClient() {
30         mockClient = MockWebServiceClient.createClient(applicationContext);
31     }
32
33     @Test
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>" +
38                 "</ExampleRequest>");
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));
45     }
46 }
47