Add ReactiveAdapterRegistry
Issue: SPR-14159
This commit is contained in:
@@ -30,7 +30,6 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.codec.StringEncoder;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -43,6 +42,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.reactive.accept.HeaderContentTypeResolver;
|
||||
import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter;
|
||||
import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping;
|
||||
import org.springframework.web.reactive.result.method.annotation.ResponseBodyResultHandler;
|
||||
@@ -198,7 +198,7 @@ public class DispatcherHandlerErrorTests {
|
||||
public ResponseBodyResultHandler resultHandler() {
|
||||
return new ResponseBodyResultHandler(
|
||||
Collections.singletonList(new EncoderHttpMessageWriter<>(new StringEncoder())),
|
||||
new DefaultConversionService());
|
||||
new HeaderContentTypeResolver());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Set;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.convert.support.GenericConversionService;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.MockServerHttpRequest;
|
||||
@@ -125,7 +124,7 @@ public class ContentNegotiatingResultHandlerSupportTests {
|
||||
}
|
||||
|
||||
public TestResultHandler(RequestedContentTypeResolver contentTypeResolver) {
|
||||
super(new GenericConversionService(), contentTypeResolver);
|
||||
super(contentTypeResolver);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,6 @@ import rx.Observable;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.convert.support.MonoToCompletableFutureConverter;
|
||||
import org.springframework.core.convert.support.ReactorToRxJava1Converter;
|
||||
import org.springframework.format.support.DefaultFormattingConversionService;
|
||||
import org.springframework.format.support.FormattingConversionService;
|
||||
import org.springframework.web.reactive.HandlerResult;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -47,10 +43,7 @@ public class SimpleResultHandlerTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
FormattingConversionService service = new DefaultFormattingConversionService();
|
||||
service.addConverter(new MonoToCompletableFutureConverter());
|
||||
service.addConverter(new ReactorToRxJava1Converter());
|
||||
this.resultHandler = new SimpleResultHandler(service);
|
||||
this.resultHandler = new SimpleResultHandler();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import reactor.core.publisher.Mono;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
@@ -147,7 +146,7 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler
|
||||
|
||||
@Bean
|
||||
public SimpleResultHandler resultHandler() {
|
||||
return new SimpleResultHandler(new DefaultConversionService());
|
||||
return new SimpleResultHandler();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,12 +35,8 @@ import rx.Single;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.codec.StringDecoder;
|
||||
import org.springframework.core.convert.support.MonoToCompletableFutureConverter;
|
||||
import org.springframework.core.convert.support.ReactorToRxJava1Converter;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.format.support.DefaultFormattingConversionService;
|
||||
import org.springframework.format.support.FormattingConversionService;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -50,14 +46,20 @@ import org.springframework.http.converter.reactive.HttpMessageReader;
|
||||
import org.springframework.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.MockServerHttpResponse;
|
||||
import org.springframework.ui.ExtendedModelMap;
|
||||
import org.springframework.validation.Validator;
|
||||
import org.springframework.web.reactive.result.ResolvableMethod;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.ServerWebInputException;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.MockWebSessionManager;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.core.ResolvableType.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.springframework.core.ResolvableType.forClassWithGenerics;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link HttpEntityArgumentResolver}.When adding a test also
|
||||
@@ -87,12 +89,7 @@ public class HttpEntityArgumentResolverTests {
|
||||
private HttpEntityArgumentResolver createResolver() {
|
||||
List<HttpMessageReader<?>> readers = new ArrayList<>();
|
||||
readers.add(new DecoderHttpMessageReader<>(new StringDecoder()));
|
||||
|
||||
FormattingConversionService service = new DefaultFormattingConversionService();
|
||||
service.addConverter(new MonoToCompletableFutureConverter());
|
||||
service.addConverter(new ReactorToRxJava1Converter());
|
||||
|
||||
return new HttpEntityArgumentResolver(readers, service);
|
||||
return new HttpEntityArgumentResolver(readers, mock(Validator.class));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,12 +42,8 @@ import rx.Single;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.codec.Decoder;
|
||||
import org.springframework.core.convert.support.MonoToCompletableFutureConverter;
|
||||
import org.springframework.core.convert.support.ReactorToRxJava1Converter;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.format.support.DefaultFormattingConversionService;
|
||||
import org.springframework.format.support.FormattingConversionService;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.json.JacksonJsonDecoder;
|
||||
@@ -66,8 +62,12 @@ import org.springframework.web.server.UnsupportedMediaTypeStatusException;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.MockWebSessionManager;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.core.ResolvableType.*;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.core.ResolvableType.forClass;
|
||||
import static org.springframework.core.ResolvableType.forClassWithGenerics;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link AbstractMessageReaderArgumentResolver}.
|
||||
@@ -275,15 +275,9 @@ public class MessageReaderArgumentResolverTests {
|
||||
|
||||
@SuppressWarnings("Convert2MethodRef")
|
||||
private AbstractMessageReaderArgumentResolver resolver(Decoder<?>... decoders) {
|
||||
|
||||
List<HttpMessageReader<?>> readers = new ArrayList<>();
|
||||
Arrays.asList(decoders).forEach(decoder -> readers.add(new DecoderHttpMessageReader<>(decoder)));
|
||||
|
||||
FormattingConversionService service = new DefaultFormattingConversionService();
|
||||
service.addConverter(new MonoToCompletableFutureConverter());
|
||||
service.addConverter(new ReactorToRxJava1Converter());
|
||||
|
||||
return new AbstractMessageReaderArgumentResolver(readers, service, new TestBeanValidator()) {};
|
||||
return new AbstractMessageReaderArgumentResolver(readers, new TestBeanValidator()) {};
|
||||
}
|
||||
|
||||
private DataBuffer dataBuffer(String body) {
|
||||
|
||||
@@ -41,9 +41,6 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.codec.ByteBufferEncoder;
|
||||
import org.springframework.core.codec.StringEncoder;
|
||||
import org.springframework.core.convert.support.GenericConversionService;
|
||||
import org.springframework.core.convert.support.MonoToCompletableFutureConverter;
|
||||
import org.springframework.core.convert.support.ReactorToRxJava1Converter;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.buffer.support.DataBufferTestUtils;
|
||||
@@ -64,9 +61,11 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.MockWebSessionManager;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.http.MediaType.*;
|
||||
import static org.springframework.web.reactive.HandlerMapping.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8;
|
||||
import static org.springframework.web.reactive.HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link AbstractMessageWriterResultHandler}.
|
||||
@@ -93,7 +92,7 @@ public class MessageWriterResultHandlerTests {
|
||||
public void useDefaultContentType() throws Exception {
|
||||
Resource body = new ClassPathResource("logo.png", getClass());
|
||||
ResolvableType type = ResolvableType.forType(Resource.class);
|
||||
this.resultHandler.writeBody(this.exchange, body, type, returnType(type)).block(Duration.ofSeconds(5));
|
||||
this.resultHandler.writeBody(body, returnType(type), this.exchange).block(Duration.ofSeconds(5));
|
||||
|
||||
assertEquals("image/x-png", this.response.getHeaders().getFirst("Content-Type"));
|
||||
}
|
||||
@@ -105,7 +104,7 @@ public class MessageWriterResultHandlerTests {
|
||||
|
||||
String body = "foo";
|
||||
ResolvableType type = ResolvableType.forType(String.class);
|
||||
this.resultHandler.writeBody(this.exchange, body, type, returnType(type)).block(Duration.ofSeconds(5));
|
||||
this.resultHandler.writeBody(body, returnType(type), this.exchange).block(Duration.ofSeconds(5));
|
||||
|
||||
assertEquals(APPLICATION_JSON_UTF8, this.response.getHeaders().getContentType());
|
||||
}
|
||||
@@ -119,7 +118,7 @@ public class MessageWriterResultHandlerTests {
|
||||
}
|
||||
|
||||
private void testVoidReturnType(Object body, ResolvableType type) {
|
||||
this.resultHandler.writeBody(this.exchange, body, type, returnType(type)).block(Duration.ofSeconds(5));
|
||||
this.resultHandler.writeBody(body, returnType(type), this.exchange).block(Duration.ofSeconds(5));
|
||||
|
||||
assertNull(this.response.getHeaders().get("Content-Type"));
|
||||
assertNull(this.response.getBody());
|
||||
@@ -131,7 +130,7 @@ public class MessageWriterResultHandlerTests {
|
||||
ResolvableType type = ResolvableType.forType(OutputStream.class);
|
||||
|
||||
HttpMessageWriter<?> writer = new EncoderHttpMessageWriter<>(new ByteBufferEncoder());
|
||||
Mono<Void> mono = createResultHandler(writer).writeBody(this.exchange, body, type, returnType(type));
|
||||
Mono<Void> mono = createResultHandler(writer).writeBody(body, returnType(type), this.exchange);
|
||||
|
||||
TestSubscriber.subscribe(mono).assertError(IllegalStateException.class);
|
||||
}
|
||||
@@ -140,7 +139,7 @@ public class MessageWriterResultHandlerTests {
|
||||
public void jacksonTypeOfListElement() throws Exception {
|
||||
List<ParentClass> body = Arrays.asList(new Foo("foo"), new Bar("bar"));
|
||||
ResolvableType type = ResolvableType.forClassWithGenerics(List.class, ParentClass.class);
|
||||
this.resultHandler.writeBody(this.exchange, body, type, returnType(type)).block(Duration.ofSeconds(5));
|
||||
this.resultHandler.writeBody(body, returnType(type), this.exchange).block(Duration.ofSeconds(5));
|
||||
|
||||
assertEquals(APPLICATION_JSON_UTF8, this.response.getHeaders().getContentType());
|
||||
assertResponseBody("[{\"type\":\"foo\",\"parentProperty\":\"foo\"}," +
|
||||
@@ -151,7 +150,7 @@ public class MessageWriterResultHandlerTests {
|
||||
public void jacksonTypeWithSubType() throws Exception {
|
||||
SimpleBean body = new SimpleBean(123L, "foo");
|
||||
ResolvableType type = ResolvableType.forClass(Identifiable.class);
|
||||
this.resultHandler.writeBody(this.exchange, body, type, returnType(type)).block(Duration.ofSeconds(5));
|
||||
this.resultHandler.writeBody(body, returnType(type), this.exchange).block(Duration.ofSeconds(5));
|
||||
|
||||
assertEquals(APPLICATION_JSON_UTF8, this.response.getHeaders().getContentType());
|
||||
assertResponseBody("{\"id\":123,\"name\":\"foo\"}");
|
||||
@@ -161,7 +160,7 @@ public class MessageWriterResultHandlerTests {
|
||||
public void jacksonTypeWithSubTypeOfListElement() throws Exception {
|
||||
List<SimpleBean> body = Arrays.asList(new SimpleBean(123L, "foo"), new SimpleBean(456L, "bar"));
|
||||
ResolvableType type = ResolvableType.forClassWithGenerics(List.class, Identifiable.class);
|
||||
this.resultHandler.writeBody(this.exchange, body, type, returnType(type)).block(Duration.ofSeconds(5));
|
||||
this.resultHandler.writeBody(body, returnType(type), this.exchange).block(Duration.ofSeconds(5));
|
||||
|
||||
assertEquals(APPLICATION_JSON_UTF8, this.response.getHeaders().getContentType());
|
||||
assertResponseBody("[{\"id\":123,\"name\":\"foo\"},{\"id\":456,\"name\":\"bar\"}]");
|
||||
@@ -185,14 +184,8 @@ public class MessageWriterResultHandlerTests {
|
||||
else {
|
||||
writerList = Arrays.asList(writers);
|
||||
}
|
||||
|
||||
GenericConversionService service = new GenericConversionService();
|
||||
service.addConverter(new MonoToCompletableFutureConverter());
|
||||
service.addConverter(new ReactorToRxJava1Converter());
|
||||
|
||||
RequestedContentTypeResolver resolver = new RequestedContentTypeResolverBuilder().build();
|
||||
|
||||
return new AbstractMessageWriterResultHandler(writerList, service, resolver) {};
|
||||
return new AbstractMessageWriterResultHandler(writerList, resolver) {};
|
||||
}
|
||||
|
||||
private void assertResponseBody(String responseBody) {
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
@@ -38,18 +37,15 @@ import rx.Single;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.codec.StringDecoder;
|
||||
import org.springframework.core.convert.support.MonoToCompletableFutureConverter;
|
||||
import org.springframework.core.convert.support.ReactorToRxJava1Converter;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.format.support.DefaultFormattingConversionService;
|
||||
import org.springframework.format.support.FormattingConversionService;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.converter.reactive.DecoderHttpMessageReader;
|
||||
import org.springframework.http.converter.reactive.HttpMessageReader;
|
||||
import org.springframework.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.MockServerHttpResponse;
|
||||
import org.springframework.ui.ExtendedModelMap;
|
||||
import org.springframework.validation.Validator;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.reactive.result.ResolvableMethod;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
@@ -62,6 +58,7 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.springframework.core.ResolvableType.forClass;
|
||||
import static org.springframework.core.ResolvableType.forClassWithGenerics;
|
||||
|
||||
@@ -93,12 +90,7 @@ public class RequestBodyArgumentResolverTests {
|
||||
private RequestBodyArgumentResolver resolver() {
|
||||
List<HttpMessageReader<?>> readers = new ArrayList<>();
|
||||
readers.add(new DecoderHttpMessageReader<>(new StringDecoder()));
|
||||
|
||||
FormattingConversionService service = new DefaultFormattingConversionService();
|
||||
service.addConverter(new MonoToCompletableFutureConverter());
|
||||
service.addConverter(new ReactorToRxJava1Converter());
|
||||
|
||||
return new RequestBodyArgumentResolver(readers, service);
|
||||
return new RequestBodyArgumentResolver(readers, mock(Validator.class));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,11 +27,6 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.codec.ByteBufferEncoder;
|
||||
import org.springframework.core.codec.StringEncoder;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.core.convert.support.MonoToCompletableFutureConverter;
|
||||
import org.springframework.core.convert.support.ReactorToRxJava1Converter;
|
||||
import org.springframework.format.support.DefaultFormattingConversionService;
|
||||
import org.springframework.format.support.FormattingConversionService;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.codec.json.JacksonJsonEncoder;
|
||||
@@ -99,12 +94,8 @@ public class ResponseBodyResultHandlerTests {
|
||||
else {
|
||||
writerList = Arrays.asList(writers);
|
||||
}
|
||||
FormattingConversionService service = new DefaultFormattingConversionService();
|
||||
service.addConverter(new MonoToCompletableFutureConverter());
|
||||
service.addConverter(new ReactorToRxJava1Converter());
|
||||
RequestedContentTypeResolver resolver = new RequestedContentTypeResolverBuilder().build();
|
||||
|
||||
return new ResponseBodyResultHandler(writerList, new DefaultConversionService(), resolver);
|
||||
return new ResponseBodyResultHandler(writerList, resolver);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -34,11 +34,7 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.codec.ByteBufferEncoder;
|
||||
import org.springframework.core.codec.StringEncoder;
|
||||
import org.springframework.core.convert.support.MonoToCompletableFutureConverter;
|
||||
import org.springframework.core.convert.support.ReactorToRxJava1Converter;
|
||||
import org.springframework.core.io.buffer.support.DataBufferTestUtils;
|
||||
import org.springframework.format.support.DefaultFormattingConversionService;
|
||||
import org.springframework.format.support.FormattingConversionService;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -59,8 +55,11 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.MockWebSessionManager;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.core.ResolvableType.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.core.ResolvableType.forClassWithGenerics;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ResponseEntityResultHandler}. When adding a test also
|
||||
@@ -100,14 +99,8 @@ public class ResponseEntityResultHandlerTests {
|
||||
else {
|
||||
writerList = Arrays.asList(writers);
|
||||
}
|
||||
FormattingConversionService service = new DefaultFormattingConversionService();
|
||||
service.addConverter(new MonoToCompletableFutureConverter());
|
||||
service.addConverter(new ReactorToRxJava1Converter());
|
||||
|
||||
|
||||
RequestedContentTypeResolver resolver = new RequestedContentTypeResolverBuilder().build();
|
||||
|
||||
return new ResponseEntityResultHandler(writerList, service, resolver);
|
||||
return new ResponseEntityResultHandler(writerList, resolver);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,13 +38,9 @@ import rx.Single;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.convert.support.MonoToCompletableFutureConverter;
|
||||
import org.springframework.core.convert.support.ReactorToRxJava1Converter;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.core.io.buffer.support.DataBufferTestUtils;
|
||||
import org.springframework.format.support.DefaultFormattingConversionService;
|
||||
import org.springframework.format.support.FormattingConversionService;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.MockServerHttpRequest;
|
||||
@@ -55,6 +51,8 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.reactive.HandlerResult;
|
||||
import org.springframework.web.reactive.accept.HeaderContentTypeResolver;
|
||||
import org.springframework.web.reactive.accept.RequestedContentTypeResolver;
|
||||
import org.springframework.web.reactive.result.ResolvableMethod;
|
||||
import org.springframework.web.server.NotAcceptableStatusException;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
@@ -62,9 +60,10 @@ import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.DefaultWebSessionManager;
|
||||
import org.springframework.web.server.session.WebSessionManager;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.springframework.http.MediaType.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ViewResolutionResultHandler}.
|
||||
@@ -247,12 +246,9 @@ public class ViewResolutionResultHandlerTests {
|
||||
}
|
||||
|
||||
private ViewResolutionResultHandler createResultHandler(List<View> defaultViews, ViewResolver... resolvers) {
|
||||
FormattingConversionService service = new DefaultFormattingConversionService();
|
||||
service.addConverter(new MonoToCompletableFutureConverter());
|
||||
service.addConverter(new ReactorToRxJava1Converter());
|
||||
List<ViewResolver> resolverList = Arrays.asList(resolvers);
|
||||
|
||||
ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolverList, service);
|
||||
RequestedContentTypeResolver contentTypeResolver = new HeaderContentTypeResolver();
|
||||
ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolverList, contentTypeResolver);
|
||||
handler.setDefaultViews(defaultViews);
|
||||
return handler;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user