use of com.alipay.sofa.ark.loader.jar.JarEntry in project sofa-ark by alipay.
the class JarFileTest method testJarFile.
@Test
public void testJarFile() throws IOException {
JarFile jarFile = new JarFile(getTempDemoZip());
Manifest manifest = jarFile.getManifest();
Assert.assertTrue(manifest.getMainAttributes().getValue("k1").equals("v1"));
Assert.assertTrue(manifest.getMainAttributes().getValue("k2").equals("v2"));
Assert.assertTrue(jarFile.containsEntry(TEST_ENTRY));
ZipEntry zipEntry = jarFile.getEntry(TEST_ENTRY);
Assert.assertTrue(zipEntry.getName().equals(TEST_ENTRY));
Assert.assertTrue(zipEntry.getComment().equals(TEST_ENTRY_COMMENT));
Assert.assertTrue(compareByteArray(zipEntry.getExtra(), TEST_ENTRY_EXTRA.getBytes()));
JarEntry jarEntry = jarFile.getJarEntry("lib/junit-4.12.jar");
JarFile nestJarFile = jarFile.getNestedJarFile(jarEntry);
Manifest nestManifest = nestJarFile.getManifest();
Assert.assertTrue(nestManifest.getMainAttributes().getValue("Implementation-Title").equals("JUnit"));
Assert.assertTrue(nestManifest.getMainAttributes().getValue("Implementation-Version").equals("4.12"));
}