ChecklistPlanner { static String bestModuleName(final URL manifestUrl) throws Exception { try (InputStream is = manifestUrl.openStream()) { final Manifest manifest = new Manifest(is); List<String> omns = Util.getManifestHeaderValues(manifest, OAKPAL_MODULENAME); if (!omns.isEmpty()) { return omns.get(0); } List<String> bsns = Util.getManifestHeaderValues(manifest, BUNDLE_SYMBOLICNAME); if (!bsns.isEmpty()) { return bsns.get(0); } List<String> amns = Util.getManifestHeaderValues(manifest, AUTOMATIC_MODULE_NAME); if (!amns.isEmpty()) { return amns.get(0); } } return ""; } ChecklistPlanner(final List<String> activeChecklistIds); void provideChecklists(final List<Checklist> constructed); void discoverChecklists(); void discoverChecklists(final ClassLoader classLoader); void discoverChecklists(final List<File> files); List<InitStage> getInitStages(); List<CheckSpec> getEffectiveCheckSpecs(final List<CheckSpec> checkOverrides); static List<Checklist> constructChecklists(final Map<URL, List<JsonObject>> parsed); static Map<URL, List<JsonObject>> parseChecklists(final URL manifestUrl); static Map<URL, List<JsonObject>> parseChecklists(final ClassLoader classLoader); static Map<URL, List<JsonObject>> parseChecklists(final List<File> files); static final String OAKPAL_CHECKLIST; static final String OAKPAL_MODULENAME; static final String BUNDLE_SYMBOLICNAME; static final String AUTOMATIC_MODULE_NAME; }
@Test public void testBestModuleName() throws Exception { final File manifestWithOakpalModuleName = new File("src/test/resources/manifestWithOakpalModuleName.mf"); final File manifestWithBundleSymbolicName = new File("src/test/resources/manifestWithBundleSymbolicName.mf"); final File manifestWithAutomaticModuleName = new File("src/test/resources/manifestWithAutomaticModuleName.mf"); final File manifestWithNoModuleName = new File("src/test/resources/manifestWithNoModuleName.mf"); assertEquals(ChecklistPlanner.OAKPAL_MODULENAME + " takes precedence", "oakpal.moduleName", ChecklistPlanner.bestModuleName(manifestWithOakpalModuleName.toURI().toURL())); assertEquals(ChecklistPlanner.BUNDLE_SYMBOLICNAME + " takes precedence over AMN", "bundle.symbolicName", ChecklistPlanner.bestModuleName(manifestWithBundleSymbolicName.toURI().toURL())); assertEquals(ChecklistPlanner.AUTOMATIC_MODULE_NAME + " is last resort", "auto.module.name", ChecklistPlanner.bestModuleName(manifestWithAutomaticModuleName.toURI().toURL())); assertEquals("empty string if no header is present", "", ChecklistPlanner.bestModuleName(manifestWithNoModuleName.toURI().toURL())); }