SpringBootTestUtils->EnvironmentTestUtils
This commit is contained in:
@@ -32,7 +32,7 @@ import org.springframework.boot.actuate.endpoint.ShutdownEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.TraceEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationReport;
|
||||
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
|
||||
import org.springframework.boot.test.SpringBootTestUtils;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -104,7 +104,7 @@ public class EndpointAutoConfigurationTests {
|
||||
@Test
|
||||
public void testInfoEndpointConfiguration() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
SpringBootTestUtils.addEnvironment(this.context, "info.foo:bar");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "info.foo:bar");
|
||||
this.context.register(EndpointAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
InfoEndpoint endpoint = this.context.getBean(InfoEndpoint.class);
|
||||
@@ -116,7 +116,7 @@ public class EndpointAutoConfigurationTests {
|
||||
@Test
|
||||
public void testNoGitProperties() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
SpringBootTestUtils.addEnvironment(this.context,
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.git.properties:classpath:nonexistent");
|
||||
this.context.register(EndpointAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfi
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
||||
import org.springframework.boot.test.SpringBootTestUtils;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -121,7 +121,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void specificPortsViaProperties() throws Exception {
|
||||
SpringBootTestUtils.addEnvironment(this.applicationContext, "server.port:7070",
|
||||
EnvironmentTestUtils.addEnvironment(this.applicationContext, "server.port:7070",
|
||||
"management.port:7071");
|
||||
this.applicationContext.register(RootConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
@@ -142,7 +142,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void contextPath() throws Exception {
|
||||
SpringBootTestUtils.addEnvironment(this.applicationContext, "management.contextPath:/test");
|
||||
EnvironmentTestUtils.addEnvironment(this.applicationContext, "management.contextPath:/test");
|
||||
this.applicationContext.register(RootConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
ManagementServerPropertiesAutoConfiguration.class,
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomi
|
||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
||||
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.SpringBootTestUtils;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class JolokiaAutoConfigurationTests {
|
||||
@Test
|
||||
public void agentDisabled() throws Exception {
|
||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
||||
SpringBootTestUtils.addEnvironment(this.context, "endpoints.jolokia.enabled:false");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "endpoints.jolokia.enabled:false");
|
||||
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
||||
ManagementServerPropertiesAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class,
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
|
||||
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.context.listener.LoggingApplicationListener;
|
||||
import org.springframework.boot.test.SpringBootTestUtils;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
@@ -117,7 +117,7 @@ public class ManagementSecurityAutoConfigurationTests {
|
||||
EndpointAutoConfiguration.class,
|
||||
ManagementServerPropertiesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
SpringBootTestUtils.addEnvironment(this.context, "security.ignored:none");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "security.ignored:none");
|
||||
this.context.refresh();
|
||||
// Just the application and management endpoints now
|
||||
assertEquals(2, this.context.getBean(FilterChainProxy.class).getFilterChains()
|
||||
@@ -134,7 +134,7 @@ public class ManagementSecurityAutoConfigurationTests {
|
||||
EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
|
||||
ManagementServerPropertiesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
SpringBootTestUtils.addEnvironment(this.context, "security.basic.enabled:false");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "security.basic.enabled:false");
|
||||
this.context.refresh();
|
||||
// Just the management endpoints (one filter) and ignores now
|
||||
assertEquals(7, this.context.getBean(FilterChainProxy.class).getFilterChains()
|
||||
@@ -171,7 +171,7 @@ public class ManagementSecurityAutoConfigurationTests {
|
||||
|
||||
private static AnnotationConfigWebApplicationContext debugRefresh(
|
||||
AnnotationConfigWebApplicationContext context) {
|
||||
SpringBootTestUtils.addEnvironment(context, "debug:true");
|
||||
EnvironmentTestUtils.addEnvironment(context, "debug:true");
|
||||
LoggingApplicationListener logging = new LoggingApplicationListener();
|
||||
logging.onApplicationEvent(new SpringApplicationBeforeRefreshEvent(
|
||||
new SpringApplication(), context, new String[0]));
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Collections;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.test.SpringBootTestUtils;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
@@ -84,7 +84,7 @@ public abstract class AbstractEndpointTests<T extends Endpoint<?>> {
|
||||
@Test
|
||||
public void idOverride() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
SpringBootTestUtils.addEnvironment(this.context, this.property + ".id:myid");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, this.property + ".id:myid");
|
||||
this.context.register(this.configClass);
|
||||
this.context.refresh();
|
||||
assertThat(getEndpointBean().getId(), equalTo("myid"));
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties
|
||||
import org.springframework.boot.actuate.endpoint.EnvironmentEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpointTests.TestConfiguration;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.SpringBootTestUtils;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -59,7 +59,7 @@ public class EnvironmentMvcEndpointTests {
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
SpringBootTestUtils.addEnvironment((ConfigurableApplicationContext) this.context, "foo:bar");
|
||||
EnvironmentTestUtils.addEnvironment((ConfigurableApplicationContext) this.context, "foo:bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties
|
||||
import org.springframework.boot.actuate.endpoint.mvc.JolokiaEndpointTests.Config;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.SpringBootTestUtils;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -66,7 +66,7 @@ public class JolokiaEndpointTests {
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
SpringBootTestUtils.addEnvironment((ConfigurableApplicationContext) this.context, "foo:bar");
|
||||
EnvironmentTestUtils.addEnvironment((ConfigurableApplicationContext) this.context, "foo:bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user