/** * @throws Exception */ @Test public void testAllBundlesActiveAndFeaturesInstalled() throws Exception { // Asssert all bundles except fragments are ACTIVE. for (Bundle b : bundleCtx.getBundles()) { System.out.println(String.format("Checking state of bundle [symbolicName=%s, state=%s]", b.getSymbolicName(), b.getState())); if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) assertTrue(b.getState() == Bundle.ACTIVE); } // Check that according to the FeaturesService, all Ignite features except ignite-log4j are installed. Feature[] features = featuresSvc.getFeatures(IGNITE_FEATURES_NAME_REGEX); assertNotNull(features); assertEquals(EXPECTED_FEATURES, features.length); for (Feature f : features) { if (IGNORED_FEATURES.contains(f.getName())) continue; boolean installed = featuresSvc.isInstalled(f); System.out.println(String.format("Checking if feature is installed [featureName=%s, installed=%s]", f.getName(), installed)); assertTrue(installed); assertEquals(PROJECT_VERSION.replaceAll("-", "."), f.getVersion().replaceAll("-", ".")); } }
/** * @return * @see org.apache.karaf.features.Feature#getName() */ @Override public String getName() { return feature.getName(); }
@Override public String getName() { return this.feature.getName(); }
private boolean isInstalled(Feature[] features, String name) { try { for (Feature feature : features) { if (feature.getName().equals(name)) { return true; } } } catch (Exception e) { logger.error("Failed retrieving features: {}", e.getMessage()); } return false; }
@Override public void installFeatures(Set<Feature> features, EnumSet<Option> options) throws Exception { StringBuffer sb = new StringBuffer(); for (Feature feature : features) { sb.append("--feature ").append(feature.getName()); } unsupportedInstallFeature(sb.toString()); }
@Override public void installFeatures(Set<Feature> features, EnumSet<Option> options) throws Exception { StringBuffer sb = new StringBuffer(); for (Feature feature : features) { sb.append("--feature ").append(feature.getName()); } unsupportedInstallFeature(sb.toString()); }
public void assertFeaturesInstalled(String ... expectedFeatures) throws Exception { Set<String> expectedFeaturesSet = new HashSet<>(Arrays.asList(expectedFeatures)); Feature[] features = featureService.listInstalledFeatures(); Set<String> installedFeatures = new HashSet<>(); for (Feature feature : features) { installedFeatures.add(feature.getName()); } String msg = "Expecting the following features to be installed : " + expectedFeaturesSet + " but found " + installedFeatures; Assert.assertTrue(msg, installedFeatures.containsAll(expectedFeaturesSet)); }
ChildAwareFeatureWrapper(Feature f, FeaturesService s) throws Exception { super(s.getFeature(f.getName(), f.getVersion())); Preconditions.checkNotNull(s, "FeatureWrapper requires non-null FeatureService in constructor"); this.featuresService = s; }
@Override public Feature getFeature(String name) throws Exception { assertValid(); Feature[] features = listFeatures(); for (Feature feature : features) { if (name.equals(feature.getName())) { return feature; } } return null; }
@Override public Feature getFeature(String name) throws Exception { assertValid(); Feature[] features = listFeatures(); for (Feature feature : features) { if (name.equals(feature.getName())) { return feature; } } return null; }
@Override public Feature getFeature(String name, String version) throws Exception { assertValid(); Feature[] features = listFeatures(); for (Feature feature : features) { if (name.equals(feature.getName()) && version.equals(feature.getVersion())) { return feature; } } return null; }
/** * Adds {@link Feature} and its dependencies to the set of {@link Feature}s. */ private void addFeatures(Feature feature, Set<Feature> features) { if (features.contains(feature)) { return; } features.add(feature); for (Feature dependency : feature.getDependencies()) { addFeatures(search(dependency.getName(), dependency.getVersion(), repositories.asMap().values()), features); } }
private FeatureResource(Feature feature) { super(feature.getName(), TYPE_FEATURE, VersionTable.getVersion(feature.getVersion())); this.feature = feature; }
@Override public Feature getFeature(String name, String version) throws Exception { assertValid(); Feature[] features = listFeatures(); for (Feature feature : features) { if (name.equals(feature.getName()) && version.equals(feature.getVersion())) { return feature; } } return null; }
private Collection<String> getInstalledOsgiPluginIds() { Collection<String> potentialOsgiPluginIds = new HashSet<>(); try { for( String installedKar : this.getKarService().list() ) { potentialOsgiPluginIds.add( installedKar ); } } catch ( Exception e ) { } for( Feature feature : this.getFeaturesService().listInstalledFeatures() ) { potentialOsgiPluginIds.add( feature.getName() ); } return potentialOsgiPluginIds; }
static TabularData getFeatureIdentifierTable(List<Feature> features) throws OpenDataException { TabularDataSupport table = new TabularDataSupport(JmxFeature.FEATURE_IDENTIFIER_TABLE); for (Feature feature : features) { String[] itemNames = new String[]{FeaturesServiceMBean.FEATURE_NAME, FeaturesServiceMBean.FEATURE_VERSION}; Object[] itemValues = new Object[]{feature.getName(), feature.getVersion()}; CompositeData ident = new CompositeDataSupport(JmxFeature.FEATURE_IDENTIFIER, itemNames, itemValues); table.put(ident); } return table; }
@Override protected void doExecute(FeaturesService service) throws Exception { ShellTable table = new ShellTable(); table.column("Name"); table.column("Version"); for (Feature feature : service.repositoryProvidedFeatures(featuresRepositoryUri)) { table.addRow().addContent(feature.getName(), feature.getVersion()); } table.print(System.out); }