From fff50657d241a2756d885f49b3d5eda1b1c4af55 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 20 Nov 2023 21:01:40 +0100 Subject: [PATCH] Polishing --- .../config/EnableCachingIntegrationTests.java | 2 +- .../interceptor/CacheErrorHandlerTests.java | 29 ++++++++++--------- .../interceptor/CachePutEvaluationTests.java | 10 +++---- .../CacheResolverCustomizationTests.java | 17 ++++++----- .../web/servlet/config/spring-mvc.xsd | 10 +++---- .../web/socket/config/spring-websocket.xsd | 6 ++-- 6 files changed, 39 insertions(+), 35 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java index f4e25b70caf..0c3b2181eb2 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java @@ -54,7 +54,7 @@ class EnableCachingIntegrationTests { @AfterEach - public void closeContext() { + void closeContext() { if (this.context != null) { this.context.close(); } diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheErrorHandlerTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheErrorHandlerTests.java index 8593ba54b6b..ade3d831b82 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheErrorHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheErrorHandlerTests.java @@ -60,6 +60,7 @@ class CacheErrorHandlerTests { private SimpleService simpleService; + @BeforeEach void setup() { this.context = new AnnotationConfigApplicationContext(Config.class); @@ -69,11 +70,13 @@ class CacheErrorHandlerTests { this.simpleService = context.getBean(SimpleService.class); } + @AfterEach - void tearDown() { + void closeContext() { this.context.close(); } + @Test void getFail() { UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get"); @@ -107,9 +110,9 @@ class CacheErrorHandlerTests { this.cacheInterceptor.setErrorHandler(new SimpleCacheErrorHandler()); - assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> - this.simpleService.get(0L)) - .withMessage("Test exception on get"); + assertThatExceptionOfType(UnsupportedOperationException.class) + .isThrownBy(() -> this.simpleService.get(0L)) + .withMessage("Test exception on get"); } @Test @@ -128,9 +131,9 @@ class CacheErrorHandlerTests { this.cacheInterceptor.setErrorHandler(new SimpleCacheErrorHandler()); - assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> - this.simpleService.put(0L)) - .withMessage("Test exception on put"); + assertThatExceptionOfType(UnsupportedOperationException.class) + .isThrownBy(() -> this.simpleService.put(0L)) + .withMessage("Test exception on put"); } @Test @@ -149,9 +152,9 @@ class CacheErrorHandlerTests { this.cacheInterceptor.setErrorHandler(new SimpleCacheErrorHandler()); - assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> - this.simpleService.evict(0L)) - .withMessage("Test exception on evict"); + assertThatExceptionOfType(UnsupportedOperationException.class) + .isThrownBy(() -> this.simpleService.evict(0L)) + .withMessage("Test exception on evict"); } @Test @@ -170,9 +173,9 @@ class CacheErrorHandlerTests { this.cacheInterceptor.setErrorHandler(new SimpleCacheErrorHandler()); - assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> - this.simpleService.clear()) - .withMessage("Test exception on clear"); + assertThatExceptionOfType(UnsupportedOperationException.class) + .isThrownBy(() -> this.simpleService.clear()) + .withMessage("Test exception on clear"); } diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java index f80f6b8461c..3bc0eacdd89 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 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. @@ -51,6 +51,7 @@ public class CachePutEvaluationTests { private SimpleService service; + @BeforeEach public void setup() { this.context = new AnnotationConfigApplicationContext(Config.class); @@ -59,12 +60,11 @@ public class CachePutEvaluationTests { } @AfterEach - public void close() { - if (this.context != null) { - this.context.close(); - } + public void closeContext() { + this.context.close(); } + @Test public void mutualGetPutExclusion() { String key = "1"; diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java index 51200a4408a..4e5cafd54b9 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -72,7 +72,7 @@ class CacheResolverCustomizationTests { } @AfterEach - void tearDown() { + void closeContext() { this.context.close(); } @@ -142,16 +142,17 @@ class CacheResolverCustomizationTests { @Test void noCacheResolved() { Method method = ReflectionUtils.findMethod(SimpleService.class, "noCacheResolved", Object.class); - assertThatIllegalStateException().isThrownBy(() -> - this.simpleService.noCacheResolved(new Object())) - .withMessageContaining(method.toString()); + + assertThatIllegalStateException() + .isThrownBy(() -> this.simpleService.noCacheResolved(new Object())) + .withMessageContaining(method.toString()); } @Test void unknownCacheResolver() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> - this.simpleService.unknownCacheResolver(new Object())) - .satisfies(ex -> assertThat(ex.getBeanName()).isEqualTo("unknownCacheResolver")); + assertThatExceptionOfType(NoSuchBeanDefinitionException.class) + .isThrownBy(() -> this.simpleService.unknownCacheResolver(new Object())) + .satisfies(ex -> assertThat(ex.getBeanName()).isEqualTo("unknownCacheResolver")); } diff --git a/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc.xsd b/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc.xsd index db09c916c74..6a674fcf179 100644 --- a/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc.xsd +++ b/spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc.xsd @@ -1350,12 +1350,12 @@ set on the "Access-Control-Allow-Credentials" response header of preflight requests. - NOTE: Be aware that this option establishes a high - level of trust with the configured domains and also increases the surface - attack of the web application by exposing sensitive user-specific - information such as cookies and CSRF tokens. + NOTE: Be aware that this option establishes a high level of trust with + the configured domains and also increases the surface attack of the web + application by exposing sensitive user-specific information such as + cookies and CSRF tokens. - By default this is not set in which case the + By default, this is not set in which case the "Access-Control-Allow-Credentials" header is also not set and credentials are therefore not allowed. ]]> diff --git a/spring-websocket/src/main/resources/org/springframework/web/socket/config/spring-websocket.xsd b/spring-websocket/src/main/resources/org/springframework/web/socket/config/spring-websocket.xsd index 271332f5cb0..31de8dbb07c 100644 --- a/spring-websocket/src/main/resources/org/springframework/web/socket/config/spring-websocket.xsd +++ b/spring-websocket/src/main/resources/org/springframework/web/socket/config/spring-websocket.xsd @@ -420,7 +420,7 @@ @@ -453,7 +453,7 @@