diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java index bd6bea3..15a00d2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java @@ -35,6 +35,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.RawLocalFileSystem; @@ -49,6 +50,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; public class TestFileSystemApplicationHistoryStore extends ApplicationHistoryStoreTestUtils { @@ -271,7 +273,9 @@ public void testInitExistingWorkingDirectoryInSafeMode() throws Exception { // Setup file system to inject startup conditions FileSystem fs = spy(new RawLocalFileSystem()); - doReturn(true).when(fs).isDirectory(any(Path.class)); + FileStatus fileStatus = Mockito.mock(FileStatus.class); + doReturn(true).when(fileStatus).isDirectory(); + doReturn(fileStatus).when(fs).getFileStatus(any(Path.class)); try { initAndStartStore(fs); @@ -280,7 +284,7 @@ public void testInitExistingWorkingDirectoryInSafeMode() throws Exception { } // Make sure that directory creation was not attempted - verify(fs, never()).isDirectory(any(Path.class)); + verify(fileStatus, never()).isDirectory(); verify(fs, times(1)).mkdirs(any(Path.class)); } @@ -291,7 +295,9 @@ public void testInitNonExistingWorkingDirectoryInSafeMode() throws Exception { // Setup file system to inject startup conditions FileSystem fs = spy(new RawLocalFileSystem()); - doReturn(false).when(fs).isDirectory(any(Path.class)); + FileStatus fileStatus = Mockito.mock(FileStatus.class); + doReturn(false).when(fileStatus).isDirectory(); + doReturn(fileStatus).when(fs).getFileStatus(any(Path.class)); doThrow(new IOException()).when(fs).mkdirs(any(Path.class)); try { @@ -302,7 +308,7 @@ public void testInitNonExistingWorkingDirectoryInSafeMode() throws Exception { } // Make sure that directory creation was attempted - verify(fs, never()).isDirectory(any(Path.class)); + verify(fileStatus, never()).isDirectory(); verify(fs, times(1)).mkdirs(any(Path.class)); } }