From 9c2f1f7a2b0dc4eab57e7b7747791adb0e5bd89a Mon Sep 17 00:00:00 2001 From: Adam <37170106+hsiangawang@users.noreply.github.com> Date: Thu, 10 Dec 2020 08:28:21 -0600 Subject: [PATCH] HBASE-25370 Fix flaky test TestClassFinder#testClassFinderDefaultsToOwnPackage (#2740) Signed-off-by: Duo Zhang --- hbase-common/pom.xml | 5 +++++ .../java/org/apache/hadoop/hbase/TestClassFinder.java | 8 ++++++-- pom.xml | 2 -- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hbase-common/pom.xml b/hbase-common/pom.xml index cc0905a3bd1..de4a22ef19d 100644 --- a/hbase-common/pom.xml +++ b/hbase-common/pom.xml @@ -210,6 +210,11 @@ compile true + + org.hamcrest + hamcrest-library + test + org.mockito mockito-core diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java index b1c09032247..cf97e313cf0 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestClassFinder.java @@ -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> pkgClasses = allClassesFinder.findClasses( ClassFinder.class.getPackage().getName(), false); Set> 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 { diff --git a/pom.xml b/pom.xml index bb0cb75f8d5..0803b1a6ed4 100755 --- a/pom.xml +++ b/pom.xml @@ -2114,13 +2114,11 @@ org.hamcrest hamcrest-core ${hamcrest.version} - test org.hamcrest hamcrest-library ${hamcrest.version} - test org.mockito