コード例 #1
0
  public void testName() throws Exception {
    Field field = TestClass.class.getDeclaredField("producer2");
    Producer annotation = field.getAnnotation(Producer.class);
    IntrospectionContext context = new DefaultIntrospectionContext();
    TypeMapping mapping = new TypeMapping();
    context.addTypeMapping(TestClass.class, mapping);

    processor.visitField(annotation, field, TestClass.class, componentType, context);
    assertEquals(0, context.getErrors().size());
    assertTrue(componentType.getProducers().containsKey("foo"));
  }
コード例 #2
0
  public void testMethod() throws Exception {
    Method method = TestClass.class.getDeclaredMethod("setProducer", TestProducer.class);
    Producer annotation = method.getAnnotation(Producer.class);
    IntrospectionContext context = new DefaultIntrospectionContext();
    TypeMapping mapping = new TypeMapping();
    context.addTypeMapping(TestClass.class, mapping);

    processor.visitMethod(annotation, method, TestClass.class, componentType, context);
    assertEquals(0, context.getErrors().size());
    assertTrue(componentType.getProducers().containsKey("producer"));
  }