Skip to content

Commit f031364

Browse files
committed
Merge pull request #40111 from snicoll
* pr/40111: Avoid use of bean overriding in tests Closes gh-40111
2 parents af0353d + 49c97bf commit f031364

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfigurationTests.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,6 @@
3636
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext;
3737
import org.springframework.context.annotation.Bean;
3838
import org.springframework.context.annotation.Configuration;
39-
import org.springframework.context.annotation.Import;
4039
import org.springframework.http.server.ServerHttpRequest;
4140
import org.springframework.http.server.ServerHttpResponse;
4241
import org.springframework.mock.web.MockFilterChain;
@@ -241,14 +240,14 @@ private void assertRestartInvoked(boolean value) {
241240
private AnnotationConfigServletWebApplicationContext loadContext(String... properties) {
242241
AnnotationConfigServletWebApplicationContext context = new AnnotationConfigServletWebApplicationContext();
243242
context.setServletContext(new MockServletContext());
244-
context.register(Config.class, PropertyPlaceholderAutoConfiguration.class);
243+
context.register(Config.class, SecurityAutoConfiguration.class, RemoteDevToolsAutoConfiguration.class,
244+
PropertyPlaceholderAutoConfiguration.class);
245245
TestPropertyValues.of(properties).applyTo(context);
246246
context.refresh();
247247
return context;
248248
}
249249

250250
@Configuration(proxyBeanMethods = false)
251-
@Import({ SecurityAutoConfiguration.class, RemoteDevToolsAutoConfiguration.class })
252251
static class Config {
253252

254253
@Bean

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrationAotProcessorTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -117,7 +117,7 @@ void aotContributedInitializerBindsValueObjectWithSpecificConstructor() {
117117
@Test
118118
@CompileWithForkedClassLoader
119119
void aotContributedInitializerBindsJavaBean() {
120-
compile(createContext(JavaBeanSampleBeanConfiguration.class), (freshContext) -> {
120+
compile(createContext(), (freshContext) -> {
121121
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(freshContext, "test.name=Hello");
122122
freshContext.refresh();
123123
JavaBeanSampleBean bean = freshContext.getBean(JavaBeanSampleBean.class);

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void loadWhenBindingWithoutAnnotationValueShouldBind() {
261261
@Test
262262
void loadWhenBindingWithDefaultsInXmlShouldBind() {
263263
removeSystemProperties();
264-
load(new Class<?>[] { BasicConfiguration.class, DefaultsInXmlConfiguration.class });
264+
load(new Class<?>[] { DefaultsInXmlConfiguration.class });
265265
BasicProperties bean = this.context.getBean(BasicProperties.class);
266266
assertThat(bean.name).isEqualTo("bar");
267267
}
@@ -1354,6 +1354,7 @@ static class WithoutAnnotationValueConfiguration {
13541354
}
13551355

13561356
@Configuration(proxyBeanMethods = false)
1357+
@EnableConfigurationProperties
13571358
@ImportResource("org/springframework/boot/context/properties/testProperties.xml")
13581359
static class DefaultsInXmlConfiguration {
13591360

0 commit comments

Comments
 (0)