public static void rename(FileSystem fs, String oldName, String newName)
    throws IOException {
    Path oldDir = new Path(oldName);
    Path newDir = new Path(newName);
    if (!fs.rename(oldDir, newDir)) {
      throw new IOException("Could not rename " + oldDir + " to " + newDir);
    }
  }
@Test
  public void testRename() {
    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);
      writer = createWriter(OLD_FILE_NAME, IntWritable.class, IntWritable.class);
      writer.close();
      MapFile.rename(fs, new Path(TEST_DIR, OLD_FILE_NAME).toString(), 
          new Path(TEST_DIR, NEW_FILE_NAME).toString());
      MapFile.delete(fs, new Path(TEST_DIR, NEW_FILE_NAME).toString());
    } catch (IOException ex) {
      fail("testRename error " + ex);
    } finally {
      IOUtils.cleanupWithLogger(LOG, writer);
    }
  }