コード例 #1
0
  @Test
  @SuppressWarnings("unchecked")
  public void findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes()
      throws Exception {
    Class<?> startClass = MetaConfigWithOverriddenAttributesTestCase.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[] {MetaAnnotationUtilsTests.class},
        descriptor.getAnnotationAttributes().getClassArray("classes"));
    assertNotNull(descriptor.getComposedAnnotation());
    assertEquals(MetaConfig.class, descriptor.getComposedAnnotationType());
  }
コード例 #2
0
 @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());
 }
コード例 #3
0
 @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());
 }