Package org.dbunit.annotation.runtime
Interface AnnotationLookup
public interface AnnotationLookup
A binding's way of finding the
org.dbunit.annotation annotation that applies to the
test it is running, and the class that declares it: the one search strategy that differs
between test frameworks, since each has its own rules for meta-annotations, inheritance and
enclosing classes. Everything else that turns annotations into a configuration is shared - see
AnnotatedTestConfiguration.from(Class, AnnotationLookup).
Public so a binding outside org.dbunit.annotation.runtime - such as
DbUnitExtension or a Spring TestExecutionListener - can implement it.
- Since:
- 3.6.0
- Author:
- Jeff Jensen
-
Method Summary
Modifier and TypeMethodDescription<A extends Annotation>
AFinds the annotation ofannotationTypethat applies to the test.Class<?> findDeclaringClass(Class<? extends Annotation> annotationType) Finds the class that declares the annotationfind(Class)returns forannotationType, so a dataset path written relative to a package resolves against the package of the class the author wrote it in, not that of the concrete test class that merely inherits it.
-
Method Details
-
find
Finds the annotation ofannotationTypethat applies to the test. A binding looks on the test method first and on the test class second, so a method-level annotation wins over a class-level one.- Type Parameters:
A- The annotation type.- Parameters:
annotationType- The annotation to look for.- Returns:
- The annotation, or
nullwhen the test has none.
-
findDeclaringClass
Finds the class that declares the annotationfind(Class)returns forannotationType, so a dataset path written relative to a package resolves against the package of the class the author wrote it in, not that of the concrete test class that merely inherits it.For a method-level annotation that is the class declaring the test method, which is a superclass of the test class for an inherited test method. For a class-level one it is the class or interface carrying the annotation, or carrying the composed annotation that carries it, which may be a superclass or an enclosing class of the test class. A binding answers from the same search as
find(Class), so the two never name different declarations.- Parameters:
annotationType- The annotation to find the declaring class of.- Returns:
- The declaring class, or the test class itself when the test has no such annotation.
-