1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.test.server.integration;
18
19 import javax.xml.transform.Source;
20
21 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.context.ApplicationContext;
23 import org.springframework.test.context.ContextConfiguration;
24 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
25 import org.springframework.ws.test.server.MockWebServiceClient;
26 import org.springframework.xml.transform.StringSource;
27
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31
32 import static org.springframework.ws.test.server.RequestCreators.withPayload;
33 import static org.springframework.ws.test.server.ResponseMatchers.payload;
34
35
36
37
38 @RunWith(SpringJUnit4ClassRunner.class)
39 @ContextConfiguration("integration-test.xml")
40 public class ServerIntegrationTest {
41
42 @Autowired
43 private ApplicationContext applicationContext;
44
45 private MockWebServiceClient mockClient;
46
47 @Before
48 public void createClient() {
49 mockClient = MockWebServiceClient.createClient(applicationContext);
50 }
51
52 @Test
53 public void basic() throws Exception {
54 Source requestPayload = new StringSource("<customerCountRequest xmlns='http://springframework.org/spring-ws'>" +
55 "<customerName>John Doe</customerName>" + "</customerCountRequest>");
56 Source expectedResponsePayload = new StringSource(
57 "<customerCountResponse xmlns='http://springframework.org/spring-ws'>" +
58 "<customerCount>42</customerCount>" + "</customerCountResponse>");
59
60 mockClient.sendRequest(withPayload(requestPayload)).andExpect(payload(expectedResponsePayload));
61 }
62
63
64 }