use of javassist.bytecode.ClassFile in project reflections by ronmamo.
the class VfsTest method vfsFromDirWithJarInJar.
@Test
public void vfsFromDirWithJarInJar() throws Exception {
URL resource = ClasspathHelper.contextClassLoader().getResource("jarWithBootLibJar.jar");
URL innerJarUrl = new URL("jar:" + resource.toExternalForm() + "!/BOOT-INF/lib/jarWithManifest.jar");
assertFalse(Vfs.DefaultUrlTypes.jarUrl.matches(innerJarUrl));
Vfs.Dir jarUrlDir = Vfs.DefaultUrlTypes.jarUrl.createDir(innerJarUrl);
assertNotEquals(innerJarUrl.getPath(), jarUrlDir.getPath());
assertTrue(Vfs.DefaultUrlTypes.jarInputStream.matches(innerJarUrl));
Vfs.Dir jarInputStreamDir = Vfs.DefaultUrlTypes.jarInputStream.createDir(innerJarUrl);
assertEquals(innerJarUrl.getPath(), jarInputStreamDir.getPath());
List<Vfs.File> files = StreamSupport.stream(jarInputStreamDir.getFiles().spliterator(), false).collect(Collectors.toList());
assertEquals(1, files.size());
Vfs.File file1 = files.get(0);
assertEquals("empty.class", file1.getName());
assertEquals("pack/empty.class", file1.getRelativePath());
for (Vfs.File file : jarInputStreamDir.getFiles()) {
try (DataInputStream dis = new DataInputStream(new BufferedInputStream(file.openInputStream()))) {
ClassFile classFile = new ClassFile(dis);
assertEquals("org.reflections.empty", classFile.getName());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Aggregations