@Test public void testGetStream() throws Exception { URL urlArchives = getClass().getResource("."); String root = new File(urlArchives.toURI()).getAbsolutePath(); String path = root + "/ar-with-dir-and-ar-with-config-dir.zip!/ar-without-dir.zip!/foo/foo.xml"; URL url = Archive.parse(path); try { getContent(url); fail("A FileNotFoundException was expected"); } catch (FileNotFoundException e) { } path = root + "/ar-with-dir-and-ar-with-config-dir.zip!/ar-without-dir.zip!/foo"; url = Archive.parse(path); try { getContent(url); fail("A IOException was expected"); } catch (IOException e) { } path = root + "/dir-without-ext/foo/config.xml"; url = Archive.parse(path); String contentRef = getContent(url); assertNotNull(contentRef); assertFalse(contentRef.isEmpty()); path = root + "/ar-without-dir.zip!/foo/config.xml"; url = Archive.parse(path); String content = getContent(url); assertNotNull(content); assertFalse(content.isEmpty()); assertEquals(linearize(contentRef), linearize(content)); path = root + "/ar-with-dir-and-ar-with-config-dir.zip!/ar-without-dir.zip!/foo/config.xml"; url = Archive.parse(path); content = getContent(url); assertNotNull(content); assertFalse(content.isEmpty()); assertEquals(linearize(contentRef), linearize(content)); }
static URL parse(String path2Convert) throws MalformedURLException { if (File.separatorChar != '/') path2Convert = path2Convert.replace(File.separatorChar, '/'); if (!path2Convert.startsWith("/")) path2Convert = "/" + path2Convert; return new URL(Archive.PROTOCOL, null, -1, path2Convert, Archive.HANDLER); }
Archive { static URL parse(String path2Convert) throws MalformedURLException { if (File.separatorChar != '/') path2Convert = path2Convert.replace(File.separatorChar, '/'); if (!path2Convert.startsWith("/")) path2Convert = "/" + path2Convert; return new URL(Archive.PROTOCOL, null, -1, path2Convert, Archive.HANDLER); } }
Archive { static URL parse(String path2Convert) throws MalformedURLException { if (File.separatorChar != '/') path2Convert = path2Convert.replace(File.separatorChar, '/'); if (!path2Convert.startsWith("/")) path2Convert = "/" + path2Convert; return new URL(Archive.PROTOCOL, null, -1, path2Convert, Archive.HANDLER); } Archive(String type, boolean useDirWoExt, boolean allowsDir, Set<Archive> subArchives); }
Archive { static URL parse(String path2Convert) throws MalformedURLException { if (File.separatorChar != '/') path2Convert = path2Convert.replace(File.separatorChar, '/'); if (!path2Convert.startsWith("/")) path2Convert = "/" + path2Convert; return new URL(Archive.PROTOCOL, null, -1, path2Convert, Archive.HANDLER); } Archive(String type, boolean useDirWoExt, boolean allowsDir, Set<Archive> subArchives); String getType(); boolean isUseDirWoExt(); boolean isAllowsDir(); Set<Archive> getSubArchives(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static Collection<URL> getConfigurationURL(List<String> appDeployDirectories,
      Set<Archive> appDeployArchives, String configuration); static URL createArchiveURL(String url); static boolean isArchiveURL(String url); }
Archive { static URL parse(String path2Convert) throws MalformedURLException { if (File.separatorChar != '/') path2Convert = path2Convert.replace(File.separatorChar, '/'); if (!path2Convert.startsWith("/")) path2Convert = "/" + path2Convert; return new URL(Archive.PROTOCOL, null, -1, path2Convert, Archive.HANDLER); } Archive(String type, boolean useDirWoExt, boolean allowsDir, Set<Archive> subArchives); String getType(); boolean isUseDirWoExt(); boolean isAllowsDir(); Set<Archive> getSubArchives(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static Collection<URL> getConfigurationURL(List<String> appDeployDirectories,
      Set<Archive> appDeployArchives, String configuration); static URL createArchiveURL(String url); static boolean isArchiveURL(String url); static final String PROTOCOL; static final Archive WAR; static final Archive EAR; }