public ManifestContents create( String manifestTemplatePath, String manifestTemplate, String bundleSymbolicName, String defaultBundleSymbolicName, String bundleVersion, String defaultBundleVersion) { ManifestContents template; if (StringUtils.hasText(manifestTemplate)) { template = BundleManifestUtils.getManifest(new StringReader(manifestTemplate)); } else if (StringUtils.hasText(manifestTemplatePath)) { template = BundleManifestUtils.getManifest(new File(manifestTemplatePath)); } else { template = new SimpleManifestContents(); } Map<String, String> attributes = template.getMainAttributes(); if (StringUtils.hasText(bundleSymbolicName)) { attributes.put(BUNDLE_SYMBOLIC_NAME, bundleSymbolicName); } else if (!StringUtils.hasText(attributes.get(BUNDLE_SYMBOLIC_NAME))) { attributes.put(BUNDLE_SYMBOLIC_NAME, defaultBundleSymbolicName); } if (StringUtils.hasText(bundleVersion)) { attributes.put(BUNDLE_VERSION, bundleVersion); } else if (!StringUtils.hasText(attributes.get(BUNDLE_VERSION))) { attributes.put(BUNDLE_VERSION, defaultBundleVersion); } return template; }
@Test public void invalid() { ManifestContents manifest = new SimpleManifestContents(); manifest.getMainAttributes().put("Export-Package", "test.package"); manifest.getMainAttributes().put("Import-Package", "test.package"); Set<String> warnings = this.validator.validate(manifest); assertEquals(1, warnings.size()); }