Add Builder to HttpServiceProxyFactory

HttpServiceProxyFactory now support programmatic initialization through
a builder, while bean-style initialization is deprecated.

See gh-29296
This commit is contained in:
rstoyanchev
2022-10-17 12:23:42 +01:00
parent e03abc94ff
commit 5cb3af708c
14 changed files with 413 additions and 107 deletions

View File

@@ -42,8 +42,7 @@ class CookieValueArgumentResolverTests {
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
proxyFactory.afterPropertiesSet();
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}

View File

@@ -43,7 +43,7 @@ public class HttpMethodArgumentResolverTests {
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
proxyFactory.afterPropertiesSet();
this.service = proxyFactory.createClient(Service.class);
}

View File

@@ -64,7 +64,7 @@ public class HttpServiceMethodTests {
@BeforeEach
void setUp() throws Exception {
this.proxyFactory = new HttpServiceProxyFactory(this.client);
this.proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.proxyFactory.afterPropertiesSet();
}
@@ -174,10 +174,10 @@ public class HttpServiceMethodTests {
}
@Test
void typeAndMethodAnnotatedService() throws Exception {
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
proxyFactory.setEmbeddedValueResolver(value -> (value.equals("${baseUrl}") ? "/base" : value));
proxyFactory.afterPropertiesSet();
void typeAndMethodAnnotatedService() {
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client)
.embeddedValueResolver(value -> (value.equals("${baseUrl}") ? "/base" : value))
.build();
MethodLevelAnnotatedService service = proxyFactory.createClient(TypeAndMethodLevelAnnotatedService.class);

View File

@@ -61,8 +61,9 @@ class NamedValueArgumentResolverTests {
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
proxyFactory.addCustomArgumentResolver(this.argumentResolver);
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client)
.customArgumentResolver(this.argumentResolver)
.build();
proxyFactory.afterPropertiesSet();
this.service = proxyFactory.createClient(Service.class);

View File

@@ -41,7 +41,7 @@ class PathVariableArgumentResolverTests {
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
proxyFactory.afterPropertiesSet();
this.service = proxyFactory.createClient(Service.class);
}

View File

@@ -40,8 +40,7 @@ class RequestAttributeArgumentResolverTests {
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
proxyFactory.afterPropertiesSet();
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}

View File

@@ -45,8 +45,7 @@ public class RequestBodyArgumentResolverTests {
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
proxyFactory.afterPropertiesSet();
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}

View File

@@ -43,8 +43,7 @@ class RequestHeaderArgumentResolverTests {
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
proxyFactory.afterPropertiesSet();
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}

View File

@@ -45,8 +45,7 @@ public class RequestParamArgumentResolverTests {
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
proxyFactory.afterPropertiesSet();
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}

View File

@@ -40,8 +40,7 @@ public class UrlArgumentResolverTests {
@BeforeEach
void setUp() throws Exception {
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
proxyFactory.afterPropertiesSet();
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
this.service = proxyFactory.createClient(Service.class);
}