@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2014 the original author or authors .
* Copyright 2002 - 2015 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 .
@ -29,6 +29,8 @@ import org.springframework.core.annotation.Order;
@@ -29,6 +29,8 @@ import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component ;
import org.springframework.stereotype.Service ;
import org.springframework.test.context.ContextConfiguration ;
import org.springframework.test.util.MetaAnnotationUtils.AnnotationDescriptor ;
import org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor ;
import org.springframework.transaction.annotation.Transactional ;
import static org.junit.Assert.* ;
@ -161,6 +163,22 @@ public class MetaAnnotationUtilsTests {
@@ -161,6 +163,22 @@ public class MetaAnnotationUtilsTests {
assertNull ( findAnnotationDescriptor ( ClassWithMetaAnnotatedInterface . class , Component . class ) ) ;
}
@Test
public void findAnnotationDescriptorForClassWithLocalMetaAnnotationAndAnnotatedSuperclass ( ) {
AnnotationDescriptor < ContextConfiguration > descriptor = findAnnotationDescriptor (
MetaAnnotatedAndSuperAnnotatedContextConfigClass . class , ContextConfiguration . class ) ;
assertNotNull ( "AnnotationDescriptor should not be null" , descriptor ) ;
assertEquals ( "rootDeclaringClass" , MetaAnnotatedAndSuperAnnotatedContextConfigClass . class , descriptor . getRootDeclaringClass ( ) ) ;
assertEquals ( "declaringClass" , MetaConfig . class , descriptor . getDeclaringClass ( ) ) ;
assertEquals ( "annotationType" , ContextConfiguration . class , descriptor . getAnnotationType ( ) ) ;
assertNotNull ( "composedAnnotation should not be null" , descriptor . getComposedAnnotation ( ) ) ;
assertEquals ( "composedAnnotationType" , MetaConfig . class , descriptor . getComposedAnnotationType ( ) ) ;
assertArrayEquals ( "configured classes" , new Class [ ] { String . class } ,
descriptor . getAnnotationAttributes ( ) . getClassArray ( "classes" ) ) ;
}
@Test
public void findAnnotationDescriptorForClassWithLocalMetaAnnotationAndMetaAnnotatedInterface ( ) {
assertAtComponentOnComposedAnnotation ( ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface . class , "meta2" ,
@ -546,4 +564,12 @@ public class MetaAnnotationUtilsTests {
@@ -546,4 +564,12 @@ public class MetaAnnotationUtilsTests {
static class SubNonInheritedAnnotationClass extends NonInheritedAnnotationClass {
}
@ContextConfiguration ( classes = Number . class )
static class AnnotatedContextConfigClass {
}
@MetaConfig ( classes = String . class )
static class MetaAnnotatedAndSuperAnnotatedContextConfigClass extends AnnotatedContextConfigClass {
}
}