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.runner.RunWith;
import org.junit.runners.Suite; import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; import org.junit.runners.Suite.SuiteClasses;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests; import org.springframework.boot.autoconfigure.integration.IntegrationAutoConfigurationTests;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfigurationTests; 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. * 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 * @author Dave Syer
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({ HibernateJpaAutoConfigurationTests.class, @SuiteClasses({ BasicErrorControllerDirectMockMvcTests.class,
LiquibaseAutoConfigurationTests.class }) JmxAutoConfigurationTests.class, IntegrationAutoConfigurationTests.class })
@Ignore @Ignore
public class AdhocTestSuite { public class AdhocTestSuite {

@ -16,16 +16,19 @@
package org.springframework.boot.autoconfigure.web; 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.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
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.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
@ -85,18 +88,25 @@ public class BasicErrorControllerDirectMockMvcTests {
assertTrue("Wrong content: " + content, content.contains("status=999")); 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 @Configuration
@EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class, @MinimalWebConfiguration
HibernateJpaAutoConfiguration.class, DataSourceAutoConfiguration.class,
HornetQAutoConfiguration.class})
protected static class ParentConfiguration { protected static class ParentConfiguration {
} }
@Configuration @Configuration
@EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class, @MinimalWebConfiguration
HibernateJpaAutoConfiguration.class, DataSourceAutoConfiguration.class,
HornetQAutoConfiguration.class})
@EnableWebMvc @EnableWebMvc
protected static class WebMvcIncludedConfiguration { protected static class WebMvcIncludedConfiguration {
// For manual testing // For manual testing
@ -107,11 +117,9 @@ public class BasicErrorControllerDirectMockMvcTests {
} }
@Configuration @Configuration
@EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class, @MinimalWebConfiguration
HibernateJpaAutoConfiguration.class, DataSourceAutoConfiguration.class,
HornetQAutoConfiguration.class})
protected static class VanillaConfiguration { protected static class VanillaConfiguration {
// For manual testingm // For manual testing
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(VanillaConfiguration.class, args); SpringApplication.run(VanillaConfiguration.class, args);
} }
@ -119,9 +127,7 @@ public class BasicErrorControllerDirectMockMvcTests {
} }
@Configuration @Configuration
@EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class, @MinimalWebConfiguration
HibernateJpaAutoConfiguration.class, DataSourceAutoConfiguration.class,
HornetQAutoConfiguration.class})
protected static class ChildConfiguration { protected static class ChildConfiguration {
// For manual testing // For manual testing
public static void main(String[] args) { public static void main(String[] args) {

@ -16,6 +16,11 @@
package org.springframework.boot.autoconfigure.web; 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 java.util.Map;
import javax.servlet.DispatcherType; import javax.servlet.DispatcherType;
@ -28,14 +33,12 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
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.web.BasicErrorControllerMockMvcTests.TestConfiguration; import org.springframework.boot.autoconfigure.web.BasicErrorControllerMockMvcTests.TestConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
@ -122,9 +125,19 @@ public class BasicErrorControllerMockMvcTests {
assertTrue("Wrong content: " + content, content.contains("ERROR_BEAN")); 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 @Configuration
@EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class, @MinimalWebConfiguration
DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class })
public static class TestConfiguration { public static class TestConfiguration {
// For manual testing // For manual testing

@ -16,17 +16,22 @@
package org.springframework.boot.autoconfigure.web; 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.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.web.DefaultErrorViewIntegrationTests.TestConfiguration; import org.springframework.boot.autoconfigure.web.DefaultErrorViewIntegrationTests.TestConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ -69,9 +74,19 @@ public class DefaultErrorViewIntegrationTests {
assertTrue("Wrong content: " + content, content.contains("999")); 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 @Configuration
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, @MinimalWebConfiguration
HibernateJpaAutoConfiguration.class })
public static class TestConfiguration { public static class TestConfiguration {
// For manual testing // For manual testing

Loading…
Cancel
Save