Here is some annotation test code using JUnit
This code lived at the SeePeople project.
public class LongParameterListRefactoringTest {
@Test
public void isAnnotationWhenAsked() throws Exception {
assertTrue(LongParameterListRefactoring.class.isAnnotation());
}
@Test
public void annotationIsAnnotated() throws Exception {
assertTrue(LongParameterListRefactoring.class.getAnnotations().length > 0);
}
@Test
public void isAnnotatedWithRetentionAnnotation() throws Exception {
Annotation annotation = LongParameterListRefactoring.class.getAnnotations()[0];
assertTrue(annotation instanceof Retention);
}
@Test
public void isAnnotatedAsSourceCodeAnnotation() throws Exception {
Annotation annotation = LongParameterListRefactoring.class.getAnnotations()[0];
Retention retention = (Retention)annotation;
assertEquals(RetentionPolicy.SOURCE, retention.value());
}
}
Note: annotationIsAnnotated has since been changed. Can you guess why?
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.