Replace usages of EnvironmentTestUtils

pull/3335/merge
Madhura Bhave 8 years ago
parent 05254fe322
commit d745b69630

@ -23,7 +23,7 @@ import net.minidev.json.JSONArray;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer; import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext; import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
@ -123,7 +123,7 @@ public class BootCuriesHrefIntegrationTests {
} }
}); });
EnvironmentTestUtils.addEnvironment(this.context, properties); TestPropertyValues.of(properties).applyTo(this.context);
this.context.register(TestConfiguration.class); this.context.register(TestConfiguration.class);
new ServerPortInfoApplicationContextInitializer().initialize(this.context); new ServerPortInfoApplicationContextInitializer().initialize(this.context);
this.context.refresh(); this.context.refresh();

@ -59,7 +59,7 @@ import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder; import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource; import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
import org.springframework.boot.logging.LoggingSystem; import org.springframework.boot.logging.LoggingSystem;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -172,7 +172,7 @@ public class EndpointAutoConfigurationTests {
@Test @Test
public void testInfoEndpoint() throws Exception { public void testInfoEndpoint() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "info.foo:bar"); TestPropertyValues.of("info.foo:bar").applyTo(this.context);
this.context.register(ProjectInfoAutoConfiguration.class, this.context.register(ProjectInfoAutoConfiguration.class,
InfoContributorAutoConfiguration.class, EndpointAutoConfiguration.class); InfoContributorAutoConfiguration.class, EndpointAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -186,8 +186,7 @@ public class EndpointAutoConfigurationTests {
@Test @Test
public void testInfoEndpointNoGitProperties() throws Exception { public void testInfoEndpointNoGitProperties() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of("spring.info.git.location:classpath:nonexistent").applyTo(this.context);
"spring.info.git.location:classpath:nonexistent");
this.context.register(InfoContributorAutoConfiguration.class, this.context.register(InfoContributorAutoConfiguration.class,
EndpointAutoConfiguration.class); EndpointAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -199,7 +198,7 @@ public class EndpointAutoConfigurationTests {
@Test @Test
public void testInfoEndpointOrdering() throws Exception { public void testInfoEndpointOrdering() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "info.name:foo"); TestPropertyValues.of("info.name:foo").applyTo(this.context);
this.context.register(CustomInfoContributorsConfig.class, this.context.register(CustomInfoContributorsConfig.class,
ProjectInfoAutoConfiguration.class, ProjectInfoAutoConfiguration.class,
InfoContributorAutoConfiguration.class, EndpointAutoConfiguration.class); InfoContributorAutoConfiguration.class, EndpointAutoConfiguration.class);

@ -64,7 +64,7 @@ import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConf
import org.springframework.boot.context.event.ApplicationFailedEvent; import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources; import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.logging.LoggingSystem; import org.springframework.boot.logging.LoggingSystem;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.testutil.Matched; import org.springframework.boot.testutil.Matched;
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer; import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
@ -124,9 +124,9 @@ public class EndpointWebMvcAutoConfigurationTests {
public void setUp() { public void setUp() {
Ports values = new Ports(); Ports values = new Ports();
ports.set(values); ports.set(values);
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.context-path=", "management.security.enabled=false", "management.context-path=", "management.security.enabled=false",
"server.servlet.context-path=", "server.port=" + ports.get().server); "server.servlet.context-path=", "server.port=" + ports.get().server).applyTo(this.applicationContext);
} }
@After @After
@ -137,8 +137,8 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void onSamePort() throws Exception { public void onSamePort() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.security.enabled=false"); "management.security.enabled=false").applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class); BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class);
this.applicationContext.refresh(); this.applicationContext.refresh();
@ -154,8 +154,8 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void onSamePortWithHeader() throws Exception { public void onSamePortWithHeader() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.add-application-context-header:true"); "management.add-application-context-header:true").applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class); BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class);
this.applicationContext.refresh(); this.applicationContext.refresh();
@ -167,8 +167,8 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void onDifferentPort() throws Exception { public void onDifferentPort() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.port=" + ports.get().management); "management.port=" + ports.get().management).applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class, DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
@ -187,8 +187,8 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void onDifferentPortWithSpecificServer() throws Exception { public void onDifferentPortWithSpecificServer() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.port=" + ports.get().management); "management.port=" + ports.get().management).applyTo(this.applicationContext);
this.applicationContext.register(SpecificWebServerConfig.class, RootConfig.class, this.applicationContext.register(SpecificWebServerConfig.class, RootConfig.class,
DifferentPortConfig.class, EndpointConfig.class, BaseConfiguration.class, DifferentPortConfig.class, EndpointConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
@ -214,9 +214,9 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void onDifferentPortAndContext() throws Exception { public void onDifferentPortAndContext() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.port=" + ports.get().management, "management.port=" + ports.get().management,
"management.context-path=/admin"); "management.context-path=/admin").applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class, DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
@ -228,10 +228,10 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void onDifferentPortAndMainContext() throws Exception { public void onDifferentPortAndMainContext() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"server.servlet.context-path=/spring", "server.servlet.context-path=/spring",
"management.port=" + ports.get().management, "management.port=" + ports.get().management,
"management.context-path=/admin"); "management.context-path=/admin").applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class, DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
@ -243,8 +243,8 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void onDifferentPortWithoutErrorMvcAutoConfiguration() throws Exception { public void onDifferentPortWithoutErrorMvcAutoConfiguration() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.port=" + ports.get().management); "management.port=" + ports.get().management).applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class, DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class);
@ -254,8 +254,8 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void onDifferentPortInWebServer() throws Exception { public void onDifferentPortInWebServer() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.port=" + ports.get().management); "management.port=" + ports.get().management).applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class, DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
@ -272,8 +272,8 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void onRandomPort() throws Exception { public void onRandomPort() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, "management.port=0", TestPropertyValues.of("management.port=0",
"management.security.enabled=false"); "management.security.enabled=false").applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class, BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class); ErrorMvcAutoConfiguration.class);
@ -291,8 +291,8 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void onDifferentPortWithPrimaryFailure() throws Exception { public void onDifferentPortWithPrimaryFailure() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.port=" + ports.get().management); "management.port=" + ports.get().management).applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class, DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
@ -308,8 +308,7 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void disabled() throws Exception { public void disabled() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of("management.port=-1").applyTo(this.applicationContext);
"management.port=-1");
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class); BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class);
this.applicationContext.refresh(); this.applicationContext.refresh();
@ -321,10 +320,10 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void specificPortsViaProperties() throws Exception { public void specificPortsViaProperties() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"server.port:" + ports.get().server, "server.port:" + ports.get().server,
"management.port:" + ports.get().management, "management.port:" + ports.get().management,
"management.security.enabled:false"); "management.security.enabled:false").applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class, BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class); ErrorMvcAutoConfiguration.class);
@ -340,9 +339,8 @@ public class EndpointWebMvcAutoConfigurationTests {
int managementPort = ports.get().management; int managementPort = ports.get().management;
try (ServerSocket serverSocket = new ServerSocket()) { try (ServerSocket serverSocket = new ServerSocket()) {
serverSocket.bind(new InetSocketAddress(managementPort)); serverSocket.bind(new InetSocketAddress(managementPort));
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of("server.port:" + ports.get().server,
"server.port:" + ports.get().server, "management.port:" + ports.get().management).applyTo(this.applicationContext);
"management.port:" + ports.get().management);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class, BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class); ErrorMvcAutoConfiguration.class);
@ -353,8 +351,7 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void contextPath() throws Exception { public void contextPath() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of("management.context-path:/test", "management.security.enabled:false").applyTo(this.applicationContext);
"management.context-path:/test", "management.security.enabled:false");
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
PropertyPlaceholderAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
JacksonAutoConfiguration.class, JacksonAutoConfiguration.class,
@ -369,8 +366,8 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void overrideServerProperties() throws Exception { public void overrideServerProperties() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"server.displayName:foo"); "server.displayName:foo").applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
PropertyPlaceholderAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
JacksonAutoConfiguration.class, JacksonAutoConfiguration.class,
@ -403,8 +400,8 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void portPropertiesOnDifferentPort() throws Exception { public void portPropertiesOnDifferentPort() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.port=" + ports.get().management); "management.port=" + ports.get().management).applyTo(this.applicationContext);
new ServerPortInfoApplicationContextInitializer() new ServerPortInfoApplicationContextInitializer()
.initialize(this.applicationContext); .initialize(this.applicationContext);
this.applicationContext.register(RootConfig.class, DifferentPortConfig.class, this.applicationContext.register(RootConfig.class, DifferentPortConfig.class,
@ -444,8 +441,8 @@ public class EndpointWebMvcAutoConfigurationTests {
public void endpointsAllDisabled() throws Exception { public void endpointsAllDisabled() throws Exception {
this.applicationContext.register(RootConfig.class, BaseConfiguration.class, this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"endpoints.enabled:false"); "endpoints.enabled:false").applyTo(this.applicationContext);
this.applicationContext.refresh(); this.applicationContext.refresh();
assertThat(this.applicationContext.getBeansOfType(MvcEndpoint.class)).isEmpty(); assertThat(this.applicationContext.getBeansOfType(MvcEndpoint.class)).isEmpty();
} }
@ -494,8 +491,8 @@ public class EndpointWebMvcAutoConfigurationTests {
public void shutdownEndpointEnabled() { public void shutdownEndpointEnabled() {
this.applicationContext.register(RootConfig.class, BaseConfiguration.class, this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"endpoints.shutdown.enabled:true"); "endpoints.shutdown.enabled:true").applyTo(this.applicationContext);
this.applicationContext.refresh(); this.applicationContext.refresh();
assertThat(this.applicationContext.getBeansOfType(ShutdownMvcEndpoint.class)) assertThat(this.applicationContext.getBeansOfType(ShutdownMvcEndpoint.class))
.hasSize(1); .hasSize(1);
@ -505,8 +502,7 @@ public class EndpointWebMvcAutoConfigurationTests {
public void actuatorEndpointEnabledIndividually() { public void actuatorEndpointEnabledIndividually() {
this.applicationContext.register(RootConfig.class, BaseConfiguration.class, this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of("endpoints.enabled:false", "endpoints.actuator.enabled:true").applyTo(this.applicationContext);
"endpoints.enabled:false", "endpoints.actuator.enabled:true");
this.applicationContext.refresh(); this.applicationContext.refresh();
assertThat(this.applicationContext.getBeansOfType(HalJsonMvcEndpoint.class)) assertThat(this.applicationContext.getBeansOfType(HalJsonMvcEndpoint.class))
.hasSize(1); .hasSize(1);
@ -514,11 +510,10 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void managementSpecificSslUsingDifferentPort() throws Exception { public void managementSpecificSslUsingDifferentPort() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of("management.port=" + ports.get().management,
"management.port=" + ports.get().management,
"management.ssl.enabled=true", "management.ssl.enabled=true",
"management.ssl.key-store=classpath:test.jks", "management.ssl.key-store=classpath:test.jks",
"management.ssl.key-password=password"); "management.ssl.key-password=password").applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class, DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
@ -541,10 +536,10 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void managementSpecificSslUsingSamePortFails() throws Exception { public void managementSpecificSslUsingSamePortFails() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.ssl.enabled=true", "management.ssl.enabled=true",
"management.ssl.key-store=classpath:test.jks", "management.ssl.key-store=classpath:test.jks",
"management.ssl.key-password=password"); "management.ssl.key-password=password").applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class, BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class); ErrorMvcAutoConfiguration.class);
@ -556,10 +551,10 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void managementServerCanDisableSslWhenUsingADifferentPort() throws Exception { public void managementServerCanDisableSslWhenUsingADifferentPort() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.port=" + ports.get().management, "server.ssl.enabled=true", "management.port=" + ports.get().management, "server.ssl.enabled=true",
"server.ssl.key-store=classpath:test.jks", "server.ssl.key-store=classpath:test.jks",
"server.ssl.key-password=password", "management.ssl.enabled=false"); "server.ssl.key-password=password", "management.ssl.enabled=false").applyTo(this.applicationContext);
this.applicationContext.register(RootConfig.class, EndpointConfig.class, this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class, DifferentPortConfig.class, BaseConfiguration.class,
@ -583,13 +578,13 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void tomcatManagementAccessLogUsesCustomPrefix() throws Exception { public void tomcatManagementAccessLogUsesCustomPrefix() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.port=" + ports.get().management); "management.port=" + ports.get().management).applyTo(this.applicationContext);
this.applicationContext.register(TomcatWebServerConfig.class, RootConfig.class, this.applicationContext.register(TomcatWebServerConfig.class, RootConfig.class,
EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class, EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"server.tomcat.accesslog.enabled: true"); "server.tomcat.accesslog.enabled: true").applyTo(this.applicationContext);
this.applicationContext.refresh(); this.applicationContext.refresh();
ApplicationContext managementContext = this.applicationContext ApplicationContext managementContext = this.applicationContext
.getBean(ManagementContextResolver.class).getApplicationContext(); .getBean(ManagementContextResolver.class).getApplicationContext();
@ -604,9 +599,9 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test @Test
public void undertowManagementAccessLogUsesCustomPrefix() throws Exception { public void undertowManagementAccessLogUsesCustomPrefix() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"management.port=" + ports.get().management, "management.port=" + ports.get().management,
"server.undertow.accesslog.enabled: true"); "server.undertow.accesslog.enabled: true").applyTo(this.applicationContext);
this.applicationContext.register(UndertowWebServerConfig.class, RootConfig.class, this.applicationContext.register(UndertowWebServerConfig.class, RootConfig.class,
EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class, EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
@ -633,8 +628,7 @@ public class EndpointWebMvcAutoConfigurationTests {
private void endpointDisabled(String name, Class<? extends MvcEndpoint> type) { private void endpointDisabled(String name, Class<? extends MvcEndpoint> type) {
this.applicationContext.register(RootConfig.class, BaseConfiguration.class, this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class); EndpointWebMvcAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(String.format("endpoints.%s.enabled:false", name)).applyTo(this.applicationContext);
String.format("endpoints.%s.enabled:false", name));
this.applicationContext.refresh(); this.applicationContext.refresh();
assertThat(this.applicationContext.getBeansOfType(type)).isEmpty(); assertThat(this.applicationContext.getBeansOfType(type)).isEmpty();
} }
@ -644,9 +638,9 @@ public class EndpointWebMvcAutoConfigurationTests {
this.applicationContext.register(LoggingConfig.class, RootConfig.class, this.applicationContext.register(LoggingConfig.class, RootConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class); BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class);
ConfigurationPropertySources.attach(this.applicationContext.getEnvironment()); ConfigurationPropertySources.attach(this.applicationContext.getEnvironment());
EnvironmentTestUtils.addEnvironment(this.applicationContext, TestPropertyValues.of(
"endpoints.enabled:false", "endpoints.enabled:false",
String.format("endpoints.%s.enabled:true", name)); String.format("endpoints.%s.enabled:true", name)).applyTo(this.applicationContext);
this.applicationContext.refresh(); this.applicationContext.refresh();
assertThat(this.applicationContext.getBeansOfType(type)).hasSize(1); assertThat(this.applicationContext.getBeansOfType(type)).hasSize(1);
} }

@ -29,7 +29,7 @@ import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoints;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
@ -126,7 +126,7 @@ public class EndpointWebMvcHypermediaManagementContextConfigurationTests {
} }
}); });
EnvironmentTestUtils.addEnvironment(this.context, properties); TestPropertyValues.of(properties).applyTo(this.context);
this.context.register(TestConfiguration.class, this.context.register(TestConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,
EndpointWebMvcHypermediaManagementContextConfiguration.class); EndpointWebMvcHypermediaManagementContextConfiguration.class);

@ -30,7 +30,7 @@ import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration; import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration; import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.mock.web.MockServletContext; import org.springframework.mock.web.MockServletContext;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
@ -68,9 +68,9 @@ public class EndpointWebMvcManagementContextConfigurationTests {
@Test @Test
public void endpointHandlerMapping() throws Exception { public void endpointHandlerMapping() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.security.enabled=false", "management.security.enabled=false",
"management.security.roles=my-role,your-role"); "management.security.roles=my-role,your-role").applyTo(this.context);
this.context.refresh(); this.context.refresh();
EndpointHandlerMapping mapping = this.context.getBean("endpointHandlerMapping", EndpointHandlerMapping mapping = this.context.getBean("endpointHandlerMapping",
EndpointHandlerMapping.class); EndpointHandlerMapping.class);

@ -57,7 +57,7 @@ import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration; import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -92,8 +92,8 @@ public class HealthIndicatorAutoConfigurationTests {
public void defaultHealthIndicator() { public void defaultHealthIndicator() {
this.context.register(HealthIndicatorAutoConfiguration.class, this.context.register(HealthIndicatorAutoConfiguration.class,
ManagementServerProperties.class); ManagementServerProperties.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -106,8 +106,8 @@ public class HealthIndicatorAutoConfigurationTests {
public void defaultHealthIndicatorsDisabled() { public void defaultHealthIndicatorsDisabled() {
this.context.register(HealthIndicatorAutoConfiguration.class, this.context.register(HealthIndicatorAutoConfiguration.class,
ManagementServerProperties.class); ManagementServerProperties.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.defaults.enabled:false"); "management.health.defaults.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -120,8 +120,8 @@ public class HealthIndicatorAutoConfigurationTests {
public void defaultHealthIndicatorsDisabledWithCustomOne() { public void defaultHealthIndicatorsDisabledWithCustomOne() {
this.context.register(CustomHealthIndicator.class, this.context.register(CustomHealthIndicator.class,
HealthIndicatorAutoConfiguration.class, ManagementServerProperties.class); HealthIndicatorAutoConfiguration.class, ManagementServerProperties.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.defaults.enabled:false"); "management.health.defaults.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -134,9 +134,9 @@ public class HealthIndicatorAutoConfigurationTests {
public void defaultHealthIndicatorsDisabledButOne() { public void defaultHealthIndicatorsDisabledButOne() {
this.context.register(HealthIndicatorAutoConfiguration.class, this.context.register(HealthIndicatorAutoConfiguration.class,
ManagementServerProperties.class); ManagementServerProperties.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.defaults.enabled:false", "management.health.defaults.enabled:false",
"management.health.diskspace.enabled:true"); "management.health.diskspace.enabled:true").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -149,8 +149,8 @@ public class HealthIndicatorAutoConfigurationTests {
public void redisHealthIndicator() { public void redisHealthIndicator() {
this.context.register(RedisAutoConfiguration.class, this.context.register(RedisAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -163,9 +163,9 @@ public class HealthIndicatorAutoConfigurationTests {
public void notRedisHealthIndicator() { public void notRedisHealthIndicator() {
this.context.register(RedisAutoConfiguration.class, this.context.register(RedisAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.redis.enabled:false", "management.health.redis.enabled:false",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -179,8 +179,8 @@ public class HealthIndicatorAutoConfigurationTests {
this.context.register(MongoAutoConfiguration.class, this.context.register(MongoAutoConfiguration.class,
ManagementServerProperties.class, MongoDataAutoConfiguration.class, ManagementServerProperties.class, MongoDataAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class); HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -194,9 +194,9 @@ public class HealthIndicatorAutoConfigurationTests {
this.context.register(MongoAutoConfiguration.class, this.context.register(MongoAutoConfiguration.class,
ManagementServerProperties.class, MongoDataAutoConfiguration.class, ManagementServerProperties.class, MongoDataAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class); HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.mongo.enabled:false", "management.health.mongo.enabled:false",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -220,8 +220,8 @@ public class HealthIndicatorAutoConfigurationTests {
public void dataSourceHealthIndicator() { public void dataSourceHealthIndicator() {
this.context.register(EmbeddedDataSourceConfiguration.class, this.context.register(EmbeddedDataSourceConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -235,8 +235,8 @@ public class HealthIndicatorAutoConfigurationTests {
this.context.register(EmbeddedDataSourceConfiguration.class, this.context.register(EmbeddedDataSourceConfiguration.class,
DataSourceConfig.class, ManagementServerProperties.class, DataSourceConfig.class, ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class); HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -252,8 +252,8 @@ public class HealthIndicatorAutoConfigurationTests {
this.context.register(EmbeddedDataSourceConfiguration.class, this.context.register(EmbeddedDataSourceConfiguration.class,
RoutingDatasourceConfig.class, ManagementServerProperties.class, RoutingDatasourceConfig.class, ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class); HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -269,9 +269,9 @@ public class HealthIndicatorAutoConfigurationTests {
DataSourceConfig.class, DataSourceConfig.class,
DataSourcePoolMetadataProvidersConfiguration.class, DataSourcePoolMetadataProvidersConfiguration.class,
HealthIndicatorAutoConfiguration.class); HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.test.validation-query:SELECT from FOOBAR", "spring.datasource.test.validation-query:SELECT from FOOBAR",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -286,9 +286,9 @@ public class HealthIndicatorAutoConfigurationTests {
public void notDataSourceHealthIndicator() { public void notDataSourceHealthIndicator() {
this.context.register(EmbeddedDataSourceConfiguration.class, this.context.register(EmbeddedDataSourceConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.db.enabled:false", "management.health.db.enabled:false",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -301,8 +301,8 @@ public class HealthIndicatorAutoConfigurationTests {
public void rabbitHealthIndicator() { public void rabbitHealthIndicator() {
this.context.register(RabbitAutoConfiguration.class, this.context.register(RabbitAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -315,9 +315,9 @@ public class HealthIndicatorAutoConfigurationTests {
public void notRabbitHealthIndicator() { public void notRabbitHealthIndicator() {
this.context.register(RabbitAutoConfiguration.class, this.context.register(RabbitAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.rabbit.enabled:false", "management.health.rabbit.enabled:false",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -330,8 +330,8 @@ public class HealthIndicatorAutoConfigurationTests {
public void solrHealthIndicator() { public void solrHealthIndicator() {
this.context.register(SolrAutoConfiguration.class, this.context.register(SolrAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -344,9 +344,9 @@ public class HealthIndicatorAutoConfigurationTests {
public void notSolrHealthIndicator() { public void notSolrHealthIndicator() {
this.context.register(SolrAutoConfiguration.class, this.context.register(SolrAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.solr.enabled:false", "management.health.solr.enabled:false",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
@ -368,9 +368,9 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void mailHealthIndicator() { public void mailHealthIndicator() {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.mail.host:smtp.acme.org", "spring.mail.host:smtp.acme.org",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.register(MailSenderAutoConfiguration.class, this.context.register(MailSenderAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -384,9 +384,9 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void notMailHealthIndicator() { public void notMailHealthIndicator() {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.mail.host:smtp.acme.org", "management.health.mail.enabled:false", "spring.mail.host:smtp.acme.org", "management.health.mail.enabled:false",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.register(MailSenderAutoConfiguration.class, this.context.register(MailSenderAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -400,8 +400,8 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void jmsHealthIndicator() { public void jmsHealthIndicator() {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.register(ActiveMQAutoConfiguration.class, this.context.register(ActiveMQAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -415,9 +415,9 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void notJmsHealthIndicator() { public void notJmsHealthIndicator() {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.jms.enabled:false", "management.health.jms.enabled:false",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.register(ActiveMQAutoConfiguration.class, this.context.register(ActiveMQAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -431,9 +431,9 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void elasticsearchHealthIndicator() { public void elasticsearchHealthIndicator() {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.elasticsearch.properties.path.home:target", "spring.data.elasticsearch.properties.path.home:target",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class, this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class,
ElasticsearchAutoConfiguration.class, ManagementServerProperties.class, ElasticsearchAutoConfiguration.class, ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class); HealthIndicatorAutoConfiguration.class);
@ -448,8 +448,8 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void elasticsearchJestHealthIndicator() { public void elasticsearchJestHealthIndicator() {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class, this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -463,10 +463,10 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void notElasticsearchHealthIndicator() { public void notElasticsearchHealthIndicator() {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.elasticsearch.enabled:false", "management.health.elasticsearch.enabled:false",
"spring.data.elasticsearch.properties.path.home:target", "spring.data.elasticsearch.properties.path.home:target",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class, this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class,
ElasticsearchAutoConfiguration.class, ManagementServerProperties.class, ElasticsearchAutoConfiguration.class, ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class); HealthIndicatorAutoConfiguration.class);
@ -481,8 +481,8 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void cassandraHealthIndicator() throws Exception { public void cassandraHealthIndicator() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.register(CassandraConfiguration.class, this.context.register(CassandraConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -495,9 +495,9 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void notCassandraHealthIndicator() throws Exception { public void notCassandraHealthIndicator() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false", "management.health.diskspace.enabled:false",
"management.health.cassandra.enabled:false"); "management.health.cassandra.enabled:false").applyTo(this.context);
this.context.register(CassandraConfiguration.class, this.context.register(CassandraConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -510,8 +510,8 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void couchbaseHealthIndicator() throws Exception { public void couchbaseHealthIndicator() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.register(CouchbaseConfiguration.class, this.context.register(CouchbaseConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -524,9 +524,9 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void notCouchbaseHealthIndicator() throws Exception { public void notCouchbaseHealthIndicator() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false", "management.health.diskspace.enabled:false",
"management.health.couchbase.enabled:false"); "management.health.couchbase.enabled:false").applyTo(this.context);
this.context.register(CouchbaseConfiguration.class, this.context.register(CouchbaseConfiguration.class,
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -539,8 +539,8 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void ldapHealthIndicator() throws Exception { public void ldapHealthIndicator() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false").applyTo(this.context);
this.context.register(LdapConfiguration.class, ManagementServerProperties.class, this.context.register(LdapConfiguration.class, ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class); HealthIndicatorAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -553,9 +553,9 @@ public class HealthIndicatorAutoConfigurationTests {
@Test @Test
public void notLdapHealthIndicator() throws Exception { public void notLdapHealthIndicator() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.health.diskspace.enabled:false", "management.health.diskspace.enabled:false",
"management.health.ldap.enabled:false"); "management.health.ldap.enabled:false").applyTo(this.context);
this.context.register(LdapConfiguration.class, ManagementServerProperties.class, this.context.register(LdapConfiguration.class, ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class); HealthIndicatorAutoConfiguration.class);
this.context.refresh(); this.context.refresh();

@ -35,7 +35,7 @@ import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConf
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration; import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
@ -80,8 +80,8 @@ public class HealthMvcEndpointAutoConfigurationTests {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext()); this.context.setServletContext(new MockServletContext());
this.context.register(TestConfiguration.class); this.context.register(TestConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.security.enabled=false"); "management.security.enabled=false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
Health health = (Health) this.context.getBean(HealthMvcEndpoint.class) Health health = (Health) this.context.getBean(HealthMvcEndpoint.class)
.invoke(null, null); .invoke(null, null);
@ -96,8 +96,8 @@ public class HealthMvcEndpointAutoConfigurationTests {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext()); this.context.setServletContext(new MockServletContext());
this.context.register(TestConfiguration.class); this.context.register(TestConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.security.roles[0]=super"); "management.security.roles[0]=super").applyTo(this.context);
this.context.refresh(); this.context.refresh();
HealthMvcEndpoint health = this.context.getBean(HealthMvcEndpoint.class); HealthMvcEndpoint health = this.context.getBean(HealthMvcEndpoint.class);
assertThat(ReflectionTestUtils.getField(health, "roles")) assertThat(ReflectionTestUtils.getField(health, "roles"))

@ -28,7 +28,7 @@ import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor; import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.boot.info.BuildProperties; import org.springframework.boot.info.BuildProperties;
import org.springframework.boot.info.GitProperties; import org.springframework.boot.info.GitProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -152,7 +152,7 @@ public class InfoContributorAutoConfigurationTests {
context.register(config); context.register(config);
} }
context.register(InfoContributorAutoConfiguration.class); context.register(InfoContributorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(context, environment); TestPropertyValues.of(environment).applyTo(context);
context.refresh(); context.refresh();
this.context = context; this.context = context;
} }

@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor; import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext; import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory; import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
@ -68,8 +68,8 @@ public class JolokiaAutoConfigurationTests {
@Test @Test
public void agentServletRegisteredWithAppContext() throws Exception { public void agentServletRegisteredWithAppContext() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext(); this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "jolokia.config[key1]:value1", TestPropertyValues.of("jolokia.config[key1]:value1",
"jolokia.config[key2]:value2"); "jolokia.config[key2]:value2").applyTo(this.context);
this.context.register(Config.class, WebMvcAutoConfiguration.class, this.context.register(Config.class, WebMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,
@ -81,8 +81,8 @@ public class JolokiaAutoConfigurationTests {
@Test @Test
public void agentServletWithCustomPath() throws Exception { public void agentServletWithCustomPath() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext(); this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.jolokia.path=/foo/bar"); "endpoints.jolokia.path=/foo/bar").applyTo(this.context);
this.context.register(EndpointsConfig.class, WebMvcAutoConfiguration.class, this.context.register(EndpointsConfig.class, WebMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,
@ -113,7 +113,7 @@ public class JolokiaAutoConfigurationTests {
private void assertEndpointDisabled(String... pairs) { private void assertEndpointDisabled(String... pairs) {
this.context = new AnnotationConfigServletWebServerApplicationContext(); this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, pairs); TestPropertyValues.of(pairs).applyTo(this.context);
this.context.register(Config.class, WebMvcAutoConfiguration.class, this.context.register(Config.class, WebMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,
@ -124,7 +124,7 @@ public class JolokiaAutoConfigurationTests {
private void assertEndpointEnabled(String... pairs) { private void assertEndpointEnabled(String... pairs) {
this.context = new AnnotationConfigServletWebServerApplicationContext(); this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, pairs); TestPropertyValues.of(pairs).applyTo(this.context);
this.context.register(Config.class, WebMvcAutoConfiguration.class, this.context.register(Config.class, WebMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,

@ -23,7 +23,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.junit.runner.classpath.ClassPathExclusions; import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner; import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -54,7 +54,7 @@ public class ManagementServerPropertiesNoSecurityTests {
public ManagementServerProperties load(String... environment) { public ManagementServerProperties load(String... environment) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, environment); TestPropertyValues.of(environment).applyTo(context);
context.register(Config.class); context.register(Config.class);
context.refresh(); context.refresh();
this.context = context; this.context = context;

@ -20,7 +20,7 @@ import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -88,7 +88,7 @@ public class ManagementServerPropertiesTests {
public ManagementServerProperties load(String... environment) { public ManagementServerProperties load(String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
ctx.register(Config.class); ctx.register(Config.class);
ctx.refresh(); ctx.refresh();
this.context = ctx; this.context = ctx;

@ -32,7 +32,7 @@ import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration; import org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration; import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockServletContext; import org.springframework.mock.web.MockServletContext;
@ -91,7 +91,7 @@ public class ManagementWebSecurityAutoConfigurationTests {
HttpMessageConvertersAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,
EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class, EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, AuditAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class, AuditAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, "security.basic.enabled:false"); TestPropertyValues.of("security.basic.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(AuthenticationManagerBuilder.class)).isNotNull(); assertThat(this.context.getBean(AuthenticationManagerBuilder.class)).isNotNull();
FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class); FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
@ -140,7 +140,7 @@ public class ManagementWebSecurityAutoConfigurationTests {
ManagementWebSecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class,
EndpointAutoConfiguration.class, EndpointAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, "security.ignored:none"); TestPropertyValues.of("security.ignored:none").applyTo(this.context);
this.context.refresh(); this.context.refresh();
// Just the application and management endpoints now // Just the application and management endpoints now
assertThat(this.context.getBean(FilterChainProxy.class).getFilterChains()) assertThat(this.context.getBean(FilterChainProxy.class).getFilterChains())
@ -152,7 +152,7 @@ public class ManagementWebSecurityAutoConfigurationTests {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext()); this.context.setServletContext(new MockServletContext());
this.context.register(WebConfiguration.class); this.context.register(WebConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, "security.basic.enabled:false"); TestPropertyValues.of("security.basic.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
// Just the management endpoints (one filter) and ignores now plus the backup // Just the management endpoints (one filter) and ignores now plus the backup
// filter on app endpoints // filter on app endpoints
@ -233,7 +233,7 @@ public class ManagementWebSecurityAutoConfigurationTests {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext()); this.context.setServletContext(new MockServletContext());
this.context.register(WebConfiguration.class); this.context.register(WebConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, "endpoints.sensitive:true"); TestPropertyValues.of("endpoints.sensitive:true").applyTo(this.context);
this.context.refresh(); this.context.refresh();
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context) // MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context) //

@ -34,7 +34,7 @@ import org.springframework.boot.actuate.metrics.statsd.StatsdMetricWriter;
import org.springframework.boot.actuate.metrics.writer.GaugeWriter; import org.springframework.boot.actuate.metrics.writer.GaugeWriter;
import org.springframework.boot.actuate.metrics.writer.MetricWriter; import org.springframework.boot.actuate.metrics.writer.MetricWriter;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -148,8 +148,8 @@ public class MetricExportAutoConfigurationTests {
@Test @Test
public void statsdWithHost() throws Exception { public void statsdWithHost() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.metrics.export.statsd.host=localhost"); "spring.metrics.export.statsd.host=localhost").applyTo(this.context);
this.context.register(MetricEndpointConfiguration.class, this.context.register(MetricEndpointConfiguration.class,
MetricExportAutoConfiguration.class, MetricExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);

@ -31,7 +31,7 @@ import org.mockito.stubbing.Answer;
import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.actuate.metrics.GaugeService; import org.springframework.boot.actuate.metrics.GaugeService;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -234,8 +234,8 @@ public class MetricFilterAutoConfigurationTests {
@Test @Test
public void skipsFilterIfPropertyDisabled() throws Exception { public void skipsFilterIfPropertyDisabled() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, TestPropertyValues.of(
"endpoints.metrics.filter.enabled:false"); "endpoints.metrics.filter.enabled:false").applyTo(context);
context.register(Config.class, MetricFilterAutoConfiguration.class); context.register(Config.class, MetricFilterAutoConfiguration.class);
context.refresh(); context.refresh();
assertThat(context.getBeansOfType(Filter.class).size()).isEqualTo(0); assertThat(context.getBeansOfType(Filter.class).size()).isEqualTo(0);
@ -355,9 +355,9 @@ public class MetricFilterAutoConfigurationTests {
throws Exception { throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.register(Config.class, MetricFilterAutoConfiguration.class); context.register(Config.class, MetricFilterAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(context, TestPropertyValues.of(
"endpoints.metrics.filter.gauge-submissions=merged,per-http-method", "endpoints.metrics.filter.gauge-submissions=merged,per-http-method",
"endpoints.metrics.filter.counter-submissions=merged,per-http-method"); "endpoints.metrics.filter.counter-submissions=merged,per-http-method").applyTo(context);
context.refresh(); context.refresh();
Filter filter = context.getBean(Filter.class); Filter filter = context.getBean(Filter.class);
final MockHttpServletRequest request = new MockHttpServletRequest("PUT", final MockHttpServletRequest request = new MockHttpServletRequest("PUT",
@ -387,9 +387,9 @@ public class MetricFilterAutoConfigurationTests {
public void doesNotRecordRolledUpMetricsIfConfigured() throws Exception { public void doesNotRecordRolledUpMetricsIfConfigured() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.register(Config.class, MetricFilterAutoConfiguration.class); context.register(Config.class, MetricFilterAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(context, TestPropertyValues.of(
"endpoints.metrics.filter.gauge-submissions=", "endpoints.metrics.filter.gauge-submissions=",
"endpoints.metrics.filter.counter-submissions="); "endpoints.metrics.filter.counter-submissions=").applyTo(context);
context.refresh(); context.refresh();
Filter filter = context.getBean(Filter.class); Filter filter = context.getBean(Filter.class);
final MockHttpServletRequest request = new MockHttpServletRequest("PUT", final MockHttpServletRequest request = new MockHttpServletRequest("PUT",

@ -52,7 +52,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport; import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.logging.LoggingSystem; import org.springframework.boot.logging.LoggingSystem;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockServletContext; import org.springframework.mock.web.MockServletContext;
@ -117,10 +117,10 @@ public class MvcEndpointPathConfigurationTests {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.register(TestConfiguration.class); this.context.register(TestConfiguration.class);
this.context.setServletContext(new MockServletContext()); this.context.setServletContext(new MockServletContext());
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints." + this.endpointName + ".path" + ":/custom/path", "endpoints." + this.endpointName + ".path" + ":/custom/path",
"endpoints." + this.endpointName + ".enabled:true", "endpoints." + this.endpointName + ".enabled:true",
"logging.file:target/test.log"); "logging.file:target/test.log").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertThat(getConfiguredPath()).isEqualTo("/custom/path"); assertThat(getConfiguredPath()).isEqualTo("/custom/path");
} }

@ -25,7 +25,7 @@ import org.springframework.boot.actuate.trace.TraceProperties;
import org.springframework.boot.actuate.trace.TraceRepository; import org.springframework.boot.actuate.trace.TraceRepository;
import org.springframework.boot.actuate.trace.WebRequestTraceFilter; import org.springframework.boot.actuate.trace.WebRequestTraceFilter;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -75,7 +75,7 @@ public class TraceWebFilterAutoConfigurationTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, environment); TestPropertyValues.of(environment).applyTo(context);
if (config != null) { if (config != null) {
context.register(config); context.register(config);
} }

@ -35,7 +35,7 @@ import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration; import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources; import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockServletContext; import org.springframework.mock.web.MockServletContext;
@ -119,8 +119,8 @@ public class CloudFoundryActuatorAutoConfigurationTests {
@Test @Test
public void skipSslValidation() throws Exception { public void skipSslValidation() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.cloudfoundry.skipSslValidation:true"); "management.cloudfoundry.skipSslValidation:true").applyTo(this.context);
ConfigurationPropertySources.attach(this.context.getEnvironment()); ConfigurationPropertySources.attach(this.context.getEnvironment());
this.context.refresh(); this.context.refresh();
CloudFoundryEndpointHandlerMapping handlerMapping = getHandlerMapping(); CloudFoundryEndpointHandlerMapping handlerMapping = getHandlerMapping();
@ -137,8 +137,8 @@ public class CloudFoundryActuatorAutoConfigurationTests {
@Test @Test
public void cloudFoundryPlatformActiveAndCloudControllerUrlNotPresent() public void cloudFoundryPlatformActiveAndCloudControllerUrlNotPresent()
throws Exception { throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, "VCAP_APPLICATION:---", TestPropertyValues.of("VCAP_APPLICATION:---",
"vcap.application.application_id:my-app-id"); "vcap.application.application_id:my-app-id").applyTo(this.context);
this.context.refresh(); this.context.refresh();
CloudFoundryEndpointHandlerMapping handlerMapping = this.context.getBean( CloudFoundryEndpointHandlerMapping handlerMapping = this.context.getBean(
"cloudFoundryEndpointHandlerMapping", "cloudFoundryEndpointHandlerMapping",
@ -152,8 +152,8 @@ public class CloudFoundryActuatorAutoConfigurationTests {
@Test @Test
public void cloudFoundryPathsIgnoredBySpringSecurity() throws Exception { public void cloudFoundryPathsIgnoredBySpringSecurity() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, "VCAP_APPLICATION:---", TestPropertyValues.of("VCAP_APPLICATION:---",
"vcap.application.application_id:my-app-id"); "vcap.application.application_id:my-app-id").applyTo(this.context);
this.context.refresh(); this.context.refresh();
IgnoredRequestCustomizer customizer = (IgnoredRequestCustomizer) this.context IgnoredRequestCustomizer customizer = (IgnoredRequestCustomizer) this.context
.getBean("cloudFoundryIgnoredRequestCustomizer"); .getBean("cloudFoundryIgnoredRequestCustomizer");
@ -179,17 +179,17 @@ public class CloudFoundryActuatorAutoConfigurationTests {
@Test @Test
public void cloudFoundryManagementEndpointsDisabled() throws Exception { public void cloudFoundryManagementEndpointsDisabled() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, "VCAP_APPLICATION=---", TestPropertyValues.of("VCAP_APPLICATION=---",
"management.cloudfoundry.enabled:false"); "management.cloudfoundry.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertThat(this.context.containsBean("cloudFoundryEndpointHandlerMapping")) assertThat(this.context.containsBean("cloudFoundryEndpointHandlerMapping"))
.isFalse(); .isFalse();
} }
private CloudFoundryEndpointHandlerMapping getHandlerMapping() { private CloudFoundryEndpointHandlerMapping getHandlerMapping() {
EnvironmentTestUtils.addEnvironment(this.context, "VCAP_APPLICATION:---", TestPropertyValues.of("VCAP_APPLICATION:---",
"vcap.application.application_id:my-app-id", "vcap.application.application_id:my-app-id",
"vcap.application.cf_api:http://my-cloud-controller.com"); "vcap.application.cf_api:http://my-cloud-controller.com").applyTo(this.context);
this.context.refresh(); this.context.refresh();
return this.context.getBean("cloudFoundryEndpointHandlerMapping", return this.context.getBean("cloudFoundryEndpointHandlerMapping",
CloudFoundryEndpointHandlerMapping.class); CloudFoundryEndpointHandlerMapping.class);

@ -26,7 +26,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource; import org.springframework.core.env.PropertySource;
@ -89,7 +89,7 @@ public abstract class AbstractEndpointTests<T extends Endpoint<?>> {
@Test @Test
public void idOverride() throws Exception { public void idOverride() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, this.property + ".id:myid"); TestPropertyValues.of(this.property + ".id:myid").applyTo(this.context);
this.context.register(this.configClass); this.context.register(this.configClass);
this.context.refresh(); this.context.refresh();
assertThat(getEndpointBean().getId()).isEqualTo("myid"); assertThat(getEndpointBean().getId()).isEqualTo("myid");

@ -24,7 +24,7 @@ import org.junit.Test;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -56,8 +56,8 @@ public class ConfigurationPropertiesReportEndpointMethodAnnotationsTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testNaming() throws Exception { public void testNaming() throws Exception {
this.context.register(Config.class); this.context.register(Config.class);
EnvironmentTestUtils.addEnvironment(this.context, "other.name:foo", TestPropertyValues.of("other.name:foo",
"first.name:bar"); "first.name:bar").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = this.context ConfigurationPropertiesReportEndpoint report = this.context
.getBean(ConfigurationPropertiesReportEndpoint.class); .getBean(ConfigurationPropertiesReportEndpoint.class);
@ -73,7 +73,7 @@ public class ConfigurationPropertiesReportEndpointMethodAnnotationsTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testOverride() throws Exception { public void testOverride() throws Exception {
this.context.register(Other.class); this.context.register(Other.class);
EnvironmentTestUtils.addEnvironment(this.context, "other.name:foo"); TestPropertyValues.of("other.name:foo").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = this.context ConfigurationPropertiesReportEndpoint report = this.context
.getBean(ConfigurationPropertiesReportEndpoint.class); .getBean(ConfigurationPropertiesReportEndpoint.class);

@ -28,7 +28,7 @@ import org.junit.Test;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -63,7 +63,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testNaming() throws Exception { public void testNaming() throws Exception {
this.context.register(FooConfig.class); this.context.register(FooConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, "foo.name:foo"); TestPropertyValues.of("foo.name:foo").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = this.context ConfigurationPropertiesReportEndpoint report = this.context
.getBean(ConfigurationPropertiesReportEndpoint.class); .getBean(ConfigurationPropertiesReportEndpoint.class);
@ -83,7 +83,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testNestedNaming() throws Exception { public void testNestedNaming() throws Exception {
this.context.register(FooConfig.class); this.context.register(FooConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, "foo.bar.name:foo"); TestPropertyValues.of("foo.bar.name:foo").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = this.context ConfigurationPropertiesReportEndpoint report = this.context
.getBean(ConfigurationPropertiesReportEndpoint.class); .getBean(ConfigurationPropertiesReportEndpoint.class);
@ -102,7 +102,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testCycle() throws Exception { public void testCycle() throws Exception {
this.context.register(CycleConfig.class); this.context.register(CycleConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, "foo.name:foo"); TestPropertyValues.of("foo.name:foo").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = this.context ConfigurationPropertiesReportEndpoint report = this.context
.getBean(ConfigurationPropertiesReportEndpoint.class); .getBean(ConfigurationPropertiesReportEndpoint.class);
@ -122,7 +122,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testMap() throws Exception { public void testMap() throws Exception {
this.context.register(MapConfig.class); this.context.register(MapConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, "foo.map.name:foo"); TestPropertyValues.of("foo.map.name:foo").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = this.context ConfigurationPropertiesReportEndpoint report = this.context
.getBean(ConfigurationPropertiesReportEndpoint.class); .getBean(ConfigurationPropertiesReportEndpoint.class);
@ -162,7 +162,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testList() throws Exception { public void testList() throws Exception {
this.context.register(ListConfig.class); this.context.register(ListConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, "foo.list[0]:foo"); TestPropertyValues.of("foo.list[0]:foo").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = this.context ConfigurationPropertiesReportEndpoint report = this.context
.getBean(ConfigurationPropertiesReportEndpoint.class); .getBean(ConfigurationPropertiesReportEndpoint.class);
@ -182,7 +182,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testInetAddress() throws Exception { public void testInetAddress() throws Exception {
this.context.register(AddressedConfig.class); this.context.register(AddressedConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, "foo.address:192.168.1.10"); TestPropertyValues.of("foo.address:192.168.1.10").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = this.context ConfigurationPropertiesReportEndpoint report = this.context
.getBean(ConfigurationPropertiesReportEndpoint.class); .getBean(ConfigurationPropertiesReportEndpoint.class);
@ -203,8 +203,8 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testInitializedMapAndList() throws Exception { public void testInitializedMapAndList() throws Exception {
this.context.register(InitializedMapAndListPropertiesConfig.class); this.context.register(InitializedMapAndListPropertiesConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, "foo.map.entryOne:true", TestPropertyValues.of("foo.map.entryOne:true",
"foo.list[0]:abc"); "foo.list[0]:abc").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = this.context ConfigurationPropertiesReportEndpoint report = this.context
.getBean(ConfigurationPropertiesReportEndpoint.class); .getBean(ConfigurationPropertiesReportEndpoint.class);

@ -26,7 +26,7 @@ import org.junit.Test;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -130,8 +130,8 @@ public class ConfigurationPropertiesReportEndpointTests
@Test @Test
public void testKeySanitizationWithCustomKeysByEnvironment() throws Exception { public void testKeySanitizationWithCustomKeysByEnvironment() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.configprops.keys-to-sanitize:property"); "endpoints.configprops.keys-to-sanitize:property").applyTo(this.context);
this.context.register(Config.class); this.context.register(Config.class);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = getEndpointBean(); ConfigurationPropertiesReportEndpoint report = getEndpointBean();
@ -147,8 +147,8 @@ public class ConfigurationPropertiesReportEndpointTests
@Test @Test
public void testKeySanitizationWithCustomPatternByEnvironment() throws Exception { public void testKeySanitizationWithCustomPatternByEnvironment() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.configprops.keys-to-sanitize: .*pass.*"); "endpoints.configprops.keys-to-sanitize: .*pass.*").applyTo(this.context);
this.context.register(Config.class); this.context.register(Config.class);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = getEndpointBean(); ConfigurationPropertiesReportEndpoint report = getEndpointBean();
@ -165,8 +165,8 @@ public class ConfigurationPropertiesReportEndpointTests
public void testKeySanitizationWithCustomPatternAndKeyByEnvironment() public void testKeySanitizationWithCustomPatternAndKeyByEnvironment()
throws Exception { throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.configprops.keys-to-sanitize: .*pass.*, property"); "endpoints.configprops.keys-to-sanitize: .*pass.*, property").applyTo(this.context);
this.context.register(Config.class); this.context.register(Config.class);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = getEndpointBean(); ConfigurationPropertiesReportEndpoint report = getEndpointBean();
@ -184,8 +184,8 @@ public class ConfigurationPropertiesReportEndpointTests
throws Exception { throws Exception {
// gh-4415 // gh-4415
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.configprops.keys-to-sanitize: .*\\.secrets\\..*, .*\\.hidden\\..*"); "endpoints.configprops.keys-to-sanitize: .*\\.secrets\\..*, .*\\.hidden\\..*").applyTo(this.context);
this.context.register(Config.class); this.context.register(Config.class);
this.context.refresh(); this.context.refresh();
ConfigurationPropertiesReportEndpoint report = getEndpointBean(); ConfigurationPropertiesReportEndpoint report = getEndpointBean();

@ -24,7 +24,7 @@ import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -151,8 +151,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
@Test @Test
public void testKeySanitizationWithCustomKeysByEnvironment() throws Exception { public void testKeySanitizationWithCustomKeysByEnvironment() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.env.keys-to-sanitize: key"); "endpoints.env.keys-to-sanitize: key").applyTo(this.context);
this.context.register(Config.class); this.context.register(Config.class);
this.context.refresh(); this.context.refresh();
System.setProperty("dbPassword", "123456"); System.setProperty("dbPassword", "123456");
@ -170,8 +170,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
@Test @Test
public void testKeySanitizationWithCustomPatternByEnvironment() throws Exception { public void testKeySanitizationWithCustomPatternByEnvironment() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.env.keys-to-sanitize: .*pass.*"); "endpoints.env.keys-to-sanitize: .*pass.*").applyTo(this.context);
this.context.register(Config.class); this.context.register(Config.class);
this.context.refresh(); this.context.refresh();
System.setProperty("dbPassword", "123456"); System.setProperty("dbPassword", "123456");
@ -190,8 +190,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
public void testKeySanitizationWithCustomPatternAndKeyByEnvironment() public void testKeySanitizationWithCustomPatternAndKeyByEnvironment()
throws Exception { throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.env.keys-to-sanitize: .*pass.*, key"); "endpoints.env.keys-to-sanitize: .*pass.*, key").applyTo(this.context);
this.context.register(Config.class); this.context.register(Config.class);
this.context.refresh(); this.context.refresh();
System.setProperty("dbPassword", "123456"); System.setProperty("dbPassword", "123456");
@ -209,8 +209,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
@Test @Test
public void propertyWithPlaceholderResolved() throws Exception { public void propertyWithPlaceholderResolved() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "my.foo: ${bar.blah}", TestPropertyValues.of("my.foo: ${bar.blah}",
"bar.blah: hello"); "bar.blah: hello").applyTo(this.context);
this.context.register(Config.class); this.context.register(Config.class);
this.context.refresh(); this.context.refresh();
EnvironmentEndpoint report = getEndpointBean(); EnvironmentEndpoint report = getEndpointBean();
@ -223,7 +223,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
@Test @Test
public void propertyWithPlaceholderNotResolved() throws Exception { public void propertyWithPlaceholderNotResolved() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "my.foo: ${bar.blah}"); TestPropertyValues.of("my.foo: ${bar.blah}").applyTo(this.context);
this.context.register(Config.class); this.context.register(Config.class);
this.context.refresh(); this.context.refresh();
EnvironmentEndpoint report = getEndpointBean(); EnvironmentEndpoint report = getEndpointBean();
@ -236,8 +236,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
@Test @Test
public void propertyWithSensitivePlaceholderResolved() throws Exception { public void propertyWithSensitivePlaceholderResolved() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"my.foo: http://${bar.password}://hello", "bar.password: hello"); "my.foo: http://${bar.password}://hello", "bar.password: hello").applyTo(this.context);
this.context.register(Config.class); this.context.register(Config.class);
this.context.refresh(); this.context.refresh();
EnvironmentEndpoint report = getEndpointBean(); EnvironmentEndpoint report = getEndpointBean();
@ -250,8 +250,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
@Test @Test
public void propertyWithSensitivePlaceholderNotResolved() throws Exception { public void propertyWithSensitivePlaceholderNotResolved() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"my.foo: http://${bar.password}://hello"); "my.foo: http://${bar.password}://hello").applyTo(this.context);
this.context.register(Config.class); this.context.register(Config.class);
this.context.refresh(); this.context.refresh();
EnvironmentEndpoint report = getEndpointBean(); EnvironmentEndpoint report = getEndpointBean();

@ -32,7 +32,7 @@ import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConf
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -76,8 +76,8 @@ public class EnvironmentMvcEndpointTests {
public void setUp() { public void setUp() {
this.context.getBean(EnvironmentEndpoint.class).setEnabled(true); this.context.getBean(EnvironmentEndpoint.class).setEnabled(true);
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build(); this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
EnvironmentTestUtils.addEnvironment((ConfigurableApplicationContext) this.context, TestPropertyValues.of(
"foo:bar", "fool:baz"); "foo:bar", "fool:baz").applyTo((ConfigurableApplicationContext) this.context);
} }
@Test @Test

@ -30,7 +30,7 @@ import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConf
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -71,8 +71,7 @@ public class JolokiaMvcEndpointContextPathTests {
@Before @Before
public void setUp() { public void setUp() {
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build(); this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
EnvironmentTestUtils.addEnvironment((ConfigurableApplicationContext) this.context, TestPropertyValues.of("foo:bar").applyTo((ConfigurableApplicationContext) this.context);
"foo:bar");
} }
@Test @Test
@ -97,7 +96,7 @@ public class JolokiaMvcEndpointContextPathTests {
@Override @Override
public void initialize(ConfigurableApplicationContext context) { public void initialize(ConfigurableApplicationContext context) {
EnvironmentTestUtils.addEnvironment(context, "management.contextPath:/admin"); TestPropertyValues.of("management.contextPath:/admin").applyTo(context);
} }
} }

@ -30,7 +30,7 @@ import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConf
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@ -67,8 +67,7 @@ public class JolokiaMvcEndpointIntegrationTests {
@Before @Before
public void setUp() { public void setUp() {
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build(); this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
EnvironmentTestUtils.addEnvironment((ConfigurableApplicationContext) this.context, TestPropertyValues.of("foo:bar").applyTo((ConfigurableApplicationContext) this.context);
"foo:bar");
} }
@Test @Test

@ -27,7 +27,7 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.mock.web.MockServletContext; import org.springframework.mock.web.MockServletContext;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
@ -70,8 +70,8 @@ public class MvcEndpointCorsIntegrationTests {
@Test @Test
public void settingAllowedOriginsEnablesCors() throws Exception { public void settingAllowedOriginsEnablesCors() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.cors.allowed-origins:foo.example.com"); "endpoints.cors.allowed-origins:foo.example.com").applyTo(this.context);
createMockMvc() createMockMvc()
.perform(options("/application/beans").header("Origin", "bar.example.com") .perform(options("/application/beans").header("Origin", "bar.example.com")
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")) .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"))
@ -81,25 +81,25 @@ public class MvcEndpointCorsIntegrationTests {
@Test @Test
public void maxAgeDefaultsTo30Minutes() throws Exception { public void maxAgeDefaultsTo30Minutes() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.cors.allowed-origins:foo.example.com"); "endpoints.cors.allowed-origins:foo.example.com").applyTo(this.context);
performAcceptedCorsRequest() performAcceptedCorsRequest()
.andExpect(header().string(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "1800")); .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "1800"));
} }
@Test @Test
public void maxAgeCanBeConfigured() throws Exception { public void maxAgeCanBeConfigured() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.cors.allowed-origins:foo.example.com", "endpoints.cors.allowed-origins:foo.example.com",
"endpoints.cors.max-age: 2400"); "endpoints.cors.max-age: 2400").applyTo(this.context);
performAcceptedCorsRequest() performAcceptedCorsRequest()
.andExpect(header().string(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "2400")); .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "2400"));
} }
@Test @Test
public void requestsWithDisallowedHeadersAreRejected() throws Exception { public void requestsWithDisallowedHeadersAreRejected() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.cors.allowed-origins:foo.example.com"); "endpoints.cors.allowed-origins:foo.example.com").applyTo(this.context);
createMockMvc() createMockMvc()
.perform(options("/application/beans").header("Origin", "foo.example.com") .perform(options("/application/beans").header("Origin", "foo.example.com")
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")
@ -109,9 +109,9 @@ public class MvcEndpointCorsIntegrationTests {
@Test @Test
public void allowedHeadersCanBeConfigured() throws Exception { public void allowedHeadersCanBeConfigured() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.cors.allowed-origins:foo.example.com", "endpoints.cors.allowed-origins:foo.example.com",
"endpoints.cors.allowed-headers:Alpha,Bravo"); "endpoints.cors.allowed-headers:Alpha,Bravo").applyTo(this.context);
createMockMvc() createMockMvc()
.perform(options("/application/beans").header("Origin", "foo.example.com") .perform(options("/application/beans").header("Origin", "foo.example.com")
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")
@ -122,8 +122,8 @@ public class MvcEndpointCorsIntegrationTests {
@Test @Test
public void requestsWithDisallowedMethodsAreRejected() throws Exception { public void requestsWithDisallowedMethodsAreRejected() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.cors.allowed-origins:foo.example.com"); "endpoints.cors.allowed-origins:foo.example.com").applyTo(this.context);
createMockMvc() createMockMvc()
.perform(options("/application/health").header(HttpHeaders.ORIGIN, "foo.example.com") .perform(options("/application/health").header(HttpHeaders.ORIGIN, "foo.example.com")
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "PATCH")) .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "PATCH"))
@ -132,9 +132,9 @@ public class MvcEndpointCorsIntegrationTests {
@Test @Test
public void allowedMethodsCanBeConfigured() throws Exception { public void allowedMethodsCanBeConfigured() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.cors.allowed-origins:foo.example.com", "endpoints.cors.allowed-origins:foo.example.com",
"endpoints.cors.allowed-methods:GET,HEAD"); "endpoints.cors.allowed-methods:GET,HEAD").applyTo(this.context);
createMockMvc() createMockMvc()
.perform(options("/application/health").header(HttpHeaders.ORIGIN, "foo.example.com") .perform(options("/application/health").header(HttpHeaders.ORIGIN, "foo.example.com")
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "HEAD")) .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "HEAD"))
@ -144,26 +144,26 @@ public class MvcEndpointCorsIntegrationTests {
@Test @Test
public void credentialsCanBeAllowed() throws Exception { public void credentialsCanBeAllowed() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.cors.allowed-origins:foo.example.com", "endpoints.cors.allowed-origins:foo.example.com",
"endpoints.cors.allow-credentials:true"); "endpoints.cors.allow-credentials:true").applyTo(this.context);
performAcceptedCorsRequest().andExpect( performAcceptedCorsRequest().andExpect(
header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true")); header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"));
} }
@Test @Test
public void credentialsCanBeDisabled() throws Exception { public void credentialsCanBeDisabled() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.cors.allowed-origins:foo.example.com", "endpoints.cors.allowed-origins:foo.example.com",
"endpoints.cors.allow-credentials:false"); "endpoints.cors.allow-credentials:false").applyTo(this.context);
performAcceptedCorsRequest().andExpect( performAcceptedCorsRequest().andExpect(
header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS)); header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS));
} }
@Test @Test
public void jolokiaEndpointUsesGlobalCorsConfiguration() throws Exception { public void jolokiaEndpointUsesGlobalCorsConfiguration() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.cors.allowed-origins:foo.example.com"); "endpoints.cors.allowed-origins:foo.example.com").applyTo(this.context);
createMockMvc() createMockMvc()
.perform(options("/application/jolokia").header("Origin", "bar.example.com") .perform(options("/application/jolokia").header("Origin", "bar.example.com")
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")) .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"))

@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConf
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration; import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.mock.web.MockServletContext; import org.springframework.mock.web.MockServletContext;
import org.springframework.security.authentication.TestingAuthenticationToken; import org.springframework.security.authentication.TestingAuthenticationToken;
@ -124,8 +124,8 @@ public class MvcEndpointIntegrationTests {
throws Exception { throws Exception {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SecureConfiguration.class); this.context.register(SecureConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.context-path:/management"); "management.context-path:/management").applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc(); MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/info")).andExpect(status().isOk()); mockMvc.perform(get("/management/info")).andExpect(status().isOk());
mockMvc.perform(get("/management")).andExpect(status().isOk()); mockMvc.perform(get("/management")).andExpect(status().isOk());
@ -144,8 +144,8 @@ public class MvcEndpointIntegrationTests {
throws Exception { throws Exception {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SecureConfiguration.class); this.context.register(SecureConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.context-path:/management"); "management.context-path:/management").applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc(); MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/beans")).andExpect(status().isUnauthorized()); mockMvc.perform(get("/management/beans")).andExpect(status().isUnauthorized());
} }
@ -157,8 +157,8 @@ public class MvcEndpointIntegrationTests {
new TestingAuthenticationToken("user", "N/A", "ROLE_USER")); new TestingAuthenticationToken("user", "N/A", "ROLE_USER"));
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SecureConfiguration.class); this.context.register(SecureConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.context-path:/management"); "management.context-path:/management").applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc(); MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/beans")).andExpect(status().isForbidden()); mockMvc.perform(get("/management/beans")).andExpect(status().isForbidden());
} }
@ -170,8 +170,8 @@ public class MvcEndpointIntegrationTests {
new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR")); new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SecureConfiguration.class); this.context.register(SecureConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.context-path:/management"); "management.context-path:/management").applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc(); MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/beans")).andExpect(status().isOk()); mockMvc.perform(get("/management/beans")).andExpect(status().isOk());
} }
@ -180,9 +180,9 @@ public class MvcEndpointIntegrationTests {
public void endpointSecurityCanBeDisabledWithCustomContextPath() throws Exception { public void endpointSecurityCanBeDisabledWithCustomContextPath() throws Exception {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SecureConfiguration.class); this.context.register(SecureConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.context-path:/management", "management.context-path:/management",
"management.security.enabled:false"); "management.security.enabled:false").applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc(); MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/beans")).andExpect(status().isOk()); mockMvc.perform(get("/management/beans")).andExpect(status().isOk());
} }
@ -191,8 +191,8 @@ public class MvcEndpointIntegrationTests {
public void endpointSecurityCanBeDisabled() throws Exception { public void endpointSecurityCanBeDisabled() throws Exception {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SecureConfiguration.class); this.context.register(SecureConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.security.enabled:false"); "management.security.enabled:false").applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc(); MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/application/beans")).andExpect(status().isOk()); mockMvc.perform(get("/application/beans")).andExpect(status().isOk());
} }
@ -202,8 +202,8 @@ public class MvcEndpointIntegrationTests {
new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR")); new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.register(configuration); this.context.register(configuration);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.serialization.indent-output:true"); "spring.jackson.serialization.indent-output:true").applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc(); MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/application/mappings")) mockMvc.perform(get("/application/mappings"))
.andExpect(content().string(startsWith("{" + LINE_SEPARATOR))); .andExpect(content().string(startsWith("{" + LINE_SEPARATOR)));

@ -21,7 +21,7 @@ import org.junit.Test;
import org.springframework.boot.actuate.endpoint.AbstractEndpoint; import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
import org.springframework.boot.actuate.endpoint.Endpoint; import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.support.StaticApplicationContext; import org.springframework.context.support.StaticApplicationContext;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -68,8 +68,8 @@ public class MvcEndpointsTests {
@Test @Test
public void changesPath() throws Exception { public void changesPath() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"endpoints.test.path=/foo/bar/"); "endpoints.test.path=/foo/bar/").applyTo(this.context);
this.context.getDefaultListableBeanFactory().registerSingleton("endpoint", this.context.getDefaultListableBeanFactory().registerSingleton("endpoint",
new TestEndpoint()); new TestEndpoint());
this.endpoints.setApplicationContext(this.context); this.endpoints.setApplicationContext(this.context);

@ -33,7 +33,7 @@ import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.junit.runner.classpath.ClassPathExclusions; import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner; import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
@ -84,8 +84,8 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext()); this.context.setServletContext(new MockServletContext());
this.context.register(TestConfiguration.class); this.context.register(TestConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"management.security.enabled:false"); "management.security.enabled:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build(); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
mockMvc.perform(get("/application/health")).andExpect(status().isOk()) mockMvc.perform(get("/application/health")).andExpect(status().isOk())

@ -16,16 +16,14 @@
package org.springframework.boot.actuate.info; package org.springframework.boot.actuate.info;
import java.util.Collections;
import java.util.Map; import java.util.Map;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.test.util.TestPropertyValues.Type;
import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.StandardEnvironment; import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.SystemEnvironmentPropertySource;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -40,8 +38,8 @@ public class EnvironmentInfoContributorTests {
@Test @Test
public void extractOnlyInfoProperty() { public void extractOnlyInfoProperty() {
EnvironmentTestUtils.addEnvironment(this.environment, "info.app=my app", TestPropertyValues.of("info.app=my app",
"info.version=1.0.0", "foo=bar"); "info.version=1.0.0", "foo=bar").applyTo(this.environment);
Info actual = contributeFrom(this.environment); Info actual = contributeFrom(this.environment);
assertThat(actual.get("app", String.class)).isEqualTo("my app"); assertThat(actual.get("app", String.class)).isEqualTo("my app");
assertThat(actual.get("version", String.class)).isEqualTo("1.0.0"); assertThat(actual.get("version", String.class)).isEqualTo("1.0.0");
@ -50,7 +48,7 @@ public class EnvironmentInfoContributorTests {
@Test @Test
public void extractNoEntry() { public void extractNoEntry() {
EnvironmentTestUtils.addEnvironment(this.environment, "foo=bar"); TestPropertyValues.of("foo=bar").applyTo(this.environment);
Info actual = contributeFrom(this.environment); Info actual = contributeFrom(this.environment);
assertThat(actual.getDetails().size()).isEqualTo(0); assertThat(actual.getDetails().size()).isEqualTo(0);
} }
@ -58,9 +56,7 @@ public class EnvironmentInfoContributorTests {
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void propertiesFromEnvironmentShouldBindCorrectly() throws Exception { public void propertiesFromEnvironmentShouldBindCorrectly() throws Exception {
MutablePropertySources propertySources = this.environment.getPropertySources(); TestPropertyValues.of("INFO_ENVIRONMENT_FOO=green").applyTo(this.environment, Type.SYSTEM);
propertySources.addFirst(new SystemEnvironmentPropertySource("system",
Collections.singletonMap("INFO_ENVIRONMENT_FOO", "green")));
Info actual = contributeFrom(this.environment); Info actual = contributeFrom(this.environment);
assertThat(actual.get("environment", Map.class)).containsEntry("foo", "green"); assertThat(actual.get("environment", Map.class)).containsEntry("foo", "green");
} }

@ -38,7 +38,7 @@ import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext; import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@ -175,7 +175,7 @@ public class SpringApplicationAdminJmxAutoConfigurationTests {
private void load(String... environment) { private void load(String... environment) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(applicationContext, environment); TestPropertyValues.of(environment).applyTo(applicationContext);
applicationContext.register(JmxAutoConfiguration.class, applicationContext.register(JmxAutoConfiguration.class,
SpringApplicationAdminJmxAutoConfiguration.class); SpringApplicationAdminJmxAutoConfiguration.class);
applicationContext.refresh(); applicationContext.refresh();

@ -45,7 +45,7 @@ import org.springframework.amqp.rabbit.support.ValueExpression;
import org.springframework.amqp.support.converter.MessageConverter; import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -497,7 +497,7 @@ public class RabbitAutoConfigurationTests {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
applicationContext.register(configs); applicationContext.register(configs);
applicationContext.register(RabbitAutoConfiguration.class); applicationContext.register(RabbitAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(applicationContext, environment); TestPropertyValues.of(environment).applyTo(applicationContext);
applicationContext.refresh(); applicationContext.refresh();
this.context = applicationContext; this.context = applicationContext;
} }

@ -21,7 +21,7 @@ import org.aspectj.lang.annotation.Before;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -101,7 +101,7 @@ public class AopAutoConfigurationTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(config); ctx.register(config);
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
ctx.register(AopAutoConfiguration.class); ctx.register(AopAutoConfiguration.class);
ctx.refresh(); ctx.refresh();
this.context = ctx; this.context = ctx;

@ -53,7 +53,7 @@ import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfigurati
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.test.City; import org.springframework.boot.autoconfigure.orm.jpa.test.City;
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration; import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -263,7 +263,7 @@ public class BatchAutoConfigurationTests {
private void load(Class<?>[] configs, String... environment) { private void load(Class<?>[] configs, String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
if (configs != null) { if (configs != null) {
ctx.register(configs); ctx.register(configs);
} }

@ -34,7 +34,7 @@ import org.springframework.boot.autoconfigure.orm.jpa.test.City;
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration; import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
import org.springframework.boot.junit.runner.classpath.ClassPathExclusions; import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner; import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
@ -100,7 +100,7 @@ public class BatchAutoConfigurationWithoutJpaTests {
private void load(Class<?>[] configs, String... environment) { private void load(Class<?>[] configs, String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
if (configs != null) { if (configs != null) {
ctx.register(configs); ctx.register(configs);
} }

@ -58,7 +58,7 @@ import org.springframework.boot.autoconfigure.cache.support.MockCachingProvider;
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration; import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
import org.springframework.boot.junit.runner.classpath.ClassPathExclusions; import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner; import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.CachingConfigurerSupport;
@ -697,7 +697,7 @@ public class CacheAutoConfigurationTests {
private void load(Class<?>[] configs, String... environment) { private void load(Class<?>[] configs, String... environment) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(applicationContext, environment); TestPropertyValues.of(environment).applyTo(applicationContext);
applicationContext.register(configs); applicationContext.register(configs);
applicationContext.register(CacheAutoConfiguration.class); applicationContext.register(CacheAutoConfiguration.class);
applicationContext.refresh(); applicationContext.refresh();

@ -21,7 +21,7 @@ import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -91,7 +91,7 @@ public class CassandraAutoConfigurationTests {
} }
ctx.register(PropertyPlaceholderAutoConfiguration.class, ctx.register(PropertyPlaceholderAutoConfiguration.class,
CassandraAutoConfiguration.class); CassandraAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
ctx.refresh(); ctx.refresh();
this.context = ctx; this.context = ctx;
} }

@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.condition;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Condition; import org.springframework.context.annotation.Condition;
@ -64,7 +64,7 @@ public class AllNestedConditionsTests {
private AnnotationConfigApplicationContext load(Class<?> config, String... env) { private AnnotationConfigApplicationContext load(Class<?> config, String... env) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, env); TestPropertyValues.of(env).applyTo(context);
context.register(config); context.register(config);
context.refresh(); context.refresh();
return context; return context;

@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.condition;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Condition; import org.springframework.context.annotation.Condition;
@ -67,7 +67,7 @@ public class AnyNestedConditionTests {
private AnnotationConfigApplicationContext load(Class<?> config, String... env) { private AnnotationConfigApplicationContext load(Class<?> config, String... env) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, env); TestPropertyValues.of(env).applyTo(context);
context.register(config); context.register(config);
context.refresh(); context.refresh();
return context; return context;

@ -32,7 +32,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionEvaluationRepor
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcomes; import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcomes;
import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.testutil.Matched; import org.springframework.boot.testutil.Matched;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -227,7 +227,7 @@ public class ConditionEvaluationReportTests {
@Test @Test
public void negativeOuterPositiveInnerBean() throws Exception { public void negativeOuterPositiveInnerBean() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, "test.present=true"); TestPropertyValues.of("test.present=true").applyTo(context);
context.register(NegativeOuterConfig.class); context.register(NegativeOuterConfig.class);
context.refresh(); context.refresh();
ConditionEvaluationReport report = ConditionEvaluationReport ConditionEvaluationReport report = ConditionEvaluationReport

@ -28,7 +28,7 @@ import org.junit.Test;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -124,7 +124,7 @@ public class ConditionalOnBeanTests {
@Test @Test
public void withPropertyPlaceholderClassName() throws Exception { public void withPropertyPlaceholderClassName() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, "mybeanclass=java.lang.String"); TestPropertyValues.of("mybeanclass=java.lang.String").applyTo(this.context);
this.context.register(PropertySourcesPlaceholderConfigurer.class, this.context.register(PropertySourcesPlaceholderConfigurer.class,
WithPropertyPlaceholderClassName.class, OnBeanClassConfiguration.class); WithPropertyPlaceholderClassName.class, OnBeanClassConfiguration.class);
this.context.refresh(); this.context.refresh();

@ -20,7 +20,7 @@ import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.cloud.CloudPlatform; import org.springframework.boot.cloud.CloudPlatform;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -62,7 +62,7 @@ public class ConditionalOnCloudPlatformTests {
} }
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
EnvironmentTestUtils.addEnvironment(this.context, environment); TestPropertyValues.of(environment).applyTo(this.context);
this.context.register(config); this.context.register(config);
this.context.refresh(); this.context.refresh();
} }

@ -27,7 +27,7 @@ import org.junit.Test;
import org.springframework.boot.autoconfigure.jndi.JndiPropertiesHidingClassLoader; import org.springframework.boot.autoconfigure.jndi.JndiPropertiesHidingClassLoader;
import org.springframework.boot.autoconfigure.jndi.TestableInitialContextFactory; import org.springframework.boot.autoconfigure.jndi.TestableInitialContextFactory;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -133,7 +133,7 @@ public class ConditionalOnJndiTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(applicationContext, environment); TestPropertyValues.of(environment).applyTo(applicationContext);
applicationContext.register(config); applicationContext.register(config);
applicationContext.register(JndiConditionConfiguration.class); applicationContext.register(JndiConditionConfiguration.class);
applicationContext.refresh(); applicationContext.refresh();

@ -32,7 +32,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.boot.autoconfigure.condition.scan.ScannedFactoryBeanConfiguration; import org.springframework.boot.autoconfigure.condition.scan.ScannedFactoryBeanConfiguration;
import org.springframework.boot.autoconfigure.condition.scan.ScannedFactoryBeanWithBeanMethodArgumentsConfiguration; import org.springframework.boot.autoconfigure.condition.scan.ScannedFactoryBeanWithBeanMethodArgumentsConfiguration;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
@ -176,7 +176,7 @@ public class ConditionalOnMissingBeanTests {
this.context.register(FactoryBeanWithBeanMethodArgumentsConfiguration.class, this.context.register(FactoryBeanWithBeanMethodArgumentsConfiguration.class,
ConditionalOnFactoryBean.class, ConditionalOnFactoryBean.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, "theValue:foo"); TestPropertyValues.of("theValue:foo").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(ExampleBean.class).toString()) assertThat(this.context.getBean(ExampleBean.class).toString())
.isEqualTo("fromFactory"); .isEqualTo("fromFactory");

@ -28,7 +28,7 @@ import org.junit.rules.ExpectedException;
import org.springframework.boot.WebApplicationType; import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -258,7 +258,7 @@ public class ConditionalOnPropertyTests {
} }
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
EnvironmentTestUtils.addEnvironment(this.environment, environment); TestPropertyValues.of(environment).applyTo(this.environment);
this.context = new SpringApplicationBuilder(config).environment(this.environment) this.context = new SpringApplicationBuilder(config).environment(this.environment)
.web(WebApplicationType.NONE).run(); .web(WebApplicationType.NONE).run();
} }

@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.condition;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -44,7 +44,7 @@ public class ConditionalOnResourceTests {
@Test @Test
public void testResourceExistsWithPlaceholder() { public void testResourceExistsWithPlaceholder() {
EnvironmentTestUtils.addEnvironment(this.context, "schema=schema.sql"); TestPropertyValues.of("schema=schema.sql").applyTo(this.context);
this.context.register(PlaceholderConfiguration.class); this.context.register(PlaceholderConfiguration.class);
this.context.refresh(); this.context.refresh();
assertThat(this.context.containsBean("foo")).isTrue(); assertThat(this.context.containsBean("foo")).isTrue();

@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.condition;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Condition; import org.springframework.context.annotation.Condition;
@ -64,7 +64,7 @@ public class NoneNestedConditionsTests {
private AnnotationConfigApplicationContext load(Class<?> config, String... env) { private AnnotationConfigApplicationContext load(Class<?> config, String... env) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, env); TestPropertyValues.of(env).applyTo(context);
context.register(config); context.register(config);
context.refresh(); context.refresh();
return context; return context;

@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.condition;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -65,7 +65,7 @@ public class ResourceConditionTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(applicationContext, environment); TestPropertyValues.of(environment).applyTo(applicationContext);
applicationContext.register(config); applicationContext.register(config);
applicationContext.refresh(); applicationContext.refresh();
this.context = applicationContext; this.context = applicationContext;

@ -21,7 +21,7 @@ import org.junit.Test;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -59,7 +59,7 @@ public class ConfigurationPropertiesAutoConfigurationTests {
private void load(Class<?>[] configs, String... environment) { private void load(Class<?>[] configs, String... environment) {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
this.context.register(configs); this.context.register(configs);
EnvironmentTestUtils.addEnvironment(this.context, environment); TestPropertyValues.of(environment).applyTo(this.context);
this.context.refresh(); this.context.refresh();
} }

@ -22,7 +22,7 @@ import org.junit.After;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceResolvable; import org.springframework.context.MessageSourceResolvable;
@ -147,8 +147,8 @@ public class MessageSourceAutoConfigurationTests {
parent.refresh(); parent.refresh();
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
this.context.setParent(parent); this.context.setParent(parent);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.messages.basename:test/messages"); "spring.messages.basename:test/messages").applyTo(this.context);
this.context.register(MessageSourceAutoConfiguration.class, this.context.register(MessageSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -159,7 +159,7 @@ public class MessageSourceAutoConfigurationTests {
private void load(String... environment) { private void load(String... environment) {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, environment); TestPropertyValues.of(environment).applyTo(this.context);
this.context.register(MessageSourceAutoConfiguration.class, this.context.register(MessageSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
this.context.refresh(); this.context.refresh();

@ -20,7 +20,7 @@ import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -49,7 +49,7 @@ public class PropertyPlaceholderAutoConfigurationTests {
public void propertyPlaceholders() throws Exception { public void propertyPlaceholders() throws Exception {
this.context.register(PropertyPlaceholderAutoConfiguration.class, this.context.register(PropertyPlaceholderAutoConfiguration.class,
PlaceholderConfig.class); PlaceholderConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, "foo:two"); TestPropertyValues.of("foo:two").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(PlaceholderConfig.class).getFoo()) assertThat(this.context.getBean(PlaceholderConfig.class).getFoo())
.isEqualTo("two"); .isEqualTo("two");
@ -59,7 +59,7 @@ public class PropertyPlaceholderAutoConfigurationTests {
public void propertyPlaceholdersOverride() throws Exception { public void propertyPlaceholdersOverride() throws Exception {
this.context.register(PropertyPlaceholderAutoConfiguration.class, this.context.register(PropertyPlaceholderAutoConfiguration.class,
PlaceholderConfig.class, PlaceholdersOverride.class); PlaceholderConfig.class, PlaceholdersOverride.class);
EnvironmentTestUtils.addEnvironment(this.context, "foo:two"); TestPropertyValues.of("foo:two").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(PlaceholderConfig.class).getFoo()) assertThat(this.context.getBean(PlaceholderConfig.class).getFoo())
.isEqualTo("spam"); .isEqualTo("spam");

@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.couchbase;
import org.junit.After; import org.junit.After;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/** /**
@ -40,7 +40,7 @@ public abstract class AbstractCouchbaseAutoConfigurationTests {
protected void load(Class<?> config, String... environment) { protected void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, environment); TestPropertyValues.of(environment).applyTo(context);
if (config != null) { if (config != null) {
context.register(config); context.register(config);
} }

@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.couchbase;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Conditional;
@ -75,7 +75,7 @@ public class OnBootstrapHostsConditionTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, environment); TestPropertyValues.of(environment).applyTo(this.context);
this.context.register(config); this.context.register(config);
this.context.refresh(); this.context.refresh();
} }

@ -26,7 +26,7 @@ import org.junit.Test;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -66,8 +66,8 @@ public class PersistenceExceptionTranslationAutoConfigurationTests {
@Test @Test
public void exceptionTranslationPostProcessorCanBeConfiguredToUseJdkProxy() { public void exceptionTranslationPostProcessorCanBeConfiguredToUseJdkProxy() {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.aop.proxy-target-class=false"); "spring.aop.proxy-target-class=false").applyTo(this.context);
this.context.register(PersistenceExceptionTranslationAutoConfiguration.class); this.context.register(PersistenceExceptionTranslationAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context
@ -79,8 +79,8 @@ public class PersistenceExceptionTranslationAutoConfigurationTests {
@Test @Test
public void exceptionTranslationPostProcessorCanBeDisabled() { public void exceptionTranslationPostProcessorCanBeDisabled() {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.dao.exceptiontranslation.enabled=false"); "spring.dao.exceptiontranslation.enabled=false").applyTo(this.context);
this.context.register(PersistenceExceptionTranslationAutoConfiguration.class); this.context.register(PersistenceExceptionTranslationAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context

@ -24,7 +24,7 @@ import org.junit.Test;
import org.springframework.boot.autoconfigure.AutoConfigurationPackages; import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration; import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
import org.springframework.boot.autoconfigure.data.cassandra.city.City; import org.springframework.boot.autoconfigure.data.cassandra.city.City;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.data.cassandra.config.CassandraSessionFactoryBean; import org.springframework.data.cassandra.config.CassandraSessionFactoryBean;
import org.springframework.data.cassandra.config.SchemaAction; import org.springframework.data.cassandra.config.SchemaAction;
@ -71,9 +71,9 @@ public class CassandraDataAutoConfigurationIntegrationTests {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
String cityPackage = City.class.getPackage().getName(); String cityPackage = City.class.getPackage().getName();
AutoConfigurationPackages.register(this.context, cityPackage); AutoConfigurationPackages.register(this.context, cityPackage);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.cassandra.schemaAction=recreate_drop_unused", "spring.data.cassandra.schemaAction=recreate_drop_unused",
"spring.data.cassandra.keyspaceName=boot_test"); "spring.data.cassandra.keyspaceName=boot_test").applyTo(this.context);
this.context.register(CassandraAutoConfiguration.class, this.context.register(CassandraAutoConfiguration.class,
CassandraDataAutoConfiguration.class); CassandraDataAutoConfiguration.class);
this.context.refresh(); this.context.refresh();

@ -26,7 +26,7 @@ import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfigurati
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.data.cassandra.city.City; import org.springframework.boot.autoconfigure.data.cassandra.city.City;
import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
@ -60,8 +60,8 @@ public class CassandraDataAutoConfigurationTests {
@Test @Test
public void templateExists() { public void templateExists() {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.cassandra.keyspaceName:boot_test"); "spring.data.cassandra.keyspaceName:boot_test").applyTo(this.context);
this.context.register(TestExcludeConfiguration.class, TestConfiguration.class, this.context.register(TestExcludeConfiguration.class, TestConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class); CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class);
@ -74,7 +74,7 @@ public class CassandraDataAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void entityScanShouldSetInitialEntitySet() throws Exception { public void entityScanShouldSetInitialEntitySet() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.cassandra.keyspaceName:boot_test"); "spring.data.cassandra.keyspaceName:boot_test");
this.context.register(TestConfiguration.class, EntityScanConfig.class, this.context.register(TestConfiguration.class, EntityScanConfig.class,
PropertyPlaceholderAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
@ -90,8 +90,8 @@ public class CassandraDataAutoConfigurationTests {
@Test @Test
public void userTypeResolverShouldBeSet() throws Exception { public void userTypeResolverShouldBeSet() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.cassandra.keyspaceName:boot_test"); "spring.data.cassandra.keyspaceName:boot_test").applyTo(this.context);
this.context.register(TestConfiguration.class, this.context.register(TestConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class,
CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class); CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class);

@ -25,7 +25,7 @@ import org.junit.Test;
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration; import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
import org.springframework.boot.autoconfigure.data.cassandra.city.City; import org.springframework.boot.autoconfigure.data.cassandra.city.City;
import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -88,7 +88,7 @@ public class CassandraReactiveDataAutoConfigurationTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
if (config != null) { if (config != null) {
ctx.register(config); ctx.register(config);
} }

@ -29,7 +29,7 @@ import org.springframework.boot.autoconfigure.couchbase.CouchbaseTestConfigurer;
import org.springframework.boot.autoconfigure.data.couchbase.city.City; import org.springframework.boot.autoconfigure.data.couchbase.city.City;
import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration; import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -135,7 +135,7 @@ public class CouchbaseDataAutoConfigurationTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, environment); TestPropertyValues.of(environment).applyTo(context);
if (config != null) { if (config != null) {
context.register(config); context.register(config);
} }

@ -26,7 +26,7 @@ import org.springframework.boot.autoconfigure.couchbase.CouchbaseTestConfigurer;
import org.springframework.boot.autoconfigure.data.couchbase.city.City; import org.springframework.boot.autoconfigure.data.couchbase.city.City;
import org.springframework.boot.autoconfigure.data.couchbase.city.CityRepository; import org.springframework.boot.autoconfigure.data.couchbase.city.CityRepository;
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage; import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@ -77,7 +77,7 @@ public class CouchbaseRepositoriesAutoConfigurationTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, environment); TestPropertyValues.of(environment).applyTo(context);
if (config != null) { if (config != null) {
context.register(config); context.register(config);
} }

@ -25,7 +25,7 @@ import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -55,9 +55,9 @@ public class ElasticsearchAutoConfigurationTests {
@Test @Test
public void createNodeClientWithDefaults() { public void createNodeClientWithDefaults() {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.elasticsearch.properties.foo.bar:baz", "spring.data.elasticsearch.properties.foo.bar:baz",
"spring.data.elasticsearch.properties.path.home:target"); "spring.data.elasticsearch.properties.path.home:target").applyTo(this.context);
this.context.register(PropertyPlaceholderAutoConfiguration.class, this.context.register(PropertyPlaceholderAutoConfiguration.class,
ElasticsearchAutoConfiguration.class); ElasticsearchAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -71,12 +71,12 @@ public class ElasticsearchAutoConfigurationTests {
@Test @Test
public void createNodeClientWithOverrides() { public void createNodeClientWithOverrides() {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.elasticsearch.properties.foo.bar:baz", "spring.data.elasticsearch.properties.foo.bar:baz",
"spring.data.elasticsearch.properties.path.home:target", "spring.data.elasticsearch.properties.path.home:target",
"spring.data.elasticsearch.properties.node.local:false", "spring.data.elasticsearch.properties.node.local:false",
"spring.data.elasticsearch.properties.node.data:true", "spring.data.elasticsearch.properties.node.data:true",
"spring.data.elasticsearch.properties.http.enabled:true"); "spring.data.elasticsearch.properties.http.enabled:true").applyTo(this.context);
this.context.register(PropertyPlaceholderAutoConfiguration.class, this.context.register(PropertyPlaceholderAutoConfiguration.class,
ElasticsearchAutoConfiguration.class); ElasticsearchAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -105,9 +105,9 @@ public class ElasticsearchAutoConfigurationTests {
// We don't have a local elasticsearch server so use an address that's missing // We don't have a local elasticsearch server so use an address that's missing
// a port and check the exception // a port and check the exception
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.elasticsearch.cluster-nodes:localhost", "spring.data.elasticsearch.cluster-nodes:localhost",
"spring.data.elasticsearch.properties.path.home:target"); "spring.data.elasticsearch.properties.path.home:target").applyTo(this.context);
this.context.register(PropertyPlaceholderAutoConfiguration.class, this.context.register(PropertyPlaceholderAutoConfiguration.class,
ElasticsearchAutoConfiguration.class); ElasticsearchAutoConfiguration.class);
this.thrown.expect(BeanCreationException.class); this.thrown.expect(BeanCreationException.class);

@ -20,7 +20,7 @@ import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
@ -48,9 +48,9 @@ public class ElasticsearchDataAutoConfigurationTests {
@Test @Test
public void templateExists() { public void templateExists() {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.elasticsearch.properties.path.data:target/data", "spring.data.elasticsearch.properties.path.data:target/data",
"spring.data.elasticsearch.properties.path.logs:target/logs"); "spring.data.elasticsearch.properties.path.logs:target/logs").applyTo(this.context);
this.context.register(PropertyPlaceholderAutoConfiguration.class, this.context.register(PropertyPlaceholderAutoConfiguration.class,
ElasticsearchAutoConfiguration.class, ElasticsearchAutoConfiguration.class,
ElasticsearchDataAutoConfiguration.class); ElasticsearchDataAutoConfiguration.class);
@ -62,7 +62,7 @@ public class ElasticsearchDataAutoConfigurationTests {
@Test @Test
public void mappingContextExists() { public void mappingContextExists() {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.elasticsearch.properties.path.data:target/data", "spring.data.elasticsearch.properties.path.data:target/data",
"spring.data.elasticsearch.properties.path.logs:target/logs"); "spring.data.elasticsearch.properties.path.logs:target/logs");
this.context.register(PropertyPlaceholderAutoConfiguration.class, this.context.register(PropertyPlaceholderAutoConfiguration.class,
@ -77,7 +77,7 @@ public class ElasticsearchDataAutoConfigurationTests {
@Test @Test
public void converterExists() { public void converterExists() {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.elasticsearch.properties.path.data:target/data", "spring.data.elasticsearch.properties.path.data:target/data",
"spring.data.elasticsearch.properties.path.logs:target/logs"); "spring.data.elasticsearch.properties.path.logs:target/logs");
this.context.register(PropertyPlaceholderAutoConfiguration.class, this.context.register(PropertyPlaceholderAutoConfiguration.class,

@ -26,7 +26,7 @@ import org.springframework.boot.autoconfigure.data.alt.elasticsearch.CityElastic
import org.springframework.boot.autoconfigure.data.elasticsearch.city.City; import org.springframework.boot.autoconfigure.data.elasticsearch.city.City;
import org.springframework.boot.autoconfigure.data.elasticsearch.city.CityRepository; import org.springframework.boot.autoconfigure.data.elasticsearch.city.CityRepository;
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage; import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
@ -88,8 +88,8 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
} }
private void addElasticsearchProperties(AnnotationConfigApplicationContext context) { private void addElasticsearchProperties(AnnotationConfigApplicationContext context) {
EnvironmentTestUtils.addEnvironment(context, TestPropertyValues.of(
"spring.data.elasticsearch.properties.path.home:target"); "spring.data.elasticsearch.properties.path.home:target").applyTo(context);
} }
@Configuration @Configuration

@ -21,7 +21,7 @@ import org.junit.Test;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration; import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.ldap.core.LdapTemplate; import org.springframework.ldap.core.LdapTemplate;
@ -46,8 +46,8 @@ public class LdapDataAutoConfigurationTests {
@Test @Test
public void templateExists() { public void templateExists() {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.ldap.urls:ldap://localhost:389"); "spring.ldap.urls:ldap://localhost:389").applyTo(this.context);
this.context.register(PropertyPlaceholderAutoConfiguration.class, this.context.register(PropertyPlaceholderAutoConfiguration.class,
LdapAutoConfiguration.class, LdapDataAutoConfiguration.class); LdapAutoConfiguration.class, LdapDataAutoConfiguration.class);
this.context.refresh(); this.context.refresh();

@ -26,7 +26,7 @@ import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
import org.springframework.boot.autoconfigure.data.ldap.person.Person; import org.springframework.boot.autoconfigure.data.ldap.person.Person;
import org.springframework.boot.autoconfigure.data.ldap.person.PersonRepository; import org.springframework.boot.autoconfigure.data.ldap.person.PersonRepository;
import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration; import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.ldap.repository.config.EnableLdapRepositories; import org.springframework.data.ldap.repository.config.EnableLdapRepositories;
@ -69,8 +69,8 @@ public class LdapRepositoriesAutoConfigurationTests {
private void load(Class<?>... configurationClasses) { private void load(Class<?>... configurationClasses) {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.ldap.urls:ldap://localhost:389"); "spring.ldap.urls:ldap://localhost:389").applyTo(this.context);
this.context.register(configurationClasses); this.context.register(configurationClasses);
this.context.register(LdapAutoConfiguration.class, this.context.register(LdapAutoConfiguration.class,
LdapDataAutoConfiguration.class, LdapRepositoriesAutoConfiguration.class, LdapDataAutoConfiguration.class, LdapRepositoriesAutoConfiguration.class,

@ -33,7 +33,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfigurationTests; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfigurationTests;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@ -62,8 +62,8 @@ public class MixedMongoRepositoriesAutoConfigurationTests {
@Test @Test
public void testDefaultRepositoryConfiguration() throws Exception { public void testDefaultRepositoryConfiguration() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false"); "spring.datasource.initialize:false").applyTo(this.context);
this.context.register(TestConfiguration.class, BaseConfiguration.class); this.context.register(TestConfiguration.class, BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(CountryRepository.class)).isNotNull(); assertThat(this.context.getBean(CountryRepository.class)).isNotNull();
@ -72,8 +72,8 @@ public class MixedMongoRepositoriesAutoConfigurationTests {
@Test @Test
public void testMixedRepositoryConfiguration() throws Exception { public void testMixedRepositoryConfiguration() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false"); "spring.datasource.initialize:false").applyTo(this.context);
this.context.register(MixedConfiguration.class, BaseConfiguration.class); this.context.register(MixedConfiguration.class, BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(CountryRepository.class)).isNotNull(); assertThat(this.context.getBean(CountryRepository.class)).isNotNull();
@ -83,8 +83,8 @@ public class MixedMongoRepositoriesAutoConfigurationTests {
@Test @Test
public void testJpaRepositoryConfigurationWithMongoTemplate() throws Exception { public void testJpaRepositoryConfigurationWithMongoTemplate() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false"); "spring.datasource.initialize:false").applyTo(this.context);
this.context.register(JpaConfiguration.class, BaseConfiguration.class); this.context.register(JpaConfiguration.class, BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(CityRepository.class)).isNotNull(); assertThat(this.context.getBean(CityRepository.class)).isNotNull();
@ -93,8 +93,8 @@ public class MixedMongoRepositoriesAutoConfigurationTests {
@Test @Test
public void testJpaRepositoryConfigurationWithMongoOverlap() throws Exception { public void testJpaRepositoryConfigurationWithMongoOverlap() throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false"); "spring.datasource.initialize:false").applyTo(this.context);
this.context.register(OverlapConfiguration.class, BaseConfiguration.class); this.context.register(OverlapConfiguration.class, BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(CityRepository.class)).isNotNull(); assertThat(this.context.getBean(CityRepository.class)).isNotNull();
@ -104,9 +104,9 @@ public class MixedMongoRepositoriesAutoConfigurationTests {
public void testJpaRepositoryConfigurationWithMongoOverlapDisabled() public void testJpaRepositoryConfigurationWithMongoOverlapDisabled()
throws Exception { throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false", "spring.datasource.initialize:false",
"spring.data.mongodb.repositories.enabled:false"); "spring.data.mongodb.repositories.enabled:false").applyTo(this.context);
this.context.register(OverlapConfiguration.class, BaseConfiguration.class); this.context.register(OverlapConfiguration.class, BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(CityRepository.class)).isNotNull(); assertThat(this.context.getBean(CityRepository.class)).isNotNull();

@ -35,7 +35,7 @@ import org.springframework.boot.autoconfigure.data.mongo.city.City;
import org.springframework.boot.autoconfigure.data.mongo.country.Country; import org.springframework.boot.autoconfigure.data.mongo.country.Country;
import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -86,7 +86,7 @@ public class MongoDataAutoConfigurationTests {
@Test @Test
public void gridFsTemplateExists() { public void gridFsTemplateExists() {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.mongodb.gridFsDatabase:grid"); "spring.data.mongodb.gridFsDatabase:grid");
this.context.register(PropertyPlaceholderAutoConfiguration.class, this.context.register(PropertyPlaceholderAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class); MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
@ -180,8 +180,8 @@ public class MongoDataAutoConfigurationTests {
Class<? extends FieldNamingStrategy> expectedType) { Class<? extends FieldNamingStrategy> expectedType) {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
if (strategy != null) { if (strategy != null) {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.mongodb.field-naming-strategy:" + strategy); "spring.data.mongodb.field-naming-strategy:" + strategy).applyTo(this.context);
} }
this.context.register(PropertyPlaceholderAutoConfiguration.class, this.context.register(PropertyPlaceholderAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class); MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);

@ -28,7 +28,7 @@ import org.springframework.boot.autoconfigure.data.mongo.city.ReactiveCityReposi
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfigurationTests; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfigurationTests;
import org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@ -58,8 +58,8 @@ public class MongoReactiveAndBlockingRepositoriesAutoConfigurationTests {
public void shouldCreateInstancesForReactiveAndBlockingRepositories() public void shouldCreateInstancesForReactiveAndBlockingRepositories()
throws Exception { throws Exception {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false"); "spring.datasource.initialize:false").applyTo(this.context);
this.context.register(BlockingAndReactiveConfiguration.class, this.context.register(BlockingAndReactiveConfiguration.class,
BaseConfiguration.class); BaseConfiguration.class);
this.context.refresh(); this.context.refresh();

@ -33,7 +33,7 @@ import org.springframework.boot.autoconfigure.data.neo4j.empty.EmptyMarker;
import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@ -64,8 +64,8 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
@Test @Test
public void testDefaultRepositoryConfiguration() throws Exception { public void testDefaultRepositoryConfiguration() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false"); "spring.datasource.initialize:false").applyTo(this.context);
this.context.register(TestConfiguration.class, BaseConfiguration.class); this.context.register(TestConfiguration.class, BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(CountryRepository.class)).isNotNull(); assertThat(this.context.getBean(CountryRepository.class)).isNotNull();
@ -73,7 +73,7 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
@Test @Test
public void testMixedRepositoryConfiguration() throws Exception { public void testMixedRepositoryConfiguration() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false"); "spring.datasource.initialize:false");
this.context.register(MixedConfiguration.class, BaseConfiguration.class); this.context.register(MixedConfiguration.class, BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -83,8 +83,8 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
@Test @Test
public void testJpaRepositoryConfigurationWithNeo4jTemplate() throws Exception { public void testJpaRepositoryConfigurationWithNeo4jTemplate() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false"); "spring.datasource.initialize:false").applyTo(this.context);
this.context.register(JpaConfiguration.class, BaseConfiguration.class); this.context.register(JpaConfiguration.class, BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(CityRepository.class)).isNotNull(); assertThat(this.context.getBean(CityRepository.class)).isNotNull();
@ -93,8 +93,8 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
@Test @Test
@Ignore @Ignore
public void testJpaRepositoryConfigurationWithNeo4jOverlap() throws Exception { public void testJpaRepositoryConfigurationWithNeo4jOverlap() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false"); "spring.datasource.initialize:false").applyTo(this.context);
this.context.register(OverlapConfiguration.class, BaseConfiguration.class); this.context.register(OverlapConfiguration.class, BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(CityRepository.class)).isNotNull(); assertThat(this.context.getBean(CityRepository.class)).isNotNull();
@ -103,9 +103,9 @@ public class MixedNeo4jRepositoriesAutoConfigurationTests {
@Test @Test
public void testJpaRepositoryConfigurationWithNeo4jOverlapDisabled() public void testJpaRepositoryConfigurationWithNeo4jOverlapDisabled()
throws Exception { throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false", "spring.datasource.initialize:false",
"spring.data.neo4j.repositories.enabled:false"); "spring.data.neo4j.repositories.enabled:false").applyTo(this.context);
this.context.register(OverlapConfiguration.class, BaseConfiguration.class); this.context.register(OverlapConfiguration.class, BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(CityRepository.class)).isNotNull(); assertThat(this.context.getBean(CityRepository.class)).isNotNull();

@ -32,7 +32,7 @@ import org.springframework.boot.autoconfigure.data.neo4j.city.City;
import org.springframework.boot.autoconfigure.data.neo4j.country.Country; import org.springframework.boot.autoconfigure.data.neo4j.country.Country;
import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration; import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -141,7 +141,7 @@ public class Neo4jDataAutoConfigurationTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
if (config != null) { if (config != null) {
ctx.register(config); ctx.register(config);
} }

@ -27,7 +27,7 @@ import org.neo4j.ogm.config.Configuration;
import org.neo4j.ogm.config.Credentials; import org.neo4j.ogm.config.Credentials;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -182,7 +182,7 @@ public class Neo4jPropertiesTests {
} }
}); });
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
ctx.register(TestConfiguration.class); ctx.register(TestConfiguration.class);
ctx.refresh(); ctx.refresh();
this.context = ctx; this.context = ctx;

@ -27,7 +27,7 @@ import org.springframework.boot.autoconfigure.data.alt.neo4j.CityNeo4jRepository
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage; import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
import org.springframework.boot.autoconfigure.data.neo4j.city.City; import org.springframework.boot.autoconfigure.data.neo4j.city.City;
import org.springframework.boot.autoconfigure.data.neo4j.city.CityRepository; import org.springframework.boot.autoconfigure.data.neo4j.city.CityRepository;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.mapping.Neo4jMappingContext; import org.springframework.data.neo4j.mapping.Neo4jMappingContext;
@ -82,8 +82,8 @@ public class Neo4jRepositoriesAutoConfigurationTests {
private void prepareApplicationContext(Class<?>... configurationClasses) { private void prepareApplicationContext(Class<?>... configurationClasses) {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.data.neo4j.uri=http://localhost:9797"); "spring.data.neo4j.uri=http://localhost:9797").applyTo(this.context);
this.context.register(configurationClasses); this.context.register(configurationClasses);
this.context.register(Neo4jDataAutoConfiguration.class, this.context.register(Neo4jDataAutoConfiguration.class,
Neo4jRepositoriesAutoConfiguration.class, Neo4jRepositoriesAutoConfiguration.class,

@ -26,7 +26,7 @@ import redis.clients.jedis.Jedis;
import org.springframework.boot.junit.runner.classpath.ClassPathExclusions; import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner; import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -131,7 +131,7 @@ public class RedisAutoConfigurationJedisTests {
private void load(String... environment) { private void load(String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
ctx.register(RedisAutoConfiguration.class); ctx.register(RedisAutoConfiguration.class);
ctx.refresh(); ctx.refresh();
this.context = ctx; this.context = ctx;

@ -26,7 +26,7 @@ import io.lettuce.core.api.StatefulRedisConnection;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.data.redis.connection.lettuce.DefaultLettucePool; import org.springframework.data.redis.connection.lettuce.DefaultLettucePool;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
@ -191,7 +191,7 @@ public class RedisAutoConfigurationTests {
private void load(String... environment) { private void load(String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
ctx.register(RedisAutoConfiguration.class); ctx.register(RedisAutoConfiguration.class);
ctx.refresh(); ctx.refresh();
this.context = ctx; this.context = ctx;

@ -21,7 +21,7 @@ import java.util.Map;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.data.redis.core.ReactiveRedisTemplate; import org.springframework.data.redis.core.ReactiveRedisTemplate;
@ -52,7 +52,7 @@ public class RedisReactiveAutoConfigurationTests {
private void load(String... environment) { private void load(String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
ctx.register(RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class); ctx.register(RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class);
ctx.refresh(); ctx.refresh();
this.context = ctx; this.context = ctx;

@ -33,7 +33,7 @@ import org.springframework.boot.autoconfigure.data.jpa.city.City;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@ -175,7 +175,7 @@ public class RepositoryRestMvcAutoConfigurationTests {
AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext(); AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
applicationContext.setServletContext(new MockServletContext()); applicationContext.setServletContext(new MockServletContext());
applicationContext.register(config, BaseConfiguration.class); applicationContext.register(config, BaseConfiguration.class);
EnvironmentTestUtils.addEnvironment(applicationContext, environment); TestPropertyValues.of(environment).applyTo(applicationContext);
applicationContext.refresh(); applicationContext.refresh();
this.context = applicationContext; this.context = applicationContext;
} }

@ -34,7 +34,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.diagnostics.FailureAnalysis; import org.springframework.boot.diagnostics.FailureAnalysis;
import org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter; import org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -237,7 +237,7 @@ public class NoSuchBeanDefinitionFailureAnalyzerTests {
private FatalBeanException createFailure(Class<?> config, String... environment) { private FatalBeanException createFailure(Class<?> config, String... environment) {
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
this.analyzer.setBeanFactory(context.getBeanFactory()); this.analyzer.setBeanFactory(context.getBeanFactory());
EnvironmentTestUtils.addEnvironment(context, environment); TestPropertyValues.of(environment).applyTo(context);
context.register(config); context.register(config);
context.refresh(); context.refresh();
return null; return null;

@ -36,7 +36,7 @@ import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration; import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration; import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -129,7 +129,7 @@ public class JestAutoConfigurationTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, environment); TestPropertyValues.of(environment).applyTo(context);
if (config != null) { if (config != null) {
context.register(config); context.register(config);
} }

@ -41,7 +41,7 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -76,8 +76,8 @@ public class FlywayAutoConfigurationTests {
@Before @Before
public void init() { public void init() {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.name:flywaytest"); "spring.datasource.name:flywaytest").applyTo(this.context);
} }
@After @After
@ -96,8 +96,8 @@ public class FlywayAutoConfigurationTests {
@Test @Test
public void createDataSource() throws Exception { public void createDataSource() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"flyway.url:jdbc:hsqldb:mem:flywaytest", "flyway.user:sa"); "flyway.url:jdbc:hsqldb:mem:flywaytest", "flyway.user:sa").applyTo(this.context);
registerAndRefresh(EmbeddedDataSourceConfiguration.class, registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class, FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
@ -126,8 +126,8 @@ public class FlywayAutoConfigurationTests {
@Test @Test
public void overrideLocations() throws Exception { public void overrideLocations() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"flyway.locations:classpath:db/changelog,classpath:db/migration"); "flyway.locations:classpath:db/changelog,classpath:db/migration").applyTo(this.context);
registerAndRefresh(EmbeddedDataSourceConfiguration.class, registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class, FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
@ -138,9 +138,9 @@ public class FlywayAutoConfigurationTests {
@Test @Test
public void overrideLocationsList() throws Exception { public void overrideLocationsList() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"flyway.locations[0]:classpath:db/changelog", "flyway.locations[0]:classpath:db/changelog",
"flyway.locations[1]:classpath:db/migration"); "flyway.locations[1]:classpath:db/migration").applyTo(this.context);
registerAndRefresh(EmbeddedDataSourceConfiguration.class, registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class, FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
@ -151,7 +151,7 @@ public class FlywayAutoConfigurationTests {
@Test @Test
public void overrideSchemas() throws Exception { public void overrideSchemas() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, "flyway.schemas:public"); TestPropertyValues.of("flyway.schemas:public").applyTo(this.context);
registerAndRefresh(EmbeddedDataSourceConfiguration.class, registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class, FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
@ -161,8 +161,8 @@ public class FlywayAutoConfigurationTests {
@Test @Test
public void changeLogDoesNotExist() throws Exception { public void changeLogDoesNotExist() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"flyway.locations:file:no-such-dir"); "flyway.locations:file:no-such-dir").applyTo(this.context);
this.thrown.expect(BeanCreationException.class); this.thrown.expect(BeanCreationException.class);
registerAndRefresh(EmbeddedDataSourceConfiguration.class, registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class, FlywayAutoConfiguration.class,
@ -171,9 +171,9 @@ public class FlywayAutoConfigurationTests {
@Test @Test
public void checkLocationsAllMissing() throws Exception { public void checkLocationsAllMissing() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"flyway.locations:classpath:db/missing1,classpath:db/migration2", "flyway.locations:classpath:db/missing1,classpath:db/migration2",
"flyway.check-location:true"); "flyway.check-location:true").applyTo(this.context);
this.thrown.expect(BeanCreationException.class); this.thrown.expect(BeanCreationException.class);
this.thrown.expectMessage("Cannot find migrations location in"); this.thrown.expectMessage("Cannot find migrations location in");
registerAndRefresh(EmbeddedDataSourceConfiguration.class, registerAndRefresh(EmbeddedDataSourceConfiguration.class,
@ -183,9 +183,9 @@ public class FlywayAutoConfigurationTests {
@Test @Test
public void checkLocationsAllExist() throws Exception { public void checkLocationsAllExist() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"flyway.locations:classpath:db/changelog,classpath:db/migration", "flyway.locations:classpath:db/changelog,classpath:db/migration",
"flyway.check-location:true"); "flyway.check-location:true").applyTo(this.context);
registerAndRefresh(EmbeddedDataSourceConfiguration.class, registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class, FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
@ -220,7 +220,7 @@ public class FlywayAutoConfigurationTests {
@Test @Test
public void overrideBaselineVersionString() throws Exception { public void overrideBaselineVersionString() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, "flyway.baseline-version=0"); TestPropertyValues.of("flyway.baseline-version=0").applyTo(this.context);
registerAndRefresh(EmbeddedDataSourceConfiguration.class, registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class, FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
@ -245,8 +245,8 @@ public class FlywayAutoConfigurationTests {
@Test @Test
public void useVendorDirectory() throws Exception { public void useVendorDirectory() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"flyway.locations=classpath:db/vendors/{vendor},classpath:db/changelog"); "flyway.locations=classpath:db/vendors/{vendor},classpath:db/changelog").applyTo(this.context);
registerAndRefresh(EmbeddedDataSourceConfiguration.class, registerAndRefresh(EmbeddedDataSourceConfiguration.class,
FlywayAutoConfiguration.class, FlywayAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);

@ -28,7 +28,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.rule.OutputCapture; import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
@ -202,7 +202,7 @@ public class FreeMarkerAutoConfigurationTests {
} }
private void registerAndRefreshContext(String... env) { private void registerAndRefreshContext(String... env) {
EnvironmentTestUtils.addEnvironment(this.context, env); TestPropertyValues.of(env).applyTo(this.context);
this.context.register(FreeMarkerAutoConfiguration.class); this.context.register(FreeMarkerAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
} }

@ -30,7 +30,7 @@ import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
@ -101,8 +101,8 @@ public class GroovyTemplateAutoConfigurationTests {
@Test @Test
public void disableViewResolution() throws Exception { public void disableViewResolution() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.groovy.template.enabled:false"); "spring.groovy.template.enabled:false").applyTo(this.context);
registerAndRefreshContext(); registerAndRefreshContext();
assertThat(this.context.getBeanNamesForType(ViewResolver.class)).isEmpty(); assertThat(this.context.getBeanNamesForType(ViewResolver.class)).isEmpty();
} }
@ -179,7 +179,7 @@ public class GroovyTemplateAutoConfigurationTests {
} }
private void registerAndRefreshContext(String... env) { private void registerAndRefreshContext(String... env) {
EnvironmentTestUtils.addEnvironment(this.context, env); TestPropertyValues.of(env).applyTo(this.context);
this.context.register(GroovyTemplateAutoConfiguration.class); this.context.register(GroovyTemplateAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
} }

@ -23,7 +23,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.mock.web.MockServletContext; import org.springframework.mock.web.MockServletContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
@ -66,8 +66,8 @@ public class H2ConsoleAutoConfigurationTests {
@Test @Test
public void propertyCanEnableConsole() { public void propertyCanEnableConsole() {
this.context.register(H2ConsoleAutoConfiguration.class); this.context.register(H2ConsoleAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.h2.console.enabled:true"); "spring.h2.console.enabled:true").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1); assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
ServletRegistrationBean<?> registrationBean = this.context ServletRegistrationBean<?> registrationBean = this.context
@ -83,16 +83,16 @@ public class H2ConsoleAutoConfigurationTests {
this.thrown.expect(BeanCreationException.class); this.thrown.expect(BeanCreationException.class);
this.thrown.expectMessage("Failed to bind properties under 'spring.h2.console'"); this.thrown.expectMessage("Failed to bind properties under 'spring.h2.console'");
this.context.register(H2ConsoleAutoConfiguration.class); this.context.register(H2ConsoleAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.h2.console.enabled:true", "spring.h2.console.path:custom"); "spring.h2.console.enabled:true", "spring.h2.console.path:custom").applyTo(this.context);
this.context.refresh(); this.context.refresh();
} }
@Test @Test
public void customPathWithTrailingSlash() { public void customPathWithTrailingSlash() {
this.context.register(H2ConsoleAutoConfiguration.class); this.context.register(H2ConsoleAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.h2.console.enabled:true", "spring.h2.console.path:/custom/"); "spring.h2.console.enabled:true", "spring.h2.console.path:/custom/").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1); assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
ServletRegistrationBean<?> servletRegistrationBean = this.context ServletRegistrationBean<?> servletRegistrationBean = this.context
@ -103,8 +103,8 @@ public class H2ConsoleAutoConfigurationTests {
@Test @Test
public void customPath() { public void customPath() {
this.context.register(H2ConsoleAutoConfiguration.class); this.context.register(H2ConsoleAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.h2.console.enabled:true", "spring.h2.console.path:/custom"); "spring.h2.console.enabled:true", "spring.h2.console.path:/custom").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1); assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
ServletRegistrationBean<?> servletRegistrationBean = this.context ServletRegistrationBean<?> servletRegistrationBean = this.context
@ -115,9 +115,9 @@ public class H2ConsoleAutoConfigurationTests {
@Test @Test
public void customInitParameters() { public void customInitParameters() {
this.context.register(H2ConsoleAutoConfiguration.class); this.context.register(H2ConsoleAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.h2.console.enabled:true", "spring.h2.console.settings.trace=true", "spring.h2.console.enabled:true", "spring.h2.console.settings.trace=true",
"spring.h2.console.settings.webAllowOthers=true"); "spring.h2.console.settings.webAllowOthers=true").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1); assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
ServletRegistrationBean<?> registrationBean = this.context ServletRegistrationBean<?> registrationBean = this.context

@ -25,7 +25,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.EntityLinks; import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.LinkDiscoverer; import org.springframework.hateoas.LinkDiscoverer;
@ -88,8 +88,8 @@ public class HypermediaAutoConfigurationTests {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext()); this.context.setServletContext(new MockServletContext());
this.context.register(EnableHypermediaSupportConfig.class, BaseConfig.class); this.context.register(EnableHypermediaSupportConfig.class, BaseConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.serialization.INDENT_OUTPUT:true"); "spring.jackson.serialization.INDENT_OUTPUT:true").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper objectMapper = this.context.getBean("_halObjectMapper", ObjectMapper objectMapper = this.context.getBean("_halObjectMapper",
ObjectMapper.class); ObjectMapper.class);
@ -102,8 +102,8 @@ public class HypermediaAutoConfigurationTests {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext()); this.context.setServletContext(new MockServletContext());
this.context.register(BaseConfig.class); this.context.register(BaseConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.serialization.INDENT_OUTPUT:true"); "spring.jackson.serialization.INDENT_OUTPUT:true").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper objectMapper = this.context.getBean("_halObjectMapper", ObjectMapper objectMapper = this.context.getBean("_halObjectMapper",
ObjectMapper.class); ObjectMapper.class);
@ -132,8 +132,8 @@ public class HypermediaAutoConfigurationTests {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext()); this.context.setServletContext(new MockServletContext());
this.context.register(BaseConfig.class); this.context.register(BaseConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.hateoas.use-hal-as-default-json-media-type:false"); "spring.hateoas.use-hal-as-default-json-media-type:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
RequestMappingHandlerAdapter handlerAdapter = this.context RequestMappingHandlerAdapter handlerAdapter = this.context
.getBean(RequestMappingHandlerAdapter.class); .getBean(RequestMappingHandlerAdapter.class);

@ -31,7 +31,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -133,7 +133,7 @@ public class HazelcastAutoConfigurationClientTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(applicationContext, environment); TestPropertyValues.of(environment).applyTo(applicationContext);
if (config != null) { if (config != null) {
applicationContext.register(config); applicationContext.register(config);
} }

@ -32,7 +32,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.junit.runner.classpath.ClassPathExclusions; import org.springframework.boot.junit.runner.classpath.ClassPathExclusions;
import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner; import org.springframework.boot.junit.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -150,7 +150,7 @@ public class HazelcastAutoConfigurationServerTests {
private void load(Class<?> config, String... environment) { private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(applicationContext, environment); TestPropertyValues.of(environment).applyTo(applicationContext);
if (config != null) { if (config != null) {
applicationContext.register(config); applicationContext.register(config);
} }

@ -22,7 +22,7 @@ import com.hazelcast.core.HazelcastInstance;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
@ -55,7 +55,7 @@ public class HazelcastAutoConfigurationTests {
private void load(String... environment) { private void load(String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
ctx.register(HazelcastAutoConfiguration.class); ctx.register(HazelcastAutoConfiguration.class);
ctx.refresh(); ctx.refresh();
this.context = ctx; this.context = ctx;

@ -28,7 +28,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration; import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
import org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration.MappingJackson2HttpMessageConverterConfiguration; import org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration.MappingJackson2HttpMessageConverterConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -153,8 +153,8 @@ public class HttpMessageConvertersAutoConfigurationTests {
public void gsonCanBePreferredWhenBothGsonAndJacksonAreAvailable() { public void gsonCanBePreferredWhenBothGsonAndJacksonAreAvailable() {
this.context.register(GsonAutoConfiguration.class, JacksonAutoConfiguration.class, this.context.register(GsonAutoConfiguration.class, JacksonAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class); HttpMessageConvertersAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.http.converters.preferred-json-mapper:gson"); "spring.http.converters.preferred-json-mapper:gson").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertConverterBeanExists(GsonHttpMessageConverter.class, assertConverterBeanExists(GsonHttpMessageConverter.class,
"gsonHttpMessageConverter"); "gsonHttpMessageConverter");

@ -25,7 +25,7 @@ import org.junit.Test;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.info.BuildProperties; import org.springframework.boot.info.BuildProperties;
import org.springframework.boot.info.GitProperties; import org.springframework.boot.info.GitProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -141,7 +141,7 @@ public class ProjectInfoAutoConfigurationTests {
} }
context.register(PropertyPlaceholderAutoConfiguration.class, context.register(PropertyPlaceholderAutoConfiguration.class,
ProjectInfoAutoConfiguration.class); ProjectInfoAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(context, environment); TestPropertyValues.of(environment).applyTo(context);
context.refresh(); context.refresh();
this.context = context; this.context = context;
} }

@ -32,7 +32,7 @@ import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfigurati
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration; import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources; import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -207,7 +207,7 @@ public class IntegrationAutoConfigurationTests {
private void load(Class<?>[] configs, String... environment) { private void load(Class<?>[] configs, String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
if (configs != null) { if (configs != null) {
ctx.register(configs); ctx.register(configs);
} }

@ -53,7 +53,7 @@ import org.junit.Test;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.jackson.JsonComponent; import org.springframework.boot.jackson.JsonComponent;
import org.springframework.boot.jackson.JsonObjectSerializer; import org.springframework.boot.jackson.JsonObjectSerializer;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -126,8 +126,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void customDateFormat() throws Exception { public void customDateFormat() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.date-format:yyyyMMddHHmmss"); "spring.jackson.date-format:yyyyMMddHHmmss").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
DateFormat dateFormat = mapper.getDateFormat(); DateFormat dateFormat = mapper.getDateFormat();
@ -139,9 +139,9 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void customJodaDateTimeFormat() throws Exception { public void customJodaDateTimeFormat() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.date-format:yyyyMMddHHmmss", "spring.jackson.date-format:yyyyMMddHHmmss",
"spring.jackson.joda-date-time-format:yyyy-MM-dd HH:mm:ss"); "spring.jackson.joda-date-time-format:yyyy-MM-dd HH:mm:ss").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
DateTime dateTime = new DateTime(1988, 6, 25, 20, 30, DateTimeZone.UTC); DateTime dateTime = new DateTime(1988, 6, 25, 20, 30, DateTimeZone.UTC);
@ -154,8 +154,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void customDateFormatClass() throws Exception { public void customDateFormatClass() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.date-format:org.springframework.boot.autoconfigure.jackson.JacksonAutoConfigurationTests.MyDateFormat"); "spring.jackson.date-format:org.springframework.boot.autoconfigure.jackson.JacksonAutoConfigurationTests.MyDateFormat").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(mapper.getDateFormat()).isInstanceOf(MyDateFormat.class); assertThat(mapper.getDateFormat()).isInstanceOf(MyDateFormat.class);
@ -172,8 +172,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void customPropertyNamingStrategyField() throws Exception { public void customPropertyNamingStrategyField() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.property-naming-strategy:SNAKE_CASE"); "spring.jackson.property-naming-strategy:SNAKE_CASE").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(mapper.getPropertyNamingStrategy()) assertThat(mapper.getPropertyNamingStrategy())
@ -183,8 +183,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void customPropertyNamingStrategyClass() throws Exception { public void customPropertyNamingStrategyClass() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.property-naming-strategy:com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy"); "spring.jackson.property-naming-strategy:com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(mapper.getPropertyNamingStrategy()) assertThat(mapper.getPropertyNamingStrategy())
@ -194,8 +194,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void enableSerializationFeature() throws Exception { public void enableSerializationFeature() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.serialization.indent_output:true"); "spring.jackson.serialization.indent_output:true").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(SerializationFeature.INDENT_OUTPUT.enabledByDefault()).isFalse(); assertThat(SerializationFeature.INDENT_OUTPUT.enabledByDefault()).isFalse();
@ -207,8 +207,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void disableSerializationFeature() throws Exception { public void disableSerializationFeature() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.serialization.write_dates_as_timestamps:false"); "spring.jackson.serialization.write_dates_as_timestamps:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS.enabledByDefault()) assertThat(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS.enabledByDefault())
@ -220,8 +220,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void enableDeserializationFeature() throws Exception { public void enableDeserializationFeature() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.deserialization.use_big_decimal_for_floats:true"); "spring.jackson.deserialization.use_big_decimal_for_floats:true").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS.enabledByDefault()) assertThat(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS.enabledByDefault())
@ -233,8 +233,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void disableDeserializationFeature() throws Exception { public void disableDeserializationFeature() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.deserialization.fail-on-unknown-properties:false"); "spring.jackson.deserialization.fail-on-unknown-properties:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES.enabledByDefault()) assertThat(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES.enabledByDefault())
@ -246,8 +246,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void enableMapperFeature() throws Exception { public void enableMapperFeature() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.mapper.require_setters_for_getters:true"); "spring.jackson.mapper.require_setters_for_getters:true").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS.enabledByDefault()) assertThat(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS.enabledByDefault())
@ -263,8 +263,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void disableMapperFeature() throws Exception { public void disableMapperFeature() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.mapper.use_annotations:false"); "spring.jackson.mapper.use_annotations:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(MapperFeature.USE_ANNOTATIONS.enabledByDefault()).isTrue(); assertThat(MapperFeature.USE_ANNOTATIONS.enabledByDefault()).isTrue();
@ -277,8 +277,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void enableParserFeature() throws Exception { public void enableParserFeature() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.parser.allow_single_quotes:true"); "spring.jackson.parser.allow_single_quotes:true").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(JsonParser.Feature.ALLOW_SINGLE_QUOTES.enabledByDefault()).isFalse(); assertThat(JsonParser.Feature.ALLOW_SINGLE_QUOTES.enabledByDefault()).isFalse();
@ -289,8 +289,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void disableParserFeature() throws Exception { public void disableParserFeature() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.parser.auto_close_source:false"); "spring.jackson.parser.auto_close_source:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(JsonParser.Feature.AUTO_CLOSE_SOURCE.enabledByDefault()).isTrue(); assertThat(JsonParser.Feature.AUTO_CLOSE_SOURCE.enabledByDefault()).isTrue();
@ -301,8 +301,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void enableGeneratorFeature() throws Exception { public void enableGeneratorFeature() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.generator.write_numbers_as_strings:true"); "spring.jackson.generator.write_numbers_as_strings:true").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS.enabledByDefault()) assertThat(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS.enabledByDefault())
@ -314,8 +314,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void disableGeneratorFeature() throws Exception { public void disableGeneratorFeature() throws Exception {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.generator.auto_close_target:false"); "spring.jackson.generator.auto_close_target:false").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class); ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertThat(JsonGenerator.Feature.AUTO_CLOSE_TARGET.enabledByDefault()).isTrue(); assertThat(JsonGenerator.Feature.AUTO_CLOSE_TARGET.enabledByDefault()).isTrue();
@ -369,8 +369,8 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void customSerializationInclusion() { public void customSerializationInclusion() {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.default-property-inclusion:non_null"); "spring.jackson.default-property-inclusion:non_null").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper objectMapper = this.context ObjectMapper objectMapper = this.context
.getBean(Jackson2ObjectMapperBuilder.class).build(); .getBean(Jackson2ObjectMapperBuilder.class).build();
@ -381,11 +381,11 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void customTimeZoneFormattingADateTime() throws JsonProcessingException { public void customTimeZoneFormattingADateTime() throws JsonProcessingException {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.time-zone:America/Los_Angeles"); "spring.jackson.time-zone:America/Los_Angeles").applyTo(this.context);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.date-format:zzzz"); "spring.jackson.date-format:zzzz").applyTo(this.context);
EnvironmentTestUtils.addEnvironment(this.context, "spring.jackson.locale:en"); TestPropertyValues.of("spring.jackson.locale:en").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper objectMapper = this.context ObjectMapper objectMapper = this.context
.getBean(Jackson2ObjectMapperBuilder.class).build(); .getBean(Jackson2ObjectMapperBuilder.class).build();
@ -397,9 +397,9 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void customTimeZoneFormattingADate() throws JsonProcessingException { public void customTimeZoneFormattingADate() throws JsonProcessingException {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.time-zone:GMT+10"); "spring.jackson.time-zone:GMT+10").applyTo(this.context);
EnvironmentTestUtils.addEnvironment(this.context, "spring.jackson.date-format:z"); TestPropertyValues.of("spring.jackson.date-format:z").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper objectMapper = this.context ObjectMapper objectMapper = this.context
.getBean(Jackson2ObjectMapperBuilder.class).build(); .getBean(Jackson2ObjectMapperBuilder.class).build();
@ -410,9 +410,9 @@ public class JacksonAutoConfigurationTests {
@Test @Test
public void customLocale() throws JsonProcessingException { public void customLocale() throws JsonProcessingException {
this.context.register(JacksonAutoConfiguration.class); this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, "spring.jackson.locale:de"); TestPropertyValues.of("spring.jackson.locale:de").applyTo(this.context);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.jackson.date-format:zzzz"); "spring.jackson.date-format:zzzz").applyTo(this.context);
this.context.refresh(); this.context.refresh();
ObjectMapper objectMapper = this.context ObjectMapper objectMapper = this.context
.getBean(Jackson2ObjectMapperBuilder.class).build(); .getBean(Jackson2ObjectMapperBuilder.class).build();

@ -36,7 +36,7 @@ import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.boot.jdbc.DatabaseDriver;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -58,9 +58,9 @@ public class DataSourceAutoConfigurationTests {
@Before @Before
public void init() { public void init() {
EmbeddedDatabaseConnection.override = null; EmbeddedDatabaseConnection.override = null;
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false", "spring.datasource.initialize:false",
"spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt()); "spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt()).applyTo(this.context);
} }
@After @After
@ -89,8 +89,8 @@ public class DataSourceAutoConfigurationTests {
@Test(expected = BeanCreationException.class) @Test(expected = BeanCreationException.class)
public void testBadUrl() throws Exception { public void testBadUrl() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.url:jdbc:not-going-to-work"); "spring.datasource.url:jdbc:not-going-to-work").applyTo(this.context);
EmbeddedDatabaseConnection.override = EmbeddedDatabaseConnection.NONE; EmbeddedDatabaseConnection.override = EmbeddedDatabaseConnection.NONE;
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
@ -100,9 +100,9 @@ public class DataSourceAutoConfigurationTests {
@Test(expected = BeanCreationException.class) @Test(expected = BeanCreationException.class)
public void testBadDriverClass() throws Exception { public void testBadDriverClass() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.driverClassName:org.none.jdbcDriver", "spring.datasource.driverClassName:org.none.jdbcDriver",
"spring.datasource.url:jdbc:hsqldb:mem:testdb"); "spring.datasource.url:jdbc:hsqldb:mem:testdb").applyTo(this.context);
EmbeddedDatabaseConnection.override = EmbeddedDatabaseConnection.NONE; EmbeddedDatabaseConnection.override = EmbeddedDatabaseConnection.NONE;
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
@ -152,9 +152,9 @@ public class DataSourceAutoConfigurationTests {
@Test @Test
public void testEmbeddedTypeDefaultsUsername() throws Exception { public void testEmbeddedTypeDefaultsUsername() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver", "spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
"spring.datasource.url:jdbc:hsqldb:mem:testdb"); "spring.datasource.url:jdbc:hsqldb:mem:testdb").applyTo(this.context);
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -172,10 +172,10 @@ public class DataSourceAutoConfigurationTests {
*/ */
@Test @Test
public void explicitTypeNoSupportedDataSource() { public void explicitTypeNoSupportedDataSource() {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver", "spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
"spring.datasource.url:jdbc:hsqldb:mem:testdb", "spring.datasource.url:jdbc:hsqldb:mem:testdb",
"spring.datasource.type:" + SimpleDriverDataSource.class.getName()); "spring.datasource.type:" + SimpleDriverDataSource.class.getName()).applyTo(this.context);
this.context.setClassLoader( this.context.setClassLoader(
new HidePackagesClassLoader("org.apache.tomcat", "com.zaxxer.hikari", new HidePackagesClassLoader("org.apache.tomcat", "com.zaxxer.hikari",
"org.apache.commons.dbcp", "org.apache.commons.dbcp2")); "org.apache.commons.dbcp", "org.apache.commons.dbcp2"));
@ -184,10 +184,10 @@ public class DataSourceAutoConfigurationTests {
@Test @Test
public void explicitTypeSupportedDataSource() { public void explicitTypeSupportedDataSource() {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver", "spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
"spring.datasource.url:jdbc:hsqldb:mem:testdb", "spring.datasource.url:jdbc:hsqldb:mem:testdb",
"spring.datasource.type:" + SimpleDriverDataSource.class.getName()); "spring.datasource.type:" + SimpleDriverDataSource.class.getName()).applyTo(this.context);
testExplicitType(); testExplicitType();
} }
@ -203,11 +203,11 @@ public class DataSourceAutoConfigurationTests {
@Test @Test
public void testExplicitDriverClassClearsUsername() throws Exception { public void testExplicitDriverClassClearsUsername() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.driverClassName:" "spring.datasource.driverClassName:"
+ "org.springframework.boot.autoconfigure.jdbc." + "org.springframework.boot.autoconfigure.jdbc."
+ "DataSourceAutoConfigurationTests$DatabaseTestDriver", + "DataSourceAutoConfigurationTests$DatabaseTestDriver",
"spring.datasource.url:jdbc:foo://localhost"); "spring.datasource.url:jdbc:foo://localhost").applyTo(this.context);
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -232,9 +232,9 @@ public class DataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <T extends DataSource> T autoConfigureDataSource(Class<T> expectedType, private <T extends DataSource> T autoConfigureDataSource(Class<T> expectedType,
final String... hiddenPackages) { final String... hiddenPackages) {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver", "spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
"spring.datasource.url:jdbc:hsqldb:mem:testdb"); "spring.datasource.url:jdbc:hsqldb:mem:testdb").applyTo(this.context);
this.context.setClassLoader(new HidePackagesClassLoader(hiddenPackages)); this.context.setClassLoader(new HidePackagesClassLoader(hiddenPackages));
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);

@ -35,7 +35,7 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -69,9 +69,9 @@ public class DataSourceInitializerTests {
@Before @Before
public void init() { public void init() {
EmbeddedDatabaseConnection.override = null; EmbeddedDatabaseConnection.override = null;
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false", "spring.datasource.initialize:false",
"spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt()); "spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt()).applyTo(this.context);
} }
@After @After
@ -93,9 +93,9 @@ public class DataSourceInitializerTests {
@Test @Test
public void testTwoDataSources() throws Exception { public void testTwoDataSources() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"datasource.one.url=jdbc:hsqldb:mem:/one", "datasource.one.url=jdbc:hsqldb:mem:/one",
"datasource.two.url=jdbc:hsqldb:mem:/two"); "datasource.two.url=jdbc:hsqldb:mem:/two").applyTo(this.context);
this.context.register(TwoDataSources.class, DataSourceInitializer.class, this.context.register(TwoDataSources.class, DataSourceInitializer.class,
PropertyPlaceholderAutoConfiguration.class, DataSourceProperties.class); PropertyPlaceholderAutoConfiguration.class, DataSourceProperties.class);
this.context.refresh(); this.context.refresh();
@ -105,8 +105,8 @@ public class DataSourceInitializerTests {
@Test @Test
public void testDataSourceInitialized() throws Exception { public void testDataSourceInitialized() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:true"); "spring.datasource.initialize:true").applyTo(this.context);
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -122,12 +122,12 @@ public class DataSourceInitializerTests {
public void testDataSourceInitializedWithExplicitScript() throws Exception { public void testDataSourceInitializedWithExplicitScript() throws Exception {
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:true", "spring.datasource.initialize:true",
"spring.datasource.schema:" + ClassUtils "spring.datasource.schema:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "schema.sql"), .addResourcePathToPackagePath(getClass(), "schema.sql"),
"spring.datasource.data:" + ClassUtils "spring.datasource.data:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "data.sql")); .addResourcePathToPackagePath(getClass(), "data.sql")).applyTo(this.context);
this.context.refresh(); this.context.refresh();
DataSource dataSource = this.context.getBean(DataSource.class); DataSource dataSource = this.context.getBean(DataSource.class);
assertThat(dataSource).isInstanceOf(HikariDataSource.class); assertThat(dataSource).isInstanceOf(HikariDataSource.class);
@ -139,7 +139,7 @@ public class DataSourceInitializerTests {
@Test @Test
public void testDataSourceInitializedWithMultipleScripts() throws Exception { public void testDataSourceInitializedWithMultipleScripts() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:true", "spring.datasource.initialize:true",
"spring.datasource.schema:" "spring.datasource.schema:"
+ ClassUtils.addResourcePathToPackagePath(getClass(), + ClassUtils.addResourcePathToPackagePath(getClass(),
@ -148,7 +148,7 @@ public class DataSourceInitializerTests {
+ ClassUtils.addResourcePathToPackagePath(getClass(), + ClassUtils.addResourcePathToPackagePath(getClass(),
"another.sql"), "another.sql"),
"spring.datasource.data:" + ClassUtils "spring.datasource.data:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "data.sql")); .addResourcePathToPackagePath(getClass(), "data.sql")).applyTo(this.context);
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -167,13 +167,13 @@ public class DataSourceInitializerTests {
throws Exception { throws Exception {
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:true", "spring.datasource.initialize:true",
"spring.datasource.sqlScriptEncoding:UTF-8", "spring.datasource.sqlScriptEncoding:UTF-8",
"spring.datasource.schema:" + ClassUtils "spring.datasource.schema:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "encoding-schema.sql"), .addResourcePathToPackagePath(getClass(), "encoding-schema.sql"),
"spring.datasource.data:" + ClassUtils "spring.datasource.data:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "encoding-data.sql")); .addResourcePathToPackagePath(getClass(), "encoding-data.sql")).applyTo(this.context);
this.context.refresh(); this.context.refresh();
DataSource dataSource = this.context.getBean(DataSource.class); DataSource dataSource = this.context.getBean(DataSource.class);
assertThat(dataSource).isInstanceOf(HikariDataSource.class); assertThat(dataSource).isInstanceOf(HikariDataSource.class);
@ -214,7 +214,7 @@ public class DataSourceInitializerTests {
public void testDataSourceInitializedWithSchemaCredentials() { public void testDataSourceInitializedWithSchemaCredentials() {
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:true", "spring.datasource.initialize:true",
"spring.datasource.sqlScriptEncoding:UTF-8", "spring.datasource.sqlScriptEncoding:UTF-8",
"spring.datasource.schema:" + ClassUtils "spring.datasource.schema:" + ClassUtils
@ -222,7 +222,7 @@ public class DataSourceInitializerTests {
"spring.datasource.data:" + ClassUtils "spring.datasource.data:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "encoding-data.sql"), .addResourcePathToPackagePath(getClass(), "encoding-data.sql"),
"spring.datasource.schema-username:admin", "spring.datasource.schema-username:admin",
"spring.datasource.schema-password:admin"); "spring.datasource.schema-password:admin").applyTo(this.context);
try { try {
this.context.refresh(); this.context.refresh();
fail("User does not exist"); fail("User does not exist");
@ -236,7 +236,7 @@ public class DataSourceInitializerTests {
public void testDataSourceInitializedWithDataCredentials() { public void testDataSourceInitializedWithDataCredentials() {
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:true", "spring.datasource.initialize:true",
"spring.datasource.sqlScriptEncoding:UTF-8", "spring.datasource.sqlScriptEncoding:UTF-8",
"spring.datasource.schema:" + ClassUtils "spring.datasource.schema:" + ClassUtils
@ -244,7 +244,7 @@ public class DataSourceInitializerTests {
"spring.datasource.data:" + ClassUtils "spring.datasource.data:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "encoding-data.sql"), .addResourcePathToPackagePath(getClass(), "encoding-data.sql"),
"spring.datasource.data-username:admin", "spring.datasource.data-username:admin",
"spring.datasource.data-password:admin"); "spring.datasource.data-password:admin").applyTo(this.context);
try { try {
this.context.refresh(); this.context.refresh();
fail("User does not exist"); fail("User does not exist");
@ -256,12 +256,12 @@ public class DataSourceInitializerTests {
@Test @Test
public void multipleScriptsAppliedInLexicalOrder() throws Exception { public void multipleScriptsAppliedInLexicalOrder() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:true", "spring.datasource.initialize:true",
"spring.datasource.schema:" + ClassUtils "spring.datasource.schema:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "lexical-schema-*.sql"), .addResourcePathToPackagePath(getClass(), "lexical-schema-*.sql"),
"spring.datasource.data:" + ClassUtils "spring.datasource.data:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "data.sql")); .addResourcePathToPackagePath(getClass(), "data.sql")).applyTo(this.context);
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
ReverseOrderResourceLoader resourceLoader = new ReverseOrderResourceLoader( ReverseOrderResourceLoader resourceLoader = new ReverseOrderResourceLoader(
@ -280,9 +280,9 @@ public class DataSourceInitializerTests {
public void testDataSourceInitializedWithInvalidSchemaResource() { public void testDataSourceInitializedWithInvalidSchemaResource() {
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:true", "spring.datasource.initialize:true",
"spring.datasource.schema:classpath:does/not/exist.sql"); "spring.datasource.schema:classpath:does/not/exist.sql").applyTo(this.context);
this.thrown.expect(BeanCreationException.class); this.thrown.expect(BeanCreationException.class);
this.thrown.expectMessage("does/not/exist.sql"); this.thrown.expectMessage("does/not/exist.sql");
@ -294,11 +294,11 @@ public class DataSourceInitializerTests {
public void testDataSourceInitializedWithInvalidDataResource() { public void testDataSourceInitializedWithInvalidDataResource() {
this.context.register(DataSourceAutoConfiguration.class, this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:true", "spring.datasource.initialize:true",
"spring.datasource.schema:" + ClassUtils "spring.datasource.schema:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "schema.sql"), .addResourcePathToPackagePath(getClass(), "schema.sql"),
"spring.datasource.data:classpath:does/not/exist.sql"); "spring.datasource.data:classpath:does/not/exist.sql").applyTo(this.context);
this.thrown.expect(BeanCreationException.class); this.thrown.expect(BeanCreationException.class);
this.thrown.expectMessage("does/not/exist.sql"); this.thrown.expectMessage("does/not/exist.sql");

@ -21,7 +21,7 @@ import javax.sql.DataSource;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration; import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -110,9 +110,9 @@ public class DataSourceTransactionManagerAutoConfigurationTests {
@Test @Test
public void testCustomizeDataSourceTransactionManagerUsingProperties() public void testCustomizeDataSourceTransactionManagerUsingProperties()
throws Exception { throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.transaction.default-timeout:30", "spring.transaction.default-timeout:30",
"spring.transaction.rollback-on-commit-failure:true"); "spring.transaction.rollback-on-commit-failure:true").applyTo(this.context);
this.context.register(EmbeddedDataSourceConfiguration.class, this.context.register(EmbeddedDataSourceConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class,
TransactionAutoConfiguration.class); TransactionAutoConfiguration.class);

@ -25,7 +25,7 @@ import javax.sql.DataSource;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -79,7 +79,7 @@ public class EmbeddedDataSourceConfigurationTests {
private AnnotationConfigApplicationContext load(String... environment) { private AnnotationConfigApplicationContext load(String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); TestPropertyValues.of(environment).applyTo(ctx);
ctx.register(EmbeddedDataSourceConfiguration.class); ctx.register(EmbeddedDataSourceConfiguration.class);
ctx.refresh(); ctx.refresh();
return ctx; return ctx;

@ -26,7 +26,7 @@ import org.junit.Test;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -61,9 +61,9 @@ public class HikariDataSourceConfigurationTests {
@Test @Test
public void testDataSourcePropertiesOverridden() throws Exception { public void testDataSourcePropertiesOverridden() throws Exception {
this.context.register(HikariDataSourceConfiguration.class); this.context.register(HikariDataSourceConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
PREFIX + "jdbcUrl:jdbc:foo//bar/spam"); PREFIX + "jdbcUrl:jdbc:foo//bar/spam").applyTo(this.context);
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "maxLifetime:1234"); TestPropertyValues.of(PREFIX + "maxLifetime:1234").applyTo(this.context);
this.context.refresh(); this.context.refresh();
HikariDataSource ds = this.context.getBean(HikariDataSource.class); HikariDataSource ds = this.context.getBean(HikariDataSource.class);
assertThat(ds.getJdbcUrl()).isEqualTo("jdbc:foo//bar/spam"); assertThat(ds.getJdbcUrl()).isEqualTo("jdbc:foo//bar/spam");
@ -74,8 +74,8 @@ public class HikariDataSourceConfigurationTests {
@Test @Test
public void testDataSourceGenericPropertiesOverridden() throws Exception { public void testDataSourceGenericPropertiesOverridden() throws Exception {
this.context.register(HikariDataSourceConfiguration.class); this.context.register(HikariDataSourceConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, PREFIX TestPropertyValues.of(PREFIX
+ "dataSourceProperties.dataSourceClassName:org.h2.JDBCDataSource"); + "dataSourceProperties.dataSourceClassName:org.h2.JDBCDataSource").applyTo(this.context);
this.context.refresh(); this.context.refresh();
HikariDataSource ds = this.context.getBean(HikariDataSource.class); HikariDataSource ds = this.context.getBean(HikariDataSource.class);
assertThat(ds.getDataSourceProperties().getProperty("dataSourceClassName")) assertThat(ds.getDataSourceProperties().getProperty("dataSourceClassName"))

@ -22,7 +22,7 @@ import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.diagnostics.FailureAnalysis; import org.springframework.boot.diagnostics.FailureAnalysis;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -61,9 +61,9 @@ public class HikariDriverConfigurationFailureAnalyzerTests {
private BeanCreationException createFailure(Class<?> configuration) { private BeanCreationException createFailure(Class<?> configuration) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, TestPropertyValues.of(
"spring.datasource.type=" + HikariDataSource.class.getName(), "spring.datasource.type=" + HikariDataSource.class.getName(),
"spring.datasource.hikari.data-source-class-name=com.example.Foo"); "spring.datasource.hikari.data-source-class-name=com.example.Foo").applyTo(context);
context.register(configuration); context.register(configuration);
try { try {
context.refresh(); context.refresh();

@ -26,7 +26,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -52,9 +52,9 @@ public class JdbcTemplateAutoConfigurationTests {
@Before @Before
public void init() { public void init() {
EmbeddedDatabaseConnection.override = null; EmbeddedDatabaseConnection.override = null;
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.initialize:false", "spring.datasource.initialize:false",
"spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt()); "spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt()).applyTo(this.context);
} }
@After @After

@ -30,7 +30,7 @@ import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.jndi.JndiPropertiesHidingClassLoader; import org.springframework.boot.autoconfigure.jndi.JndiPropertiesHidingClassLoader;
import org.springframework.boot.autoconfigure.jndi.TestableInitialContextFactory; import org.springframework.boot.autoconfigure.jndi.TestableInitialContextFactory;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.jmx.export.MBeanExporter; import org.springframework.jmx.export.MBeanExporter;
@ -88,8 +88,8 @@ public class JndiDataSourceAutoConfigurationTests {
configureJndi("foo", dataSource); configureJndi("foo", dataSource);
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.jndi-name:foo"); "spring.datasource.jndi-name:foo").applyTo(this.context);
this.context.register(JndiDataSourceAutoConfiguration.class); this.context.register(JndiDataSourceAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -104,8 +104,8 @@ public class JndiDataSourceAutoConfigurationTests {
configureJndi("foo", dataSource); configureJndi("foo", dataSource);
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.jndi-name:foo"); "spring.datasource.jndi-name:foo").applyTo(this.context);
this.context.register(JndiDataSourceAutoConfiguration.class, this.context.register(JndiDataSourceAutoConfiguration.class,
MBeanExporterConfiguration.class); MBeanExporterConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -125,8 +125,8 @@ public class JndiDataSourceAutoConfigurationTests {
configureJndi("foo", dataSource); configureJndi("foo", dataSource);
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
"spring.datasource.jndi-name:foo"); "spring.datasource.jndi-name:foo").applyTo(this.context);
this.context.register(JndiDataSourceAutoConfiguration.class, this.context.register(JndiDataSourceAutoConfiguration.class,
MBeanExporterConfiguration.class); MBeanExporterConfiguration.class);
this.context.refresh(); this.context.refresh();

@ -29,7 +29,7 @@ import org.junit.Test;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -53,7 +53,7 @@ public class TomcatDataSourceConfigurationTests {
@Before @Before
public void init() { public void init() {
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "initialize:false"); TestPropertyValues.of(PREFIX + "initialize:false");
} }
@After @After
@ -64,8 +64,8 @@ public class TomcatDataSourceConfigurationTests {
@Test @Test
public void testDataSourceExists() throws Exception { public void testDataSourceExists() throws Exception {
this.context.register(TomcatDataSourceConfiguration.class); this.context.register(TomcatDataSourceConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
PREFIX + "url:jdbc:h2:mem:testdb"); PREFIX + "url:jdbc:h2:mem:testdb").applyTo(this.context);
this.context.refresh(); this.context.refresh();
assertThat(this.context.getBean(DataSource.class)).isNotNull(); assertThat(this.context.getBean(DataSource.class)).isNotNull();
assertThat(this.context.getBean(org.apache.tomcat.jdbc.pool.DataSource.class)) assertThat(this.context.getBean(org.apache.tomcat.jdbc.pool.DataSource.class))
@ -75,20 +75,16 @@ public class TomcatDataSourceConfigurationTests {
@Test @Test
public void testDataSourcePropertiesOverridden() throws Exception { public void testDataSourcePropertiesOverridden() throws Exception {
this.context.register(TomcatDataSourceConfiguration.class); this.context.register(TomcatDataSourceConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
PREFIX + "url:jdbc:h2:mem:testdb"); PREFIX + "url:jdbc:h2:mem:testdb",
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testWhileIdle:true"); PREFIX + "testWhileIdle:true",
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testOnBorrow:true"); PREFIX + "testOnBorrow:true",
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testOnReturn:true"); PREFIX + "testOnReturn:true",
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "timeBetweenEvictionRunsMillis:10000",
PREFIX + "timeBetweenEvictionRunsMillis:10000"); PREFIX + "minEvictableIdleTimeMillis:12345",
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "maxWait:1234",
PREFIX + "minEvictableIdleTimeMillis:12345"); PREFIX + "jdbcInterceptors:SlowQueryReport",
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "maxWait:1234"); PREFIX + "validationInterval:9999").applyTo(this.context);
EnvironmentTestUtils.addEnvironment(this.context,
PREFIX + "jdbcInterceptors:SlowQueryReport");
EnvironmentTestUtils.addEnvironment(this.context,
PREFIX + "validationInterval:9999");
this.context.refresh(); this.context.refresh();
org.apache.tomcat.jdbc.pool.DataSource ds = this.context org.apache.tomcat.jdbc.pool.DataSource ds = this.context
.getBean(org.apache.tomcat.jdbc.pool.DataSource.class); .getBean(org.apache.tomcat.jdbc.pool.DataSource.class);
@ -118,8 +114,8 @@ public class TomcatDataSourceConfigurationTests {
@Test @Test
public void testDataSourceDefaultsPreserved() throws Exception { public void testDataSourceDefaultsPreserved() throws Exception {
this.context.register(TomcatDataSourceConfiguration.class); this.context.register(TomcatDataSourceConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, TestPropertyValues.of(
PREFIX + "url:jdbc:h2:mem:testdb"); PREFIX + "url:jdbc:h2:mem:testdb").applyTo(this.context);
this.context.refresh(); this.context.refresh();
org.apache.tomcat.jdbc.pool.DataSource ds = this.context org.apache.tomcat.jdbc.pool.DataSource ds = this.context
.getBean(org.apache.tomcat.jdbc.pool.DataSource.class); .getBean(org.apache.tomcat.jdbc.pool.DataSource.class);

@ -23,7 +23,7 @@ import org.hsqldb.jdbc.pool.JDBCXADataSource;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.jta.XADataSourceWrapper; import org.springframework.boot.jta.XADataSourceWrapper;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -75,7 +75,7 @@ public class XADataSourceAutoConfigurationTests {
private ApplicationContext createContext(Class<?> configuration, String... env) { private ApplicationContext createContext(Class<?> configuration, String... env) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(context, env); TestPropertyValues.of(env).applyTo(context);
context.register(configuration, XADataSourceAutoConfiguration.class); context.register(configuration, XADataSourceAutoConfiguration.class);
context.refresh(); context.refresh();
return context; return context;

@ -28,7 +28,7 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration; import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -405,7 +405,7 @@ public class JmsAutoConfigurationTests {
applicationContext.register(configs); applicationContext.register(configs);
applicationContext.register(ActiveMQAutoConfiguration.class, applicationContext.register(ActiveMQAutoConfiguration.class,
JmsAutoConfiguration.class); JmsAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(applicationContext, environment); TestPropertyValues.of(environment).applyTo(applicationContext);
applicationContext.refresh(); applicationContext.refresh();
return applicationContext; return applicationContext;
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save