use of org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor in project spring-framework by spring-projects.
the class MetaAnnotationUtilsTests method findAnnotationDescriptorForTypesOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation.
/**
* @since 4.0.3
*/
@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() {
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(MetaCycleAnnotatedClass.class, Service.class, Component.class, Order.class);
assertNull("Should not find @Component on MetaCycleAnnotatedClass", descriptor);
}
use of org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor in project spring-framework by spring-projects.
the class MetaAnnotationUtilsTests method assertAtComponentOnComposedAnnotationForMultipleCandidateTypes.
@SuppressWarnings("unchecked")
private void assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(Class<?> startClass, Class<?> rootDeclaringClass, Class<?> declaringClass, String name, Class<? extends Annotation> composedAnnotationType) {
Class<Component> annotationType = Component.class;
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass, Service.class, annotationType, Order.class, Transactional.class);
assertNotNull("UntypedAnnotationDescriptor should not be null", descriptor);
assertEquals("rootDeclaringClass", rootDeclaringClass, descriptor.getRootDeclaringClass());
assertEquals("declaringClass", declaringClass, descriptor.getDeclaringClass());
assertEquals("annotationType", annotationType, descriptor.getAnnotationType());
assertEquals("component name", name, ((Component) descriptor.getAnnotation()).value());
assertNotNull("composedAnnotation should not be null", descriptor.getComposedAnnotation());
assertEquals("composedAnnotationType", composedAnnotationType, descriptor.getComposedAnnotationType());
}
use of org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor in project spring-framework by spring-projects.
the class MetaAnnotationUtilsTests method findAnnotationDescriptorForTypesOnAnnotatedClassWithMissingTargetMetaAnnotation.
/**
* @since 4.0.3
*/
@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesOnAnnotatedClassWithMissingTargetMetaAnnotation() {
// InheritedAnnotationClass is NOT annotated or meta-annotated with @Component,
// @Service, or @Order, but it is annotated with @Transactional.
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(InheritedAnnotationClass.class, Service.class, Component.class, Order.class);
assertNull("Should not find @Component on InheritedAnnotationClass", descriptor);
}
use of org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor in project spring-framework by spring-projects.
the class MetaAnnotationUtilsTests method findAnnotationDescriptorForTypesWithMetaAnnotationWithDefaultAttributes.
@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithDefaultAttributes() throws Exception {
Class<?> startClass = MetaConfigWithDefaultAttributesTestCase.class;
Class<ContextConfiguration> annotationType = ContextConfiguration.class;
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass, Service.class, ContextConfiguration.class, Order.class, Transactional.class);
assertNotNull(descriptor);
assertEquals(startClass, descriptor.getRootDeclaringClass());
assertEquals(annotationType, descriptor.getAnnotationType());
assertArrayEquals(new Class[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
assertArrayEquals(new Class[] { MetaConfig.DevConfig.class, MetaConfig.ProductionConfig.class }, descriptor.getAnnotationAttributes().getClassArray("classes"));
assertNotNull(descriptor.getComposedAnnotation());
assertEquals(MetaConfig.class, descriptor.getComposedAnnotationType());
}
use of org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor in project spring-framework by spring-projects.
the class MetaAnnotationUtilsTests method findAnnotationDescriptorForTypesWithInheritedAnnotationOnInterface.
@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesWithInheritedAnnotationOnInterface() throws Exception {
// Note: @Transactional is inherited
Transactional rawAnnotation = InheritedAnnotationInterface.class.getAnnotation(Transactional.class);
UntypedAnnotationDescriptor descriptor;
descriptor = findAnnotationDescriptorForTypes(InheritedAnnotationInterface.class, Transactional.class);
assertNotNull(descriptor);
assertEquals(InheritedAnnotationInterface.class, descriptor.getRootDeclaringClass());
assertEquals(InheritedAnnotationInterface.class, descriptor.getDeclaringClass());
assertEquals(rawAnnotation, descriptor.getAnnotation());
descriptor = findAnnotationDescriptorForTypes(SubInheritedAnnotationInterface.class, Transactional.class);
assertNotNull(descriptor);
assertEquals(SubInheritedAnnotationInterface.class, descriptor.getRootDeclaringClass());
assertEquals(InheritedAnnotationInterface.class, descriptor.getDeclaringClass());
assertEquals(rawAnnotation, descriptor.getAnnotation());
descriptor = findAnnotationDescriptorForTypes(SubSubInheritedAnnotationInterface.class, Transactional.class);
assertNotNull(descriptor);
assertEquals(SubSubInheritedAnnotationInterface.class, descriptor.getRootDeclaringClass());
assertEquals(InheritedAnnotationInterface.class, descriptor.getDeclaringClass());
assertEquals(rawAnnotation, descriptor.getAnnotation());
}
Aggregations