|
|
|
|
@ -34,6 +34,7 @@ import static org.springframework.test.web.client.ExpectedCount.max;
@@ -34,6 +34,7 @@ import static org.springframework.test.web.client.ExpectedCount.max;
|
|
|
|
|
import static org.springframework.test.web.client.ExpectedCount.min; |
|
|
|
|
import static org.springframework.test.web.client.ExpectedCount.once; |
|
|
|
|
import static org.springframework.test.web.client.ExpectedCount.times; |
|
|
|
|
import static org.springframework.test.web.client.ExpectedCount.twice; |
|
|
|
|
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; |
|
|
|
|
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; |
|
|
|
|
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; |
|
|
|
|
@ -105,13 +106,15 @@ public class SimpleRequestExpectationManagerTests {
@@ -105,13 +106,15 @@ public class SimpleRequestExpectationManagerTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void repeatedRequests() throws Exception { |
|
|
|
|
this.manager.expectRequest(times(2), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess()); |
|
|
|
|
this.manager.expectRequest(times(2), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess()); |
|
|
|
|
this.manager.expectRequest(times(3), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess()); |
|
|
|
|
this.manager.expectRequest(times(3), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess()); |
|
|
|
|
|
|
|
|
|
this.manager.validateRequest(createRequest(GET, "/foo")); |
|
|
|
|
this.manager.validateRequest(createRequest(GET, "/bar")); |
|
|
|
|
this.manager.validateRequest(createRequest(GET, "/foo")); |
|
|
|
|
this.manager.validateRequest(createRequest(GET, "/bar")); |
|
|
|
|
this.manager.validateRequest(createRequest(GET, "/foo")); |
|
|
|
|
this.manager.validateRequest(createRequest(GET, "/bar")); |
|
|
|
|
this.manager.verify(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -152,9 +155,9 @@ public class SimpleRequestExpectationManagerTests {
@@ -152,9 +155,9 @@ public class SimpleRequestExpectationManagerTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void repeatedRequestsNotInOrder() throws Exception { |
|
|
|
|
this.manager.expectRequest(times(2), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess()); |
|
|
|
|
this.manager.expectRequest(times(2), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess()); |
|
|
|
|
this.manager.expectRequest(times(2), requestTo("/baz")).andExpect(method(GET)).andRespond(withSuccess()); |
|
|
|
|
this.manager.expectRequest(twice(), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess()); |
|
|
|
|
this.manager.expectRequest(twice(), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess()); |
|
|
|
|
this.manager.expectRequest(twice(), requestTo("/baz")).andExpect(method(GET)).andRespond(withSuccess()); |
|
|
|
|
|
|
|
|
|
this.thrown.expectMessage("Unexpected HttpMethod expected:<GET> but was:<POST>"); |
|
|
|
|
this.manager.validateRequest(createRequest(POST, "/foo")); |
|
|
|
|
|