24
24
import java .util .jar .Attributes ;
25
25
import java .util .jar .JarOutputStream ;
26
26
import java .util .jar .Manifest ;
27
+ import java .util .zip .ZipOutputStream ;
27
28
28
29
import org .junit .Rule ;
29
30
import org .junit .Test ;
@@ -76,9 +77,11 @@ public void urlsFromJarClassPathAreConsidered() throws Exception {
76
77
URL projectCore = makeUrl ("project-core" );
77
78
URL projectWeb = makeUrl ("project-web" );
78
79
File relative = this .temporaryFolder .newFolder ();
79
- ChangeableUrls urls = ChangeableUrls .fromUrlClassLoader (new URLClassLoader (
80
- new URL [] { makeJarFileWithUrlsInManifestClassPath (projectCore ,
81
- projectWeb , relative .getName () + "/" ) }));
80
+ ChangeableUrls urls = ChangeableUrls
81
+ .fromUrlClassLoader (new URLClassLoader (new URL [] {
82
+ makeJarFileWithUrlsInManifestClassPath (projectCore , projectWeb ,
83
+ relative .getName () + "/" ),
84
+ makeJarFileWithNoManifest () }));
82
85
assertThat (urls .toList ()).containsExactly (projectCore , projectWeb ,
83
86
relative .toURI ().toURL ());
84
87
}
@@ -103,4 +106,10 @@ private URL makeJarFileWithUrlsInManifestClassPath(Object... urls) throws Except
103
106
return classpathJar .toURI ().toURL ();
104
107
}
105
108
109
+ private URL makeJarFileWithNoManifest () throws Exception {
110
+ File classpathJar = this .temporaryFolder .newFile ("no-manifest.jar" );
111
+ new ZipOutputStream (new FileOutputStream (classpathJar )).close ();
112
+ return classpathJar .toURI ().toURL ();
113
+ }
114
+
106
115
}
0 commit comments