@Test
  public void testCopyWithDistcp() throws IOException {
    String file1Name = "file1.txt";
    String file2Name = "file2.txt";
    Path copySrc = new Path(basePath, "copySrc");
    Path copyDst = new Path(basePath, "copyDst");
    Path srcFile1 = new Path(basePath, new Path(copySrc, file1Name));
    Path srcFile2 = new Path(basePath, new Path(copySrc, file2Name));
    try {
      OutputStream os1 = fs.create(srcFile1);
      os1.write(new byte[]{1, 2, 3});
      os1.close();

      OutputStream os2 = fs.create(srcFile2);
      os2.write(new byte[]{1, 2, 3});
      os2.close();

      conf.set(HiveConf.ConfVars.HIVE_EXEC_COPYFILE_MAXNUMFILES.varname, "1");
      conf.set(HiveConf.ConfVars.HIVE_EXEC_COPYFILE_MAXSIZE.varname, "1");
      DataCopyStatistics copyStatistics = new DataCopyStatistics();
      Assert.assertTrue("FileUtils.copy failed to copy data",
              FileUtils.copy(fs, copySrc, fs, copyDst, false, false, conf, copyStatistics));
      Assert.assertEquals(6, copyStatistics.getBytesCopied());

      Path dstFileName1 = new Path(copyDst, file1Name);
      Assert.assertTrue(fs.exists(new Path(copyDst, file1Name)));
      Assert.assertEquals(fs.getFileStatus(dstFileName1).getLen(), 3);

      Path dstFileName2 = new Path(copyDst, file2Name);
      Assert.assertTrue(fs.exists(new Path(copyDst, file2Name)));
      Assert.assertEquals(fs.getFileStatus(dstFileName2).getLen(), 3);
    } finally {
      try {
        fs.delete(copySrc, true);
        fs.delete(copyDst, true);
      } catch (IOException e) {
        // Do nothing
      }
    }
  }
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