ManifestUtil { public static Map<String, String> getVersionAttributes(ServletContext servletContext) throws IOException { URL url = servletContext.getResource("/META-INF/MANIFEST.MF"); if (url != null) { return getVersionAttributes(url); } else { return new LinkedHashMap<>(); } }  static Map<String, String> getVersionAttributes(ServletContext servletContext);  }
@Test public void testEmpty() throws IOException { Map<String, String> expected = new LinkedHashMap<>(); expected.put(ManifestUtil.IMPLEMENTATION_VERSION, ManifestUtil.UNKNOWN_VALUE); expected.put(ManifestUtil.BUILT_FROM_GIT, ManifestUtil.UNKNOWN_VALUE); Assert.assertEquals(expected, ManifestUtil.getVersionAttributes(getClass().getResource("/manifests/MANIFEST-empty.txt"))); }
@Test public void testFull() throws IOException { Map<String, String> expected = new LinkedHashMap<>(); expected.put(ManifestUtil.IMPLEMENTATION_VERSION, "1.2.3.Final"); expected.put(ManifestUtil.BUILT_FROM_GIT, "eb699f45f5461bb4cf52aca651679edb01802c04"); Assert.assertEquals(expected, ManifestUtil.getVersionAttributes(getClass().getResource("/manifests/MANIFEST-full.txt"))); }
@Test public void testPartial() throws IOException { Map<String, String> expected = new LinkedHashMap<>(); expected.put(ManifestUtil.IMPLEMENTATION_VERSION, ManifestUtil.UNKNOWN_VALUE); expected.put(ManifestUtil.BUILT_FROM_GIT, "eb699f45f5461bb4cf52aca651679edb01802c04"); Assert.assertEquals(expected, ManifestUtil.getVersionAttributes(getClass().getResource("/manifests/MANIFEST-partial.txt"))); }