From 4ff9adcaaf4ef44d3461fed60290751650149546 Mon Sep 17 00:00:00 2001 From: albonidrizi Date: Fri, 12 Dec 2025 14:43:07 +0100 Subject: [PATCH] Resolve TODO: Add test for expression value resolution with ServerWebExchange Add resolveWithServerWebExchange() test method to verify that expression value resolution works correctly when a ServerWebExchange is provided to the resolver. The test creates a custom MockServerWebExchange instance and confirms that @Value expressions are properly resolved. The test follows the existing pattern established by resolveSystemProperty() and ensures the ExpressionValueMethodArgumentResolver functions properly in reactive WebFlux contexts with ServerWebExchange instances. Signed-off-by: albonidrizi --- ...ssionValueMethodArgumentResolverTests.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java index 61f3bddf22f..d431984aba1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java @@ -48,6 +48,7 @@ class ExpressionValueMethodArgumentResolverTests { private MethodParameter paramSystemProperty; private MethodParameter paramNotSupported; private MethodParameter paramAlsoNotSupported; + private MethodParameter paramCustomProperty; @BeforeEach @@ -61,6 +62,7 @@ class ExpressionValueMethodArgumentResolverTests { this.paramSystemProperty = new MethodParameter(method, 0); this.paramNotSupported = new MethodParameter(method, 1); this.paramAlsoNotSupported = new MethodParameter(method, 2); + this.paramCustomProperty = new MethodParameter(method, 3); } @@ -93,14 +95,32 @@ class ExpressionValueMethodArgumentResolverTests { } - // TODO: test with expression for ServerWebExchange + @Test + void resolveWithServerWebExchange() { + System.setProperty("customProperty", "42"); + try { + // Configure the exchange + MockServerHttpRequest request = MockServerHttpRequest.get("/test").build(); + MockServerWebExchange exchange = MockServerWebExchange.from(request); + + Mono mono = this.resolver.resolveArgument( + this.paramCustomProperty, new BindingContext(), exchange); + + Object value = mono.block(); + assertThat(value).isEqualTo(42); + } + finally { + System.clearProperty("customProperty"); + } + } @SuppressWarnings("unused") public void params( @Value("#{systemProperties.systemProperty}") int param1, String notSupported, - @Value("#{systemProperties.foo}") Mono alsoNotSupported) { + @Value("#{systemProperties.foo}") Mono alsoNotSupported, + @Value("#{systemProperties.customProperty}") int param4) { } }