Replace usages of EnvironmentTestUtils

This commit is contained in:
Madhura Bhave
2017-05-23 10:05:43 -07:00
parent 05254fe322
commit d745b69630
156 changed files with 863 additions and 883 deletions

View File

@@ -30,7 +30,7 @@ import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefiniti
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
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.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -110,11 +110,11 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
context.register(classes);
context.register(DevToolsDataSourceAutoConfiguration.class);
if (driverClassName != null) {
EnvironmentTestUtils.addEnvironment(context,
"spring.datasource.driver-class-name:" + driverClassName);
TestPropertyValues.of(
"spring.datasource.driver-class-name:" + driverClassName).applyTo(context);
}
if (url != null) {
EnvironmentTestUtils.addEnvironment(context, "spring.datasource.url:" + url);
TestPropertyValues.of("spring.datasource.url:" + url).applyTo(context);
}
context.refresh();
return context;

View File

@@ -34,7 +34,7 @@ import org.springframework.boot.devtools.tunnel.server.HttpTunnelServer;
import org.springframework.boot.devtools.tunnel.server.RemoteDebugPortProvider;
import org.springframework.boot.devtools.tunnel.server.SocketTargetServerConnection;
import org.springframework.boot.devtools.tunnel.server.TargetServerConnection;
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.Configuration;
import org.springframework.context.annotation.Import;
@@ -231,7 +231,7 @@ public class RemoteDevToolsAutoConfigurationTests {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(Config.class, PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, properties);
TestPropertyValues.of(properties).applyTo(this.context);
this.context.refresh();
}

View File

@@ -23,7 +23,7 @@ import javax.net.ServerSocketFactory;
import org.junit.Test;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.util.SocketUtils;
@@ -64,8 +64,8 @@ public class LocalDebugPortAvailableConditionTests {
private ConditionOutcome getOutcome() {
MockEnvironment environment = new MockEnvironment();
EnvironmentTestUtils.addEnvironment(environment,
"spring.devtools.remote.debug.local-port:" + this.port);
TestPropertyValues.of(
"spring.devtools.remote.debug.local-port:" + this.port).applyTo(environment);
ConditionContext context = mock(ConditionContext.class);
given(context.getEnvironment()).willReturn(environment);
ConditionOutcome outcome = this.condition.getMatchOutcome(context, null);

View File

@@ -40,7 +40,7 @@ import org.springframework.boot.devtools.restart.MockRestarter;
import org.springframework.boot.devtools.restart.RestartScopeInitializer;
import org.springframework.boot.devtools.tunnel.client.TunnelClient;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -154,11 +154,11 @@ public class RemoteClientConfigurationTests {
this.context.register(Config.class, RemoteClientConfiguration.class);
String remoteUrlProperty = "remoteUrl:" + remoteUrl + ":"
+ RemoteClientConfigurationTests.remotePort;
EnvironmentTestUtils.addEnvironment(this.context, remoteUrlProperty);
EnvironmentTestUtils.addEnvironment(this.context, pairs);
TestPropertyValues.of(remoteUrlProperty).applyTo(this.context);
TestPropertyValues.of(pairs).applyTo(this.context);
if (setSecret) {
EnvironmentTestUtils.addEnvironment(this.context,
"spring.devtools.remote.secret:secret");
TestPropertyValues.of(
"spring.devtools.remote.secret:secret").applyTo(this.context);
}
this.context.refresh();
}