JarUtil { public static Optional<String> getManifestValue(Path file, String attribute) throws IOException { checkNotNull(file); checkNotNull(attribute); return getManifestValue(file.toFile(), attribute); } private  JarUtil(); static Optional<String> getManifestValue(Path file, String attribute); static Optional<String> getManifestValue(File file, String attribute); static Attributes getManifest(Path file); static Attributes getManifest(File file); static long getResourceSize(Path file, String resource); static long getResourceSize(File file, String resource); static URL getResourceUrl(Path file, String resource); static boolean resourceExists(Path file, String resource);  }
@Test @DisplayName("Get a manifest value that exists") void getManifestValue_1() throws IOException { assertEquals("93834", getManifestValue(new File("src/test/resources/small_program.jar"), "test-attribute").get()); }
@Test @DisplayName("Get a manifest value that does not exist") void getManifestValue_2() throws IOException { assertTrue(getManifestValue(new File("src/test/resources/small_program.jar"), "nonexist-attribute").isEmpty()); assertTrue(getManifestValue(new File("src/test/resources/small_program.jar"), "").isEmpty()); }
@Test @DisplayName("Try to get a value from a nonexistent manifest") void getManifestValue_3() { assertThrows(IOException.class, () -> getManifestValue(new File("src/test/resources/test6.jar"), "test-attribute")); }
@Test @DisplayName("Try to get a value from an invalid file") void getManifestValue_4() { assertThrows(IOException.class, () -> getManifestValue(new File("src/test/resources/text1.txt"), "test-attribute")); }