/** * @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#getVersion() */ @Override public String getVersion() { return feature.getVersion(); }
@Override public String getVersion() { return this.feature.getVersion(); }
private void logInstalledOrUpdated(Feature f) { String msg = f.getVersion().endsWith("SNAPSHOT") ? "has been upgraded": "is already installed"; LOGGER.info("The specified feature: '{}' version '{}' {}", f.getName(), f.getVersion(), msg); }
private boolean isSameFeature(Feature a, Feature b) { return b.getName().equals(a.getName()) && b.getVersion().equals(a.getVersion()); }
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; }
/** * 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); } }
@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 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; }
/** * 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); } }
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; }
public void assertFeatureInstalled(String featureName, String featureVersion) { try { Feature[] features = featuresService.listInstalledFeatures(); for (Feature feature : features) { if (featureName.equals(feature.getName()) && featureVersion.equals(feature.getVersion())) { return; } } fail("Feature " + featureName + "/" + featureVersion + " should be installed but is not"); } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } }
public FeatureReq(Feature feature) { this(feature.getName(), exactVersion(feature.getVersion()), feature.isBlacklisted()); }
@Override public Feature asFeature() { if (owner == null) { throw new IllegalStateException("No owner set for conditional"); } String name = owner.getName(); String version = owner.getVersion(); String conditionName = name + "-condition-" + getConditionId().replaceAll("[^A-Za-z0-9 ]", "_"); org.apache.karaf.features.internal.model.Feature f = new org.apache.karaf.features.internal.model.Feature(conditionName, version); f.getBundle().addAll(getBundle()); f.getConfig().addAll(getConfig()); f.getConfigfile().addAll(getConfigfile()); f.getFeature().addAll(getFeature()); return f; }
private Extension getExtension(Feature feature) { String name = getName(feature.getName()); String type = getType(feature.getName()); String extId = type + "-" + name; String label = feature.getDescription(); String version = feature.getVersion(); String link = null; if (type.equals("binding")) { link = "https://www.openhab.org/addons/bindings/" + name + "/"; } else if (type.equals("action")) { link = "https://www.openhab.org/addons/actions/" + name + "/"; } else if (type.equals("persistence")) { link = "https://www.openhab.org/addons/persistence/" + name + "/"; } boolean installed = featuresService.isInstalled(feature); return new Extension(extId, type, label, version, link, installed); }
public JmxFeature(Feature feature, boolean installed, boolean required) { try { String[] itemNames = FeaturesServiceMBean.FEATURE; Object[] itemValues = new Object[itemNames.length]; itemValues[0] = feature.getName(); itemValues[1] = feature.getVersion(); itemValues[2] = getDependencyIdentifierTable(feature.getDependencies()); itemValues[3] = getBundleUris(feature.getBundles()); itemValues[4] = getConfigList(feature.getConfigurations()); itemValues[5] = getConfigFileList(feature.getConfigurationFiles()); itemValues[6] = installed; itemValues[7] = feature.isBlacklisted(); itemValues[8] = required; data = new CompositeDataSupport(FEATURE, itemNames, itemValues); } catch (OpenDataException e) { throw new IllegalStateException("Cannot form feature open data", e); } }
protected void doExecute(FeaturesService admin) throws Exception { ShellTable table = new ShellTable(); table.column("Version"); table.column("Repository"); table.column("Repository URL"); table.emptyTableText("No versions available for features '" + feature + "'"); for (Repository r : Arrays.asList(admin.listRepositories())) { for (Feature f : r.getFeatures()) { if (f.getName().equals(feature)) { table.addRow().addContent(f.getVersion(), r.getName(), r.getURI()); } } } table.print(System.out, !noFormat); }
@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); }
protected void doExecute(FeaturesService admin) throws Exception { ShellTable table = new ShellTable(); table.column("Version"); table.column("Repository"); table.column("Repository URL"); table.emptyTableText("No versions available for features '" + feature + "'"); for (Repository r : Arrays.asList(admin.listRepositories())) { for (Feature f : r.getFeatures()) { if (f.getName().equals(feature)) { table.addRow().addContent(f.getVersion(), r.getName(), r.getURI()); } } } table.print(System.out, !noFormat); }