Polishing
This commit is contained in:
@@ -81,17 +81,13 @@ public class DecoderHttpMessageReader<T> implements HttpMessageReader<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<T> read(ResolvableType elementType, ReactiveHttpInputMessage message,
|
||||
Map<String, Object> hints) {
|
||||
|
||||
public Flux<T> read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) {
|
||||
MediaType contentType = getContentType(message);
|
||||
return this.decoder.decode(message.getBody(), elementType, contentType, hints);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<T> readMono(ResolvableType elementType, ReactiveHttpInputMessage message,
|
||||
Map<String, Object> hints) {
|
||||
|
||||
public Mono<T> readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) {
|
||||
MediaType contentType = getContentType(message);
|
||||
return this.decoder.decodeToMono(message.getBody(), elementType, contentType, hints);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import reactor.core.publisher.Mono;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.codec.Encoder;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpOutputMessage;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
@@ -92,17 +91,15 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> {
|
||||
|
||||
@Override
|
||||
public Mono<Void> write(Publisher<? extends T> inputStream, ResolvableType elementType,
|
||||
MediaType mediaType, ReactiveHttpOutputMessage message,
|
||||
Map<String, Object> hints) {
|
||||
MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints) {
|
||||
|
||||
MediaType contentType = updateContentType(message, mediaType);
|
||||
DataBufferFactory factory = message.bufferFactory();
|
||||
|
||||
Flux<DataBuffer> body = this.encoder.encode(inputStream, factory, elementType, contentType, hints);
|
||||
Flux<DataBuffer> body = this.encoder.encode(
|
||||
inputStream, message.bufferFactory(), elementType, contentType, hints);
|
||||
|
||||
return isStreamingMediaType(contentType) ?
|
||||
message.writeAndFlushWith(body.map(Flux::just)) :
|
||||
message.writeWith(body);
|
||||
return (isStreamingMediaType(contentType) ?
|
||||
message.writeAndFlushWith(body.map(Flux::just)) : message.writeWith(body));
|
||||
}
|
||||
|
||||
private MediaType updateContentType(ReactiveHttpOutputMessage message, MediaType mediaType) {
|
||||
@@ -120,8 +117,8 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> {
|
||||
}
|
||||
|
||||
private static boolean useFallback(MediaType main, MediaType fallback) {
|
||||
return main == null || !main.isConcrete() ||
|
||||
main.equals(MediaType.APPLICATION_OCTET_STREAM) && fallback != null;
|
||||
return (main == null || !main.isConcrete() ||
|
||||
main.equals(MediaType.APPLICATION_OCTET_STREAM) && fallback != null);
|
||||
}
|
||||
|
||||
private static MediaType addDefaultCharset(MediaType main, MediaType defaultType) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -53,7 +53,6 @@ public class FormHttpMessageReader implements HttpMessageReader<MultiValueMap<St
|
||||
private static final ResolvableType MULTIVALUE_TYPE =
|
||||
ResolvableType.forClassWithGenerics(MultiValueMap.class, String.class, String.class);
|
||||
|
||||
|
||||
private Charset defaultCharset = DEFAULT_CHARSET;
|
||||
|
||||
|
||||
@@ -63,7 +62,7 @@ public class FormHttpMessageReader implements HttpMessageReader<MultiValueMap<St
|
||||
* <p>By default this is set to "UTF-8".
|
||||
*/
|
||||
public void setDefaultCharset(Charset charset) {
|
||||
Assert.notNull(charset, "'charset' must not be null");
|
||||
Assert.notNull(charset, "Charset must not be null");
|
||||
this.defaultCharset = charset;
|
||||
}
|
||||
|
||||
@@ -77,8 +76,8 @@ public class FormHttpMessageReader implements HttpMessageReader<MultiValueMap<St
|
||||
|
||||
@Override
|
||||
public boolean canRead(ResolvableType elementType, MediaType mediaType) {
|
||||
return MULTIVALUE_TYPE.isAssignableFrom(elementType) &&
|
||||
(mediaType == null || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType));
|
||||
return (MULTIVALUE_TYPE.isAssignableFrom(elementType) &&
|
||||
(mediaType == null || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,7 +62,7 @@ public class FormHttpMessageWriter implements HttpMessageWriter<MultiValueMap<St
|
||||
* <p>By default this is set to "UTF-8".
|
||||
*/
|
||||
public void setDefaultCharset(Charset charset) {
|
||||
Assert.notNull(charset, "'charset' must not be null");
|
||||
Assert.notNull(charset, "Charset must not be null");
|
||||
this.defaultCharset = charset;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ public interface HttpMessageDecoder<T> extends Decoder<T> {
|
||||
/**
|
||||
* Get decoding hints based on the server request or annotations on the
|
||||
* target controller method parameter.
|
||||
*
|
||||
* @param actualType the actual target type to decode to, possibly a reactive
|
||||
* wrapper and sourced from {@link org.springframework.core.MethodParameter},
|
||||
* i.e. providing access to method parameter annotations.
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
|
||||
|
||||
/**
|
||||
* Extension of {@code Encoder} exposing extra methods relevant in the context
|
||||
* of HTTP request or response body encoding.
|
||||
@@ -45,7 +44,6 @@ public interface HttpMessageEncoder<T> extends Encoder<T> {
|
||||
/**
|
||||
* Get decoding hints based on the server request or annotations on the
|
||||
* target controller method parameter.
|
||||
*
|
||||
* @param actualType the actual source type to encode, possibly a reactive
|
||||
* wrapper and sourced from {@link org.springframework.core.MethodParameter},
|
||||
* i.e. providing access to method annotations.
|
||||
|
||||
@@ -57,7 +57,6 @@ public interface HttpMessageReader<T> {
|
||||
|
||||
/**
|
||||
* Read from the input message and encode to a stream of objects.
|
||||
*
|
||||
* @param elementType the type of objects in the stream which must have been
|
||||
* previously checked via {@link #canRead(ResolvableType, MediaType)}
|
||||
* @param message the message to read from
|
||||
@@ -68,7 +67,6 @@ public interface HttpMessageReader<T> {
|
||||
|
||||
/**
|
||||
* Read from the input message and encode to a single object.
|
||||
*
|
||||
* @param elementType the type of objects in the stream which must have been
|
||||
* previously checked via {@link #canRead(ResolvableType, MediaType)}
|
||||
* @param message the message to read from
|
||||
@@ -79,12 +77,11 @@ public interface HttpMessageReader<T> {
|
||||
|
||||
/**
|
||||
* Server-side only alternative to
|
||||
* {@link #read(ResolvableType, ReactiveHttpInputMessage, Map)} with
|
||||
* additional context available.
|
||||
*
|
||||
* @param actualType the actual type of the target method parameter; for
|
||||
* annotated controllers, the {@link MethodParameter} can be accessed via
|
||||
* {@link ResolvableType#getSource()}.
|
||||
* {@link #read(ResolvableType, ReactiveHttpInputMessage, Map)}
|
||||
* with additional context available.
|
||||
* @param actualType the actual type of the target method parameter;
|
||||
* for annotated controllers, the {@link MethodParameter} can be accessed
|
||||
* via {@link ResolvableType#getSource()}.
|
||||
* @param elementType the type of Objects in the output stream
|
||||
* @param request the current request
|
||||
* @param response the current response
|
||||
@@ -99,12 +96,11 @@ public interface HttpMessageReader<T> {
|
||||
|
||||
/**
|
||||
* Server-side only alternative to
|
||||
* {@link #readMono(ResolvableType, ReactiveHttpInputMessage, Map)} with
|
||||
* additional, context available.
|
||||
*
|
||||
* @param actualType the actual type of the target method parameter; for
|
||||
* annotated controllers, the {@link MethodParameter} can be accessed via
|
||||
* {@link ResolvableType#getSource()}.
|
||||
* {@link #readMono(ResolvableType, ReactiveHttpInputMessage, Map)}
|
||||
* with additional, context available.
|
||||
* @param actualType the actual type of the target method parameter;
|
||||
* for annotated controllers, the {@link MethodParameter} can be accessed
|
||||
* via {@link ResolvableType#getSource()}.
|
||||
* @param elementType the type of Objects in the output stream
|
||||
* @param request the current request
|
||||
* @param response the current response
|
||||
|
||||
@@ -69,7 +69,6 @@ public interface HttpMessageWriter<T> {
|
||||
Mono<Void> write(Publisher<? extends T> inputStream, ResolvableType elementType,
|
||||
MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints);
|
||||
|
||||
|
||||
/**
|
||||
* Server-side only alternative to
|
||||
* {@link #write(Publisher, ResolvableType, MediaType, ReactiveHttpOutputMessage, Map)}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,14 +26,14 @@ import javax.xml.bind.Unmarshaller;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Holder for {@link JAXBContext} isntances.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 5.0
|
||||
*/
|
||||
final class JaxbContextContainer {
|
||||
|
||||
|
||||
private final ConcurrentMap<Class<?>, JAXBContext> jaxbContexts =
|
||||
new ConcurrentHashMap<>(64);
|
||||
private final ConcurrentMap<Class<?>, JAXBContext> jaxbContexts = new ConcurrentHashMap<>(64);
|
||||
|
||||
|
||||
public Marshaller createMarshaller(Class<?> clazz) throws JAXBException {
|
||||
@@ -47,7 +47,7 @@ final class JaxbContextContainer {
|
||||
}
|
||||
|
||||
private JAXBContext getJaxbContext(Class<?> clazz) throws JAXBException {
|
||||
Assert.notNull(clazz, "'clazz' must not be null");
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
JAXBContext jaxbContext = this.jaxbContexts.get(clazz);
|
||||
if (jaxbContext == null) {
|
||||
jaxbContext = JAXBContext.newInstance(clazz);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -109,9 +109,9 @@ public class HttpMessageConverterExtractor<T> implements ResponseExtractor<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(IOException | HttpMessageNotReadableException exc) {
|
||||
throw new RestClientException("Error while extracting response for type ["
|
||||
+ this.responseType + "] and content type [" + contentType + "]", exc);
|
||||
catch (IOException | HttpMessageNotReadableException ex) {
|
||||
throw new RestClientException("Error while extracting response for type [" +
|
||||
this.responseType + "] and content type [" + contentType + "]", ex);
|
||||
}
|
||||
|
||||
throw new RestClientException("Could not extract response: no suitable HttpMessageConverter found " +
|
||||
|
||||
@@ -102,7 +102,7 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
outputMessage.getHeaders().getContentType());
|
||||
}
|
||||
|
||||
@Test(expected = HttpMessageNotReadableException.class)
|
||||
@Test(expected = IOException.class)
|
||||
public void readInvalidXml() throws IOException {
|
||||
String body = "FooBar";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8"));
|
||||
@@ -154,7 +154,7 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8"));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "xml"));
|
||||
|
||||
this.thrown.expect(HttpMessageNotReadableException.class);
|
||||
this.thrown.expect(IOException.class);
|
||||
this.converter.read(MyBean.class, inputMessage);
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8"));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "xml"));
|
||||
|
||||
this.thrown.expect(HttpMessageNotReadableException.class);
|
||||
this.thrown.expect(IOException.class);
|
||||
this.converter.read(MyBean.class, inputMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,21 +35,23 @@ public class ServerResponseResultHandler implements HandlerResultHandler {
|
||||
|
||||
private final HandlerStrategies strategies;
|
||||
|
||||
|
||||
/**
|
||||
* Create a {@code ResponseResultHandler} with default strategies.
|
||||
* Create a {@code ServerResponseResultHandler} with default strategies.
|
||||
*/
|
||||
public ServerResponseResultHandler() {
|
||||
this(HandlerStrategies.builder().build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@code ResponseResultHandler} with the given strategies.
|
||||
* Create a {@code ServerResponseResultHandler} with the given strategies.
|
||||
*/
|
||||
public ServerResponseResultHandler(HandlerStrategies strategies) {
|
||||
Assert.notNull(strategies, "'strategies' must not be null");
|
||||
Assert.notNull(strategies, "HandlerStrategies must not be null");
|
||||
this.strategies = strategies;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean supports(HandlerResult result) {
|
||||
return result.getReturnValue()
|
||||
@@ -59,8 +61,8 @@ public class ServerResponseResultHandler implements HandlerResultHandler {
|
||||
|
||||
@Override
|
||||
public Mono<Void> handleResult(ServerWebExchange exchange, HandlerResult result) {
|
||||
ServerResponse response = (ServerResponse) result.getReturnValue().orElseThrow(
|
||||
IllegalStateException::new);
|
||||
ServerResponse response = (ServerResponse) result.getReturnValue().orElseThrow(IllegalStateException::new);
|
||||
return response.writeTo(exchange, this.strategies);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.reactive.result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -54,15 +55,11 @@ public abstract class HandlerResultHandlerSupport implements Ordered {
|
||||
private int order = LOWEST_PRECEDENCE;
|
||||
|
||||
|
||||
protected HandlerResultHandlerSupport(RequestedContentTypeResolver contentTypeResolver) {
|
||||
this(contentTypeResolver, new ReactiveAdapterRegistry());
|
||||
}
|
||||
|
||||
protected HandlerResultHandlerSupport(RequestedContentTypeResolver contentTypeResolver,
|
||||
ReactiveAdapterRegistry adapterRegistry) {
|
||||
|
||||
Assert.notNull(contentTypeResolver, "'contentTypeResolver' is required.");
|
||||
Assert.notNull(adapterRegistry, "'adapterRegistry' is required.");
|
||||
Assert.notNull(contentTypeResolver, "RequestedContentTypeResolver is required");
|
||||
Assert.notNull(adapterRegistry, "ReactiveAdapterRegistry is required");
|
||||
this.contentTypeResolver = contentTypeResolver;
|
||||
this.adapterRegistry = adapterRegistry;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -84,8 +83,8 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
||||
ReactiveAdapterRegistry adapterRegistry) {
|
||||
|
||||
super(adapterRegistry);
|
||||
Assert.notEmpty(messageReaders, "At least one HttpMessageReader is required.");
|
||||
Assert.notNull(adapterRegistry, "'adapterRegistry' is required");
|
||||
Assert.notEmpty(messageReaders, "At least one HttpMessageReader is required");
|
||||
Assert.notNull(adapterRegistry, "ReactiveAdapterRegistry is required");
|
||||
this.messageReaders = messageReaders;
|
||||
this.supportedMediaTypes = messageReaders.stream()
|
||||
.flatMap(converter -> converter.getReadableMediaTypes().stream())
|
||||
@@ -156,13 +155,12 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
||||
}
|
||||
|
||||
private Throwable handleReadError(MethodParameter parameter, Throwable ex) {
|
||||
return ex instanceof DecodingException ?
|
||||
new ServerWebInputException("Failed to read HTTP message", parameter, ex) : ex;
|
||||
return (ex instanceof DecodingException ?
|
||||
new ServerWebInputException("Failed to read HTTP message", parameter, ex) : ex);
|
||||
}
|
||||
|
||||
private ServerWebInputException handleMissingBody(MethodParameter parameter) {
|
||||
Method method = parameter.getMethod();
|
||||
return new ServerWebInputException("Request body is missing: " + method.toGenericString());
|
||||
private ServerWebInputException handleMissingBody(MethodParameter param) {
|
||||
return new ServerWebInputException("Request body is missing: " + param.getMethod().toGenericString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,32 +51,27 @@ public abstract class AbstractMessageWriterResultHandler extends HandlerResultHa
|
||||
/**
|
||||
* Constructor with {@link HttpMessageWriter}s and a
|
||||
* {@code RequestedContentTypeResolver}.
|
||||
*
|
||||
* @param messageWriters for serializing Objects to the response body stream
|
||||
* @param contentTypeResolver for resolving the requested content type
|
||||
*/
|
||||
protected AbstractMessageWriterResultHandler(List<HttpMessageWriter<?>> messageWriters,
|
||||
RequestedContentTypeResolver contentTypeResolver) {
|
||||
|
||||
super(contentTypeResolver);
|
||||
Assert.notEmpty(messageWriters, "At least one message writer is required.");
|
||||
this.messageWriters = messageWriters;
|
||||
this(messageWriters, contentTypeResolver, new ReactiveAdapterRegistry());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with an additional {@link ReactiveAdapterRegistry}.
|
||||
*
|
||||
* @param messageWriters for serializing Objects to the response body stream
|
||||
* @param contentTypeResolver for resolving the requested content type
|
||||
* @param adapterRegistry for adapting other reactive types (e.g. rx.Observable,
|
||||
* rx.Single, etc.) to Flux or Mono
|
||||
*/
|
||||
protected AbstractMessageWriterResultHandler(List<HttpMessageWriter<?>> messageWriters,
|
||||
RequestedContentTypeResolver contentTypeResolver,
|
||||
ReactiveAdapterRegistry adapterRegistry) {
|
||||
RequestedContentTypeResolver contentTypeResolver, ReactiveAdapterRegistry adapterRegistry) {
|
||||
|
||||
super(contentTypeResolver, adapterRegistry);
|
||||
Assert.notEmpty(messageWriters, "At least one message writer is required.");
|
||||
Assert.notEmpty(messageWriters, "At least one message writer is required");
|
||||
this.messageWriters = messageWriters;
|
||||
}
|
||||
|
||||
@@ -124,8 +119,7 @@ public abstract class AbstractMessageWriterResultHandler extends HandlerResultHa
|
||||
}
|
||||
else {
|
||||
if (getProducibleMediaTypes(elementType).isEmpty()) {
|
||||
return Mono.error(new IllegalStateException(
|
||||
"No converter for return value type: " + elementType));
|
||||
return Mono.error(new IllegalStateException("No converter for return value type: " + elementType));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.ReactiveAdapterRegistry;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerWebExchange;
|
||||
@@ -31,28 +31,17 @@ import org.springframework.web.reactive.accept.FixedContentTypeResolver;
|
||||
import org.springframework.web.reactive.accept.HeaderContentTypeResolver;
|
||||
import org.springframework.web.reactive.accept.RequestedContentTypeResolver;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.http.MediaType.ALL;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8;
|
||||
import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM;
|
||||
import static org.springframework.http.MediaType.IMAGE_GIF;
|
||||
import static org.springframework.http.MediaType.IMAGE_JPEG;
|
||||
import static org.springframework.http.MediaType.IMAGE_PNG;
|
||||
import static org.springframework.http.MediaType.TEXT_PLAIN;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.http.MediaType.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link HandlerResultHandlerSupport}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class HandlerResultHandlerTests {
|
||||
|
||||
private TestResultHandler resultHandler;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
this.resultHandler = new TestResultHandler();
|
||||
}
|
||||
private final TestResultHandler resultHandler = new TestResultHandler();
|
||||
|
||||
|
||||
@Test
|
||||
@@ -116,7 +105,7 @@ public class HandlerResultHandlerTests {
|
||||
}
|
||||
|
||||
public TestResultHandler(RequestedContentTypeResolver contentTypeResolver) {
|
||||
super(contentTypeResolver);
|
||||
super(contentTypeResolver, new ReactiveAdapterRegistry());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -156,8 +156,8 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
||||
* @param inputMessage the input messages. Used to inspect the {@code Accept} header.
|
||||
* @param outputMessage the output message to write to
|
||||
* @throws IOException thrown in case of I/O errors
|
||||
* @throws HttpMediaTypeNotAcceptableException thrown when the conditions indicated by {@code Accept} header on
|
||||
* the request cannot be met by the message converters
|
||||
* @throws HttpMediaTypeNotAcceptableException thrown when the conditions indicated
|
||||
* by the {@code Accept} header on the request cannot be met by the message converters
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> void writeWithMessageConverters(T value, MethodParameter returnType,
|
||||
|
||||
Reference in New Issue
Block a user