Skip to content

Commit dd4468a

Browse files
committed
Polishing
1 parent 7f1a8d7 commit dd4468a

File tree

6 files changed

+28
-30
lines changed

6 files changed

+28
-30
lines changed

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@
5252
import static org.hamcrest.CoreMatchers.instanceOf;
5353
import static org.hamcrest.CoreMatchers.startsWith;
5454
import static org.hamcrest.Matchers.is;
55-
import static org.junit.Assert.assertEquals;
56-
import static org.junit.Assert.assertSame;
57-
import static org.junit.Assert.assertThat;
58-
import static org.springframework.http.MediaType.APPLICATION_JSON;
55+
import static org.junit.Assert.*;
56+
import static org.springframework.http.MediaType.*;
5957

6058
/**
6159
* Test the effect of exceptions at different stages of request processing by
@@ -72,7 +70,7 @@ public class DispatcherHandlerErrorTests {
7270

7371

7472
@Before
75-
public void setup() throws Exception {
73+
public void setup() {
7674
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
7775
ctx.register(TestConfig.class);
7876
ctx.refresh();
@@ -81,7 +79,7 @@ public void setup() throws Exception {
8179

8280

8381
@Test
84-
public void noHandler() throws Exception {
82+
public void noHandler() {
8583
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/does-not-exist"));
8684
Mono<Void> publisher = this.dispatcherHandler.handle(exchange);
8785

@@ -95,7 +93,7 @@ public void noHandler() throws Exception {
9593
}
9694

9795
@Test
98-
public void controllerReturnsMonoError() throws Exception {
96+
public void controllerReturnsMonoError() {
9997
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/error-signal"));
10098
Mono<Void> publisher = this.dispatcherHandler.handle(exchange);
10199

@@ -105,7 +103,7 @@ public void controllerReturnsMonoError() throws Exception {
105103
}
106104

107105
@Test
108-
public void controllerThrowsException() throws Exception {
106+
public void controllerThrowsException() {
109107
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/raise-exception"));
110108
Mono<Void> publisher = this.dispatcherHandler.handle(exchange);
111109

@@ -115,7 +113,7 @@ public void controllerThrowsException() throws Exception {
115113
}
116114

117115
@Test
118-
public void unknownReturnType() throws Exception {
116+
public void unknownReturnType() {
119117
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/unknown-return-type"));
120118
Mono<Void> publisher = this.dispatcherHandler.handle(exchange);
121119

@@ -128,7 +126,7 @@ public void unknownReturnType() throws Exception {
128126
}
129127

130128
@Test
131-
public void responseBodyMessageConversionError() throws Exception {
129+
public void responseBodyMessageConversionError() {
132130
ServerWebExchange exchange = MockServerWebExchange.from(
133131
MockServerHttpRequest.post("/request-body").accept(APPLICATION_JSON).body("body"));
134132

@@ -140,7 +138,7 @@ public void responseBodyMessageConversionError() throws Exception {
140138
}
141139

142140
@Test
143-
public void requestBodyError() throws Exception {
141+
public void requestBodyError() {
144142
ServerWebExchange exchange = MockServerWebExchange.from(
145143
MockServerHttpRequest.post("/request-body").body(Mono.error(EXCEPTION)));
146144

@@ -152,7 +150,7 @@ public void requestBodyError() throws Exception {
152150
}
153151

154152
@Test
155-
public void webExceptionHandler() throws Exception {
153+
public void webExceptionHandler() {
156154
ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/unknown-argument-type"));
157155

158156
List<WebExceptionHandler> handlers = Collections.singletonList(new ServerError500ExceptionHandler());
@@ -202,12 +200,12 @@ public Publisher<String> errorSignal() {
202200
}
203201

204202
@RequestMapping("/raise-exception")
205-
public void raiseException() throws Exception {
203+
public void raiseException() {
206204
throw EXCEPTION;
207205
}
208206

209207
@RequestMapping("/unknown-return-type")
210-
public Foo unknownReturnType() throws Exception {
208+
public Foo unknownReturnType() {
211209
return new Foo();
212210
}
213211

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 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;
1718

1819
import java.nio.charset.StandardCharsets;
@@ -32,11 +33,9 @@
3233
import org.springframework.web.method.ResolvableMethod;
3334
import org.springframework.web.server.ServerWebExchange;
3435

35-
import static org.junit.Assert.assertEquals;
36-
import static org.mockito.ArgumentMatchers.any;
37-
import static org.mockito.Mockito.mock;
38-
import static org.mockito.Mockito.when;
39-
import static org.mockito.Mockito.withSettings;
36+
import static org.junit.Assert.*;
37+
import static org.mockito.ArgumentMatchers.*;
38+
import static org.mockito.Mockito.*;
4039

4140
/**
4241
* Unit tests for {@link DispatcherHandler}.
@@ -49,8 +48,7 @@ public class DispatcherHandlerTests {
4948

5049

5150
@Test
52-
public void handlerMappingOrder() throws Exception {
53-
51+
public void handlerMappingOrder() {
5452
HandlerMapping hm1 = mock(HandlerMapping.class, withSettings().extraInterfaces(Ordered.class));
5553
HandlerMapping hm2 = mock(HandlerMapping.class, withSettings().extraInterfaces(Ordered.class));
5654
when(((Ordered) hm1).getOrder()).thenReturn(1);
@@ -90,6 +88,7 @@ public Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler) {
9088
}
9189
}
9290

91+
9392
private static class StringHandlerResultHandler implements HandlerResultHandler {
9493

9594
@Override
@@ -105,4 +104,5 @@ public Mono<Void> handleResult(ServerWebExchange exchange, HandlerResult result)
105104
return exchange.getResponse().writeWith(Mono.just(dataBuffer));
106105
}
107106
}
107+
108108
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
/**
3838
* Integration tests for server response flushing behavior.
39+
*
3940
* @author Sebastien Deleuze
4041
* @author Rossen Stoyanchev
4142
* @since 5.0
@@ -160,4 +161,5 @@ private DataBuffer wrap(String value, ServerHttpResponse response) {
160161
return response.bufferFactory().wrap(bytes);
161162
}
162163
}
164+
163165
}

spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 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.
@@ -114,7 +114,6 @@ public static Object[][] arguments() throws IOException {
114114

115115
@Before
116116
public void setup() throws Exception {
117-
118117
this.server.setHandler(createHttpHandler());
119118
this.server.afterPropertiesSet();
120119
this.server.start();
@@ -128,7 +127,7 @@ public void setup() throws Exception {
128127
}
129128

130129
@After
131-
public void stop() throws Exception {
130+
public void stop() {
132131
if (this.client instanceof Lifecycle) {
133132
((Lifecycle) this.client).stop();
134133
}

spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
import org.springframework.web.reactive.HandlerMapping;
3939
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
4040

41-
import static org.junit.Assert.assertEquals;
42-
import static org.junit.Assert.assertThat;
41+
import static org.junit.Assert.*;
4342

4443
/**
4544
* Integration tests with server-side {@link WebSocketHandler}s.
45+
*
4646
* @author Rossen Stoyanchev
4747
*/
4848
public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests {
@@ -192,6 +192,7 @@ public Mono<Void> handle(WebSocketSession session) {
192192
}
193193
}
194194

195+
195196
private static class SessionClosingHandler implements WebSocketHandler {
196197

197198
@Override

spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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.socket.server.support;
1718

1819
import java.util.Arrays;
@@ -42,10 +43,8 @@
4243
*/
4344
public class HandshakeWebSocketServiceTests {
4445

45-
4646
@Test
4747
public void sessionAttributePredicate() {
48-
4948
MockWebSession session = new MockWebSession();
5049
session.getAttributes().put("a1", "v1");
5150
session.getAttributes().put("a2", "v2");
@@ -86,7 +85,6 @@ private static class TestRequestUpgradeStrategy implements RequestUpgradeStrateg
8685

8786
HandshakeInfo handshakeInfo;
8887

89-
9088
@Override
9189
public Mono<Void> upgrade(ServerWebExchange exchange, WebSocketHandler webSocketHandler,
9290
@Nullable String subProtocol, Supplier<HandshakeInfo> handshakeInfoFactory) {

0 commit comments

Comments
 (0)