|
21 | 21 | import org.springframework.beans.factory.annotation.Autowired; |
22 | 22 | import org.springframework.ws.client.WebServiceTransportException; |
23 | 23 | import org.springframework.ws.test.client.MockWebServiceServer; |
24 | | -import org.springframework.ws.test.client.RequestMatchers; |
25 | | -import org.springframework.ws.test.client.ResponseCreators; |
26 | 24 | import org.springframework.ws.test.support.SourceAssertionError; |
27 | 25 | import org.springframework.xml.transform.StringSource; |
28 | 26 |
|
29 | 27 | import static org.assertj.core.api.Assertions.assertThat; |
30 | 28 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
| 29 | +import static org.springframework.ws.test.client.RequestMatchers.connectionTo; |
| 30 | +import static org.springframework.ws.test.client.RequestMatchers.payload; |
| 31 | +import static org.springframework.ws.test.client.ResponseCreators.withError; |
| 32 | +import static org.springframework.ws.test.client.ResponseCreators.withPayload; |
31 | 33 |
|
32 | 34 | /** |
33 | 35 | * Tests for {@link WebServiceClientTest @WebServiceClientTest}. |
|
38 | 40 | class WebServiceClientIntegrationTests { |
39 | 41 |
|
40 | 42 | @Autowired |
41 | | - private MockWebServiceServer mockWebServiceServer; |
| 43 | + private MockWebServiceServer server; |
42 | 44 |
|
43 | 45 | @Autowired |
44 | 46 | private ExampleWebServiceClient client; |
45 | 47 |
|
46 | 48 | @Test |
47 | 49 | void mockServerCall() { |
48 | | - this.mockWebServiceServer.expect(RequestMatchers.payload(new StringSource("<request/>"))).andRespond( |
49 | | - ResponseCreators.withPayload(new StringSource("<response><status>200</status></response>"))); |
| 50 | + this.server.expect(payload(new StringSource("<request/>"))) |
| 51 | + .andRespond(withPayload(new StringSource("<response><status>200</status></response>"))); |
50 | 52 | assertThat(this.client.test()).extracting(Response::getStatus).isEqualTo(200); |
51 | 53 | } |
52 | 54 |
|
53 | 55 | @Test |
54 | 56 | void mockServerCall1() { |
55 | | - this.mockWebServiceServer.expect(RequestMatchers.connectionTo("https://example1")) |
56 | | - .andRespond(ResponseCreators.withPayload(new StringSource("<response/>"))); |
| 57 | + this.server.expect(connectionTo("https://example1")).andRespond(withPayload(new StringSource("<response/>"))); |
57 | 58 | assertThatExceptionOfType(SourceAssertionError.class).isThrownBy(this.client::test) |
58 | 59 | .withMessageContaining("Unexpected connection expected"); |
59 | 60 | } |
60 | 61 |
|
61 | 62 | @Test |
62 | 63 | void mockServerCall2() { |
63 | | - this.mockWebServiceServer.expect(RequestMatchers.payload(new StringSource("<request/>"))) |
64 | | - .andRespond(ResponseCreators.withError("Invalid Request")); |
| 64 | + this.server.expect(payload(new StringSource("<request/>"))).andRespond(withError("Invalid Request")); |
65 | 65 | assertThatExceptionOfType(WebServiceTransportException.class).isThrownBy(this.client::test) |
66 | 66 | .withMessageContaining("Invalid Request"); |
67 | 67 | } |
|
0 commit comments