use of org.apache.xbean.finder.archive.ClassesArchive in project geronimo-xbean by apache.
the class AnnotatedParametersTest method testFindAnnotatedMethodParameters.
@Test
public void testFindAnnotatedMethodParameters() {
final AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(FullyAnnotated.class, NotAnnotated.class));
List<Parameter<Method>> methodParameters = finder.findAnnotatedMethodParameters(ParamA.class);
assertEquals(1, methodParameters.size());
Parameter<Method> parameter = methodParameters.get(0);
assertEquals(0, parameter.getIndex());
assertEquals(FullyAnnotated.class, parameter.getDeclaringExecutable().getDeclaringClass());
assertEquals("setMoreStrings", parameter.getDeclaringExecutable().getName());
assertEquals(1, parameter.getDeclaringExecutable().getParameterTypes().length);
assertEquals(String[][].class, parameter.getDeclaringExecutable().getParameterTypes()[0]);
assertTrue(parameter.isAnnotationPresent(ParamA.class));
}
use of org.apache.xbean.finder.archive.ClassesArchive in project geronimo-xbean by apache.
the class AnnotatedParametersTest method testFindAnnotatedConstructorParameters.
@Test
public void testFindAnnotatedConstructorParameters() {
final AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(FullyAnnotated.class, NotAnnotated.class));
List<Parameter<Constructor<?>>> constructorParameters = finder.findAnnotatedConstructorParameters(ParamA.class);
assertEquals(1, constructorParameters.size());
Parameter<Constructor<?>> parameter = constructorParameters.get(0);
assertEquals(0, parameter.getIndex());
assertEquals(FullyAnnotated.class, parameter.getDeclaringExecutable().getDeclaringClass());
assertEquals(2, parameter.getDeclaringExecutable().getParameterTypes().length);
assertEquals(String.class, parameter.getDeclaringExecutable().getParameterTypes()[0]);
assertEquals(int.class, parameter.getDeclaringExecutable().getParameterTypes()[1]);
assertTrue(parameter.isAnnotationPresent(ParamA.class));
}
use of org.apache.xbean.finder.archive.ClassesArchive in project geronimo-xbean by apache.
the class ClassFinderDepthTest method testFindAnnotatedInterfaceImplementationsAfterGet.
public void testFindAnnotatedInterfaceImplementationsAfterGet() {
for (int i = 0; i < 10; i++) {
final ClassesArchive archive = new ClassesArchive(TargetImpl.class);
for (final AnnotationFinder finder : new AnnotationFinder[] { new AnnotationFinder(archive) }) {
assertEquals(Collections.singletonList(TargetImpl.class), finder.findAnnotatedClasses(Deprecated.class));
finder.link();
assertImplementations(finder, java.lang.annotation.Target.class, TargetImpl.class);
}
}
}
use of org.apache.xbean.finder.archive.ClassesArchive in project geronimo-xbean by apache.
the class FinderSelectTest method test.
@Test
public void test() throws Exception {
final AnnotationFinder all = new AnnotationFinder(new ClassesArchive(Red.class, Green.class, Blue.class));
final AnnotationFinder finder = all.select(Red.class.getName());
final List<Class<?>> classes = finder.findAnnotatedClasses(Color.class);
for (Class<?> aClass : classes) {
System.out.println(aClass);
}
}
use of org.apache.xbean.finder.archive.ClassesArchive in project geronimo-xbean by apache.
the class ClassAnnotationFinderTest method checkClassAnnotationOnMethod.
@Test
public void checkClassAnnotationOnMethod() throws Exception {
final AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(ClassAnnotatedClass.class, NotAnnotated.class), false);
final List<Method> annotations = finder.findAnnotatedMethods(ClassAnnotation.class);
assertEquals(1, annotations.size());
assertEquals(ClassAnnotatedClass.class.getDeclaredMethod("green"), annotations.get(0));
}
Aggregations