From a11bb2a933ad799546e7179fdf6ce75e3e22d44b Mon Sep 17 00:00:00 2001 From: Nick Dimiduk Date: Wed, 9 Sep 2015 11:08:28 -0700 Subject: [PATCH] HBASE-14382 TestInterfaceAudienceAnnotations should hadoop-compt module resources --- .../hbase/TestInterfaceAudienceAnnotations.java | 8 ++++++-- .../org/apache/hadoop/hbase/ClassFinder.java | 17 ++++++++++++++++- .../apache/hadoop/hbase/ClassTestFinder.java | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java index be79278cc31..0e0fbb024a8 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java @@ -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()), diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassFinder.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassFinder.java index d46537c1dd1..01d387c5fb8 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassFinder.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassFinder.java @@ -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() { diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassTestFinder.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassTestFinder.java index 5d4d9417719..9d5618b287e 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassTestFinder.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/ClassTestFinder.java @@ -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");