From 58955236ee3640748cdea52360893b7078470e9b Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 4 Jul 2014 16:10:52 +0200 Subject: [PATCH] Introduce tests for Spring Boot issue 885 This commit introduces unit tests that attempt to reproduce the problem described in Spring Boot issue 885; however, the tests pass and therefore do not confirm the reported problem. See: https://github.com/spring-projects/spring-boot/issues/885 --- .../ContextLoaderUtilsMergedConfigTests.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsMergedConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsMergedConfigTests.java index f7eb5600af..4c84359632 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsMergedConfigTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsMergedConfigTests.java @@ -16,7 +16,13 @@ package org.springframework.test.context.support; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + import org.junit.Test; +import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextLoader; import org.springframework.test.context.MergedContextConfiguration; @@ -66,6 +72,19 @@ public class ContextLoaderUtilsMergedConfigTests extends AbstractContextLoaderUt DelegatingSmartContextLoader.class); } + @Test + public void buildMergedConfigWithMetaAnnotationAndClasses() { + buildMergedConfigWithMetaAnnotationAndClasses(Dog.class); + buildMergedConfigWithMetaAnnotationAndClasses(WorkingDog.class); + buildMergedConfigWithMetaAnnotationAndClasses(GermanShepherd.class); + } + + private void buildMergedConfigWithMetaAnnotationAndClasses(Class testClass) { + MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); + assertMergedConfig(mergedConfig, testClass, EMPTY_STRING_ARRAY, new Class[] { FooConfig.class, + BarConfig.class }, DelegatingSmartContextLoader.class); + } + @Test public void buildMergedConfigWithLocalAnnotationAndClasses() { Class testClass = ClassesFoo.class; @@ -135,4 +154,23 @@ public class ContextLoaderUtilsMergedConfigTests extends AbstractContextLoaderUt AnnotationConfigContextLoader.class); } + + @ContextConfiguration + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public static @interface SpringAppConfig { + + Class[] classes() default {}; + } + + @SpringAppConfig(classes = { FooConfig.class, BarConfig.class }) + public static abstract class Dog { + } + + public static abstract class WorkingDog extends Dog { + } + + public static class GermanShepherd extends WorkingDog { + } + }