Package org.springframework.test.http
Class HttpMessageContentConverter
java.lang.Object
org.springframework.test.http.HttpMessageContentConverter
Convert HTTP message content for testing purposes.
- Since:
- 6.2
- Author:
- Stephane Nicoll
- 
Method SummaryModifier and TypeMethodDescription<T> Tconvert(HttpInputMessage message, MediaType mediaType, ResolvableType targetType) Convert the givenHttpInputMessagewhose content must match the givenMediaTypeto the requestedtargetType.<T> TconvertViaJson(Object value, ResolvableType targetType) Convert the given raw value to the giventargetTypeby writing it first to JSON and reading it back.static HttpMessageContentConverterof(Iterable<HttpMessageConverter<?>> candidates) Create an instance with an iterable of the candidates to use.static HttpMessageContentConverterof(HttpMessageConverter<?>... candidates) Create an instance with a vararg of the candidates to use.
- 
Method Details- 
ofCreate an instance with an iterable of the candidates to use.- Parameters:
- candidates- the candidates
 
- 
ofCreate an instance with a vararg of the candidates to use.- Parameters:
- candidates- the candidates
 
- 
convertpublic <T> T convert(HttpInputMessage message, MediaType mediaType, ResolvableType targetType) throws IOException, HttpMessageNotReadableException Convert the givenHttpInputMessagewhose content must match the givenMediaTypeto the requestedtargetType.- Type Parameters:
- T- the converted object type
- Parameters:
- message- an input message
- mediaType- the media type of the input
- targetType- the target type
- Returns:
- a value of the given targetType
- Throws:
- IOException
- HttpMessageNotReadableException
 
- 
convertViaJsonConvert the given raw value to the giventargetTypeby writing it first to JSON and reading it back.- Type Parameters:
- T- the converted object type
- Parameters:
- value- the value to convert
- targetType- the target type
- Returns:
- a value of the given targetType
- Throws:
- IOException
 
 
-