Search in sources :

Example 56 with Feature

use of org.apache.karaf.features.Feature in project tesb-rt-se by Talend.

the class StartAuxiliaryRepoTest method doExecuteNewFeatureTest.

@Test
public void doExecuteNewFeatureTest() throws Exception {
    Feature f = createMock(Feature.class);
    FeaturesService s = createMock(FeaturesService.class);
    expect(s.getFeature(FEATURE_NAME)).andReturn(f);
    expect(s.isInstalled(f)).andReturn(false);
    // new Feature must be installed
    s.installFeature(FEATURE_NAME);
    EasyMock.expectLastCall().once();
    replay(s);
    r.doExecute(s);
    EasyMock.verify(s);
}
Also used : FeaturesService(org.apache.karaf.features.FeaturesService) Feature(org.apache.karaf.features.Feature) Test(org.junit.Test)

Example 57 with Feature

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);
}
Also used : FeaturesService(org.apache.karaf.features.FeaturesService) AssertionFailedError(junit.framework.AssertionFailedError) Feature(org.apache.karaf.features.Feature) Test(org.junit.Test)

Example 58 with Feature

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);
}
Also used : FeaturesService(org.apache.karaf.features.FeaturesService) Feature(org.apache.karaf.features.Feature) Test(org.junit.Test)

Example 59 with Feature

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;
}
Also used : Version(org.osgi.framework.Version) VersionRange(org.apache.felix.utils.version.VersionRange) Feature(org.apache.karaf.features.Feature)

Example 60 with Feature

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Dependency(org.apache.karaf.features.Dependency) Feature(org.apache.karaf.features.Feature)

Aggregations

Feature (org.apache.karaf.features.Feature)127 Test (org.junit.Test)56 FeaturesService (org.apache.karaf.features.FeaturesService)43 HashSet (java.util.HashSet)41 Repository (org.apache.karaf.features.Repository)39 ApplicationService (org.codice.ddf.admin.application.service.ApplicationService)18 Bundle (org.osgi.framework.Bundle)18 HashMap (java.util.HashMap)17 ArrayList (java.util.ArrayList)16 Map (java.util.Map)16 Dependency (org.apache.karaf.features.Dependency)15 BundleInfo (org.apache.karaf.features.BundleInfo)14 Application (org.codice.ddf.admin.application.service.Application)14 URI (java.net.URI)13 IOException (java.io.IOException)12 VersionRange (org.apache.felix.utils.version.VersionRange)12 LinkedHashSet (java.util.LinkedHashSet)11 Version (org.osgi.framework.Version)11 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)10 EnumSet (java.util.EnumSet)9