"resources/install.oak/sub/five.jar"
};
private ClassLoader mockClassLoader(String ... paths) throws MalformedURLException, IOException {
final ClassLoader cl = Mockito.mock(ClassLoader.class);
final JarURLConnection conn = Mockito.mock(JarURLConnection.class);
final URLStreamHandler handler = new URLStreamHandler() {
@Override
protected URLConnection openConnection(final URL url) throws IOException {
if(throwExceptionOnOpenConnection) {
throw new IOException("Throwing up for testing that");
}
return conn;
}
};
final JarFile f = Mockito.mock(JarFile.class);
final URL url = new URL("jar://some.jar", "localhost", 1234, "some.jar", handler);
final Vector<JarEntry> entries = new Vector<JarEntry>();
for(String path : paths) {
entries.add(new JarEntry(path));
}
when(cl.getResource(Matchers.contains("install"))).thenReturn(url);
when(conn.getJarFile()).thenReturn(f);
when(f.entries()).thenReturn(entries.elements());
return cl;
}