JVMUtil { public static Manifest getManifest(File classpathItem) { if (classpathItem == null) { return null; } if (classpathItem.isFile()) { return getManifestFromJar(classpathItem); } return getManifestFromFile(classpathItem); }  static boolean appendToClassPath(String name); static String[] addAllJarsToClassPath(String dirName); static Manifest getManifest(File classpathItem); static File[] getClasspath(); static File[] getClasspath(ClassLoader classLoader); static final JavaRuntimeInfo getJavaRuntimeInfo();  }
@Ignore @Test public void getManifest() { assertNull(JVMUtil.getManifest(null)); assertNull(JVMUtil.getManifest(new File(""))); assertNull(JVMUtil.getManifest(new File("notexist"))); assertNull(JVMUtil.getManifest(new File(ClassLoaderUtil.getClasspath()))); try { assertNull(JVMUtil.getManifest(new File(ClassLoaderUtil.getClasspath(), "log4j.properties"))); } catch (Exception e) { assertEquals("JVMUtil.getManifestFromJar Error", e.getMessage()); assertEquals(RuntimeException.class, e.getClass()); assertEquals("error in opening zip file", e.getCause().getMessage()); assertEquals(java.util.zip.ZipException.class, e.getCause().getClass()); } Manifest manifest = JVMUtil.getManifest(new File(System.getProperty("user.dir"))); assertNotNull(manifest); Attributes main = manifest.getMainAttributes(); assertEquals("work", main.getValue("Built-By")); assertEquals("1.0", main.getValue("Manifest-Version")); }