@Test
  public void testXAttrsPreserved() throws Exception {
    //Case 1) src and dst are files.
    Path src = new Path(basePath, "src.txt");
    fs.create(src).close();
    setXAttrsRecursive(src);
    Path dst = new Path(basePath, "dst.txt");
    Assert.assertFalse(fs.exists(dst));
    DataCopyStatistics copyStatistics = new DataCopyStatistics();
    Assert.assertTrue(FileUtils.doIOUtilsCopyBytes(fs, fs.getFileStatus(src), fs, dst, false, true, true, conf, copyStatistics));
    Assert.assertTrue(fs.exists(dst));
    verifyXAttrsPreserved(src, dst);
    //Case 2) src is file and dst directory does not exist.
    dst = new Path(basePath, "dummyDstDir");
    Assert.assertFalse(fs.exists(dst));
    copyStatistics = new DataCopyStatistics();
    Assert.assertTrue(FileUtils.doIOUtilsCopyBytes(fs, fs.getFileStatus(src), fs, dst, false, true, true, conf, copyStatistics));
    Assert.assertTrue(fs.exists(dst));
    Assert.assertTrue(fs.exists(new Path(dst, new Path(basePath, "src.txt"))));
    verifyXAttrsPreserved(src, dst);
    //Case 3) src is a file and dst directory exists.
    dst = new Path(basePath, "dummyDstDir1");
    fs.mkdirs(dst);
    Assert.assertTrue(fs.exists(dst));
    copyStatistics = new DataCopyStatistics();
    Assert.assertTrue(FileUtils.doIOUtilsCopyBytes(fs, fs.getFileStatus(src), fs, dst, false, true, true, conf, copyStatistics));
    Assert.assertTrue(fs.exists(dst));
    Assert.assertTrue(fs.exists(new Path(dst, "src.txt")));
    verifyXAttrsPreserved(src, new Path(dst, "src.txt"));
    //Case 4) src & dst are directories and dst does not exist.
    src = new Path(basePath, "dummySrcDir2");
    dst = new Path(basePath, "dummyDstDir2");
    fs.create(new Path(src, "src.txt"));
    setXAttrsRecursive(src);
    Assert.assertFalse(fs.exists(dst));
    copyStatistics = new DataCopyStatistics();
    Assert.assertTrue(FileUtils.doIOUtilsCopyBytes(fs, fs.getFileStatus(src), fs, dst, false, true, true, conf, copyStatistics));
    Assert.assertTrue(fs.exists(dst));
    Assert.assertTrue(fs.exists(new Path(dst, "src.txt")));
    verifyXAttrsPreserved(src, dst);
    //Case 5) src & dst are directories and dst directory exists
    src = new Path(basePath, "dummySrcDir3");
    dst = new Path(basePath, "dummyDstDir3");
    fs.create(new Path(src, "src.txt"));
    fs.mkdirs(dst);
    setXAttrsRecursive(src);
    Assert.assertTrue(fs.exists(dst));
    copyStatistics = new DataCopyStatistics();
    Assert.assertTrue(FileUtils.doIOUtilsCopyBytes(fs, fs.getFileStatus(src), fs, dst, false, true, true, conf, copyStatistics));
    Assert.assertTrue(fs.exists(new Path(dst, "dummySrcDir3/src.txt")));
    verifyXAttrsPreserved(src, new Path(dst, src.getName()));
  }
Integration tests for {{@link FileUtils}. Tests run against a {@link HadoopShims.MiniDFSShim}.
itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/common/TestFileUtils.java