use of org.apache.karaf.features.Feature in project tesb-rt-se by Talend.
the class StopAuxiliaryRepoTest method doExecuteUninstallMissingFeaturesTest.
@Test
public void doExecuteUninstallMissingFeaturesTest() throws Exception {
FeaturesService s = createMock(FeaturesService.class);
for (String featureName : FEATURES) {
Feature f = createMock(Feature.class);
expect(s.getFeature(featureName)).andReturn(f);
expect(s.isInstalled(f)).andReturn(false);
s.uninstallFeature(featureName);
EasyMock.expectLastCall().andThrow(new AssertionFailedError("Feature " + featureName + " must be not uninstalled")).anyTimes();
}
replay(s);
r.doExecute(s);
EasyMock.verify(s);
}
use of org.apache.karaf.features.Feature in project tesb-rt-se by Talend.
the class StopAuxiliaryRepoTest method doExecuteUninstallExistingFeaturesTest.
@Test
public void doExecuteUninstallExistingFeaturesTest() throws Exception {
FeaturesService s = createMock(FeaturesService.class);
for (String featureName : FEATURES) {
Feature f = createMock(Feature.class);
expect(s.getFeature(featureName)).andReturn(f);
expect(s.isInstalled(f)).andReturn(true);
s.uninstallFeature(featureName);
EasyMock.expectLastCall().once();
}
replay(s);
r.doExecute(s);
EasyMock.verify(s);
}
use of org.apache.karaf.features.Feature in project controller by opendaylight.
the class ChildAwareFeatureWrapper method extractFeatureFromDependency.
protected Feature extractFeatureFromDependency(final Dependency dependency) throws Exception {
Feature[] features = featuresService.listFeatures();
VersionRange range = dependency.hasVersion() ? new VersionRange(dependency.getVersion(), true, true) : VersionRange.ANY_VERSION;
Feature fi = null;
for (Feature f : features) {
if (f.getName().equals(dependency.getName())) {
Version version = VersionTable.getVersion(f.getVersion());
if (range.contains(version) && (fi == null || VersionTable.getVersion(fi.getVersion()).compareTo(version) < 0)) {
fi = f;
break;
}
}
}
return fi;
}
use of org.apache.karaf.features.Feature in project controller by opendaylight.
the class ChildAwareFeatureWrapper method getChildFeatures.
/*
* Get FeatureConfigSnapshotHolders appropriate to feed to the config subsystem
* from the underlying Feature Config files and those of its children recursively
*/
public Set<? extends ChildAwareFeatureWrapper> getChildFeatures() throws Exception {
List<Dependency> dependencies = feature.getDependencies();
Set<ChildAwareFeatureWrapper> childFeatures = new LinkedHashSet<>();
if (dependencies != null) {
for (Dependency dependency : dependencies) {
Feature fi = extractFeatureFromDependency(dependency);
if (fi != null) {
if (featuresService.getFeature(fi.getName(), fi.getVersion()) == null) {
LOG.warn("Feature: {}, {} is missing from features service. Skipping", fi.getName(), fi.getVersion());
} else {
ChildAwareFeatureWrapper wrappedFeature = new ChildAwareFeatureWrapper(fi, featuresService);
childFeatures.add(wrappedFeature);
}
}
}
}
return childFeatures;
}
use of org.apache.karaf.features.Feature in project controller by opendaylight.
the class ConfigPushingRunnable method run.
@Override
@SuppressWarnings("IllegalCatch")
public void run() {
List<Feature> toInstall = new ArrayList<>();
FeatureEvent event = null;
boolean interrupted = false;
while (true) {
try {
if (!interrupted) {
if (toInstall.isEmpty()) {
event = queue.take();
} else {
event = queue.poll(POLL_TIME, TimeUnit.MILLISECONDS);
}
if (event != null && event.getFeature() != null) {
processFeatureEvent(event, toInstall);
}
} else if (toInstall.isEmpty()) {
LOG.error("ConfigPushingRunnable - exiting");
return;
}
} catch (final InterruptedException e) {
LOG.error("ConfigPushingRunnable - interrupted");
interrupted = true;
} catch (final Exception e) {
LOG.error("Exception while processing features {} event {}", toInstall, event, e);
}
}
}
Aggregations