From 8334cb1abbb16d8f9ddeccfd34717ed045788ee4 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Thu, 6 Mar 2025 17:32:32 +0100 Subject: [PATCH] Revise tests to better express intent --- .../function/server/PathResourceLookupFunctionTests.java | 6 ++++-- .../servlet/function/PathResourceLookupFunctionTests.java | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java index 08bf35bdcdf..25b65cdc673 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java @@ -31,6 +31,8 @@ import org.springframework.core.io.Resource; import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest; import org.springframework.web.testfixture.server.MockServerWebExchange; +import static org.assertj.core.api.Assertions.assertThatNoException; + /** * @author Arjen Poutsma */ @@ -128,13 +130,13 @@ class PathResourceLookupFunctionTests { @SuppressWarnings("removal") void withPathResource() { org.springframework.core.io.PathResource location = new org.springframework.core.io.PathResource("/static/"); - PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location); + assertThatNoException().isThrownBy(() -> new PathResourceLookupFunction("/resources/**", location)); } @Test void withFileSystemResource() { FileSystemResource location = new FileSystemResource("/static/"); - PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location); + assertThatNoException().isThrownBy(() -> new PathResourceLookupFunction("/resources/**", location)); } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/PathResourceLookupFunctionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/PathResourceLookupFunctionTests.java index 582ae35295c..de2ec886f3b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/PathResourceLookupFunctionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/PathResourceLookupFunctionTests.java @@ -29,6 +29,7 @@ import org.springframework.core.io.Resource; import org.springframework.web.servlet.handler.PathPatternsTestUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; /** * @author Arjen Poutsma @@ -107,13 +108,13 @@ class PathResourceLookupFunctionTests { @SuppressWarnings("removal") void withPathResource() { org.springframework.core.io.PathResource location = new org.springframework.core.io.PathResource("/static/"); - PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location); + assertThatNoException().isThrownBy(() -> new PathResourceLookupFunction("/resources/**", location)); } @Test void withFileSystemResource() { FileSystemResource location = new FileSystemResource("/static/"); - PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location); + assertThatNoException().isThrownBy(() -> new PathResourceLookupFunction("/resources/**", location)); } }