Skip to content

Commit f11a1e6

Browse files
committed
Polish tests
1 parent ffc7854 commit f11a1e6

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

spring-web/src/test/java/org/springframework/http/client/JdkClientHttpRequestTests.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@
2828
import java.util.concurrent.ExecutorService;
2929
import java.util.concurrent.Executors;
3030

31-
import org.junit.jupiter.api.AfterEach;
32-
import org.junit.jupiter.api.BeforeEach;
31+
import org.junit.jupiter.api.AutoClose;
3332
import org.junit.jupiter.api.Test;
3433

3534
import org.springframework.http.HttpHeaders;
3635
import org.springframework.http.HttpMethod;
3736

3837
import static org.assertj.core.api.Assertions.assertThatThrownBy;
39-
import static org.mockito.Mockito.any;
38+
import static org.mockito.ArgumentMatchers.any;
4039
import static org.mockito.Mockito.mock;
4140
import static org.mockito.Mockito.when;
4241

@@ -47,21 +46,12 @@ class JdkClientHttpRequestTests {
4746

4847
private final HttpClient client = mock(HttpClient.class);
4948

50-
private ExecutorService executor;
51-
52-
53-
@BeforeEach
54-
void setup() {
55-
executor = Executors.newSingleThreadExecutor();
56-
}
57-
58-
@AfterEach
59-
void tearDown() {
60-
executor.shutdownNow();
61-
}
49+
@AutoClose("shutdownNow")
50+
private final ExecutorService executor = Executors.newSingleThreadExecutor();
6251

6352

6453
@Test
54+
@SuppressWarnings("unchecked")
6555
void futureCancelledAfterTimeout() {
6656
CompletableFuture<HttpResponse<InputStream>> future = new CompletableFuture<>();
6757
when(client.sendAsync(any(HttpRequest.class), any(HttpResponse.BodyHandler.class))).thenReturn(future);
@@ -71,6 +61,7 @@ void futureCancelledAfterTimeout() {
7161
}
7262

7363
@Test
64+
@SuppressWarnings("unchecked")
7465
void futureCancelled() {
7566
CompletableFuture<HttpResponse<InputStream>> future = new CompletableFuture<>();
7667
future.cancel(true);

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public String handle(Model model) {
393393
}
394394

395395

396-
private static class SseController {
396+
static class SseController {
397397

398398
public ResponseEntity<?> handle(@RequestParam String q) throws IOException {
399399
if (q.equals("sse")) {

0 commit comments

Comments
 (0)