Remove @EnableAutoConfiguration from autoconfigure tests

It was doing scary things (like starting elasticsearch, hornetq etc).
There's still an outstanding question about why the context was
not being properly closed in such a scenario (maybe one of those
embedded servers lurking on a background thread?).

See gh-1034
pull/1050/merge
Dave Syer 11 years ago
parent f1b7544672
commit 38af1c2eb3

@ -20,8 +20,9 @@ import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfigurationTests;
import org.springframework.boot.autoconfigure.integration.IntegrationAutoConfigurationTests;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfigurationTests;
import org.springframework.boot.autoconfigure.web.BasicErrorControllerDirectMockMvcTests;
/**
* A test suite for probing weird ordering problems in the tests.
@ -29,8 +30,8 @@ import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfigurat
* @author Dave Syer
*/
@RunWith(Suite.class)
@SuiteClasses({ HibernateJpaAutoConfigurationTests.class,
LiquibaseAutoConfigurationTests.class })
@SuiteClasses({ BasicErrorControllerDirectMockMvcTests.class,
JmxAutoConfigurationTests.class, IntegrationAutoConfigurationTests.class })
@Ignore
public class AdhocTestSuite {

@ -16,16 +16,19 @@
package org.springframework.boot.autoconfigure.web;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.After;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jms.hornetq.HornetQAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;
@ -85,18 +88,25 @@ public class BasicErrorControllerDirectMockMvcTests {
assertTrue("Wrong content: " + content, content.contains("status=999"));
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({ EmbeddedServletContainerAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
ErrorMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
protected static @interface MinimalWebConfiguration {
}
@Configuration
@EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class,
HibernateJpaAutoConfiguration.class, DataSourceAutoConfiguration.class,
HornetQAutoConfiguration.class})
@MinimalWebConfiguration
protected static class ParentConfiguration {
}
@Configuration
@EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class,
HibernateJpaAutoConfiguration.class, DataSourceAutoConfiguration.class,
HornetQAutoConfiguration.class})
@MinimalWebConfiguration
@EnableWebMvc
protected static class WebMvcIncludedConfiguration {
// For manual testing
@ -107,11 +117,9 @@ public class BasicErrorControllerDirectMockMvcTests {
}
@Configuration
@EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class,
HibernateJpaAutoConfiguration.class, DataSourceAutoConfiguration.class,
HornetQAutoConfiguration.class})
@MinimalWebConfiguration
protected static class VanillaConfiguration {
// For manual testingm
// For manual testing
public static void main(String[] args) {
SpringApplication.run(VanillaConfiguration.class, args);
}
@ -119,9 +127,7 @@ public class BasicErrorControllerDirectMockMvcTests {
}
@Configuration
@EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class,
HibernateJpaAutoConfiguration.class, DataSourceAutoConfiguration.class,
HornetQAutoConfiguration.class})
@MinimalWebConfiguration
protected static class ChildConfiguration {
// For manual testing
public static void main(String[] args) {

@ -16,6 +16,11 @@
package org.springframework.boot.autoconfigure.web;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Map;
import javax.servlet.DispatcherType;
@ -28,14 +33,12 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.BasicErrorControllerMockMvcTests.TestConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletRequest;
@ -122,9 +125,19 @@ public class BasicErrorControllerMockMvcTests {
assertTrue("Wrong content: " + content, content.contains("ERROR_BEAN"));
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({ EmbeddedServletContainerAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
ErrorMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
protected static @interface MinimalWebConfiguration {
}
@Configuration
@EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class,
DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class })
@MinimalWebConfiguration
public static class TestConfiguration {
// For manual testing

@ -16,17 +16,22 @@
package org.springframework.boot.autoconfigure.web;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DefaultErrorViewIntegrationTests.TestConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ -69,9 +74,19 @@ public class DefaultErrorViewIntegrationTests {
assertTrue("Wrong content: " + content, content.contains("999"));
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({ EmbeddedServletContainerAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
ErrorMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
protected static @interface MinimalWebConfiguration {
}
@Configuration
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class })
@MinimalWebConfiguration
public static class TestConfiguration {
// For manual testing

Loading…
Cancel
Save