Tolerate jar files with no manifest in ChangeableUrls

Closes gh-5704
This commit is contained in:
Andy Wilkinson
2016-04-15 17:11:41 +01:00
parent a2f482b7f3
commit 1fbd43bdf0
2 changed files with 23 additions and 12 deletions

View File

@@ -24,6 +24,7 @@ import java.net.URLClassLoader;
import java.util.jar.Attributes;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipOutputStream;
import org.junit.Rule;
import org.junit.Test;
@@ -80,7 +81,7 @@ public class ChangeableUrlsTests {
File relative = this.temporaryFolder.newFolder();
ChangeableUrls urls = ChangeableUrls.fromUrlClassLoader(new URLClassLoader(
new URL[] { makeJarFileWithUrlsInManifestClassPath(projectCore,
projectWeb, relative.getName() + "/") }));
projectWeb, relative.getName() + "/"), makeJarFileWithNoManifest() }));
assertThat(urls.toList(),
contains(projectCore, projectWeb, relative.toURI().toURL()));
}
@@ -105,4 +106,10 @@ public class ChangeableUrlsTests {
return classpathJar.toURI().toURL();
}
private URL makeJarFileWithNoManifest() throws Exception {
File classpathJar = this.temporaryFolder.newFile("no-manifest.jar");
new ZipOutputStream(new FileOutputStream(classpathJar)).close();
return classpathJar.toURI().toURL();
}
}