コード例 #1
0
 @Test
 public void findAnnotationDescriptorWithLocalAndMetaComponentAnnotation() throws Exception {
   Class<Component> annotationType = Component.class;
   AnnotationDescriptor<Component> descriptor =
       findAnnotationDescriptor(HasLocalAndMetaComponentAnnotation.class, annotationType);
   assertEquals(HasLocalAndMetaComponentAnnotation.class, descriptor.getRootDeclaringClass());
   assertEquals(annotationType, descriptor.getAnnotationType());
   assertNull(descriptor.getComposedAnnotation());
   assertNull(descriptor.getComposedAnnotationType());
 }
コード例 #2
0
 private void assertAtComponentOnComposedAnnotation(
     Class<?> startClass,
     Class<?> rootDeclaringClass,
     Class<?> declaringClass,
     String name,
     Class<? extends Annotation> composedAnnotationType) {
   AnnotationDescriptor<Component> descriptor =
       findAnnotationDescriptor(startClass, Component.class);
   assertNotNull("AnnotationDescriptor should not be null", descriptor);
   assertEquals("rootDeclaringClass", rootDeclaringClass, descriptor.getRootDeclaringClass());
   assertEquals("declaringClass", declaringClass, descriptor.getDeclaringClass());
   assertEquals("annotationType", Component.class, descriptor.getAnnotationType());
   assertEquals("component name", name, descriptor.getAnnotation().value());
   assertNotNull("composedAnnotation should not be null", descriptor.getComposedAnnotation());
   assertEquals(
       "composedAnnotationType", composedAnnotationType, descriptor.getComposedAnnotationType());
 }
コード例 #3
0
  @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"));
  }