Hi all,
I was bit by a bug that caused ReflectiveFactoryMatcher to miss
factory methods that return a subclass of Matcher. That is, I believe
this test should pass:
public static class SubclassOfMatcher {
@Factory
public static BaseMatcher subclassMethod() {
return null;
}
}
public void testCatchesSubclasses() {
Iterable<FactoryMethod> reader = new
ReflectiveFactoryReader(SubclassOfMatcher.class);
Iterator<FactoryMethod> methods = reader.iterator();
assertTrue("Expected first method", methods.hasNext());
}
And I think all it takes to do it is reversing the way that
isAssignableFrom is used in ReflectiveFactoryMatcher:
protected boolean isFactoryMethod(Method javaMethod) {
return isStatic(javaMethod.getModifiers())
&& isPublic(javaMethod.getModifiers())
&& javaMethod.getAnnotation(Factory.class) != null
&& Matcher.class.isAssignableFrom(javaMethod.getReturnType());
}
Original issue reported on code.google.com by david.s...@gmail.com on 22 Dec 2006 at 4:00
Original issue reported on code.google.com by
david.s...@gmail.com
on 22 Dec 2006 at 4:00