use of org.reflections.util.FilterBuilder in project metron by apache.
the class ClasspathFunctionResolverTest method testInvalidStellarClass.
@Test
public void testInvalidStellarClass() {
StellarFunction goodFunc = mock(StellarFunction.class);
StellarFunction badFunc = mock(StellarFunction.class);
ClasspathFunctionResolver resolver = new ClasspathFunctionResolver() {
@Override
protected Iterable<Class<?>> getStellarClasses(ClassLoader cl) {
return ImmutableList.of(goodFunc.getClass(), badFunc.getClass());
}
@Override
protected boolean includeClass(Class<?> c, FilterBuilder filterBuilder) {
if (c != goodFunc.getClass()) {
throw new LinkageError("failed!");
}
return true;
}
};
Set<Class<? extends StellarFunction>> funcs = resolver.resolvables();
assertEquals(1, funcs.size());
assertEquals(goodFunc.getClass(), Iterables.getFirst(funcs, null));
}
use of org.reflections.util.FilterBuilder in project reflections by ronmamo.
the class FilterBuilderTest method test_excludePackage.
@Test
public void test_excludePackage() {
FilterBuilder filter = new FilterBuilder().excludePackage("org.reflections");
assertFalse(filter.apply("org.reflections.Reflections"));
assertFalse(filter.apply("org.reflections.foo.Reflections"));
assertTrue(filter.apply("org.foobar.Reflections"));
}
use of org.reflections.util.FilterBuilder in project reflections by ronmamo.
the class FilterBuilderTest method test_parsePackages_exclude.
@Test
public void test_parsePackages_exclude() {
FilterBuilder filter = FilterBuilder.parsePackages("-org.reflections");
assertFalse(filter.apply("org.reflections.Reflections"));
assertFalse(filter.apply("org.reflections.foo.Reflections"));
assertTrue(filter.apply("org.foobar.Reflections"));
assertTrue(filter.apply("org.reflectionsplus.Reflections"));
}
use of org.reflections.util.FilterBuilder in project reflections by ronmamo.
the class FilterBuilderTest method test_parse_exclude_notRegex.
@Test
public void test_parse_exclude_notRegex() {
FilterBuilder filter = FilterBuilder.parse("-org.reflections");
assertTrue(filter.apply("org.reflections.Reflections"));
assertTrue(filter.apply("org.reflections.foo.Reflections"));
assertTrue(filter.apply("org.foobar.Reflections"));
assertTrue(filter.apply("org.reflectionsplus.Reflections"));
}
use of org.reflections.util.FilterBuilder in project reflections by ronmamo.
the class FilterBuilderTest method test_parsePackages_exclude_trailingDot.
@Test
public void test_parsePackages_exclude_trailingDot() {
FilterBuilder filter = FilterBuilder.parsePackages("-org.reflections.");
assertFalse(filter.apply("org.reflections.Reflections"));
assertFalse(filter.apply("org.reflections.foo.Reflections"));
assertTrue(filter.apply("org.foobar.Reflections"));
assertTrue(filter.apply("org.reflectionsplus.Reflections"));
}
Aggregations