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 Duo Zhang
parent 210d8a7b56
commit 9c2f1f7a2b
3 changed files with 11 additions and 4 deletions

View File

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

View File

@ -17,7 +17,8 @@
*/
package org.apache.hadoop.hbase;
import static org.junit.Assert.assertArrayEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -295,7 +296,10 @@ public class TestClassFinder {
Set<Class<?>> pkgClasses = allClassesFinder.findClasses(
ClassFinder.class.getPackage().getName(), 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 {

View File

@ -2114,13 +2114,11 @@
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>