public class HttpTestUtils extends Object implements org.junit.rules.MethodRule, RestTemplateHolder
A rule that provides HTTP connectivity to test cases on the assumption that the server is available when test methods fire.
Modifier and Type | Class and Description |
---|---|
static class |
HttpTestUtils.UriBuilder |
Modifier and Type | Method and Description |
---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runners.model.FrameworkMethod method,
Object target) |
HttpTestUtils.UriBuilder |
buildUri(String url) |
org.springframework.web.client.RestOperations |
createRestTemplate() |
String |
getBaseUrl() |
org.springframework.http.ResponseEntity<Void> |
getForResponse(String path,
org.springframework.http.HttpHeaders headers) |
org.springframework.http.ResponseEntity<Void> |
getForResponse(String path,
org.springframework.http.HttpHeaders headers,
Map<String,String> uriVariables) |
org.springframework.http.ResponseEntity<String> |
getForString(String path) |
org.springframework.http.ResponseEntity<String> |
getForString(String path,
org.springframework.http.HttpHeaders headers) |
org.springframework.http.ResponseEntity<String> |
getForString(String path,
org.springframework.http.HttpHeaders headers,
Map<String,String> uriVariables) |
org.springframework.web.client.RestOperations |
getRestTemplate() |
org.springframework.http.HttpStatus |
getStatusCode(String path) |
org.springframework.http.HttpStatus |
getStatusCode(String path,
org.springframework.http.HttpHeaders headers) |
String |
getUrl(String path) |
org.springframework.http.ResponseEntity<Map> |
postForMap(String path,
org.springframework.http.HttpHeaders headers,
MultiValueMap<String,String> formData) |
org.springframework.http.ResponseEntity<Map> |
postForMap(String path,
MultiValueMap<String,String> formData) |
org.springframework.http.ResponseEntity<Void> |
postForRedirect(String path,
org.springframework.http.HttpHeaders headers,
MultiValueMap<String,String> params) |
org.springframework.http.ResponseEntity<Void> |
postForStatus(String path,
org.springframework.http.HttpHeaders headers,
MultiValueMap<String,String> formData) |
org.springframework.http.ResponseEntity<Void> |
postForStatus(String path,
MultiValueMap<String,String> formData) |
org.springframework.http.ResponseEntity<String> |
postForString(String path,
org.springframework.http.HttpHeaders headers,
MultiValueMap<String,String> formData) |
org.springframework.http.ResponseEntity<String> |
postForString(String path,
MultiValueMap<String,String> formData) |
HttpTestUtils |
setHostName(String hostName) |
HttpTestUtils |
setPort(int port) |
void |
setPrefix(String prefix) |
void |
setRestTemplate(org.springframework.web.client.RestOperations restTemplate) |
static HttpTestUtils |
standard() |
public static HttpTestUtils standard()
public void setPrefix(String prefix)
prefix
- public HttpTestUtils setPort(int port)
port
- the port to setpublic HttpTestUtils setHostName(String hostName)
hostName
- the hostName to setpublic org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, Object target)
apply
in interface org.junit.rules.MethodRule
public String getBaseUrl()
public org.springframework.http.ResponseEntity<String> postForString(String path, MultiValueMap<String,String> formData)
public org.springframework.http.ResponseEntity<String> postForString(String path, org.springframework.http.HttpHeaders headers, MultiValueMap<String,String> formData)
public org.springframework.http.ResponseEntity<Map> postForMap(String path, MultiValueMap<String,String> formData)
public org.springframework.http.ResponseEntity<Map> postForMap(String path, org.springframework.http.HttpHeaders headers, MultiValueMap<String,String> formData)
public org.springframework.http.ResponseEntity<Void> postForStatus(String path, MultiValueMap<String,String> formData)
public org.springframework.http.ResponseEntity<Void> postForStatus(String path, org.springframework.http.HttpHeaders headers, MultiValueMap<String,String> formData)
public org.springframework.http.ResponseEntity<Void> postForRedirect(String path, org.springframework.http.HttpHeaders headers, MultiValueMap<String,String> params)
public org.springframework.http.ResponseEntity<String> getForString(String path, org.springframework.http.HttpHeaders headers)
public org.springframework.http.ResponseEntity<String> getForString(String path, org.springframework.http.HttpHeaders headers, Map<String,String> uriVariables)
public org.springframework.http.ResponseEntity<Void> getForResponse(String path, org.springframework.http.HttpHeaders headers, Map<String,String> uriVariables)
public org.springframework.http.ResponseEntity<Void> getForResponse(String path, org.springframework.http.HttpHeaders headers)
public org.springframework.http.HttpStatus getStatusCode(String path, org.springframework.http.HttpHeaders headers)
public org.springframework.http.HttpStatus getStatusCode(String path)
public void setRestTemplate(org.springframework.web.client.RestOperations restTemplate)
setRestTemplate
in interface RestTemplateHolder
public org.springframework.web.client.RestOperations getRestTemplate()
getRestTemplate
in interface RestTemplateHolder
public org.springframework.web.client.RestOperations createRestTemplate()
public HttpTestUtils.UriBuilder buildUri(String url)
Copyright © 2014. All rights reserved.