@Test public void testHasOsgiManifestWhenNoManifest() throws Exception { assertFalse(bundleMaker.hasOsgiManifest(emptyJar)); }
@Test public void testHasOsgiManifestWhenValidManifest() throws Exception { Map<String, String> manifest = ImmutableMap.of(Attributes.Name.MANIFEST_VERSION.toString(), "1.2.3", Constants.BUNDLE_SYMBOLICNAME, "myname"); generatedJar = bundleMaker.copyAddingManifest(emptyJar, manifest); assertTrue(bundleMaker.hasOsgiManifest(generatedJar)); }
@Test public void testHasOsgiManifestWhenInvalidManifest() throws Exception { Map<String, String> manifest = ImmutableMap.of(Attributes.Name.MANIFEST_VERSION.toString(), "1.2.3", "mykey", "myval"); generatedJar = bundleMaker.copyAddingManifest(emptyJar, manifest); assertFalse(bundleMaker.hasOsgiManifest(generatedJar)); }
@Test public void testCatalogBomFromBundleWithManifest() throws Exception { bm.setDefaultClassForLoading(getClass()); File jf = bm.createJarFromClasspathDir("osgi/catalog-bundle-1"); Assert.assertTrue(bm.hasOsgiManifest(jf)); installBundle(jf); assertHasBasic1(); assertBasic1DeploysAndHasSensor(); }
@Test public void testCatalogBomFromBundleWithManualManifest() throws Exception { bm.setDefaultClassForLoading(getClass()); File jf = bm.createJarFromClasspathDir("osgi/catalog-bundle-1"); jf = bm.copyRemoving(jf, MutableSet.of(JarFile.MANIFEST_NAME)); String customName = "catalog-bundle-1-manual-"+Identifiers.makeRandomId(4); jf = bm.copyAddingManifest(jf, MutableMap.of( "Manifest-Version", "2.0", "Bundle-SymbolicName", customName, "Bundle-Version", "0.0.0.SNAPSHOT")); Assert.assertTrue(bm.hasOsgiManifest(jf)); installBundle(jf); assertHasBasic1(); Entity basic1 = assertBasic1DeploysAndHasSensor(); RegisteredType item = mgmt().getTypeRegistry().get( basic1.getCatalogItemId() ); Collection<OsgiBundleWithUrl> libs = item.getLibraries(); Asserts.assertSize(libs, 1); Assert.assertEquals(Iterables.getOnlyElement(libs).getSymbolicName(), customName); }