Revert "Fail fast if @WebAppConfiguration and @SpringBootTest are used together"

This reverts commit c54cdd6735.
This commit is contained in:
Andy Wilkinson
2016-09-14 15:04:34 +01:00
parent a68cf77386
commit 21a25ce855
4 changed files with 47 additions and 128 deletions

View File

@@ -16,7 +16,6 @@
package org.springframework.boot.test.context;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -73,7 +72,6 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
@Override
public TestContext buildTestContext() {
TestContext context = super.buildTestContext();
verifyConfiguration(context.getTestClass());
WebEnvironment webEnvironment = getWebEnvironment(context.getTestClass());
if (webEnvironment == WebEnvironment.MOCK && hasWebEnvironmentClasses()) {
context.setAttribute(ACTIVATE_SERVLET_LISTENER, true);
@@ -248,19 +246,6 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
return AnnotatedElementUtils.getMergedAnnotation(testClass, SpringBootTest.class);
}
protected void verifyConfiguration(Class<?> testClass) {
if (getAnnotation(testClass) != null
&& getAnnotation(WebAppConfiguration.class, testClass) != null) {
throw new IllegalStateException("@WebAppConfiguration is unnecessary when "
+ "using @SpringBootTest and should be removed");
}
}
private <T extends Annotation> T getAnnotation(Class<T> annotationType,
Class<?> testClass) {
return AnnotatedElementUtils.getMergedAnnotation(testClass, annotationType);
}
/**
* Create a new {@link MergedContextConfiguration} with different classes.
* @param mergedConfig the source config