HBASE-25370 Fix flaky test TestClassFinder#testClassFinderDefaultsToOwnPackage (#2740)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
Adam 2020-12-10 08:28:21 -06:00 committed by GitHub
parent 635c911532
commit c62c18dca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -211,6 +211,11 @@
<scope>compile</scope> <scope>compile</scope>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>

View File

@ -17,6 +17,8 @@
*/ */
package org.apache.hadoop.hbase; package org.apache.hadoop.hbase;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -295,7 +297,10 @@ public class TestClassFinder {
Set<Class<?>> pkgClasses = allClassesFinder.findClasses( Set<Class<?>> pkgClasses = allClassesFinder.findClasses(
ClassFinder.class.getPackage().getName(), false); ClassFinder.class.getPackage().getName(), false);
Set<Class<?>> defaultClasses = allClassesFinder.findClasses(false); Set<Class<?>> defaultClasses = allClassesFinder.findClasses(false);
assertArrayEquals(pkgClasses.toArray(), defaultClasses.toArray()); Object[] pkgClassesArray = pkgClasses.toArray();
Object[] defaultClassesArray = defaultClasses.toArray();
assertEquals(pkgClassesArray.length, defaultClassesArray.length);
assertThat(pkgClassesArray, arrayContainingInAnyOrder(defaultClassesArray));
} }
private static class FileAndPath { private static class FileAndPath {