Class DefaultResponseCreator
- java.lang.Object
 - org.springframework.test.web.client.response.DefaultResponseCreator
 
- All Implemented Interfaces:
 ResponseCreator
public class DefaultResponseCreator extends Object implements ResponseCreator
AResponseCreatorwith builder-style methods for adding response details.- Since:
 - 3.2
 - Author:
 - Rossen Stoyanchev
 
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultResponseCreator(HttpStatus statusCode)Protected constructor.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultResponseCreatorbody(byte[] content)Set the body as a byte array.DefaultResponseCreatorbody(String content)Set the body as a UTF-8 String.DefaultResponseCreatorbody(Resource resource)Set the body as aResource.DefaultResponseCreatorcontentType(MediaType mediaType)Set theContent-Typeheader.ClientHttpResponsecreateResponse(ClientHttpRequest request)Create a response for the given request.DefaultResponseCreatorheaders(HttpHeaders headers)Copy all given headers.DefaultResponseCreatorlocation(URI location)Set theLocationheader.
Constructor Detail
DefaultResponseCreator
protected DefaultResponseCreator(HttpStatus statusCode)
Protected constructor. Use static factory methods inMockRestResponseCreators.
Method Detail
body
public DefaultResponseCreator body(String content)
Set the body as a UTF-8 String.
body
public DefaultResponseCreator body(byte[] content)
Set the body as a byte array.
body
public DefaultResponseCreator body(Resource resource)
Set the body as aResource.
contentType
public DefaultResponseCreator contentType(MediaType mediaType)
Set theContent-Typeheader.
location
public DefaultResponseCreator location(URI location)
Set theLocationheader.
headers
public DefaultResponseCreator headers(HttpHeaders headers)
Copy all given headers.
createResponse
public ClientHttpResponse createResponse(ClientHttpRequest request) throws IOException
Description copied from interface:ResponseCreatorCreate a response for the given request.- Specified by:
 createResponsein interfaceResponseCreator- Parameters:
 request- the request- Throws:
 IOException