From 504779e2104fe961091d3fc274c156e8116dea4f Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 26 Feb 2016 13:41:56 -0800 Subject: [PATCH 1/2] Remove @BootstrapWith from @WebAppConfiguration Update @WebAppConfiguration so that it no longer directly specifies a TestContextBootstrapper. This allows third parties to use the annotation in combination with their own bootstrapper. BootstrapUtils now provides the detection logic for when WebTestContextBootstrapper should be used. Issue: SPR-13991 --- .../test/context/BootstrapUtils.java | 61 +++++++++-------- .../test/context/web/WebAppConfiguration.java | 5 +- .../test/context/BootstrapUtilsTests.java | 12 +++- ...ebbAppConfigurationBootstrapWithTests.java | 65 +++++++++++++++++++ 4 files changed, 112 insertions(+), 31 deletions(-) create mode 100644 spring-test/src/test/java/org/springframework/test/context/web/WebbAppConfigurationBootstrapWithTests.java diff --git a/spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java b/spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java index 411b3254ddb..806aee54a3d 100644 --- a/spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.MultiValueMap; @@ -43,6 +44,10 @@ abstract class BootstrapUtils { private static final String DEFAULT_BOOTSTRAP_CONTEXT_CLASS_NAME = "org.springframework.test.context.support.DefaultBootstrapContext"; + private static final String DEFAULT_WEB_BOOTSTRAP_CONTEXT_CLASS_NAME = "org.springframework.test.context.web.WebTestContextBootstrapper"; + + private static final String WEB_APP_CONFIGURATION_ANNOTATION = "org.springframework.test.context.web.WebAppConfiguration"; + private static final String DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME = "org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate"; private static final String DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME = "org.springframework.test.context.support.DefaultTestContextBootstrapper"; @@ -117,31 +122,15 @@ abstract class BootstrapUtils { * @param bootstrapContext the bootstrap context to use * @return a fully configured {@code TestContextBootstrapper} */ - @SuppressWarnings("unchecked") static TestContextBootstrapper resolveTestContextBootstrapper(BootstrapContext bootstrapContext) { Class testClass = bootstrapContext.getTestClass(); - Class clazz = null; + Class clazz = null; try { - - MultiValueMap attributesMultiMap = AnnotatedElementUtils.getAllAnnotationAttributes( - testClass, BootstrapWith.class.getName()); - List values = (attributesMultiMap == null ? null : attributesMultiMap.get(AnnotationUtils.VALUE)); - - if (values != null) { - if (values.size() != 1) { - String msg = String.format( - "Configuration error: found multiple declarations of @BootstrapWith on test class [%s] with values %s", - testClass.getName(), values); - throw new IllegalStateException(msg); - } - clazz = (Class) values.get(0); - } - else { - clazz = (Class) ClassUtils.forName( - DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME, BootstrapUtils.class.getClassLoader()); + clazz = resolveExplicitTestContextBootstrapper(testClass); + if (clazz == null) { + clazz = resolveDefaultTestContextBootstrapper(testClass); } - if (logger.isDebugEnabled()) { logger.debug(String.format("Instantiating TestContextBootstrapper for test class [%s] from class [%s]", testClass.getName(), clazz.getName())); @@ -152,15 +141,35 @@ abstract class BootstrapUtils { return testContextBootstrapper; } - catch (Throwable t) { - if (t instanceof IllegalStateException) { - throw (IllegalStateException) t; + catch (Throwable ex) { + if (ex instanceof IllegalStateException) { + throw (IllegalStateException) ex; } - throw new IllegalStateException("Could not load TestContextBootstrapper [" + clazz + "]. Specify @BootstrapWith's 'value' attribute " - + "or make the default bootstrapper class available.", t); + + "or make the default bootstrapper class available.", ex); + } + } + + private static Class resolveExplicitTestContextBootstrapper(Class testClass) { + MultiValueMap attributesMultiMap = AnnotatedElementUtils.getAllAnnotationAttributes( + testClass, BootstrapWith.class.getName()); + List values = (attributesMultiMap == null ? null : attributesMultiMap.get(AnnotationUtils.VALUE)); + if (values == null) { + return null; + } + Assert.state(values.size() == 1, String.format("Configuration error: found multiple declarations of " + + "@BootstrapWith on test class [%s] with values %s", testClass.getName(), values)); + return (Class) values.get(0); + } + + private static Class resolveDefaultTestContextBootstrapper(Class testClass) + throws Exception { + ClassLoader classLoader = BootstrapUtils.class.getClassLoader(); + if (AnnotatedElementUtils.isAnnotated(testClass, WEB_APP_CONFIGURATION_ANNOTATION)) { + return ClassUtils.forName(DEFAULT_WEB_BOOTSTRAP_CONTEXT_CLASS_NAME, classLoader); } + return ClassUtils.forName(DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME, classLoader); } } diff --git a/spring-test/src/main/java/org/springframework/test/context/web/WebAppConfiguration.java b/spring-test/src/main/java/org/springframework/test/context/web/WebAppConfiguration.java index b2434c5879e..cadc6bd2343 100644 --- a/spring-test/src/main/java/org/springframework/test/context/web/WebAppConfiguration.java +++ b/spring-test/src/main/java/org/springframework/test/context/web/WebAppConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +23,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.springframework.test.context.BootstrapWith; - /** * {@code @WebAppConfiguration} is a class-level annotation that is used to * declare that the {@code ApplicationContext} loaded for an integration test @@ -53,7 +51,6 @@ import org.springframework.test.context.BootstrapWith; @Inherited @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) -@BootstrapWith(WebTestContextBootstrapper.class) public @interface WebAppConfiguration { /** diff --git a/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.java index 8efb56d3ca9..75cdbc0ace3 100644 --- a/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.test.context.support.DefaultTestContextBootstrapper; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.context.web.WebTestContextBootstrapper; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; @@ -48,6 +50,11 @@ public class BootstrapUtilsTests { assertBootstrapper(NonAnnotatedClass.class, DefaultTestContextBootstrapper.class); } + @Test + public void resolveTestContextBootstrapperForWithWebAppConfigurationAnnotatedClass() throws Exception { + assertBootstrapper(WithWebAppConfiguration.class, WebTestContextBootstrapper.class); + } + @Test public void resolveTestContextBootstrapperWithEmptyBootstrapWithAnnotation() { BootstrapContext bootstrapContext = BootstrapTestUtils.buildBootstrapContext(EmptyBootstrapWithAnnotationClass.class, delegate); @@ -124,4 +131,7 @@ public class BootstrapUtilsTests { @BootWithFoo static class DoubleMetaAnnotatedBootstrapWithAnnotationClass {} + @WebAppConfiguration + static class WithWebAppConfiguration {} + } diff --git a/spring-test/src/test/java/org/springframework/test/context/web/WebbAppConfigurationBootstrapWithTests.java b/spring-test/src/test/java/org/springframework/test/context/web/WebbAppConfigurationBootstrapWithTests.java new file mode 100644 index 00000000000..4848df99a80 --- /dev/null +++ b/spring-test/src/test/java/org/springframework/test/context/web/WebbAppConfigurationBootstrapWithTests.java @@ -0,0 +1,65 @@ +/* + * Copyright 2002-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.test.context.web; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.BootstrapWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebbAppConfigurationBootstrapWithTests.TestWebTestContextBootstrapper; +import org.springframework.web.context.WebApplicationContext; + +import static org.junit.Assert.*; + +/** + * JUnit-based integration tests that verify support for loading a + * {@link WebApplicationContext} with a custom {@code @BootstrapWith}. + * + * @author Phillip Webb + * @since 4.3 + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration +@WebAppConfiguration +@BootstrapWith(TestWebTestContextBootstrapper.class) +public class WebbAppConfigurationBootstrapWithTests { + + @Autowired + private ApplicationContext context; + + + @Test + public void testApplicationContextIsWebApplicationContext() throws Exception { + assertTrue(this.context instanceof WebApplicationContext); + } + + + @Configuration + static class Config { + + } + + + static class TestWebTestContextBootstrapper extends WebTestContextBootstrapper { + + } + +} From 93fb7be783c8bbd062cb32b18f1d7cd91ca96d15 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 8 Mar 2016 15:18:21 +0100 Subject: [PATCH 2/2] Polishing --- .../test/context/BootstrapUtils.java | 32 +++++--- .../test/context/web/WebAppConfiguration.java | 4 +- .../test/context/BootstrapUtilsTests.java | 18 +++-- ...WebAppConfigurationBootstrapWithTests.java | 78 +++++++++++++++++++ ...ebbAppConfigurationBootstrapWithTests.java | 65 ---------------- 5 files changed, 111 insertions(+), 86 deletions(-) create mode 100644 spring-test/src/test/java/org/springframework/test/context/web/WebAppConfigurationBootstrapWithTests.java delete mode 100644 spring-test/src/test/java/org/springframework/test/context/web/WebbAppConfigurationBootstrapWithTests.java diff --git a/spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java b/spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java index 806aee54a3d..db791c35630 100644 --- a/spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java @@ -28,13 +28,14 @@ import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.MultiValueMap; -import static org.springframework.beans.BeanUtils.*; +import static org.springframework.beans.BeanUtils.instantiateClass; /** * {@code BootstrapUtils} is a collection of utility methods to assist with * bootstrapping the Spring TestContext Framework. * * @author Sam Brannen + * @author Phillip Webb * @since 4.1 * @see BootstrapWith * @see BootstrapContext @@ -44,14 +45,14 @@ abstract class BootstrapUtils { private static final String DEFAULT_BOOTSTRAP_CONTEXT_CLASS_NAME = "org.springframework.test.context.support.DefaultBootstrapContext"; - private static final String DEFAULT_WEB_BOOTSTRAP_CONTEXT_CLASS_NAME = "org.springframework.test.context.web.WebTestContextBootstrapper"; - - private static final String WEB_APP_CONFIGURATION_ANNOTATION = "org.springframework.test.context.web.WebAppConfiguration"; - private static final String DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME = "org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate"; private static final String DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME = "org.springframework.test.context.support.DefaultTestContextBootstrapper"; + private static final String DEFAULT_WEB_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME = "org.springframework.test.context.web.WebTestContextBootstrapper"; + + private static final String WEB_APP_CONFIGURATION_ANNOTATION_CLASS_NAME = "org.springframework.test.context.web.WebAppConfiguration"; + private static final Log logger = LogFactory.getLog(BootstrapUtils.class); @@ -116,8 +117,12 @@ abstract class BootstrapUtils { *

If the {@link BootstrapWith @BootstrapWith} annotation is present on * the test class, either directly or as a meta-annotation, then its * {@link BootstrapWith#value value} will be used as the bootstrapper type. - * Otherwise, the {@link org.springframework.test.context.support.DefaultTestContextBootstrapper - * DefaultTestContextBootstrapper} will be used. + * Otherwise, either the + * {@link org.springframework.test.context.support.DefaultTestContextBootstrapper + * DefaultTestContextBootstrapper} or the + * {@link org.springframework.test.context.web.WebTestContextBootstrapper + * WebTestContextBootstrapper} will be used, depending on the presence of + * {@link org.springframework.test.context.web.WebAppConfiguration @WebAppConfiguration}. * * @param bootstrapContext the bootstrap context to use * @return a fully configured {@code TestContextBootstrapper} @@ -151,6 +156,9 @@ abstract class BootstrapUtils { } } + /** + * @since 4.3 + */ private static Class resolveExplicitTestContextBootstrapper(Class testClass) { MultiValueMap attributesMultiMap = AnnotatedElementUtils.getAllAnnotationAttributes( testClass, BootstrapWith.class.getName()); @@ -163,11 +171,13 @@ abstract class BootstrapUtils { return (Class) values.get(0); } - private static Class resolveDefaultTestContextBootstrapper(Class testClass) - throws Exception { + /** + * @since 4.3 + */ + private static Class resolveDefaultTestContextBootstrapper(Class testClass) throws Exception { ClassLoader classLoader = BootstrapUtils.class.getClassLoader(); - if (AnnotatedElementUtils.isAnnotated(testClass, WEB_APP_CONFIGURATION_ANNOTATION)) { - return ClassUtils.forName(DEFAULT_WEB_BOOTSTRAP_CONTEXT_CLASS_NAME, classLoader); + if (AnnotatedElementUtils.isAnnotated(testClass, WEB_APP_CONFIGURATION_ANNOTATION_CLASS_NAME)) { + return ClassUtils.forName(DEFAULT_WEB_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME, classLoader); } return ClassUtils.forName(DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME, classLoader); } diff --git a/spring-test/src/main/java/org/springframework/test/context/web/WebAppConfiguration.java b/spring-test/src/main/java/org/springframework/test/context/web/WebAppConfiguration.java index cadc6bd2343..6be37864e7c 100644 --- a/spring-test/src/main/java/org/springframework/test/context/web/WebAppConfiguration.java +++ b/spring-test/src/main/java/org/springframework/test/context/web/WebAppConfiguration.java @@ -29,8 +29,8 @@ import java.lang.annotation.Target; * should be a {@link org.springframework.web.context.WebApplicationContext * WebApplicationContext}. * - *

The mere presence of {@code @WebAppConfiguration} on a test class ensures - * that a {@code WebApplicationContext} will be loaded for the test using a default + *

The presence of {@code @WebAppConfiguration} on a test class indicates that + * a {@code WebApplicationContext} should be loaded for the test using a default * for the path to the root of the web application. To override the default, * specify an explicit resource path via the {@link #value} attribute. * diff --git a/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.java index 75cdbc0ace3..70d80ee30cf 100644 --- a/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.java @@ -27,15 +27,17 @@ import org.springframework.test.context.support.DefaultTestContextBootstrapper; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.context.web.WebTestContextBootstrapper; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; -import static org.springframework.test.context.BootstrapUtils.*; +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.springframework.test.context.BootstrapUtils.resolveTestContextBootstrapper; /** * Unit tests for {@link BootstrapUtils}. * * @author Sam Brannen + * @author Phillip Webb * @since 4.2 */ public class BootstrapUtilsTests { @@ -43,7 +45,7 @@ public class BootstrapUtilsTests { private final CacheAwareContextLoaderDelegate delegate = mock(CacheAwareContextLoaderDelegate.class); @Rule - public ExpectedException exception = ExpectedException.none(); + public final ExpectedException exception = ExpectedException.none(); @Test public void resolveTestContextBootstrapperForNonAnnotatedClass() { @@ -51,8 +53,8 @@ public class BootstrapUtilsTests { } @Test - public void resolveTestContextBootstrapperForWithWebAppConfigurationAnnotatedClass() throws Exception { - assertBootstrapper(WithWebAppConfiguration.class, WebTestContextBootstrapper.class); + public void resolveTestContextBootstrapperForWebAppConfigurationAnnotatedClass() { + assertBootstrapper(WebAppConfigurationAnnotatedClass.class, WebTestContextBootstrapper.class); } @Test @@ -132,6 +134,6 @@ public class BootstrapUtilsTests { static class DoubleMetaAnnotatedBootstrapWithAnnotationClass {} @WebAppConfiguration - static class WithWebAppConfiguration {} + static class WebAppConfigurationAnnotatedClass {} } diff --git a/spring-test/src/test/java/org/springframework/test/context/web/WebAppConfigurationBootstrapWithTests.java b/spring-test/src/test/java/org/springframework/test/context/web/WebAppConfigurationBootstrapWithTests.java new file mode 100644 index 00000000000..ad03bb81f8a --- /dev/null +++ b/spring-test/src/test/java/org/springframework/test/context/web/WebAppConfigurationBootstrapWithTests.java @@ -0,0 +1,78 @@ +/* + * Copyright 2002-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.test.context.web; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.test.context.BootstrapWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.MergedContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.web.WebAppConfigurationBootstrapWithTests.CustomWebTestContextBootstrapper; +import org.springframework.web.context.WebApplicationContext; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * JUnit-based integration tests that verify support for loading a + * {@link WebApplicationContext} with a custom {@link WebTestContextBootstrapper}. + * + * @author Sam Brannen + * @author Phillip Webb + * @since 4.3 + */ +@RunWith(SpringRunner.class) +@ContextConfiguration +@WebAppConfiguration +@BootstrapWith(CustomWebTestContextBootstrapper.class) +public class WebAppConfigurationBootstrapWithTests { + + @Autowired + WebApplicationContext wac; + + + @Test + public void webApplicationContextIsLoaded() { + // from: src/test/webapp/resources/Spring.js + Resource resource = wac.getResource("/resources/Spring.js"); + assertNotNull(resource); + assertTrue(resource.exists()); + } + + + @Configuration + static class Config { + } + + /** + * Custom {@link WebTestContextBootstrapper} that requires {@code @WebAppConfiguration} + * but hard codes the resource base path. + */ + static class CustomWebTestContextBootstrapper extends WebTestContextBootstrapper { + + @Override + protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) { + return new WebMergedContextConfiguration(mergedConfig, "src/test/webapp"); + } + } + +} diff --git a/spring-test/src/test/java/org/springframework/test/context/web/WebbAppConfigurationBootstrapWithTests.java b/spring-test/src/test/java/org/springframework/test/context/web/WebbAppConfigurationBootstrapWithTests.java deleted file mode 100644 index 4848df99a80..00000000000 --- a/spring-test/src/test/java/org/springframework/test/context/web/WebbAppConfigurationBootstrapWithTests.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2002-2016 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.test.context.web; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.BootstrapWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebbAppConfigurationBootstrapWithTests.TestWebTestContextBootstrapper; -import org.springframework.web.context.WebApplicationContext; - -import static org.junit.Assert.*; - -/** - * JUnit-based integration tests that verify support for loading a - * {@link WebApplicationContext} with a custom {@code @BootstrapWith}. - * - * @author Phillip Webb - * @since 4.3 - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration -@WebAppConfiguration -@BootstrapWith(TestWebTestContextBootstrapper.class) -public class WebbAppConfigurationBootstrapWithTests { - - @Autowired - private ApplicationContext context; - - - @Test - public void testApplicationContextIsWebApplicationContext() throws Exception { - assertTrue(this.context instanceof WebApplicationContext); - } - - - @Configuration - static class Config { - - } - - - static class TestWebTestContextBootstrapper extends WebTestContextBootstrapper { - - } - -}