Search in sources :

Example 16 with Component

use of org.springframework.stereotype.Component in project spring-framework by spring-projects.

the class MetaAnnotationUtilsTests method findAnnotationDescriptorForTypesForClassWithMetaAnnotatedInterface.

@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesForClassWithMetaAnnotatedInterface() {
    Component rawAnnotation = AnnotationUtils.findAnnotation(ClassWithMetaAnnotatedInterface.class, Component.class);
    UntypedAnnotationDescriptor descriptor;
    descriptor = findAnnotationDescriptorForTypes(ClassWithMetaAnnotatedInterface.class, Service.class, Component.class, Order.class, Transactional.class);
    assertNotNull(descriptor);
    assertEquals(ClassWithMetaAnnotatedInterface.class, descriptor.getRootDeclaringClass());
    assertEquals(Meta1.class, descriptor.getDeclaringClass());
    assertEquals(rawAnnotation, descriptor.getAnnotation());
    assertEquals(Meta1.class, descriptor.getComposedAnnotation().annotationType());
}
Also used : Order(org.springframework.core.annotation.Order) Service(org.springframework.stereotype.Service) Component(org.springframework.stereotype.Component) UntypedAnnotationDescriptor(org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor) Transactional(org.springframework.transaction.annotation.Transactional) Test(org.junit.Test)

Example 17 with Component

use of org.springframework.stereotype.Component in project spring-framework by spring-projects.

the class MetaAnnotationUtilsTests method findAnnotationDescriptorForClassWithMetaAnnotatedInterface.

@Test
public void findAnnotationDescriptorForClassWithMetaAnnotatedInterface() {
    Component rawAnnotation = AnnotationUtils.findAnnotation(ClassWithMetaAnnotatedInterface.class, Component.class);
    AnnotationDescriptor<Component> descriptor;
    descriptor = findAnnotationDescriptor(ClassWithMetaAnnotatedInterface.class, Component.class);
    assertNotNull(descriptor);
    assertEquals(ClassWithMetaAnnotatedInterface.class, descriptor.getRootDeclaringClass());
    assertEquals(Meta1.class, descriptor.getDeclaringClass());
    assertEquals(rawAnnotation, descriptor.getAnnotation());
    assertEquals(Meta1.class, descriptor.getComposedAnnotation().annotationType());
}
Also used : Component(org.springframework.stereotype.Component) Test(org.junit.Test)

Example 18 with Component

use of org.springframework.stereotype.Component in project spring-framework by spring-projects.

the class MetaAnnotationUtilsTests method findAnnotationDescriptorForTypesWithLocalAndMetaComponentAnnotation.

@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesWithLocalAndMetaComponentAnnotation() throws Exception {
    Class<Component> annotationType = Component.class;
    UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(HasLocalAndMetaComponentAnnotation.class, Transactional.class, annotationType, Order.class);
    assertEquals(HasLocalAndMetaComponentAnnotation.class, descriptor.getRootDeclaringClass());
    assertEquals(annotationType, descriptor.getAnnotationType());
    assertNull(descriptor.getComposedAnnotation());
    assertNull(descriptor.getComposedAnnotationType());
}
Also used : Component(org.springframework.stereotype.Component) UntypedAnnotationDescriptor(org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor) Test(org.junit.Test)

Aggregations

Component (org.springframework.stereotype.Component)18 Test (org.junit.Test)14 UntypedAnnotationDescriptor (org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor)3 Method (java.lang.reflect.Method)1 Binding (org.glassfish.jersey.internal.inject.Binding)1 Order (org.springframework.core.annotation.Order)1 AnnotationTypeFilter (org.springframework.core.type.filter.AnnotationTypeFilter)1 Service (org.springframework.stereotype.Service)1 Transactional (org.springframework.transaction.annotation.Transactional)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1