Skip to content

Commit 77ab88b

Browse files
committed
Polishing
1 parent 738097d commit 77ab88b

20 files changed

+113
-105
lines changed

spring-web/src/test/java/org/springframework/http/server/reactive/CookieIntegrationTests.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.http.server.reactive;
1718

1819
import java.net.URI;
@@ -27,27 +28,25 @@
2728

2829
import org.springframework.http.HttpCookie;
2930
import org.springframework.http.RequestEntity;
30-
import org.springframework.http.ResponseEntity;
3131
import org.springframework.http.ResponseCookie;
32+
import org.springframework.http.ResponseEntity;
3233
import org.springframework.web.client.RestTemplate;
3334

3435
import static org.hamcrest.CoreMatchers.equalTo;
35-
import static org.hamcrest.Matchers.containsInAnyOrder;
36-
import static org.hamcrest.Matchers.equalToIgnoringCase;
37-
import static org.junit.Assert.assertEquals;
38-
import static org.junit.Assert.assertThat;
36+
import static org.hamcrest.Matchers.*;
37+
import static org.junit.Assert.*;
3938

4039
/**
4140
* @author Rossen Stoyanchev
4241
*/
4342
@RunWith(Parameterized.class)
4443
public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests {
4544

46-
private CookieHandler cookieHandler;
45+
private final CookieHandler cookieHandler = new CookieHandler();
46+
4747

4848
@Override
4949
protected HttpHandler createHttpHandler() {
50-
this.cookieHandler = new CookieHandler();
5150
return this.cookieHandler;
5251
}
5352

spring-web/src/test/java/org/springframework/http/server/reactive/EchoHandlerIntegrationTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,14 +26,16 @@
2626
import org.springframework.http.ResponseEntity;
2727
import org.springframework.web.client.RestTemplate;
2828

29-
import static org.junit.Assert.assertArrayEquals;
30-
29+
import static org.junit.Assert.*;
3130

31+
/**
32+
* @author Arjen Poutsma
33+
*/
3234
public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
3335

3436
private static final int REQUEST_SIZE = 4096 * 3;
3537

36-
private Random rnd = new Random();
38+
private final Random rnd = new Random();
3739

3840

3941
@Override

spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
*/
3535
public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
3636

37-
private ErrorHandler handler = new ErrorHandler();
37+
private final ErrorHandler handler = new ErrorHandler();
38+
3839

3940
@Override
4041
protected HttpHandler createHttpHandler() {
4142
return handler;
4243
}
4344

45+
4446
@Test
4547
public void responseBodyError() throws Exception {
4648
RestTemplate restTemplate = new RestTemplate();
@@ -75,6 +77,7 @@ public void emptyPathSegments() throws Exception {
7577
assertEquals(HttpStatus.OK, response.getStatusCode());
7678
}
7779

80+
7881
private static class ErrorHandler implements HttpHandler {
7982

8083
@Override
@@ -93,6 +96,7 @@ else if (path.endsWith("handling-error")) {
9396
}
9497
}
9598

99+
96100
private static final ResponseErrorHandler NO_OP_ERROR_HANDLER = new ResponseErrorHandler() {
97101

98102
@Override

spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,9 @@
3333

3434
import static org.junit.Assert.*;
3535

36+
/**
37+
* @author Arjen Poutsma
38+
*/
3639
public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
3740

3841
public static final int REQUEST_SIZE = 4096 * 3;

spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
import static org.junit.Assert.*;
3030

31+
/**
32+
* @author Sebastien Deleuze
33+
*/
3134
public class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegrationTests {
3235

3336
@Override
@@ -58,4 +61,5 @@ public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response)
5861
return Mono.empty();
5962
}
6063
}
64+
6165
}

spring-web/src/test/java/org/springframework/http/server/reactive/WriteOnlyHandlerIntegrationTests.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,19 +21,16 @@
2121
import java.util.Random;
2222

2323
import org.junit.Test;
24+
import reactor.core.publisher.Flux;
25+
import reactor.core.publisher.Mono;
26+
2427
import org.springframework.core.io.buffer.DataBuffer;
2528
import org.springframework.http.RequestEntity;
2629
import org.springframework.http.ResponseEntity;
27-
import org.springframework.http.server.reactive.HttpHandler;
28-
import org.springframework.http.server.reactive.ServerHttpRequest;
29-
import org.springframework.http.server.reactive.ServerHttpResponse;
3030
import org.springframework.web.client.RestTemplate;
3131

3232
import static org.junit.Assert.*;
3333

