ExternalResources { public static void copyExternalResource(File sourceFile, File destFile) throws IOException { if (!destFile.exists()) { destFile.createNewFile(); } FileChannel source = null; FileChannel destination = null; try { source = new FileInputStream(sourceFile).getChannel(); destination = new FileOutputStream(destFile).getChannel(); destination.transferFrom(source, 0, source.size()); } finally { closeQuietly(source); closeQuietly(destination); } } private  ExternalResources(); static void copyExternalResource(File sourceFile, File destFile); static String getConfiguredTemplate(String templatePath, String templateProperty);  }
@Test public void testcopyExternalResource() { try { ExternalResources.copyExternalResource(sourceFile, destFile); } catch (IOException e) { } }
@Test public void testcopyExternalResource_fileNotFound() { try { badFile = new File("/tmp/nofile.sql"); ExternalResources.copyExternalResource(badFile, destFile); } catch (IOException e) { assertTrue(e instanceof FileNotFoundException); } }
@Test public void testcopyExternalResource_emptyStringAsFile() { try { badFile = new File(" "); ExternalResources.copyExternalResource(badFile, destFile); } catch (Exception e) { assertTrue(e instanceof FileNotFoundException); } }