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
* limitations under the License.
*/
package org.springframework.test.web.reactive.server;
import java.util.function.UnaryOperator;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.web.reactive.server;
import reactor.core.publisher.Flux;
@ -25,7 +26,7 @@ import org.springframework.http.client.reactive.ClientHttpResponse;
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.
*
* @author Rossen Stoyanchev

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.web.reactive.server.samples;
import java.net.URI;
@ -23,7 +24,6 @@ import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.junit.Before;
import org.junit.Test;
import reactor.core.publisher.Flux;
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.
*
* @author Rossen Stoyanchev
* @since 5.0
*/
@SuppressWarnings("unused")
public class ResponseEntityTests {
private WebTestClient client;
@Before
public void setUp() throws Exception {
this.client = WebTestClient.bindToController(new PersonController()).build();
}
private final WebTestClient client = WebTestClient.bindToController(new PersonController()).build();
@Test
@ -152,6 +146,7 @@ public class ResponseEntityTests {
}
@GetMapping(produces = "text/event-stream")
@SuppressWarnings("deprecation")
Flux<Person> getPersonStream() {
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
* limitations under the License.
*/
package org.springframework.test.web.reactive.server.samples.bind;
import java.security.Principal;
@ -38,8 +39,8 @@ import static org.mockito.Mockito.when;
* Binding to server infrastructure declared in a Spring ApplicationContext.
*
* @author Rossen Stoyanchev
* @since 5.0
*/
@SuppressWarnings("unused")
public class ApplicationContextTests {
private WebTestClient client;

View File

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

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.web.reactive.server.samples.bind;
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.
*
* @author Rossen Stoyanchev
* @since 5.0
*/
public class HttpServerTests {

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.web.reactive.server.samples.bind;
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.
*
* @author Rossen Stoyanchev
* @since 5.0
*/
public class RouterFunctionTests {