use of cn.taketoday.web.client.RestTemplate in project today-infrastructure by TAKETODAY.
the class ErrorHandlerIntegrationTests method responseBodyError.
@ParameterizedHttpServerTest
void responseBodyError(HttpServer httpServer) throws Exception {
startServer(httpServer);
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
URI url = new URI("http://localhost:" + port + "/response-body-error");
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
}
use of cn.taketoday.web.client.RestTemplate in project today-infrastructure by TAKETODAY.
the class AsyncIntegrationTests method basicTest.
@ParameterizedHttpServerTest
void basicTest(HttpServer httpServer) throws Exception {
startServer(httpServer);
URI url = new URI("http://localhost:" + port);
ResponseEntity<String> response = new RestTemplate().exchange(RequestEntity.get(url).build(), String.class);
assertThat(response.getBody()).isEqualTo("hello");
}
use of cn.taketoday.web.client.RestTemplate in project today-infrastructure by TAKETODAY.
the class ContentRequestMatchersIntegrationTests method setup.
@BeforeEach
public void setup() {
List<HttpMessageConverter<?>> converters = new ArrayList<>();
converters.add(new StringHttpMessageConverter());
converters.add(new MappingJackson2HttpMessageConverter());
this.restTemplate = new RestTemplate();
this.restTemplate.setMessageConverters(converters);
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
use of cn.taketoday.web.client.RestTemplate in project today-infrastructure by TAKETODAY.
the class SampleTests method repeatedAccessToResponseViaResource.
// SPR-14694
@Test
public void repeatedAccessToResponseViaResource() {
Resource resource = new ClassPathResource("ludwig.json", this.getClass());
RestTemplate restTemplate = new RestTemplate();
restTemplate.setInterceptors(Collections.singletonList(new ContentInterceptor(resource)));
MockRestServiceServer mockServer = MockRestServiceServer.bindTo(restTemplate).ignoreExpectOrder(true).bufferContent().build();
mockServer.expect(requestTo("/composers/42")).andExpect(method(HttpMethod.GET)).andRespond(withSuccess(resource, MediaType.APPLICATION_JSON));
restTemplate.getForObject("/composers/{id}", Person.class, 42);
mockServer.verify();
}
use of cn.taketoday.web.client.RestTemplate in project today-infrastructure by TAKETODAY.
the class SampleTests method setup.
@BeforeEach
public void setup() {
this.restTemplate = new RestTemplate();
this.mockServer = MockRestServiceServer.bindTo(this.restTemplate).ignoreExpectOrder(true).build();
}
Aggregations