FileSupport { public static boolean supportsLinking(File sourceLocation, File targetLocation) { final Path sourcePath = requireNonNull(sourceLocation).toPath(); final Path targetPath = requireNonNull(targetLocation).toPath(); if (!exists(sourcePath)) throw new IllegalArgumentException(format("Source %s does not exist", sourcePath)); logger.debug("Creating hard link from {} to {}", sourcePath, targetPath); try { deleteIfExists(targetPath); createLink(targetPath, sourcePath); } catch (Exception e) { logger.debug("Unable to create a link from {} to {}: {}", sourcePath, targetPath, e); return false; } return true; } private  FileSupport(); static File copy(File sourceLocation, File targetLocation); static File copy(File sourceFile, File targetFile, boolean overwrite); static File link(File sourceLocation, File targetLocation); static File link(final File sourceLocation, final File targetLocation, final boolean overwrite); static boolean supportsLinking(File sourceLocation, File targetLocation); static boolean deleteHierarchyIfEmpty(File limit, File start); static boolean isEqual(File a, File b); static boolean isParent(File a, File b); static boolean delete(File f); static boolean deleteQuietly(File f); static boolean deleteQuietly(File f, boolean recurse); static boolean delete(File f, boolean recurse); static boolean delete(File dir, int mode); static void setTempDirectory(File tmpDir); static File getTempDirectory(); static File getTempDirectory(String subdir); static final int DELETE_FILES; static final int DELETE_ROOT; }
@Test public void supportsLinkingReturnsTrueOnAppropriateFile() { assertTrue(FileSupport.supportsLinking(fileToLink, linkLocation)); }
@Test(expected = IllegalArgumentException.class) public void supportsLinkingReturnsFalseOnMissingFile() { FileSupport.supportsLinking(linkLocation, fileToLink); }