Skip to content

Commit 533544d

Browse files
committed
Polish
1 parent 5ec993b commit 533544d

File tree

6 files changed

+21
-44
lines changed

6 files changed

+21
-44
lines changed

core/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/client/WebTestClientBuilderCustomizer.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818

1919
import org.springframework.context.ApplicationContext;
2020
import org.springframework.test.web.reactive.server.WebTestClient;
21-
import org.springframework.test.web.reactive.server.WebTestClient.Builder;
2221

2322
/**
24-
* A customizer that can be implemented by beans wishing to customize the {@link Builder}
25-
* to fine-tune its auto-configuration before a {@link WebTestClient} is created.
26-
* Implementations can be registered in the {@link ApplicationContext} or
27-
* {@code spring.factories}.
23+
* A customizer that can be implemented by beans wishing to customize the
24+
* {@link WebTestClient.Builder} to fine-tune its auto-configuration before a
25+
* {@link WebTestClient} is created. Implementations can be registered in the
26+
* {@link ApplicationContext} or {@code spring.factories}.
2827
*
2928
* @author Andy Wilkinson
3029
* @since 4.0.0
@@ -36,6 +35,6 @@ public interface WebTestClientBuilderCustomizer {
3635
* Customize the given {@code builder}.
3736
* @param builder the builder
3837
*/
39-
void customize(Builder builder);
38+
void customize(WebTestClient.Builder builder);
4039

4140
}

core/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizer.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) t
123123
}
124124
}
125125

126-
@Override
127-
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
128-
}
129-
130126
}
131127

132128
/**
@@ -143,11 +139,6 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
143139
this.applicationContext = applicationContext;
144140
}
145141

146-
@Override
147-
public boolean isSingleton() {
148-
return true;
149-
}
150-
151142
@Override
152143
public Class<?> getObjectType() {
153144
return WebTestClient.class;
@@ -164,26 +155,25 @@ public WebTestClient getObject() throws Exception {
164155
private WebTestClient createWebTestClient() {
165156
Assert.state(this.applicationContext != null, "ApplicationContext not injected");
166157
WebTestClient.Builder builder = WebTestClient.bindToServer();
167-
customizeWebTestClientBuilder(builder, this.applicationContext);
158+
customizeWebTestClientBuilder(builder);
168159
BaseUrl baseUrl = new BaseUrlProviders(this.applicationContext).getBaseUrl();
169160
if (baseUrl != null) {
170161
builder.baseUrl(baseUrl.resolve());
171162
}
172163
return builder.build();
173164
}
174165

175-
private void customizeWebTestClientBuilder(WebTestClient.Builder clientBuilder, ApplicationContext context) {
166+
private void customizeWebTestClientBuilder(WebTestClient.Builder clientBuilder) {
176167
Assert.state(this.applicationContext != null, "ApplicationContext not injected");
177168
getWebTestClientBuilderCustomizers(this.applicationContext)
178169
.forEach((customizer) -> customizer.customize(clientBuilder));
179170
}
180171

181172
private List<WebTestClientBuilderCustomizer> getWebTestClientBuilderCustomizers(ApplicationContext context) {
182173
List<WebTestClientBuilderCustomizer> customizers = new ArrayList<>();
183-
SpringFactoriesLoader.forDefaultResourceLocation(context.getClassLoader())
184-
.load(WebTestClientBuilderCustomizer.class, ArgumentResolver.of(ApplicationContext.class, context))
185-
.forEach(customizers::add);
186-
context.getBeansOfType(WebTestClientBuilderCustomizer.class).values().forEach(customizers::add);
174+
customizers.addAll(SpringFactoriesLoader.forDefaultResourceLocation(context.getClassLoader())
175+
.load(WebTestClientBuilderCustomizer.class, ArgumentResolver.of(ApplicationContext.class, context)));
176+
customizers.addAll(context.getBeansOfType(WebTestClientBuilderCustomizer.class).values());
187177
return customizers;
188178
}
189179

core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientBuilderCustomizer.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818

1919
import org.springframework.context.ApplicationContext;
2020
import org.springframework.test.web.servlet.client.RestTestClient;
21-
import org.springframework.test.web.servlet.client.RestTestClient.Builder;
2221

2322
/**
24-
* A customizer that can be implemented by beans wishing to customize the {@link Builder}
25-
* to fine-tune its auto-configuration before a {@link RestTestClient} is created.
26-
* Implementations can be registered in the {@link ApplicationContext} or
27-
* {@code spring.factories}.
23+
* A customizer that can be implemented by beans wishing to customize the
24+
* {@link RestTestClient.Builder} to fine-tune its auto-configuration before a
25+
* {@link RestTestClient} is created. Implementations can be registered in the
26+
* {@link ApplicationContext} or {@code spring.factories}.
2827
*
2928
* @author Stephane Nicoll
3029
* @since 4.0.0
@@ -33,9 +32,9 @@
3332
public interface RestTestClientBuilderCustomizer {
3433

3534
/**
36-
* Customize the given {@link Builder Builder}.
35+
* Customize the given {@link RestTestClient.Builder Builder}.
3736
* @param builder the builder
3837
*/
39-
void customize(Builder<?> builder);
38+
void customize(RestTestClient.Builder<?> builder);
4039

