Revised imports in tests (org.jetbrains.annotations.NotNull etc)
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2016 Pivotal Software Inc, All Rights Reserved.
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -18,7 +18,6 @@ package org.springframework.http.server.reactive.bootstrap;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import reactor.core.Loopback;
|
||||
import reactor.ipc.netty.NettyContext;
|
||||
|
||||
@@ -42,11 +41,10 @@ public class ReactorHttpServer extends AbstractHttpServer implements Loopback {
|
||||
this.reactorServer = reactor.ipc.netty.http.server.HttpServer.create(getHost(), getPort());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ReactorHttpHandlerAdapter createHttpHandlerAdapter() {
|
||||
return getHttpHandlerMap() != null ?
|
||||
return (getHttpHandlerMap() != null ?
|
||||
new ReactorHttpHandlerAdapter(getHttpHandlerMap()) :
|
||||
new ReactorHttpHandlerAdapter(getHttpHandler());
|
||||
new ReactorHttpHandlerAdapter(getHttpHandler()));
|
||||
}
|
||||
|
||||
@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.
|
||||
@@ -16,14 +16,10 @@
|
||||
|
||||
package org.springframework.http.server.reactive.bootstrap;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import org.springframework.http.server.reactive.RxNettyHttpHandlerAdapter;
|
||||
|
||||
|
||||
/**
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@@ -40,11 +36,10 @@ public class RxNettyHttpServer extends AbstractHttpServer {
|
||||
this.rxNettyServer = io.reactivex.netty.protocol.http.server.HttpServer.newServer(getPort());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private RxNettyHttpHandlerAdapter createHttpHandlerAdapter() {
|
||||
return getHttpHandlerMap() != null ?
|
||||
return (getHttpHandlerMap() != null ?
|
||||
new RxNettyHttpHandlerAdapter(getHttpHandlerMap()) :
|
||||
new RxNettyHttpHandlerAdapter(getHttpHandler());
|
||||
new RxNettyHttpHandlerAdapter(getHttpHandler()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.cors.reactive;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -28,13 +27,8 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS;
|
||||
import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN;
|
||||
import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS;
|
||||
import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.http.HttpHeaders.*;
|
||||
|
||||
/**
|
||||
* {@link DefaultCorsProcessor} tests with simple or pre-flight CORS request.
|
||||
@@ -329,6 +323,7 @@ public class DefaultCorsProcessorTests {
|
||||
assertEquals(HttpStatus.FORBIDDEN, this.response.getStatusCode());
|
||||
}
|
||||
|
||||
|
||||
private MockServerHttpRequest.BaseBuilder<?> actualRequest() {
|
||||
return corsRequest(HttpMethod.GET);
|
||||
}
|
||||
@@ -343,7 +338,6 @@ public class DefaultCorsProcessorTests {
|
||||
.header(HttpHeaders.ORIGIN, "http://domain2.com");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DefaultServerWebExchange createExchange() {
|
||||
return new DefaultServerWebExchange(this.request, this.response);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -24,7 +24,6 @@ import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -37,10 +36,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse;
|
||||
|
||||
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.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* "checkNotModified" unit tests for {@link DefaultServerWebExchange}.
|
||||
@@ -74,7 +70,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws URISyntaxException {
|
||||
public void setup() throws URISyntaxException {
|
||||
this.currentDate = Instant.now().truncatedTo(ChronoUnit.SECONDS);
|
||||
this.dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||
this.dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
@@ -319,12 +315,11 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||
assertEquals(-1, response.getHeaders().getLastModified());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
private MockServerHttpRequest.BaseBuilder<?> request() {
|
||||
return MockServerHttpRequest.get("http://example.org");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DefaultServerWebExchange createExchange() {
|
||||
return new DefaultServerWebExchange(this.request, this.response);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.server.adapter;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -36,16 +36,16 @@ import org.springframework.web.server.WebExceptionHandler;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebHandler;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link WebHttpHandlerBuilder}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class WebHttpHandlerBuilderTests {
|
||||
|
||||
|
||||
@Test // SPR-15074
|
||||
@Test // SPR-15074
|
||||
public void orderedWebFilterBeans() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.register(OrderedWebFilterBeanConfig.class);
|
||||
@@ -60,7 +60,7 @@ public class WebHttpHandlerBuilderTests {
|
||||
assertEquals("FilterB::FilterA", response.getBodyAsString().blockMillis(5000));
|
||||
}
|
||||
|
||||
@Test // SPR-15074
|
||||
@Test // SPR-15074
|
||||
public void orderedWebExceptionHandlerBeans() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.register(OrderedExceptionHandlerBeanConfig.class);
|
||||
@@ -90,6 +90,7 @@ public class WebHttpHandlerBuilderTests {
|
||||
assertEquals("handled", response.getBodyAsString().blockMillis(5000));
|
||||
}
|
||||
|
||||
|
||||
private static Mono<Void> writeToResponse(ServerWebExchange exchange, String value) {
|
||||
byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
|
||||
DataBuffer buffer = new DefaultDataBufferFactory().wrap(bytes);
|
||||
@@ -113,7 +114,6 @@ public class WebHttpHandlerBuilderTests {
|
||||
return createFilter("FilterB");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private WebFilter createFilter(String name) {
|
||||
return (exchange, chain) -> {
|
||||
String value = exchange.getAttribute(ATTRIBUTE).map(v -> v + "::" + name).orElse(name);
|
||||
@@ -131,6 +131,7 @@ public class WebHttpHandlerBuilderTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@SuppressWarnings("unused")
|
||||
static class OrderedExceptionHandlerBeanConfig {
|
||||
@@ -153,6 +154,7 @@ public class WebHttpHandlerBuilderTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@SuppressWarnings("unused")
|
||||
static class NoFilterConfig {
|
||||
|
||||
@@ -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.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.server.handler;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -30,8 +29,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ResponseStatusExceptionHandler}.
|
||||
@@ -48,7 +46,7 @@ public class ResponseStatusExceptionHandlerTests {
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setup() throws Exception {
|
||||
this.handler = new ResponseStatusExceptionHandler();
|
||||
this.request = MockServerHttpRequest.get("/").build();
|
||||
this.response = new MockServerHttpResponse();
|
||||
@@ -69,7 +67,7 @@ public class ResponseStatusExceptionHandlerTests {
|
||||
StepVerifier.create(mono).consumeErrorWith(actual -> assertSame(expected, actual)).verify();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
private DefaultServerWebExchange createExchange() {
|
||||
return new DefaultServerWebExchange(this.request, this.response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user