Fix hardcoded value MockRestServiceServerBuilder

This commit is contained in:
Rossen Stoyanchev
2016-06-06 08:46:50 -04:00
parent d7320f41c0
commit 998b83ce8c
2 changed files with 23 additions and 1 deletions

View File

@@ -241,7 +241,7 @@ public class MockRestServiceServer {
@Override
public MockRestServiceServerBuilder ignoreExpectOrder(boolean ignoreExpectOrder) {
this.ignoreExpectOrder = true;
this.ignoreExpectOrder = ignoreExpectOrder;
return this;
}

View File

@@ -54,6 +54,28 @@ public class MockRestServiceServerTests {
server.verify();
}
@Test(expected = AssertionError.class)
public void exactExpectOrder() throws Exception {
MockRestServiceServer server = MockRestServiceServer.bindTo(this.restTemplate)
.ignoreExpectOrder(false).build();
server.expect(requestTo("/foo")).andRespond(withSuccess());
server.expect(requestTo("/bar")).andRespond(withSuccess());
this.restTemplate.getForObject("/bar", Void.class);
}
@Test
public void ignoreExpectOrder() throws Exception {
MockRestServiceServer server = MockRestServiceServer.bindTo(this.restTemplate)
.ignoreExpectOrder(true).build();
server.expect(requestTo("/foo")).andRespond(withSuccess());
server.expect(requestTo("/bar")).andRespond(withSuccess());
this.restTemplate.getForObject("/bar", Void.class);
this.restTemplate.getForObject("/foo", Void.class);
server.verify();
}
@Test
public void resetAndReuseServer() throws Exception {
MockRestServiceServer server = MockRestServiceServer.bindTo(this.restTemplate).build();