Skip to content
Snippets Groups Projects
Commit ef43331c authored by felmer's avatar felmer
Browse files

PackageBasedIndexedEntityFinder fixed by ignoring test classes. This fixes the...

PackageBasedIndexedEntityFinder fixed by ignoring test classes. This fixes the bug in integration tests.

SVN: 27959
parent f1341e39
No related branches found
No related tags found
No related merge requests found
......@@ -57,5 +57,11 @@ public final class ClassFilterUtils
{
return true;
}
@Override
public boolean accept(String fullyQualifiedClassName)
{
return true;
}
}
}
......@@ -421,11 +421,14 @@ public final class ClassUtils
{
try
{
final Class<?> clazz =
org.apache.commons.lang.ClassUtils.getClass(className, false);
if (classFilter.accept(clazz))
if (classFilter.accept(className))
{
classes.add(clazz);
final Class<?> clazz =
org.apache.commons.lang.ClassUtils.getClass(className, false);
if (classFilter.accept(clazz))
{
classes.add(clazz);
}
}
} catch (final ClassNotFoundException ex)
{
......
......@@ -27,4 +27,12 @@ public interface IClassFilter
* Tests whether or not the specified <var>clazz</var> should be included.
*/
public boolean accept(final Class<?> clazz);
/**
* Returns <code>true</code> if the specified class is accepted. This method is call before
* {@link #accept(Class)}. It should return <code>false</code> if the class can not be loaded.
* If <code>true</code> is returned also {@link #accept(Class)} will be invoked which will give
* the definite answer.
*/
public boolean accept(String fullyQualifiedClassName);
}
......@@ -258,6 +258,12 @@ public final class ClassUtilsTest
{
return clazz.equals(SuiteSlave.class) == false;
}
@Override
public boolean accept(String fullyQualifiedClassName)
{
return true;
}
});
assertTrue(classes.size() > 0);
assertFalse(classes.contains(Test.class));
......
......@@ -26,7 +26,8 @@ import ch.systemsx.cisd.common.reflection.ClassUtils;
import ch.systemsx.cisd.common.reflection.IClassFilter;
/**
* A {@link IIndexedEntityFinder} based on a package name specified in the constructor.
* A {@link IIndexedEntityFinder} based on a package name specified in the constructor. Classes
* ending with <code>Test</code> will be ignored.
* <p>
* This does not work recursively and expects to find all the correctly annotated classes in the
* given package.
......@@ -53,6 +54,12 @@ public final class PackageBasedIndexedEntityFinder implements IIndexedEntityFind
// IClassFilter
//
@Override
public boolean accept(String fullyQualifiedClassName)
{
return fullyQualifiedClassName.endsWith("Test") == false;
}
@Override
public final boolean accept(final Class<?> clazz)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment