use of org.springframework.http.client.ClientHttpResponse in project spring-boot by spring-projects.
the class RestTemplateExchangeTagsTests method outcomeTagIsSuccessWhenResponseIs2xx.
@Test
void outcomeTagIsSuccessWhenResponseIs2xx() {
ClientHttpResponse response = new MockClientHttpResponse("foo".getBytes(), HttpStatus.OK);
Tag tag = RestTemplateExchangeTags.outcome(response);
assertThat(tag.getValue()).isEqualTo("SUCCESS");
}
use of org.springframework.http.client.ClientHttpResponse in project spring-boot by spring-projects.
the class RestTemplateExchangeTagsTests method outcomeTagIsRedirectionWhenResponseIs3xx.
@Test
void outcomeTagIsRedirectionWhenResponseIs3xx() {
ClientHttpResponse response = new MockClientHttpResponse("foo".getBytes(), HttpStatus.MOVED_PERMANENTLY);
Tag tag = RestTemplateExchangeTags.outcome(response);
assertThat(tag.getValue()).isEqualTo("REDIRECTION");
}
use of org.springframework.http.client.ClientHttpResponse in project spring-boot by spring-projects.
the class RestTemplateExchangeTagsTests method outcomeTagIsClientErrorWhenResponseIsNonStandardInClientSeries.
@Test
void outcomeTagIsClientErrorWhenResponseIsNonStandardInClientSeries() throws IOException {
ClientHttpResponse response = mock(ClientHttpResponse.class);
given(response.getRawStatusCode()).willReturn(490);
Tag tag = RestTemplateExchangeTags.outcome(response);
assertThat(tag.getValue()).isEqualTo("CLIENT_ERROR");
}
use of org.springframework.http.client.ClientHttpResponse in project spring-boot by spring-projects.
the class HttpHeaderInterceptorTests method intercept.
@Test
void intercept() throws IOException {
given(this.execution.execute(this.request, this.body)).willReturn(this.response);
ClientHttpResponse result = this.interceptor.intercept(this.request, this.body, this.execution);
assertThat(this.request.getHeaders().getFirst(this.name)).isEqualTo(this.value);
assertThat(result).isEqualTo(this.response);
}
use of org.springframework.http.client.ClientHttpResponse in project spring-boot by spring-projects.
the class DelayedLiveReloadTrigger method isUp.
private boolean isUp() {
try {
ClientHttpRequest request = createRequest();
ClientHttpResponse response = request.execute();
return response.getStatusCode() == HttpStatus.OK;
} catch (Exception ex) {
return false;
}
}
Aggregations