From c04d4da9a3c2615dd5634cd84f63769a56de9b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Mon, 5 Feb 2024 09:05:44 +0100 Subject: [PATCH] Polish --- .../match/MockRestRequestMatchersTests.java | 4 +-- .../MockHttpServletRequestBuilderTests.java | 2 +- .../FlashAttributeResultMatchersTests.java | 2 +- .../spr/ControllerAdviceIntegrationTests.java | 8 +++--- .../standalone/ExceptionHandlerTests.java | 28 ++----------------- 5 files changed, 11 insertions(+), 33 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/web/client/match/MockRestRequestMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/client/match/MockRestRequestMatchersTests.java index d66a8f22b1..a571c1d0f5 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/match/MockRestRequestMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/match/MockRestRequestMatchersTests.java @@ -210,7 +210,7 @@ class MockRestRequestMatchersTests { } @Test - void headerListDoesntHideHeaderWithSingleMatcher() throws IOException { + void headerListDoesNotHideHeaderWithSingleMatcher() throws IOException { this.request.getHeaders().put("foo", List.of("bar", "baz")); MockRestRequestMatchers.header("foo", equalTo("bar")).match(this.request); @@ -340,7 +340,7 @@ class MockRestRequestMatchersTests { } @Test - void queryParamListDoesntHideQueryParamWithSingleMatcher() throws IOException { + void queryParamListDoesNotHideQueryParamWithSingleMatcher() throws IOException { this.request.setURI(URI.create("http://www.foo.example/a?foo=bar&foo=baz")); MockRestRequestMatchers.queryParam("foo", equalTo("bar")).match(this.request); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java index fa09baa732..eebbd9e9e5 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java @@ -596,7 +596,7 @@ class MockHttpServletRequestBuilderTests { } - private final class User implements Principal { + private static final class User implements Principal { @Override public String getName() { diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchersTests.java index 31c028cbbd..011f256418 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchersTests.java @@ -34,7 +34,7 @@ public class FlashAttributeResultMatchersTests { } @Test - public void attributeExists_doesntExist() { + public void attributeExists_DoesNotExist() { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> new FlashAttributeResultMatchers().attributeExists("bad").match(getStubMvcResult())); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java index d15bef2efc..319e9aa7a6 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ControllerAdviceIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -138,7 +138,7 @@ class ControllerAdviceIntegrationTests { static final AtomicInteger instanceCount = new AtomicInteger(); static final AtomicInteger invocationCount = new AtomicInteger(); - { + SingletonControllerAdvice() { instanceCount.incrementAndGet(); } @@ -154,7 +154,7 @@ class ControllerAdviceIntegrationTests { static final AtomicInteger instanceCount = new AtomicInteger(); static final AtomicInteger invocationCount = new AtomicInteger(); - { + PrototypeControllerAdvice() { instanceCount.incrementAndGet(); } @@ -170,7 +170,7 @@ class ControllerAdviceIntegrationTests { static final AtomicInteger instanceCount = new AtomicInteger(); static final AtomicInteger invocationCount = new AtomicInteger(); - { + RequestScopedControllerAdvice() { instanceCount.incrementAndGet(); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ExceptionHandlerTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ExceptionHandlerTests.java index f76164c785..24b1c5cfed 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ExceptionHandlerTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ExceptionHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -184,30 +184,8 @@ public class ExceptionHandlerTests { } } - static class Person { + record Person(String name) {} - private final String name; - - Person(String name) { - this.name = name; - } - - public String getName() { - return name; - } - } - - static class Error { - - private final String error; - - Error(String error) { - this.error = error; - } - - public String getError() { - return error; - } - } + record Error(String error) {} }