### Question:
VirtualDirTgz extends VirtualDir { File createTargetDirInTemp(String name) throws IOException { File tempDir = getTempDir(); File targetDir = new File(tempDir, name); if (!targetDir.exists()) { if (!targetDir.mkdirs()) { throw new IOException("unable to create directory: " + targetDir.getAbsolutePath()); } } return targetDir; } VirtualDirTgz(File tgz); @Override String getBasePath(); @Override InputStream getInputStream(String path); @Override File getFile(String path); @Override String[] list(String path); @Override void close(); @Override boolean isCompressed(); @Override boolean isArchive(); @Override void finalize(); File getTempDir();  }### Answer:
@Test public void testCreateTargetDirInTemp_fromSystemPropertyTmpDir() throws IOException { final String tempDirName = System.getProperty("java.io.tmpdir"); assertNotNull(tempDirName); File dirInTemp = null; try { final File testTgz = TestUtil.getTestFile("tgz/test-archive.tgz"); virtualDir = new VirtualDirTgz(testTgz); dirInTemp = virtualDir.createTargetDirInTemp("wurst"); assertNotNull(dirInTemp); assertTrue(dirInTemp.isDirectory()); assertEquals(new File(tempDirName, "wurst").getAbsolutePath(), dirInTemp.getAbsolutePath()); } finally { if (dirInTemp != null) { FileUtils.deleteTree(dirInTemp); } } }
@Test public void testCreateTargetDirInTemp_fromSystemPropertyUserHome() throws IOException { final String oldTempDir = System.getProperty("java.io.tmpdir"); System.clearProperty("java.io.tmpdir"); final String userHome = System.getProperty("user.home"); assertNotNull(userHome); File dirInTemp = null; try { final File testTgz = TestUtil.getTestFile("tgz/test-archive.tgz"); virtualDir = new VirtualDirTgz(testTgz); dirInTemp = virtualDir.createTargetDirInTemp("Schneck"); assertNotNull(dirInTemp); assertTrue(dirInTemp.isDirectory()); assertEquals(new File(userHome, ".beam/temp/Schneck").getAbsolutePath(), dirInTemp.getAbsolutePath()); } finally { System.setProperty("java.io.tmpdir", oldTempDir); if (dirInTemp != null) { FileUtils.deleteTree(dirInTemp); } } }