@Test public void vfsFromDirWithinAJarUrl() throws MalformedURLException { URL directoryInJarUrl = ClasspathHelper.forClass(String.class); assertTrue(directoryInJarUrl.toString().startsWith("jar:file:")); assertTrue(directoryInJarUrl.toString().contains(".jar!")); String directoryInJarPath = directoryInJarUrl.toExternalForm().replaceFirst("jar:", ""); int start = directoryInJarPath.indexOf(":") + 1; int end = directoryInJarPath.indexOf(".jar!") + 4; String expectedJarFile = directoryInJarPath.substring(start, end); Vfs.Dir dir = Vfs.fromURL(new URL(directoryInJarPath)); assertEquals(ZipDir.class, dir.getClass()); assertEquals(expectedJarFile, dir.getPath()); }
public TmpDir(File tmpDirFile) throws IOException { this.tmpDirFile = tmpDirFile; this.zipDir = new ZipDir(new JarFile(tmpDirFile)); }