org.springframework.web.client.support.RestGatewaySupport Java Examples

The following examples show how to use org.springframework.web.client.support.RestGatewaySupport. 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: GreetingsClientTest.java    From bootiful-testing-online-training with Apache License 2.0 6 votes vote down vote up
@Test
public void greet() throws Exception {

	String yoJosh = "yo josh";
	String json = this.objectMapper.writeValueAsString(new Greeting(yoJosh));

	RestGatewaySupport restGatewaySupport = new RestGatewaySupport();
	restGatewaySupport.setRestTemplate(this.restTemplate);

	MockRestServiceServer server = MockRestServiceServer.createServer(this.restTemplate);

	server
		.expect(once(), requestTo("http://localhost:8080/greetings/josh"))
		.andRespond(withSuccess(json, MediaType.APPLICATION_JSON_UTF8));

	Greeting yoToJosh = this.greetingsClient.greet("josh");
	Assert.assertEquals(yoToJosh.getGreeting(), yoJosh);

	server.verify();
}
 
Example #2
Source File: MockRestServiceServer.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Return a builder for a {@code MockRestServiceServer} that should be used
 * to reply to the given {@code RestGatewaySupport}.
 * @since 4.3
 */
public static MockRestServiceServerBuilder bindTo(RestGatewaySupport restGateway) {
	Assert.notNull(restGateway, "'gatewaySupport' must not be null");
	return new DefaultBuilder(restGateway.getRestTemplate());
}
 
Example #3
Source File: MockRestServiceServer.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * A shortcut for {@code bindTo(restGateway).build()}.
 * @param restGateway the REST gateway to set up for mock testing
 * @return the created mock server
 */
public static MockRestServiceServer createServer(RestGatewaySupport restGateway) {
	return bindTo(restGateway).build();
}
 
Example #4
Source File: MockRestServiceServer.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Return a builder for a {@code MockRestServiceServer} that should be used
 * to reply to the given {@code RestGatewaySupport}.
 * @since 4.3
 */
public static MockRestServiceServerBuilder bindTo(RestGatewaySupport restGateway) {
	Assert.notNull(restGateway, "'gatewaySupport' must not be null");
	return new DefaultBuilder(restGateway.getRestTemplate());
}
 
Example #5
Source File: MockRestServiceServer.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * A shortcut for {@code bindTo(restGateway).build()}.
 * @param restGateway the REST gateway to set up for mock testing
 * @return the created mock server
 */
public static MockRestServiceServer createServer(RestGatewaySupport restGateway) {
	return bindTo(restGateway).build();
}
 
Example #6
Source File: MockRestServiceServer.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a {@code MockRestServiceServer} and set up the given
 * {@code RestGatewaySupport} with a mock {@link ClientHttpRequestFactory}.
 * @param restGateway the REST gateway to set up for mock testing
 * @return the created mock server
 */
public static MockRestServiceServer createServer(RestGatewaySupport restGateway) {
	Assert.notNull(restGateway, "'gatewaySupport' must not be null");
	return createServer(restGateway.getRestTemplate());
}