Class DefaultResponseCreator
java.lang.Object
org.springframework.test.web.client.response.DefaultResponseCreator
- All Implemented Interfaces:
- ResponseCreator
A 
ResponseCreator with builder-style methods for adding response details.- Since:
- 3.2
- Author:
- Rossen Stoyanchev
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedDefaultResponseCreator(int statusCode) Protected constructor.protectedDefaultResponseCreator(HttpStatusCode statusCode) Protected constructor.
- 
Method SummaryModifier and TypeMethodDescriptionbody(byte[] content) Set the body as a byte array.Set the body as a UTF-8 String.Set the body from a string using the given character set.Set the body from aResource.contentType(MediaType mediaType) Set theContent-Typeheader.cookies(ResponseCookie... cookies) Add one or more cookies.cookies(MultiValueMap<String, ResponseCookie> multiValueMap) Copy all cookies from the givenMultiValueMap.createResponse(@Nullable ClientHttpRequest request) Create a response for the given request.Add a response header with one or more values.headers(HttpHeaders headers) Copy all given headers.Set theLocationheader.
- 
Constructor Details- 
DefaultResponseCreatorprotected DefaultResponseCreator(int statusCode) Protected constructor. Use static factory methods inMockRestResponseCreators.- Since:
- 5.3.17
 
- 
DefaultResponseCreatorProtected constructor. Use static factory methods inMockRestResponseCreators.
 
- 
- 
Method Details- 
bodySet the body as a UTF-8 String.
- 
bodySet the body from a string using the given character set.- Since:
- 6.0
 
- 
bodySet the body as a byte array.
- 
bodySet the body from aResource.
- 
contentTypeSet theContent-Typeheader.
- 
locationSet theLocationheader.
- 
headerAdd a response header with one or more values.- Since:
- 6.0
 
- 
headersCopy all given headers.
- 
cookiesAdd one or more cookies.- Since:
- 6.0
 
- 
cookiesCopy all cookies from the givenMultiValueMap.- Since:
- 6.0
 
- 
createResponseDescription copied from interface:ResponseCreatorCreate a response for the given request.- Specified by:
- createResponsein interface- ResponseCreator
- Parameters:
- request- the request
- Throws:
- IOException
 
 
-