TestUtils -> SpringBootTestUtils

This commit is contained in:
Dave Syer
2014-01-08 10:46:42 +00:00
parent 147968cf83
commit 321ce3aad2
27 changed files with 110 additions and 110 deletions

View File

@@ -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());
}

View File

@@ -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);

View File

@@ -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());

View File

@@ -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,

View File

@@ -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",

View File

@@ -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)

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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]));

View File

@@ -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);