TestUtils -> SpringBootTestUtils
This commit is contained in:
parent
147968cf83
commit
321ce3aad2
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.actuate.endpoint.AutoConfigurationReportEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.BeansEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.DumpEndpoint;
|
||||
|
|
@ -104,7 +104,7 @@ public class EndpointAutoConfigurationTests {
|
|||
@Test
|
||||
public void testInfoEndpointConfiguration() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestUtils.addEnviroment(this.context, "info.foo:bar");
|
||||
SpringBootTestUtils.addEnviroment(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();
|
||||
TestUtils.addEnviroment(this.context,
|
||||
SpringBootTestUtils.addEnviroment(this.context,
|
||||
"spring.git.properties:classpath:nonexistent");
|
||||
this.context.register(EndpointAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.nio.charset.Charset;
|
|||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
|
||||
import org.springframework.boot.actuate.properties.ManagementServerProperties;
|
||||
|
|
@ -121,7 +121,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void specificPortsViaProperties() throws Exception {
|
||||
TestUtils.addEnviroment(this.applicationContext, "server.port:7070",
|
||||
SpringBootTestUtils.addEnviroment(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 {
|
||||
TestUtils.addEnviroment(this.applicationContext, "management.contextPath:/test");
|
||||
SpringBootTestUtils.addEnviroment(this.applicationContext, "management.contextPath:/test");
|
||||
this.applicationContext.register(RootConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
ManagementServerPropertiesAutoConfiguration.class,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.springframework.boot.actuate.autoconfigure;
|
|||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.JolokiaMvcEndpoint;
|
||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||
|
|
@ -65,7 +65,7 @@ public class JolokiaAutoConfigurationTests {
|
|||
@Test
|
||||
public void agentDisabled() throws Exception {
|
||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
||||
TestUtils.addEnviroment(this.context, "endpoints.jolokia.enabled:false");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "endpoints.jolokia.enabled:false");
|
||||
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
||||
ManagementServerPropertiesAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.junit.After;
|
|||
import org.junit.Test;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringApplicationBeforeRefreshEvent;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationReportLoggingInitializer;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
||||
|
|
@ -117,7 +117,7 @@ public class ManagementSecurityAutoConfigurationTests {
|
|||
EndpointAutoConfiguration.class,
|
||||
ManagementServerPropertiesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "security.ignored:none");
|
||||
SpringBootTestUtils.addEnviroment(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);
|
||||
TestUtils.addEnviroment(this.context, "security.basic.enabled:false");
|
||||
SpringBootTestUtils.addEnviroment(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) {
|
||||
TestUtils.addEnviroment(context, "debug:true");
|
||||
SpringBootTestUtils.addEnviroment(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.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
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();
|
||||
TestUtils.addEnviroment(this.context, this.property + ".id:myid");
|
||||
SpringBootTestUtils.addEnviroment(this.context, this.property + ".id:myid");
|
||||
this.context.register(this.configClass);
|
||||
this.context.refresh();
|
||||
assertThat(getEndpointBean().getId(), equalTo("myid"));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.ManagementServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.actuate.endpoint.EnvironmentEndpoint;
|
||||
|
|
@ -59,7 +59,7 @@ public class EnvironmentMvcEndpointTests {
|
|||
@Before
|
||||
public void setUp() {
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
TestUtils.addEnviroment((ConfigurableApplicationContext) this.context, "foo:bar");
|
||||
SpringBootTestUtils.addEnviroment((ConfigurableApplicationContext) this.context, "foo:bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.JolokiaAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.ManagementServerPropertiesAutoConfiguration;
|
||||
|
|
@ -66,7 +66,7 @@ public class JolokiaEndpointTests {
|
|||
@Before
|
||||
public void setUp() {
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
TestUtils.addEnviroment((ConfigurableApplicationContext) this.context, "foo:bar");
|
||||
SpringBootTestUtils.addEnviroment((ConfigurableApplicationContext) this.context, "foo:bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
@ -48,7 +48,7 @@ public class PropertyPlaceholderAutoConfigurationTests {
|
|||
public void propertyPlaceholderse() throws Exception {
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
PlaceholderConfig.class);
|
||||
TestUtils.addEnviroment(this.context, "foo:two");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "foo:two");
|
||||
this.context.refresh();
|
||||
assertEquals("two", this.context.getBean(PlaceholderConfig.class).getFoo());
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ public class PropertyPlaceholderAutoConfigurationTests {
|
|||
public void propertyPlaceholdersOverride() throws Exception {
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
PlaceholderConfig.class, PlaceholdersOverride.class);
|
||||
TestUtils.addEnviroment(this.context, "foo:two");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "foo:two");
|
||||
this.context.refresh();
|
||||
assertEquals("spam", this.context.getBean(PlaceholderConfig.class).getFoo());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
|||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
@ -65,7 +65,7 @@ public class RabbitAutoconfigurationTests {
|
|||
public void testRabbitTemplateWithOverrides() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(TestConfiguration.class, RabbitAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.rabbitmq.host:remote-server",
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.rabbitmq.host:remote-server",
|
||||
"spring.rabbitmq.port:9000", "spring.rabbitmq.username:alice",
|
||||
"spring.rabbitmq.password:secret", "spring.rabbitmq.virtual_host:/vhost");
|
||||
this.context.refresh();
|
||||
|
|
@ -80,7 +80,7 @@ public class RabbitAutoconfigurationTests {
|
|||
public void testRabbitTemplateEmptyVirtualHost() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(TestConfiguration.class, RabbitAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.rabbitmq.virtual_host:");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.rabbitmq.virtual_host:");
|
||||
this.context.refresh();
|
||||
CachingConnectionFactory connectionFactory = this.context
|
||||
.getBean(CachingConnectionFactory.class);
|
||||
|
|
@ -91,7 +91,7 @@ public class RabbitAutoconfigurationTests {
|
|||
public void testRabbitTemplateVirtualHostMissingSlash() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(TestConfiguration.class, RabbitAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.rabbitmq.virtual_host:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.rabbitmq.virtual_host:foo");
|
||||
this.context.refresh();
|
||||
CachingConnectionFactory connectionFactory = this.context
|
||||
.getBean(CachingConnectionFactory.class);
|
||||
|
|
@ -102,7 +102,7 @@ public class RabbitAutoconfigurationTests {
|
|||
public void testRabbitTemplateDefaultVirtualHost() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(TestConfiguration.class, RabbitAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.rabbitmq.virtual_host:/");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.rabbitmq.virtual_host:/");
|
||||
this.context.refresh();
|
||||
CachingConnectionFactory connectionFactory = this.context
|
||||
.getBean(CachingConnectionFactory.class);
|
||||
|
|
@ -126,7 +126,7 @@ public class RabbitAutoconfigurationTests {
|
|||
public void testStaticQueues() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(TestConfiguration.class, RabbitAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.rabbitmq.dynamic:false");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.rabbitmq.dynamic:false");
|
||||
this.context.refresh();
|
||||
// There should NOT be an AmqpAdmin bean when dynamic is switch to false
|
||||
this.thrown.expect(NoSuchBeanDefinitionException.class);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.aop;
|
|||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
@ -42,7 +42,7 @@ public class AopAutoConfigurationTests {
|
|||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(TestConfiguration.class, AopAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.aop.auto:false");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.aop.auto:false");
|
||||
this.context.refresh();
|
||||
TestAspect aspect = this.context.getBean(TestAspect.class);
|
||||
assertFalse(aspect.isCalled());
|
||||
|
|
@ -56,7 +56,7 @@ public class AopAutoConfigurationTests {
|
|||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(TestConfiguration.class, AopAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.aop.proxyTargetClass:true");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.aop.proxyTargetClass:true");
|
||||
this.context.refresh();
|
||||
TestAspect aspect = this.context.getBean(TestAspect.class);
|
||||
assertFalse(aspect.isCalled());
|
||||
|
|
@ -70,7 +70,7 @@ public class AopAutoConfigurationTests {
|
|||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(TestConfiguration.class, AopAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.aop.proxyTargetClass:false");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.aop.proxyTargetClass:false");
|
||||
this.context.refresh();
|
||||
TestAspect aspect = this.context.getBean(TestAspect.class);
|
||||
assertFalse(aspect.isCalled());
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.springframework.batch.core.launch.JobLauncher;
|
|||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.autoconfigure.ComponentScanDetectorConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
|
||||
|
|
@ -105,7 +105,7 @@ public class BatchAutoConfigurationTests {
|
|||
@Test
|
||||
public void testDisableLaunchesJob() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestUtils.addEnviroment(this.context, "spring.batch.job.enabled:false");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.batch.job.enabled:false");
|
||||
this.context.register(JobConfiguration.class, BatchAutoConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
|
|
@ -117,7 +117,7 @@ public class BatchAutoConfigurationTests {
|
|||
@Test
|
||||
public void testDisableSchemaLoader() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestUtils.addEnviroment(this.context, "spring.datasource.name:batchtest",
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.datasource.name:batchtest",
|
||||
"spring.batch.initializer.enabled:false");
|
||||
this.context.register(TestConfiguration.class, BatchAutoConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import javax.sql.DataSource;
|
|||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
@ -66,7 +66,7 @@ public class DataSourceAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void testEmbeddedTypeDefaultsUsername() throws Exception {
|
||||
TestUtils.addEnviroment(this.context,
|
||||
SpringBootTestUtils.addEnviroment(this.context,
|
||||
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb");
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
|
|
@ -81,7 +81,7 @@ public class DataSourceAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void testExplicitDriverClassClearsUserName() throws Exception {
|
||||
TestUtils
|
||||
SpringBootTestUtils
|
||||
.addEnviroment(
|
||||
this.context,
|
||||
"spring.datasource.driverClassName:org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests$DatabaseDriver",
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import javax.sql.DataSource;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
|
@ -56,7 +56,7 @@ public class TomcatDataSourceConfigurationTests {
|
|||
@Test
|
||||
public void testDataSourcePropertiesOverridden() throws Exception {
|
||||
this.context.register(TomcatDataSourceConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.datasource.url:jdbc:foo//bar/spam");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.datasource.url:jdbc:foo//bar/spam");
|
||||
this.context.refresh();
|
||||
assertEquals("jdbc:foo//bar/spam",
|
||||
this.context.getBean(org.apache.tomcat.jdbc.pool.DataSource.class)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.apache.activemq.pool.PooledConnectionFactory;
|
|||
import org.junit.Test;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
@ -118,7 +118,7 @@ public class JmsTemplateAutoConfigurationTests {
|
|||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context
|
||||
.register(TestConfiguration.class, JmsTemplateAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.jms.pubSubDomain:false");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.jms.pubSubDomain:false");
|
||||
this.context.refresh();
|
||||
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
|
||||
ActiveMQConnectionFactory connectionFactory = this.context
|
||||
|
|
@ -134,7 +134,7 @@ public class JmsTemplateAutoConfigurationTests {
|
|||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context
|
||||
.register(TestConfiguration.class, JmsTemplateAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.activemq.inMemory:false");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.activemq.inMemory:false");
|
||||
this.context.refresh();
|
||||
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
|
||||
ActiveMQConnectionFactory connectionFactory = this.context
|
||||
|
|
@ -153,7 +153,7 @@ public class JmsTemplateAutoConfigurationTests {
|
|||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context
|
||||
.register(TestConfiguration.class, JmsTemplateAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.activemq.inMemory:false",
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.activemq.inMemory:false",
|
||||
"spring.activemq.brokerURL:tcp://remote-host:10000");
|
||||
this.context.refresh();
|
||||
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
|
||||
|
|
@ -173,7 +173,7 @@ public class JmsTemplateAutoConfigurationTests {
|
|||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context
|
||||
.register(TestConfiguration.class, JmsTemplateAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.activemq.pooled:true");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.activemq.pooled:true");
|
||||
this.context.refresh();
|
||||
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
|
||||
PooledConnectionFactory pool = this.context
|
||||
|
|
@ -191,7 +191,7 @@ public class JmsTemplateAutoConfigurationTests {
|
|||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context
|
||||
.register(TestConfiguration.class, JmsTemplateAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.activemq.pooled:true",
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.activemq.pooled:true",
|
||||
"spring.activemq.inMemory:false");
|
||||
this.context.refresh();
|
||||
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
|
||||
|
|
@ -210,7 +210,7 @@ public class JmsTemplateAutoConfigurationTests {
|
|||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context
|
||||
.register(TestConfiguration.class, JmsTemplateAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring.activemq.pooled:true",
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.activemq.pooled:true",
|
||||
"spring.activemq.inMemory:false",
|
||||
"spring.activemq.brokerURL:tcp://remote-host:10000");
|
||||
this.context.refresh();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import javax.sql.DataSource;
|
|||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.autoconfigure.ComponentScanDetectorConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
|
||||
|
|
@ -112,7 +112,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
|
|||
public void testOpenEntityManagerInViewInterceptorNotRegisteredWhenExplicitlyOff()
|
||||
throws Exception {
|
||||
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
|
||||
TestUtils.addEnviroment(context, "spring.jpa.open_in_view:false");
|
||||
SpringBootTestUtils.addEnviroment(context, "spring.jpa.open_in_view:false");
|
||||
context.register(TestConfiguration.class,
|
||||
ComponentScanDetectorConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
|
|
@ -124,7 +124,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void customJpaProperties() throws Exception {
|
||||
TestUtils.addEnviroment(this.context, "spring.jpa.properties.a:b",
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.jpa.properties.a:b",
|
||||
"spring.jpa.properties.c:d");
|
||||
setupTestConfiguration();
|
||||
this.context.refresh();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.springframework.boot.autoconfigure.orm.jpa;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
|
@ -38,7 +38,7 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
|
|||
|
||||
@Test
|
||||
public void testCustomNamingStrategy() throws Exception {
|
||||
TestUtils.addEnviroment(this.context, "spring.jpa.hibernate.namingstrategy:"
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.jpa.hibernate.namingstrategy:"
|
||||
+ "org.hibernate.cfg.EJB3NamingStrategy");
|
||||
setupTestConfiguration();
|
||||
this.context.refresh();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.springframework.boot.autoconfigure.redis;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
|
|
@ -47,7 +47,7 @@ public class RedisAutoConfigurationTests {
|
|||
@Test
|
||||
public void testOverrideRedisConfiguration() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestUtils.addEnviroment(this.context, "spring.redis.host:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring.redis.host:foo");
|
||||
this.context.register(RedisAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.security;
|
|||
import org.junit.Test;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringApplicationBeforeRefreshEvent;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationReportLoggingInitializer;
|
||||
import org.springframework.boot.autoconfigure.ComponentScanDetector;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
|
|
@ -72,7 +72,7 @@ public class SecurityAutoConfigurationTests {
|
|||
this.context.setServletContext(new MockServletContext());
|
||||
this.context.register(SecurityAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "security.ignored:none");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "security.ignored:none");
|
||||
this.context.refresh();
|
||||
// Just the application endpoints now
|
||||
assertEquals(1, this.context.getBean(FilterChainProxy.class).getFilterChains()
|
||||
|
|
@ -85,7 +85,7 @@ public class SecurityAutoConfigurationTests {
|
|||
this.context.setServletContext(new MockServletContext());
|
||||
this.context.register(SecurityAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "security.basic.enabled:false");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "security.basic.enabled:false");
|
||||
this.context.refresh();
|
||||
// No security at all not even ignores
|
||||
assertEquals(0, this.context.getBeanNamesForType(FilterChainProxy.class).length);
|
||||
|
|
@ -118,7 +118,7 @@ public class SecurityAutoConfigurationTests {
|
|||
|
||||
private static AnnotationConfigWebApplicationContext debugRefresh(
|
||||
AnnotationConfigWebApplicationContext context) {
|
||||
TestUtils.addEnviroment(context, "debug:true");
|
||||
SpringBootTestUtils.addEnviroment(context, "debug:true");
|
||||
LoggingApplicationListener logging = new LoggingApplicationListener();
|
||||
logging.onApplicationEvent(new SpringApplicationBeforeRefreshEvent(
|
||||
new SpringApplication(), context, new String[0]));
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainerFactory;
|
||||
|
|
@ -72,7 +72,7 @@ public class ServerPropertiesAutoConfigurationTests {
|
|||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
||||
this.context.register(Config.class, ServerPropertiesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "server.port:9000");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "server.port:9000");
|
||||
this.context.refresh();
|
||||
ServerProperties server = this.context.getBean(ServerProperties.class);
|
||||
assertNotNull(server);
|
||||
|
|
@ -86,7 +86,7 @@ public class ServerPropertiesAutoConfigurationTests {
|
|||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
||||
this.context.register(Config.class, ServerPropertiesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "server.tomcat.basedir:target/foo",
|
||||
SpringBootTestUtils.addEnviroment(this.context, "server.tomcat.basedir:target/foo",
|
||||
"server.port:9000");
|
||||
this.context.refresh();
|
||||
ServerProperties server = this.context.getBean(ServerProperties.class);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import org.springframework.core.env.MapPropertySource;
|
|||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public abstract class TestUtils {
|
||||
public abstract class SpringBootTestUtils {
|
||||
|
||||
public static void addEnviroment(ConfigurableApplicationContext context,
|
||||
String... pairs) {
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
package org.springframework.boot.context.initializer;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ public class ContextIdApplicationContextInitializerTests {
|
|||
@Test
|
||||
public void testNameAndPort() {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
TestUtils.addEnviroment(context, "spring.application.name:foo", "PORT:8080");
|
||||
SpringBootTestUtils.addEnviroment(context, "spring.application.name:foo", "PORT:8080");
|
||||
this.initializer.initialize(context);
|
||||
assertEquals("foo:8080", context.getId());
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ public class ContextIdApplicationContextInitializerTests {
|
|||
@Test
|
||||
public void testNameAndProfiles() {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
TestUtils.addEnviroment(context, "spring.application.name:foo",
|
||||
SpringBootTestUtils.addEnviroment(context, "spring.application.name:foo",
|
||||
"spring.profiles.active: spam,bar", "spring.application.index:12");
|
||||
this.initializer.initialize(context);
|
||||
assertEquals("foo:spam,bar:12", context.getId());
|
||||
|
|
@ -59,7 +59,7 @@ public class ContextIdApplicationContextInitializerTests {
|
|||
@Test
|
||||
public void testCloudFoundry() {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
TestUtils.addEnviroment(context, "spring.config.name:foo", "PORT:8080",
|
||||
SpringBootTestUtils.addEnviroment(context, "spring.config.name:foo", "PORT:8080",
|
||||
"vcap.application.name:bar", "vcap.application.instance_index:2");
|
||||
this.initializer.initialize(context);
|
||||
assertEquals("bar:2", context.getId());
|
||||
|
|
@ -68,7 +68,7 @@ public class ContextIdApplicationContextInitializerTests {
|
|||
@Test
|
||||
public void testExplicitName() {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
TestUtils.addEnviroment(context, "spring.application.name:spam",
|
||||
SpringBootTestUtils.addEnviroment(context, "spring.application.name:spam",
|
||||
"spring.config.name:foo", "PORT:8080", "vcap.application.name:bar",
|
||||
"vcap.application.instance_index:2");
|
||||
this.initializer.initialize(context);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.springframework.boot.context.initializer;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.context.ApplicationContextException;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
|
@ -46,7 +46,7 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
|
|||
@Test
|
||||
public void orderedInitialize() throws Exception {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
TestUtils.addEnviroment(context,
|
||||
SpringBootTestUtils.addEnviroment(context,
|
||||
"context.initializer.classes:" + MockInitB.class.getName() + ","
|
||||
+ MockInitA.class.getName());
|
||||
this.initializer.initialize(context);
|
||||
|
|
@ -63,14 +63,14 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
|
|||
@Test
|
||||
public void emptyInitializers() throws Exception {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
TestUtils.addEnviroment(context, "context.initializer.classes:");
|
||||
SpringBootTestUtils.addEnviroment(context, "context.initializer.classes:");
|
||||
this.initializer.initialize(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noSuchInitializerClass() throws Exception {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
TestUtils.addEnviroment(context,
|
||||
SpringBootTestUtils.addEnviroment(context,
|
||||
"context.initializer.classes:missing.madeup.class");
|
||||
this.thrown.expect(ApplicationContextException.class);
|
||||
this.initializer.initialize(context);
|
||||
|
|
@ -79,7 +79,7 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
|
|||
@Test
|
||||
public void notAnInitializerClass() throws Exception {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
TestUtils.addEnviroment(context,
|
||||
SpringBootTestUtils.addEnviroment(context,
|
||||
"context.initializer.classes:" + Object.class.getName());
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.initializer.initialize(context);
|
||||
|
|
@ -88,7 +88,7 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
|
|||
@Test
|
||||
public void genericNotSuitable() throws Exception {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
TestUtils.addEnviroment(context, "context.initializer.classes:"
|
||||
SpringBootTestUtils.addEnviroment(context, "context.initializer.classes:"
|
||||
+ NotSuitableInit.class.getName());
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("generic parameter");
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import org.junit.Test;
|
|||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringApplicationEnvironmentAvailableEvent;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
|
|
@ -51,7 +51,7 @@ public class EnvironmentDelegateApplicationListenerTests {
|
|||
|
||||
@Test
|
||||
public void orderedInitialize() throws Exception {
|
||||
TestUtils.addEnviroment(this.context, "context.listener.classes:"
|
||||
SpringBootTestUtils.addEnviroment(this.context, "context.listener.classes:"
|
||||
+ MockInitB.class.getName() + "," + MockInitA.class.getName());
|
||||
this.listener.onApplicationEvent(new SpringApplicationEnvironmentAvailableEvent(
|
||||
new SpringApplication(), this.context.getEnvironment(), new String[0]));
|
||||
|
|
@ -69,7 +69,7 @@ public class EnvironmentDelegateApplicationListenerTests {
|
|||
|
||||
@Test
|
||||
public void emptyInitializers() throws Exception {
|
||||
TestUtils.addEnviroment(this.context, "context.listener.classes:");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "context.listener.classes:");
|
||||
this.listener.onApplicationEvent(new SpringApplicationEnvironmentAvailableEvent(
|
||||
new SpringApplication(), this.context.getEnvironment(), new String[0]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.junit.Assume;
|
|||
import org.junit.Test;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringApplicationEnvironmentAvailableEvent;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ public class FileEncodingApplicationListenerTests {
|
|||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testIllegalState() {
|
||||
TestUtils.addEnviroment(this.environment, "spring.mandatory_file_encoding:FOO");
|
||||
SpringBootTestUtils.addEnviroment(this.environment, "spring.mandatory_file_encoding:FOO");
|
||||
this.initializer.onApplicationEvent(this.event);
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ public class FileEncodingApplicationListenerTests {
|
|||
@Test
|
||||
public void testSunnyDayMandated() {
|
||||
Assume.assumeNotNull(System.getProperty("file.encoding"));
|
||||
TestUtils.addEnviroment(this.environment, "spring.mandatory_file_encoding:"
|
||||
SpringBootTestUtils.addEnviroment(this.environment, "spring.mandatory_file_encoding:"
|
||||
+ System.getProperty("file.encoding"));
|
||||
this.initializer.onApplicationEvent(this.event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import org.junit.rules.TemporaryFolder;
|
|||
import org.springframework.boot.OutputCapture;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringApplicationStartEvent;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.boot.logging.LogLevel;
|
||||
import org.springframework.boot.logging.java.JavaLoggingSystem;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
|
|
@ -95,7 +95,7 @@ public class LoggingApplicationListenerTests {
|
|||
|
||||
@Test
|
||||
public void testOverrideConfigLocation() {
|
||||
TestUtils.addEnviroment(this.context,
|
||||
SpringBootTestUtils.addEnviroment(this.context,
|
||||
"logging.config: classpath:logback-nondefault.xml");
|
||||
this.initializer.initialize(this.context.getEnvironment(),
|
||||
this.context.getClassLoader());
|
||||
|
|
@ -108,7 +108,7 @@ public class LoggingApplicationListenerTests {
|
|||
|
||||
@Test
|
||||
public void testOverrideConfigDoesNotExist() throws Exception {
|
||||
TestUtils.addEnviroment(this.context, "logging.config: doesnotexist.xml");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "logging.config: doesnotexist.xml");
|
||||
this.initializer.initialize(this.context.getEnvironment(),
|
||||
this.context.getClassLoader());
|
||||
// Should not throw
|
||||
|
|
@ -116,7 +116,7 @@ public class LoggingApplicationListenerTests {
|
|||
|
||||
@Test
|
||||
public void testAddLogFileProperty() {
|
||||
TestUtils.addEnviroment(this.context,
|
||||
SpringBootTestUtils.addEnviroment(this.context,
|
||||
"logging.config: classpath:logback-nondefault.xml",
|
||||
"logging.file: foo.log");
|
||||
this.initializer.initialize(this.context.getEnvironment(),
|
||||
|
|
@ -129,7 +129,7 @@ public class LoggingApplicationListenerTests {
|
|||
|
||||
@Test
|
||||
public void testAddLogPathProperty() {
|
||||
TestUtils.addEnviroment(this.context,
|
||||
SpringBootTestUtils.addEnviroment(this.context,
|
||||
"logging.config: classpath:logback-nondefault.xml", "logging.path: foo/");
|
||||
this.initializer.initialize(this.context.getEnvironment(),
|
||||
this.context.getClassLoader());
|
||||
|
|
@ -141,7 +141,7 @@ public class LoggingApplicationListenerTests {
|
|||
|
||||
@Test
|
||||
public void parseDebugArg() throws Exception {
|
||||
TestUtils.addEnviroment(this.context, "debug");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "debug");
|
||||
this.initializer.initialize(this.context.getEnvironment(),
|
||||
this.context.getClassLoader());
|
||||
this.logger.debug("testatdebug");
|
||||
|
|
@ -152,7 +152,7 @@ public class LoggingApplicationListenerTests {
|
|||
|
||||
@Test
|
||||
public void parseTraceArg() throws Exception {
|
||||
TestUtils.addEnviroment(this.context, "trace");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "trace");
|
||||
this.initializer.initialize(this.context.getEnvironment(),
|
||||
this.context.getClassLoader());
|
||||
this.logger.debug("testatdebug");
|
||||
|
|
@ -164,7 +164,7 @@ public class LoggingApplicationListenerTests {
|
|||
@Test
|
||||
public void parseArgsDisabled() throws Exception {
|
||||
this.initializer.setParseArgs(false);
|
||||
TestUtils.addEnviroment(this.context, "debug");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "debug");
|
||||
this.initializer.initialize(this.context.getEnvironment(),
|
||||
this.context.getClassLoader());
|
||||
this.logger.debug("testatdebug");
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.springframework.boot.context.listener;
|
|||
import org.junit.Test;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringApplicationEnvironmentAvailableEvent;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ public class VcapApplicationListenerTests {
|
|||
|
||||
@Test
|
||||
public void testApplicationProperties() {
|
||||
TestUtils
|
||||
SpringBootTestUtils
|
||||
.addEnviroment(
|
||||
this.context,
|
||||
"VCAP_APPLICATION:{\"application_users\":[],\"instance_id\":\"bb7935245adf3e650dfb7c58a06e9ece\",\"instance_index\":0,\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"foo\",\"uris\":[\"foo.cfapps.io\"],\"started_at\":\"2013-05-29 02:37:59 +0000\",\"started_at_timestamp\":1369795079,\"host\":\"0.0.0.0\",\"port\":61034,\"limits\":{\"mem\":128,\"disk\":1024,\"fds\":16384},\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"dsyerenv\",\"uris\":[\"dsyerenv.cfapps.io\"],\"users\":[],\"start\":\"2013-05-29 02:37:59 +0000\",\"state_timestamp\":1369795079}");
|
||||
|
|
@ -50,14 +50,14 @@ public class VcapApplicationListenerTests {
|
|||
|
||||
@Test
|
||||
public void testUnparseableApplicationProperties() {
|
||||
TestUtils.addEnviroment(this.context, "VCAP_APPLICATION:");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "VCAP_APPLICATION:");
|
||||
this.initializer.onApplicationEvent(this.event);
|
||||
assertEquals(null, this.context.getEnvironment().getProperty("vcap"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullApplicationProperties() {
|
||||
TestUtils
|
||||
SpringBootTestUtils
|
||||
.addEnviroment(
|
||||
this.context,
|
||||
"VCAP_APPLICATION:{\"application_users\":null,\"instance_id\":\"bb7935245adf3e650dfb7c58a06e9ece\",\"instance_index\":0,\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"foo\",\"uris\":[\"foo.cfapps.io\"],\"started_at\":\"2013-05-29 02:37:59 +0000\",\"started_at_timestamp\":1369795079,\"host\":\"0.0.0.0\",\"port\":61034,\"limits\":{\"mem\":128,\"disk\":1024,\"fds\":16384},\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"dsyerenv\",\"uris\":[\"dsyerenv.cfapps.io\"],\"users\":[],\"start\":\"2013-05-29 02:37:59 +0000\",\"state_timestamp\":1369795079}");
|
||||
|
|
@ -67,7 +67,7 @@ public class VcapApplicationListenerTests {
|
|||
|
||||
@Test
|
||||
public void testServiceProperties() {
|
||||
TestUtils
|
||||
SpringBootTestUtils
|
||||
.addEnviroment(
|
||||
this.context,
|
||||
"VCAP_SERVICES:{\"rds-mysql-n/a\":[{\"name\":\"mysql\",\"label\":\"rds-mysql-n/a\",\"plan\":\"10mb\",\"credentials\":{\"name\":\"d04fb13d27d964c62b267bbba1cffb9da\",\"hostname\":\"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com\",\"host\":\"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com\",\"port\":3306,\"user\":\"urpRuqTf8Cpe6\",\"username\":\"urpRuqTf8Cpe6\",\"password\":\"pxLsGVpsC9A5S\"}}]}");
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.TestUtils;
|
||||
import org.springframework.boot.SpringBootTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
@ -64,7 +64,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
@Test
|
||||
public void testBasicPropertiesBinding() {
|
||||
this.context.register(TestConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "name:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "name:foo");
|
||||
this.context.refresh();
|
||||
assertEquals(1, this.context.getBeanNamesForType(TestProperties.class).length);
|
||||
assertEquals("foo", this.context.getBean(TestProperties.class).name);
|
||||
|
|
@ -105,7 +105,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
public void testStrictPropertiesBinding() {
|
||||
removeSystemProperties();
|
||||
this.context.register(StrictTestConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "name:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "name:foo");
|
||||
this.context.refresh();
|
||||
assertEquals(1,
|
||||
this.context.getBeanNamesForType(StrictTestProperties.class).length);
|
||||
|
|
@ -115,7 +115,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
@Test
|
||||
public void testPropertiesEmbeddedBinding() {
|
||||
this.context.register(EmbeddedTestConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "spring_foo_name:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring_foo_name:foo");
|
||||
this.context.refresh();
|
||||
assertEquals(1,
|
||||
this.context.getBeanNamesForType(EmbeddedTestProperties.class).length);
|
||||
|
|
@ -126,7 +126,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
public void testIgnoreNestedPropertiesBinding() {
|
||||
removeSystemProperties();
|
||||
this.context.register(IgnoreNestedTestConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "name:foo", "nested.name:bar");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "name:foo", "nested.name:bar");
|
||||
this.context.refresh();
|
||||
assertEquals(1,
|
||||
this.context.getBeanNamesForType(IgnoreNestedTestProperties.class).length);
|
||||
|
|
@ -136,7 +136,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
@Test
|
||||
public void testExceptionOnValidation() {
|
||||
this.context.register(ExceptionIfInvalidTestConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "name:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "name:foo");
|
||||
this.expected.expectCause(Matchers.<Throwable> instanceOf(BindException.class));
|
||||
this.context.refresh();
|
||||
}
|
||||
|
|
@ -144,7 +144,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
@Test
|
||||
public void testNoExceptionOnValidation() {
|
||||
this.context.register(NoExceptionIfInvalidTestConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "name:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "name:foo");
|
||||
this.context.refresh();
|
||||
assertEquals(
|
||||
1,
|
||||
|
|
@ -156,7 +156,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
@Test
|
||||
public void testNestedPropertiesBinding() {
|
||||
this.context.register(NestedConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "name:foo", "nested.name:bar");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "name:foo", "nested.name:bar");
|
||||
this.context.refresh();
|
||||
assertEquals(1, this.context.getBeanNamesForType(NestedProperties.class).length);
|
||||
assertEquals("foo", this.context.getBean(NestedProperties.class).name);
|
||||
|
|
@ -166,7 +166,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
@Test
|
||||
public void testBasicPropertiesBindingWithAnnotationOnBaseClass() {
|
||||
this.context.register(DerivedConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "name:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "name:foo");
|
||||
this.context.refresh();
|
||||
assertEquals(1, this.context.getBeanNamesForType(DerivedProperties.class).length);
|
||||
assertEquals("foo", this.context.getBean(BaseProperties.class).name);
|
||||
|
|
@ -175,7 +175,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
@Test
|
||||
public void testArrayPropertiesBinding() {
|
||||
this.context.register(TestConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "name:foo", "array:1,2,3");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "name:foo", "array:1,2,3");
|
||||
this.context.refresh();
|
||||
assertEquals(1, this.context.getBeanNamesForType(TestProperties.class).length);
|
||||
assertEquals(3, this.context.getBean(TestProperties.class).getArray().length);
|
||||
|
|
@ -184,7 +184,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
@Test
|
||||
public void testCollectionPropertiesBindingFromYamlArray() {
|
||||
this.context.register(TestConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "name:foo", "list[0]:1", "list[1]:2");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "name:foo", "list[0]:1", "list[1]:2");
|
||||
this.context.refresh();
|
||||
assertEquals(2, this.context.getBean(TestProperties.class).getList().size());
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
@Test
|
||||
public void testPropertiesBindingWithoutAnnotation() {
|
||||
this.context.register(MoreConfiguration.class);
|
||||
TestUtils.addEnviroment(this.context, "name:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "name:foo");
|
||||
this.context.refresh();
|
||||
assertEquals(1, this.context.getBeanNamesForType(MoreProperties.class).length);
|
||||
assertEquals("foo", this.context.getBean(MoreProperties.class).name);
|
||||
|
|
@ -227,7 +227,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
|
||||
@Test
|
||||
public void testBindingDirectlyToFileResolvedFromEnvironment() {
|
||||
TestUtils.addEnviroment(this.context, "binding.location:classpath:other.yml");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "binding.location:classpath:other.yml");
|
||||
this.context.register(ResourceBindingProperties.class, TestConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertEquals(1,
|
||||
|
|
@ -268,7 +268,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
|
||||
parent.register(TestConfiguration.class);
|
||||
parent.refresh();
|
||||
TestUtils.addEnviroment(this.context, "name:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "name:foo");
|
||||
this.context.setParent(parent);
|
||||
this.context.register(TestConfiguration.class, TestConsumer.class);
|
||||
this.context.refresh();
|
||||
|
|
@ -280,7 +280,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
@Test
|
||||
public void testBindingOnlyParentContext() {
|
||||
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
|
||||
TestUtils.addEnviroment(parent, "name:foo");
|
||||
SpringBootTestUtils.addEnviroment(parent, "name:foo");
|
||||
parent.register(TestConfiguration.class);
|
||||
parent.refresh();
|
||||
this.context.setParent(parent);
|
||||
|
|
@ -293,7 +293,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
|
||||
@Test
|
||||
public void testUnderscoresInPrefix() throws Exception {
|
||||
TestUtils.addEnviroment(this.context, "spring_test_external_val:baz");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "spring_test_external_val:baz");
|
||||
this.context.register(SystemExampleConfig.class);
|
||||
this.context.refresh();
|
||||
assertEquals("baz", this.context.getBean(SystemEnvVar.class).getVal());
|
||||
|
|
@ -301,7 +301,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
|
||||
@Test
|
||||
public void testSimpleAutoConfig() throws Exception {
|
||||
TestUtils.addEnviroment(this.context, "external.name:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "external.name:foo");
|
||||
this.context.register(ExampleConfig.class);
|
||||
this.context.refresh();
|
||||
assertEquals("foo", this.context.getBean(External.class).getName());
|
||||
|
|
@ -309,7 +309,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
|
||||
@Test
|
||||
public void testExplicitType() throws Exception {
|
||||
TestUtils.addEnviroment(this.context, "external.name:foo");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "external.name:foo");
|
||||
this.context.register(AnotherExampleConfig.class);
|
||||
this.context.refresh();
|
||||
assertEquals("foo", this.context.getBean(External.class).getName());
|
||||
|
|
@ -317,7 +317,7 @@ public class EnableConfigurationPropertiesTests {
|
|||
|
||||
@Test
|
||||
public void testMultipleExplicitTypes() throws Exception {
|
||||
TestUtils.addEnviroment(this.context, "external.name:foo", "another.name:bar");
|
||||
SpringBootTestUtils.addEnviroment(this.context, "external.name:foo", "another.name:bar");
|
||||
this.context.register(FurtherExampleConfig.class);
|
||||
this.context.refresh();
|
||||
assertEquals("foo", this.context.getBean(External.class).getName());
|
||||
|
|
|
|||
Loading…
Reference in New Issue