|
16 | 16 |
|
17 | 17 | package org.springframework.test.web.client;
|
18 | 18 |
|
| 19 | +import java.net.SocketException; |
19 | 20 | import java.net.URI;
|
20 | 21 | import java.net.URISyntaxException;
|
21 | 22 |
|
|
30 | 31 | import static org.junit.Assert.assertEquals;
|
31 | 32 | import static org.springframework.http.HttpMethod.GET;
|
32 | 33 | import static org.springframework.http.HttpMethod.POST;
|
| 34 | +import static org.springframework.test.util.AssertionErrors.fail; |
33 | 35 | import static org.springframework.test.web.client.ExpectedCount.max;
|
34 | 36 | import static org.springframework.test.web.client.ExpectedCount.min;
|
35 | 37 | import static org.springframework.test.web.client.ExpectedCount.once;
|
@@ -184,6 +186,23 @@ public void repeatedRequestsInSequentialOrder() throws Exception {
|
184 | 186 | this.manager.validateRequest(createRequest(GET, "/bar"));
|
185 | 187 | }
|
186 | 188 |
|
| 189 | + @Test // SPR-16132 |
| 190 | + public void sequentialRequestsWithFirstFailing() throws Exception { |
| 191 | + this.manager.expectRequest(once(), requestTo("/foo")).andExpect(method(GET)) |
| 192 | + .andRespond(request -> { throw new SocketException("pseudo network error"); }); |
| 193 | + this.manager.expectRequest(once(), requestTo("/handle-error")).andExpect(method(POST)).andRespond(withSuccess()); |
| 194 | + |
| 195 | + try { |
| 196 | + this.manager.validateRequest(createRequest(GET, "/foo")); |
| 197 | + fail("expected exception"); |
| 198 | + } |
| 199 | + catch (SocketException e) { |
| 200 | + //expected |
| 201 | + } |
| 202 | + this.manager.validateRequest(createRequest(POST, "/handle-error")); |
| 203 | + this.manager.verify(); |
| 204 | + } |
| 205 | + |
187 | 206 |
|
188 | 207 | private ClientHttpRequest createRequest(HttpMethod method, String url) {
|
189 | 208 | try {
|
|
0 commit comments