34-
import reactor.core.publisher.Flux;
35-
import reactor.core.publisher.Mono;
36-
3734
/**
3835
* @author Violeta Georgieva
3936
* @since 5.0
@@ -52,7 +49,6 @@ protected WriteOnlyHandler createHttpHandler() {
5249
return new WriteOnlyHandler();
5350
}
5451

55-
5652
@Test
5753
public void writeOnly() throws Exception {
5854
RestTemplate restTemplate = new RestTemplate();
@@ -66,7 +62,6 @@ public void writeOnly() throws Exception {
6662
assertArrayEquals(body, response.getBody());
6763
}
6864

69-
7065
private byte[] randomBytes() {
7166
byte[] buffer = new byte[REQUEST_SIZE];
7267
rnd.nextBytes(buffer);
@@ -83,4 +78,5 @@ public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response)
8378
return response.writeAndFlushWith(Flux.just(Flux.just(buffer)));
8479
}
8580
}
81+
8682
}

spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer;
3333
import org.springframework.web.client.RestTemplate;
3434

35-
import static org.junit.Assert.assertEquals;
36-
import static org.junit.Assert.assertTrue;
37-
import static org.junit.Assume.assumeTrue;
35+
import static org.junit.Assert.*;
36+
import static org.junit.Assume.*;
3837

3938
/**
4039
* @author Arjen Poutsma
@@ -43,14 +42,15 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest
4342

4443
private final ZeroCopyHandler handler = new ZeroCopyHandler();
4544

45+
4646
@Override
4747
protected HttpHandler createHttpHandler() {
48-
return handler;
48+
return this.handler;
4949
}
5050

51+
5152
@Test
5253
public void zeroCopy() throws Exception {
53-
5454
// Zero-copy only does not support servlet
5555
assumeTrue(server instanceof ReactorHttpServer || server instanceof UndertowHttpServer);
5656

@@ -64,9 +64,9 @@ public void zeroCopy() throws Exception {
6464
assertEquals(logo.contentLength(), response.getHeaders().getContentLength());
6565
assertEquals(logo.contentLength(), response.getBody().length);
6666
assertEquals(MediaType.IMAGE_PNG, response.getHeaders().getContentType());
67-
6867
}
6968

69+
7070
private static class ZeroCopyHandler implements HttpHandler {
7171

7272
@Override

spring-web/src/test/java/org/springframework/web/server/session/WebSessionIntegrationTests.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,31 +38,22 @@
3838
import org.springframework.web.server.WebSession;
3939
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
4040

41-
import static org.junit.Assert.assertEquals;
42-
import static org.junit.Assert.assertNotEquals;
43-
import static org.junit.Assert.assertNotNull;
44-
import static org.junit.Assert.assertNull;
45-
import static org.junit.Assert.assertTrue;
41+
import static org.junit.Assert.*;
4642

4743
/**
4844
* Integration tests for with a server-side session.
45+
*
4946
* @author Rossen Stoyanchev
5047
*/
5148
public class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTests {
5249

53-
private RestTemplate restTemplate;
50+
private final RestTemplate restTemplate = new RestTemplate();
5451

5552
private DefaultWebSessionManager sessionManager;
5653

5754
private TestWebHandler handler;
5855

5956

60-
@Override
61-
public void setup() throws Exception {
62-
super.setup();
63-
this.restTemplate = new RestTemplate();
64-
}
65-
6657
@Override
6758
protected HttpHandler createHttpHandler() {
6859
this.sessionManager = new DefaultWebSessionManager();

spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@
4141
import static org.springframework.web.reactive.function.server.RequestPredicates.*;
4242
import static org.springframework.web.reactive.function.server.RouterFunctions.*;
4343

44+
/**
45+
* @author Sebastien Deleuze
46+
*/
4447
public class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests {
4548

4649
private final WebClient webClient = WebClient.create();
4750

51+
4852
@Test
4953
public void multipartData() {
5054
Mono<ClientResponse> result = webClient
@@ -87,6 +91,7 @@ protected RouterFunction<ServerResponse> routerFunction() {
8791
.andRoute(POST("/parts"), multipartHandler::parts);
8892
}
8993

94+
9095
private static class MultipartHandler {
9196

9297
public Mono<ServerResponse> multipartData(ServerRequest request) {

spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn
4242
private WebClient webClient;
4343

4444

45+
@Before
46+
public void setup() throws Exception {
47+
super.setup();
48+
this.webClient = WebClient.create("http://localhost:" + this.port);
49+
}
50+
4551
@Override
4652
protected RouterFunction<?> routerFunction() {
4753
SseHandler sseHandler = new SseHandler();
@@ -50,12 +56,6 @@ protected RouterFunction<?> routerFunction() {
5056
.and(route(RequestPredicates.GET("/event"), sseHandler::sse));
5157
}
5258

53-
@Before
54-
public void setup() throws Exception {
55-
super.setup();
56-
this.webClient = WebClient.create("http://localhost:" + this.port);
57-
}
58-
5959

6060
@Test
6161
public void sseAsString() {

spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ public Mono<ServerResponse> handle(ServerRequest request) {
9393
}
9494
}
9595

96-
}
96+
}

spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,13 +39,12 @@
3939
import org.springframework.web.client.HttpClientErrorException;
4040
import org.springframework.web.client.RestTemplate;
4141
import org.springframework.web.reactive.DispatcherHandler;
42-
import org.springframework.web.server.handler.ResponseStatusExceptionHandler;
4342
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
4443
import org.springframework.web.server.WebHandler;
4544
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
45+
import org.springframework.web.server.handler.ResponseStatusExceptionHandler;
4646

47-
import static org.junit.Assert.assertArrayEquals;
48-
import static org.junit.Assert.assertEquals;
47+
import static org.junit.Assert.*;
4948

5049
/**
5150
* Integration tests with requests mapped via
@@ -66,6 +65,7 @@ protected HttpHandler createHttpHandler() {
6665
.build();
6766
}
6867

68+
6969
@Test
7070
public void testRequestToFooHandler() throws Exception {
7171
URI url = new URI("http://localhost:" + this.port + "/foo");
@@ -115,7 +115,6 @@ private static DataBuffer asDataBuffer(String text) {
115115

116116

117117
@Configuration
118-
@SuppressWarnings({"unused", "WeakerAccess"})
119118
static class WebConfig {
120119

121120
@Bean

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/AbstractRequestMappingIntegrationTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.reactive.result.method.annotation;
1718

1819
import java.net.URI;
@@ -31,9 +32,7 @@
3132
import org.springframework.web.client.RestTemplate;
3233
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
3334

34-
import static org.springframework.http.RequestEntity.get;
35-
import static org.springframework.http.RequestEntity.options;
36-
import static org.springframework.http.RequestEntity.post;
35+
import static org.springframework.http.RequestEntity.*;
3736

3837
/**
3938
* Base class for integration tests with {@code @RequestMapping methods}.

0 commit comments

Comments
 (0)