Drop use of WebApplicationContext in tests

It brings along Servlet imports.
This commit is contained in:
Rossen Stoyanchev 2015-12-08 12:10:49 -05:00
parent 4616938525
commit ad4be9462b
3 changed files with 17 additions and 17 deletions

View File

@ -27,17 +27,17 @@ import org.reactivestreams.Publisher;
import reactor.io.buffer.Buffer; import reactor.io.buffer.Buffer;
import reactor.rx.Streams; import reactor.rx.Streams;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.RequestEntity; import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.http.server.AbstractHttpHandlerIntegrationTests;
import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.http.server.AbstractHttpHandlerIntegrationTests;
import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.support.StaticWebApplicationContext; import org.springframework.web.reactive.DispatcherHandler;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -54,7 +54,7 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler
@Override @Override
protected HttpHandler createHttpHandler() { protected HttpHandler createHttpHandler() {
StaticWebApplicationContext wac = new StaticWebApplicationContext(); StaticApplicationContext wac = new StaticApplicationContext();
wac.registerSingleton("hm", TestHandlerMapping.class); wac.registerSingleton("hm", TestHandlerMapping.class);
wac.registerSingleton("ha", HttpHandlerAdapter.class); wac.registerSingleton("ha", HttpHandlerAdapter.class);
wac.registerSingleton("rh", SimpleHandlerResultHandler.class); wac.registerSingleton("rh", SimpleHandlerResultHandler.class);

View File

@ -27,13 +27,13 @@ import org.junit.Test;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
import reactor.rx.Streams; import reactor.rx.Streams;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.context.support.StaticWebApplicationContext;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -49,7 +49,7 @@ public class RequestMappingHandlerMappingTests {
@Before @Before
public void setup() { public void setup() {
StaticWebApplicationContext wac = new StaticWebApplicationContext(); StaticApplicationContext wac = new StaticApplicationContext();
wac.registerSingleton("handlerMapping", RequestMappingHandlerMapping.class); wac.registerSingleton("handlerMapping", RequestMappingHandlerMapping.class);
wac.registerSingleton("controller", TestController.class); wac.registerSingleton("controller", TestController.class);
wac.refresh(); wac.refresh();

View File

@ -33,10 +33,15 @@ import reactor.rx.Streams;
import rx.Observable; import rx.Observable;
import rx.Single; import rx.Single;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.ResolvableType; import org.springframework.core.ResolvableType;
import org.springframework.core.codec.support.ByteBufferEncoder;
import org.springframework.core.codec.support.JacksonJsonEncoder;
import org.springframework.core.codec.support.JsonObjectEncoder;
import org.springframework.core.codec.support.StringEncoder;
import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.GenericConversionService; import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.core.convert.support.ReactiveStreamsToCompletableFutureConverter; import org.springframework.core.convert.support.ReactiveStreamsToCompletableFutureConverter;
@ -46,12 +51,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity; import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.core.codec.support.ByteBufferEncoder;
import org.springframework.core.codec.support.JacksonJsonEncoder;
import org.springframework.core.codec.support.JsonObjectEncoder;
import org.springframework.core.codec.support.StringEncoder;
import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.web.reactive.handler.SimpleHandlerResultHandler;
import org.springframework.http.server.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.AbstractHttpHandlerIntegrationTests;
import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -60,7 +59,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.web.reactive.handler.SimpleHandlerResultHandler;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -71,12 +71,12 @@ import static org.junit.Assert.assertEquals;
*/ */
public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrationTests { public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrationTests {
private AnnotationConfigWebApplicationContext wac; private AnnotationConfigApplicationContext wac;
@Override @Override
protected HttpHandler createHttpHandler() { protected HttpHandler createHttpHandler() {
this.wac = new AnnotationConfigWebApplicationContext(); this.wac = new AnnotationConfigApplicationContext();
this.wac.register(FrameworkConfig.class, ApplicationConfig.class); this.wac.register(FrameworkConfig.class, ApplicationConfig.class);
this.wac.refresh(); this.wac.refresh();
@ -474,7 +474,7 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati
@RequestMapping("/observable-create") @RequestMapping("/observable-create")
public Observable<Void> observableCreate(@RequestBody Observable<Person> personStream) { public Observable<Void> observableCreate(@RequestBody Observable<Person> personStream) {
return personStream.toList().doOnNext(p -> persons.addAll(p)).flatMap(document -> Observable.empty()); return personStream.toList().doOnNext(persons::addAll).flatMap(document -> Observable.empty());
} }
//TODO add mixed and T request mappings tests //TODO add mixed and T request mappings tests