I then realized that perhaps I should not rely on the assumption mtime1 == mtime2 in the first place.
Mingliang Liu, if I'm reading the test correctly, the test never checks that mtime1 == mtime2. It calls doFsStat() on both the file and directory, but checks the directory time against mtime1 and then the file against mtime2. I agree that the file status and directory status are generally free to be different, which is why I kept the file open so that they would be equal in this case (file created in directory, no other operations). It was slightly peculiar to me that we were testing the modification time of the directory (mtime2) against the modification time of the file, but it works in this contrived case.
The easier way to fix this test would be to change testDir1 to testFile2 in the following line
final FileStatus status2 = dfs.getFileStatus(testDir1);
It no longer tests that the directory gets modified when a file is created, but I don't believe that is the goal of this test.