@BeforeMethod(alwaysRun=true) public void setUp() throws Exception { super.setUp(); serializer = new XmlSerializer<Object>( new OsgiPrefixStrippingClassLoader(framework, getClass().getClassLoader()), ImmutableMap.<String, String>of()); }
@AfterMethod(alwaysRun = true) public void tearDown() throws BundleException, IOException, InterruptedException { tearDownOsgiFramework(framework, storageTempDir); }
@SuppressWarnings("deprecation") static RegisteredType addCatalogItemWithNameAndType(ManagementContext mgmt, String symName, String version, String type, String ...libraries) { OsgiTestBase.preinstallLibrariesLowLevelToPreventCatalogBomParsing(mgmt, libraries); CatalogEntityItemDto c1 = newCatalogItemWithNameAndType(symName, version, type, libraries); mgmt.getCatalog().addItem(c1); RegisteredType c2 = mgmt.getTypeRegistry().get(symName, version); Preconditions.checkNotNull(c2, "Item "+type+":"+version+" was not found after adding it"); return c2; }
@Test public void testGetFeatures() throws Exception { TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_PATH); LocalManagementContext mgmt = LocalManagementContextForTests.builder(true) .enableOsgiReusable() .build(); String symName = "org.apache.brooklyn.test.resources.osgi.brooklyn-test-osgi-entities"; String version = "0.1.0"; String type = "brooklyn.osgi.tests.SimpleEntity"; List<String> libraries = Lists.newArrayList("classpath:" + OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_PATH); OsgiTestBase.preinstallLibrariesLowLevelToPreventCatalogBomParsing(mgmt, libraries.toArray(new String[1])); CatalogEntityItemDto c1 = CatalogItemBuilder.newEntity(symName, version) .javaType(type) .libraries(CatalogItemDtoAbstract.parseLibraries(libraries)) .build(); mgmt.getCatalog().addItem(c1); Iterable<BrooklynVersion.BrooklynFeature> features = BrooklynVersion.getFeatures(mgmt); assertTrue(features.iterator().hasNext()); boolean found = false; Iterator<BrooklynVersion.BrooklynFeature> iterator = features.iterator(); while (!found && iterator.hasNext()) { BrooklynVersion.BrooklynFeature feature = iterator.next(); if (feature.getSymbolicName().equals(symName) && feature.getVersion().equals(version)) { found = true; } } assertTrue(found, "Expected to find " + symName + ":" + version + " in: " + Iterables.toString(features)); }
if (managementContext != null) Entities.destroyAll(managementContext); } finally { OsgiTestBase.tearDownOsgiFramework(framework, storageTempDir);