mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-21 13:31:46 +00:00
Polishing contribution
Closes gh-36225
This commit is contained in:
+9
-8
@@ -19,6 +19,7 @@ package org.springframework.web.service.invoker;
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.web.service.annotation.GetExchange;
|
||||
|
||||
@@ -43,19 +44,19 @@ public class HttpServiceProxyFactoryTests {
|
||||
assertThat(service.execute()).isEqualTo("decorated");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void proxyFactoryCustomizer() {
|
||||
var mi = (MethodInterceptor) invocation -> "intercepted";
|
||||
var factory = HttpServiceProxyFactory.builderFor(mock(HttpExchangeAdapter.class))
|
||||
.proxyCustomizer((fact, serviceType) -> {
|
||||
fact.addAdvice(0, mi);
|
||||
}).build();
|
||||
var interceptor = (MethodInterceptor) invocation -> "intercepted";
|
||||
var proxyFactory = HttpServiceProxyFactory.builderFor(mock(HttpExchangeAdapter.class))
|
||||
.proxyFactoryCustomizer((factory, serviceType) -> factory.addAdvice(0, interceptor))
|
||||
.build();
|
||||
|
||||
var service = factory.createClient(Service.class);
|
||||
assertThat(service.execute()).isEqualTo("intercepted");
|
||||
String result = proxyFactory.createClient(Service.class).execute();
|
||||
|
||||
assertThat(result).isEqualTo("intercepted");
|
||||
}
|
||||
|
||||
|
||||
private interface Service {
|
||||
|
||||
@GetExchange
|
||||
|
||||
Reference in New Issue
Block a user