diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCache.java index a8d36e2e7b93..1f386d31aab3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCache.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCache.java @@ -18,12 +18,10 @@ package org.apache.hadoop.hbase.master.snapshot; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.*; -import com.google.common.collect.Iterables; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.fs.FileStatus; @@ -170,9 +168,7 @@ private void createAndTestSnapshot(final SnapshotFileCache cache, // Make sure that all files are still present for (Path path: files) { - Iterable nonSnapshotFiles = getNonSnapshotFiles(cache, path); - assertFalse("Cache didn't find " + path.getName(), - Iterables.contains(nonSnapshotFiles, path.getName())); + assertFalse("Cache didn't find " + path, contains(getNonSnapshotFiles(cache, path), path)); } FSUtils.logFileSystemState(fs, rootDir, LOG); @@ -183,9 +179,8 @@ private void createAndTestSnapshot(final SnapshotFileCache cache, // The files should be in cache until next refresh for (Path filePath: files) { - Iterable nonSnapshotFiles = getNonSnapshotFiles(cache, filePath); - assertFalse("Cache didn't find " + filePath.getName(), Iterables.contains(nonSnapshotFiles, - filePath.getName())); + assertFalse("Cache didn't find " + filePath, + contains(getNonSnapshotFiles(cache, filePath), filePath)); } // then trigger a refresh @@ -193,14 +188,22 @@ private void createAndTestSnapshot(final SnapshotFileCache cache, // and not it shouldn't find those files for (Path filePath: files) { - Iterable nonSnapshotFiles = getNonSnapshotFiles(cache, filePath); - assertTrue("Cache found '" + filePath.getName() + "', but it shouldn't have.", - !Iterables.contains(nonSnapshotFiles, filePath.getName())); + assertFalse("Cache found '" + filePath + "', but it shouldn't have.", + contains(getNonSnapshotFiles(cache, filePath), filePath)); } } } - private Iterable getNonSnapshotFiles(SnapshotFileCache cache, Path storeFile) + private static boolean contains(Iterable files, Path filePath) { + for (FileStatus status: files) { + if (filePath.equals(status.getPath())) { + return true; + } + } + return false; + } + + private static Iterable getNonSnapshotFiles(SnapshotFileCache cache, Path storeFile) throws IOException { return cache.getUnreferencedFiles( Arrays.asList(FSUtils.listStatus(fs, storeFile.getParent())), null