### Question:
WinUtilsInstaller { public static File put(File directory) throws IOException { TemporaryFileInstaller installer = prepare(); assert installer != null; File file = new File(directory, TARGET_PREFIX + TARGET_SUFFIX); try { LOG.info(MessageFormat.format( "installing winutils.exe into default location: {0}", file)); installer.install(file, true); return file; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into the default location: {0}", file), e); } File temp = null; boolean success = false; try { temp = File.createTempFile(TARGET_PREFIX + '-', TARGET_SUFFIX, directory); LOG.info(MessageFormat.format( "installing winutils.exe into temporary location: {0}", temp)); installer.install(temp, false); temp.deleteOnExit(); success = true; return temp; } catch (IOException e) { LOG.debug(MessageFormat.format( "failed to install winutils into a temporary location: {0}", temp), e); } finally { if (success == false) { if (temp != null && temp.delete() == false) { LOG.warn(MessageFormat.format( "failed to delete a temporary file: {0}", temp)); } } } throw new IOException(MessageFormat.format( "error occurred while installing winutils: {0}", file)); } private  WinUtilsInstaller(); static boolean isTarget(); static boolean isAlreadyInstalled(); static File put(File directory); static void register(File executable);  }### Answer:
@Test public void simple() throws Exception { File folder = temporary.newFolder(); File file = WinUtilsInstaller.put(folder); assertThat(file.isFile(), is(true)); assertThat(file.getName(), endsWith(".exe")); assertThat(file.canExecute(), is(true)); assertThat(file.getCanonicalFile().getParentFile(), is(folder.getCanonicalFile())); }
@Test public void escape() throws Exception { File folder = temporary.newFolder(); File d = WinUtilsInstaller.put(folder); Assume.assumeTrue(d.delete()); Assume.assumeTrue(d.mkdirs() || d.isDirectory()); File file = WinUtilsInstaller.put(folder); assertThat(file.isFile(), is(true)); assertThat(file.getName(), endsWith(".exe")); assertThat(file.canExecute(), is(true)); assertThat(file.getCanonicalFile(), is(not(d.getCanonicalFile()))); }
@Test(expected = IOException.class) public void fail() throws Exception { File folder = temporary.newFolder(); folder.setWritable(false); Assume.assumeFalse(folder.canWrite()); try { WinUtilsInstaller.put(folder); } finally { folder.setWritable(true); } }