Java Code Examples for org.springframework.test.web.client.MockRestServiceServer.MockRestServiceServerBuilder#build()

The following examples show how to use org.springframework.test.web.client.MockRestServiceServer.MockRestServiceServerBuilder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockRestServiceServerTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void buildMultipleTimes() {
	MockRestServiceServerBuilder builder = MockRestServiceServer.bindTo(this.restTemplate);

	MockRestServiceServer server = builder.build();
	server.expect(requestTo("/foo")).andRespond(withSuccess());
	this.restTemplate.getForObject("/foo", Void.class);
	server.verify();

	server = builder.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();

	server = builder.build();
	server.expect(requestTo("/bar")).andRespond(withSuccess());
	this.restTemplate.getForObject("/bar", Void.class);
	server.verify();
}
 
Example 2
Source File: MockRestServiceServerTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void buildMultipleTimes() {
	MockRestServiceServerBuilder builder = MockRestServiceServer.bindTo(this.restTemplate);

	MockRestServiceServer server = builder.build();
	server.expect(requestTo("/foo")).andRespond(withSuccess());
	this.restTemplate.getForObject("/foo", Void.class);
	server.verify();

	server = builder.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();

	server = builder.build();
	server.expect(requestTo("/bar")).andRespond(withSuccess());
	this.restTemplate.getForObject("/bar", Void.class);
	server.verify();
}