Clean up warnings in spring-test

This commit is contained in:
Sam Brannen 2017-03-13 17:37:41 +01:00
parent 3c26e7f014
commit dda8beeb78
28 changed files with 57 additions and 54 deletions

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.util.function.UnaryOperator; import java.util.function.UnaryOperator;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.time.Duration; import java.time.Duration;

View File

@ -13,16 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
/** /**
* {@code ExchangeResult} sub-class that exposes the response body fully * {@code ExchangeResult} sub-class that exposes the response body fully
* extracted to a representation of type {@code <T>}. * extracted to a representation of type {@code <T>}.
* *
* @param <T> the response body type
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0 * @since 5.0
* @param <T> the response body type
* @see FluxExchangeResult * @see FluxExchangeResult
*/ */
public class EntityExchangeResult<T> extends ExchangeResult { public class EntityExchangeResult<T> extends ExchangeResult {

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.net.URI; import java.net.URI;
@ -45,7 +46,6 @@ import org.springframework.util.MultiValueMap;
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0 * @since 5.0
*
* @see EntityExchangeResult * @see EntityExchangeResult
* @see FluxExchangeResult * @see FluxExchangeResult
*/ */

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.time.Duration; import java.time.Duration;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.util.Arrays; import java.util.Arrays;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.net.URI; import java.net.URI;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
@ -48,7 +49,6 @@ public class RouterFunctionSpec extends AbstractMockServerSpec<RouterFunctionSpe
return WebHttpHandlerBuilder.applicationContext(initApplicationContext()); return WebHttpHandlerBuilder.applicationContext(initApplicationContext());
} }
@SuppressWarnings("Convert2MethodRef")
private ApplicationContext initApplicationContext() { private ApplicationContext initApplicationContext() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.registerBean("webHandler", DispatcherHandler.class, () -> new DispatcherHandler()); context.registerBean("webHandler", DispatcherHandler.class, () -> new DispatcherHandler());

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -26,7 +27,6 @@ import static org.springframework.test.util.AssertionErrors.assertEquals;
* @since 5.0 * @since 5.0
* @see WebTestClient.ResponseSpec#expectStatus() * @see WebTestClient.ResponseSpec#expectStatus()
*/ */
@SuppressWarnings("unused")
public class StatusAssertions { public class StatusAssertions {
private final ExchangeResult exchangeResult; private final ExchangeResult exchangeResult;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.net.URI; import java.net.URI;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
@ -25,7 +26,7 @@ import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.http.client.reactive.ClientHttpResponseDecorator; import org.springframework.http.client.reactive.ClientHttpResponseDecorator;
/** /**
* Client HTTP response decorator that interceptrs and saves the content read * Client HTTP response decorator that intercepts and saves the content read
* from the server. * from the server.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.net.URI; import java.net.URI;
@ -37,7 +38,6 @@ import org.springframework.util.Assert;
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0 * @since 5.0
*
* @see HttpHandlerConnector * @see HttpHandlerConnector
*/ */
class WiretapConnector implements ClientHttpConnector { class WiretapConnector implements ClientHttpConnector {

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import org.junit.Test; import org.junit.Test;
@ -25,7 +26,9 @@ import org.springframework.web.bind.annotation.RestController;
/** /**
* Unit tests for {@link DefaultControllerSpec}. * Unit tests for {@link DefaultControllerSpec}.
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
public class DefaultControllerSpecTests { public class DefaultControllerSpecTests {

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.net.URI; import java.net.URI;
@ -27,17 +28,17 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.mock.http.client.reactive.MockClientHttpRequest; import org.springframework.mock.http.client.reactive.MockClientHttpRequest;
import org.springframework.mock.http.client.reactive.MockClientHttpResponse; import org.springframework.mock.http.client.reactive.MockClientHttpResponse;
import org.springframework.web.reactive.function.client.ClientResponse;
import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNotNull;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** /**
* Unit tests for {@link HeaderAssertions}. * Unit tests for {@link HeaderAssertions}.
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
public class HeaderAssertionsTests { public class HeaderAssertionsTests {

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.net.URI; import java.net.URI;
@ -42,7 +43,9 @@ import static org.junit.Assert.assertEquals;
/** /**
* Unit tests for {@link HttpHandlerConnector}. * Unit tests for {@link HttpHandlerConnector}.
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
public class HttpHandlerConnectorTests { public class HttpHandlerConnectorTests {

View File

@ -13,30 +13,29 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server; package org.springframework.test.web.reactive.server;
import java.net.URI; import java.net.URI;
import org.junit.Test; import org.junit.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.mock.http.client.reactive.MockClientHttpRequest; import org.springframework.mock.http.client.reactive.MockClientHttpRequest;
import org.springframework.mock.http.client.reactive.MockClientHttpResponse; import org.springframework.mock.http.client.reactive.MockClientHttpResponse;
import org.springframework.web.reactive.function.client.ClientResponse;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** /**
* Unit tests for {@link StatusAssertions}. * Unit tests for {@link StatusAssertions}.
*
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
public class StatusAssertionTests { public class StatusAssertionTests {
@Test @Test
public void isEqualTo() throws Exception { public void isEqualTo() throws Exception {

View File

@ -39,10 +39,12 @@ import static org.junit.Assert.assertNotNull;
* Unit tests for {@link WiretapConnector}. * Unit tests for {@link WiretapConnector}.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
public class WebTestClientConnectorTests { public class WebTestClientConnectorTests {
@Test @Test
@SuppressWarnings("deprecation")
public void captureAndClaim() throws Exception { public void captureAndClaim() throws Exception {
ClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, "/test"); ClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, "/test");

View File

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server.samples; package org.springframework.test.web.reactive.server.samples;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -27,17 +27,11 @@ import org.springframework.web.bind.annotation.RestController;
* Tests with error status codes or error conditions. * Tests with error status codes or error conditions.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
@SuppressWarnings("unused")
public class ErrorTests { public class ErrorTests {
private WebTestClient client; private final WebTestClient client = WebTestClient.bindToController(new TestController()).build();
@Before
public void setUp() throws Exception {
this.client = WebTestClient.bindToController(new TestController()).build();
}
@Test @Test

View File

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server.samples; package org.springframework.test.web.reactive.server.samples;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -29,20 +29,14 @@ import org.springframework.web.bind.annotation.RestController;
* Tests with custom headers. * Tests with custom headers.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
@SuppressWarnings("unused")
public class HeaderTests { public class HeaderTests {
private WebTestClient client; private final WebTestClient client = WebTestClient
@Before
public void setUp() throws Exception {
this.client = WebTestClient
.bindToController(new TestController()) .bindToController(new TestController())
.configureClient().baseUrl("/header") .configureClient().baseUrl("/header")
.build(); .build();
}
@Test @Test

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server.samples; package org.springframework.test.web.reactive.server.samples;
import java.net.URI; import java.net.URI;
@ -23,7 +24,6 @@ import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -48,17 +48,11 @@ import static org.springframework.http.MediaType.TEXT_EVENT_STREAM;
* Annotated controllers accepting and returning typed Objects. * Annotated controllers accepting and returning typed Objects.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
@SuppressWarnings("unused")
public class ResponseEntityTests { public class ResponseEntityTests {
private WebTestClient client; private final WebTestClient client = WebTestClient.bindToController(new PersonController()).build();
@Before
public void setUp() throws Exception {
this.client = WebTestClient.bindToController(new PersonController()).build();
}
@Test @Test
@ -152,6 +146,7 @@ public class ResponseEntityTests {
} }
@GetMapping(produces = "text/event-stream") @GetMapping(produces = "text/event-stream")
@SuppressWarnings("deprecation")
Flux<Person> getPersonStream() { Flux<Person> getPersonStream() {
return Flux.intervalMillis(100).onBackpressureBuffer(10).map(index -> new Person("N" + index)); return Flux.intervalMillis(100).onBackpressureBuffer(10).map(index -> new Person("N" + index));
} }

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server.samples.bind; package org.springframework.test.web.reactive.server.samples.bind;
import java.security.Principal; import java.security.Principal;
@ -38,8 +39,8 @@ import static org.mockito.Mockito.when;
* Binding to server infrastructure declared in a Spring ApplicationContext. * Binding to server infrastructure declared in a Spring ApplicationContext.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
@SuppressWarnings("unused")
public class ApplicationContextTests { public class ApplicationContextTests {
private WebTestClient client; private WebTestClient client;

View File

@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server.samples.bind; package org.springframework.test.web.reactive.server.samples.bind;
import java.security.Principal; import java.security.Principal;
import java.util.function.UnaryOperator; import java.util.function.UnaryOperator;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -34,19 +34,15 @@ import static org.mockito.Mockito.when;
* Bind to annotated controllers. * Bind to annotated controllers.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
@SuppressWarnings("unused")
public class ControllerTests { public class ControllerTests {
private WebTestClient client; private final WebTestClient client = WebTestClient
.bindToController(new TestController())
@Before
public void setUp() throws Exception {
this.client = WebTestClient.bindToController(new TestController())
.exchangeMutator(identitySetup("Pablo")) .exchangeMutator(identitySetup("Pablo"))
.build(); .build();
}
private UnaryOperator<ServerWebExchange> identitySetup(String userName) { private UnaryOperator<ServerWebExchange> identitySetup(String userName) {
return exchange -> { return exchange -> {

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server.samples.bind; package org.springframework.test.web.reactive.server.samples.bind;
import org.junit.After; import org.junit.After;
@ -33,6 +34,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r
* Bind to a running server, making actual requests over a socket. * Bind to a running server, making actual requests over a socket.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
public class HttpServerTests { public class HttpServerTests {

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.reactive.server.samples.bind; package org.springframework.test.web.reactive.server.samples.bind;
import org.junit.Before; import org.junit.Before;
@ -30,6 +31,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r
* Bind to a {@link RouterFunction} and functional endpoints. * Bind to a {@link RouterFunction} and functional endpoints.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 5.0
*/ */
public class RouterFunctionTests { public class RouterFunctionTests {