source: class TestMapFile {
  
    private static final Path TEST_DIR;
    private static Configuration conf;
    private static final Progressable defaultProgressable;
    private static final CompressionCodec defaultCodec;
  
    @Test
    public void testRenameWithFalse() {
  
target:     final String ERROR_MESSAGE = "Could not rename";
      final String NEW_FILE_NAME = "test-new.mapfile";
      final String OLD_FILE_NAME = "test-old.mapfile";
      MapFile.Writer writer = null;
      try {
        FileSystem fs = FileSystem.getLocal(conf);
        FileSystem spyFs = spy(fs);
  
        writer = createWriter(OLD_FILE_NAME, IntWritable.class, IntWritable.class);
        writer.close();
  
        Path oldDir = new Path(TEST_DIR, OLD_FILE_NAME);
        Path newDir = new Path(TEST_DIR, NEW_FILE_NAME);
        when(spyFs.rename(oldDir, newDir)).thenReturn(false);
  
        MapFile.rename(spyFs, oldDir.toString(), newDir.toString());
        fail("testRenameWithException no exception error !!!");
      } catch (IOException ex) {
        assertTrue("testRenameWithFalse invalid IOExceptionMessage error !!!", ex
            .getMessage().startsWith(ERROR_MESSAGE));
      } finally {
        IOUtils.cleanup(null, writer);
      }
    }
  
  }