use of org.springframework.http.HttpStatus in project spring-framework by spring-projects.
the class RestTemplateTests method varArgsNullTemplateVariable.
@Test
public void varArgsNullTemplateVariable() throws Exception {
given(requestFactory.createRequest(new URI("http://example.com/-foo"), HttpMethod.GET)).willReturn(request);
given(request.execute()).willReturn(response);
given(errorHandler.hasError(response)).willReturn(false);
HttpStatus status = HttpStatus.OK;
given(response.getStatusCode()).willReturn(status);
given(response.getStatusText()).willReturn(status.getReasonPhrase());
template.execute("http://example.com/{first}-{last}", HttpMethod.GET, null, null, null, "foo");
verify(response).close();
}
use of org.springframework.http.HttpStatus in project spring-framework by spring-projects.
the class RestTemplateTests method put.
@Test
public void put() throws Exception {
given(converter.canWrite(String.class, null)).willReturn(true);
given(requestFactory.createRequest(new URI("http://example.com"), HttpMethod.PUT)).willReturn(request);
String helloWorld = "Hello World";
converter.write(helloWorld, null, request);
given(request.execute()).willReturn(response);
given(errorHandler.hasError(response)).willReturn(false);
HttpStatus status = HttpStatus.OK;
given(response.getStatusCode()).willReturn(status);
given(response.getStatusText()).willReturn(status.getReasonPhrase());
template.put("http://example.com", helloWorld);
verify(response).close();
}
use of org.springframework.http.HttpStatus in project spring-framework by spring-projects.
the class RestTemplateTests method uriTemplateWithTrailingSlash.
// SPR-15201
@Test
public void uriTemplateWithTrailingSlash() throws Exception {
String url = "http://example.com/spring/";
given(requestFactory.createRequest(new URI(url), HttpMethod.GET)).willReturn(request);
given(request.execute()).willReturn(response);
given(errorHandler.hasError(response)).willReturn(false);
HttpStatus status = HttpStatus.OK;
given(response.getStatusCode()).willReturn(status);
given(response.getStatusText()).willReturn(status.getReasonPhrase());
template.execute(url, HttpMethod.GET, null, null);
verify(response).close();
}
use of org.springframework.http.HttpStatus in project spring-framework by spring-projects.
the class RestTemplateTests method mapTemplateVariables.
@Test
public void mapTemplateVariables() throws Exception {
given(requestFactory.createRequest(new URI("http://example.com/hotels/42/bookings/42"), HttpMethod.GET)).willReturn(request);
given(request.execute()).willReturn(response);
given(errorHandler.hasError(response)).willReturn(false);
HttpStatus status = HttpStatus.OK;
given(response.getStatusCode()).willReturn(status);
given(response.getStatusText()).willReturn(status.getReasonPhrase());
Map<String, String> vars = Collections.singletonMap("hotel", "42");
template.execute("http://example.com/hotels/{hotel}/bookings/{hotel}", HttpMethod.GET, null, null, vars);
verify(response).close();
}
use of org.springframework.http.HttpStatus in project spring-framework by spring-projects.
the class RestTemplateTests method varArgsTemplateVariables.
@Test
public void varArgsTemplateVariables() throws Exception {
given(requestFactory.createRequest(new URI("http://example.com/hotels/42/bookings/21"), HttpMethod.GET)).willReturn(request);
given(request.execute()).willReturn(response);
given(errorHandler.hasError(response)).willReturn(false);
HttpStatus status = HttpStatus.OK;
given(response.getStatusCode()).willReturn(status);
given(response.getStatusText()).willReturn(status.getReasonPhrase());
template.execute("http://example.com/hotels/{hotel}/bookings/{booking}", HttpMethod.GET, null, null, "42", "21");
verify(response).close();
}
Aggregations