4140
}

core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizer.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) t
125125

126126
}
127127

128-
@Override
129-
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
130-
}
131-
132128
}
133129

134130
/**
@@ -145,11 +141,6 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
145141
this.applicationContext = applicationContext;
146142
}
147143

148-
@Override
149-
public boolean isSingleton() {
150-
return true;
151-
}
152-
153144
@Override
154145
public Class<?> getObjectType() {
155146
return RestTestClient.class;
@@ -166,24 +157,22 @@ public RestTestClient getObject() {
166157
private RestTestClient createRestTestClient() {
167158
Assert.state(this.applicationContext != null, "ApplicationContext not injected");
168159
RestTestClient.Builder<?> builder = RestTestClient.bindToServer();
169-
customizeRestTestClientBuilder(builder, this.applicationContext);
160+
customizeRestTestClientBuilder(builder);
170161
BaseUrl baseUrl = new BaseUrlProviders(this.applicationContext).getBaseUrl();
171162
return builder.uriBuilderFactory(BaseUrlUriBuilderFactory.get(baseUrl)).build();
172163
}
173164

174-
private void customizeRestTestClientBuilder(RestTestClient.Builder<?> clientBuilder,
175-
ApplicationContext context) {
165+
private void customizeRestTestClientBuilder(RestTestClient.Builder<?> clientBuilder) {
176166
Assert.state(this.applicationContext != null, "ApplicationContext not injected");
177167
getRestTestClientBuilderCustomizers(this.applicationContext)
178168
.forEach((customizer) -> customizer.customize(clientBuilder));
179169
}
180170

181171
private List<RestTestClientBuilderCustomizer> getRestTestClientBuilderCustomizers(ApplicationContext context) {
182172
List<RestTestClientBuilderCustomizer> customizers = new ArrayList<>();
183-
SpringFactoriesLoader.forDefaultResourceLocation(context.getClassLoader())
184-
.load(RestTestClientBuilderCustomizer.class, ArgumentResolver.of(ApplicationContext.class, context))
185-
.forEach(customizers::add);
186-
context.getBeansOfType(RestTestClientBuilderCustomizer.class).values().forEach(customizers::add);
173+
customizers.addAll(SpringFactoriesLoader.forDefaultResourceLocation(context.getClassLoader())
174+
.load(RestTestClientBuilderCustomizer.class, ArgumentResolver.of(ApplicationContext.class, context)));
175+
customizers.addAll(context.getBeansOfType(RestTestClientBuilderCustomizer.class).values());
187176
return customizers;
188177
}
189178

0 commit comments

Comments
 (0)