### Question:
Directory implements Serializable { static File relativePath(final File from, final File to, final boolean mustBeChild) { final String[] fromPaths; final String[] toPaths; try { fromPaths = splitPath(from.getCanonicalPath()); toPaths = splitPath(to.getCanonicalFile().getPath()); } catch (final IOException e) { throw new UnexpectedIOException(e); } int i = 0; while (i < fromPaths.length && i < toPaths.length && fromPaths[i].equals(toPaths[i])) { ++i; } if (mustBeChild && i != fromPaths.length) { return null; } if (i <= 1) { return null; } final StringBuilder result = new StringBuilder(); for (int j = i; j < fromPaths.length; ++j) { result.append(".."); result.append(File.separator); } for (int j = i; j < toPaths.length; ++j) { result.append(toPaths[j]); if (j != toPaths.length - 1) { result.append(File.separator); } } if (result.length() == 0) { return new File("."); } return new File(result.toString()); } Directory();  Directory(final File directory); static FileFilter getMatchAllFilesFilter(); void create(); File getFile(); File getFile(final File child); File[] listContents(final FileFilter filter); File[] listContents(final FileFilter filter,
                             final boolean includeDirectories,
                             final boolean absolutePaths); void deleteContents(); void delete(); File rebaseFromCWD(final File file); File relativeFile(final File file, final boolean mustBeChild); List<File> rebasePath(final String path); boolean isParentOf(final File file); void copyTo(final Directory target, final boolean incremental); String[] getWarnings(); @Override int hashCode(); @Override boolean equals(final Object o);  }### Answer:
@Test public void testRelativePathNotChild1() throws IOException { final File f1 = fromPath("a", "b", "c"); final File f2 = fromPath("a", "b", "x", "y"); assertEquals(".." + File.separator + "x" + File.separator + "y", Directory.relativePath(f1, f2, false).getPath()); }
@Test public void testRelativePathNotChild2() throws IOException { final File f1 = fromPath("a", "b", "c"); final File f2 = fromPath("a", "b", "x", "y"); assertNull(Directory.relativePath(f1, f2, true)); }
@Test public void testRelativePathDifferentFS1() throws IOException { final File f1 = fromPath("/", "x", "y", "z"); final File f2 = fromPath("/", "a", "b"); assertNull(Directory.relativePath(f1, f2, false)); }
@Test public void testRelativePathDifferentFS2() throws IOException { final File f1 = fromPath("/", "x", "y", "z"); final File f2 = fromPath("/", "a", "b"); assertNull(Directory.relativePath(f1, f2, true)); }
@Test public void testRelativePathDot1() throws IOException { final File f1 = fromPath("."); final File f2 = fromPath("."); assertEquals(".", Directory.relativePath(f1, f2, false).getPath()); }
@Test public void testRelativePathDot2() throws IOException { final File f1 = fromPath("."); final File f2 = fromPath("."); assertEquals(".", Directory.relativePath(f1, f2, true).getPath()); }