コード例 #1
0
  @Test
  public void dynamicClassWithSuppressedWarning() {
    Class<?> type = Instantiator.of(Point.class).instantiateAnonymousSubclass().getClass();
    AnnotationAccessor accessor =
        new AnnotationAccessor(TestSupportedAnnotations.values(), type, true);
    assertFalse(accessor.typeHas(TYPE_CLASS_RETENTION));

    // Checks if the short circuit works
    assertFalse(accessor.typeHas(TYPE_CLASS_RETENTION));
    assertFalse(accessor.fieldHas("x", FIELD_CLASS_RETENTION));
  }
コード例 #2
0
  @Test
  public void dynamicClassThrowsException() {
    Class<?> type = Instantiator.of(Point.class).instantiateAnonymousSubclass().getClass();
    AnnotationAccessor accessor =
        new AnnotationAccessor(TestSupportedAnnotations.values(), type, false);

    thrown.expect(ReflectionException.class);
    thrown.expectMessage(containsString("Cannot read class file"));

    accessor.typeHas(TYPE_CLASS_RETENTION);
  }