### Question:
PosixFileOperations { public static void recursiveCopy(File srcDir, File destDir) throws IOException { Process cpProc = Runtime.getRuntime().exec(new String[]{"cp", "-Lr", srcDir.getAbsolutePath(), destDir.getAbsolutePath()}, null); try { int result = cpProc.waitFor(); if (result != 0) { throw new IOException( formatWithStdStreams( cpProc, "error running cp process, exit code: " + result + "\nstdout:\n%s\nstderr:\n%s" )); } } catch (InterruptedException e) { log.error("exception during exec", e); throw new IOException("exec failed", e); } }  static void atomicLink(File target, File link); static void link(File target, File link); static void rmrf(File file); static void rmrf(Path path); static void cplr(File src, File dest); static void cplr(final Path src, final Path dest); static void recursiveCopy(File srcDir, File destDir); static void recursiveCopy(final Path src, final Path dest); static long du(File path); static String relativePath(String base, String path); static String relativePath(File base, File path); static String lsla(File file); static int getPID(); static boolean isProcessRunning(int pid, boolean assumeRunning); static Integer tryParseInt(String str); static Integer tryParseInt(String str, int radix);  }### Answer:
@Test public void testRecursiveCopy() throws IOException { final Path rootDir = tempDir.getRoot().toPath(); final Path aDir = Files.createDirectory(rootDir.resolve("a")); writeToFile(aDir.resolve("file1"), "file1"); writeToFile(aDir.resolve("file2"), "file2"); final Path bDir = Files.createDirectory(aDir.resolve("b")); writeToFile(bDir.resolve("file3"), "file3"); writeToFile(bDir.resolve("file4"), "file4"); final Path cDir = Files.createDirectory(aDir.resolve("c")); writeToFile(cDir.resolve("file5"), "file5"); writeToFile(cDir.resolve("file6"), "file6"); final Path dDir = Files.createDirectory(cDir.resolve("d")); writeToFile(dDir.resolve("file7"), "file7"); writeToFile(dDir.resolve("file8"), "file8"); { final CountFileVisitor countFileVisitor = new CountFileVisitor(); Files.walkFileTree(rootDir, countFileVisitor); Assert.assertEquals(5, countFileVisitor.dirs); Assert.assertEquals(8, countFileVisitor.files); } { final ConcatFileVisitor concatFileVisitor = new ConcatFileVisitor(); Files.walkFileTree(rootDir, concatFileVisitor); Collections.sort(concatFileVisitor.conents); Assert.assertEquals( Arrays.asList( "file1", "file2", "file3", "file4", "file5", "file6", "file7", "file8" ), concatFileVisitor.conents); } { final Path aDirCopy = rootDir.resolve("acopy"); PosixFileOperations.recursiveCopy(aDir, aDirCopy); { final ConcatFileVisitor concatFileVisitor = new ConcatFileVisitor(); Files.walkFileTree(aDirCopy, concatFileVisitor); Collections.sort(concatFileVisitor.conents); Assert.assertEquals( Arrays.asList( "file1", "file2", "file3", "file4", "file5", "file6", "file7", "file8" ), concatFileVisitor.conents); } writeToFile(aDir.resolve("file22"), "file22"); writeToFile(aDir.resolve("file2"), "file2-modified"); { final ConcatFileVisitor concatFileVisitor = new ConcatFileVisitor(); Files.walkFileTree(aDirCopy, concatFileVisitor); Collections.sort(concatFileVisitor.conents); Assert.assertEquals( Arrays.asList( "file1", "file2", "file3", "file4", "file5", "file6", "file7", "file8" ), concatFileVisitor.conents); } } }