HBASE-14382 TestInterfaceAudienceAnnotations should hadoop-compt module resources

This commit is contained in:
Nick Dimiduk 2015-09-09 11:08:28 -07:00
parent 27d3ab43ef
commit a11bb2a933
3 changed files with 23 additions and 3 deletions

View File

@ -231,13 +231,15 @@ public class TestInterfaceAudienceAnnotations {
// find classes that are:
// In the main jar
// AND are not in a hadoop-compat module
// AND are public
// NOT test classes
// AND NOT generated classes
// AND are NOT annotated with InterfaceAudience
// AND are NOT from Clover rewriting sources
ClassFinder classFinder = new ClassFinder(
new MainCodeResourcePathFilter(),
new And(new MainCodeResourcePathFilter(),
new TestFileNameFilter()),
new Not((FileNameFilter)new TestFileNameFilter()),
new And(new PublicClassFilter(),
new Not(new TestClassFilter()),
@ -268,13 +270,15 @@ public class TestInterfaceAudienceAnnotations {
// find classes that are:
// In the main jar
// AND are not in a hadoop-compat module
// AND are public
// NOT test classes
// AND NOT generated classes
// AND are annotated with InterfaceAudience.Public
// AND NOT annotated with InterfaceStability
ClassFinder classFinder = new ClassFinder(
new MainCodeResourcePathFilter(),
new And(new MainCodeResourcePathFilter(),
new TestFileNameFilter()),
new Not((FileNameFilter)new TestFileNameFilter()),
new And(new PublicClassFilter(),
new Not(new TestClassFilter()),

View File

@ -85,9 +85,15 @@ public class ClassFinder {
}
}
public static class And implements ClassFilter {
public static class And implements ClassFilter, ResourcePathFilter {
ClassFilter[] classFilters;
ResourcePathFilter[] resourcePathFilters;
public And(ClassFilter...classFilters) { this.classFilters = classFilters; }
public And(ResourcePathFilter... resourcePathFilters) {
this.resourcePathFilters = resourcePathFilters;
}
@Override
public boolean isCandidateClass(Class<?> c) {
for (ClassFilter filter : classFilters) {
@ -97,6 +103,15 @@ public class ClassFinder {
}
return true;
}
@Override public boolean isCandidatePath(String resourcePath, boolean isJar) {
for (ResourcePathFilter filter : resourcePathFilters) {
if (!filter.isCandidatePath(resourcePath, isJar)) {
return false;
}
}
return true;
}
}
public ClassFinder() {

View File

@ -48,6 +48,7 @@ public class ClassTestFinder extends ClassFinder {
return new Class<?>[0];
}
/** Filters both test classes and anything in the hadoop-compat modules */
public static class TestFileNameFilter implements FileNameFilter, ResourcePathFilter {
private static final Pattern hadoopCompactRe =
Pattern.compile("hbase-hadoop\\d?-compat");