Search in sources :

Example 6 with RepositoryImpl

use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.

the class FeaturesDependenciesTest method doTestFeatureDependency.

private void doTestFeatureDependency(String[] features, String[] bundles) throws Exception {
    RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data8/features.xml").toURI());
    Map<String, Set<String>> requirements = new HashMap<>();
    for (String feature : features) {
        addToMapSet(requirements, "root", feature);
    }
    Map<String, Set<String>> expected = new HashMap<>();
    for (String bundle : bundles) {
        addToMapSet(expected, "root", bundle);
    }
    SubsystemResolver resolver = new SubsystemResolver(this.resolver, new TestDownloadManager(getClass(), "data8"));
    resolver.prepare(Arrays.asList(repo.getFeatures()), requirements, Collections.emptyMap());
    resolver.resolve(Collections.emptySet(), FeaturesService.DEFAULT_FEATURE_RESOLUTION_RANGE, null, null, null);
    verify(resolver, expected);
}
Also used : Set(java.util.Set) MapUtils.addToMapSet(org.apache.karaf.features.internal.util.MapUtils.addToMapSet) HashMap(java.util.HashMap) TestDownloadManager(org.apache.karaf.features.internal.support.TestDownloadManager) RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl)

Example 7 with RepositoryImpl

use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.

the class SubsystemTest method testFeatureOptional.

@Test
public void testFeatureOptional() throws Exception {
    RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data5/features.xml").toURI());
    Map<String, Set<String>> features = new HashMap<>();
    addToMapSet(features, "root", "f1");
    Map<String, Set<String>> expected = new HashMap<>();
    addToMapSet(expected, "root", "a/1.0.0");
    addToMapSet(expected, "root", "b/1.0.0");
    SubsystemResolver resolver = new SubsystemResolver(this.resolver, new TestDownloadManager(getClass(), "data5"));
    resolver.prepare(Arrays.asList(repo.getFeatures()), features, Collections.emptyMap());
    resolver.resolve(Collections.emptySet(), FeaturesService.DEFAULT_FEATURE_RESOLUTION_RANGE, null, null, null);
    verify(resolver, expected);
}
Also used : Set(java.util.Set) MapUtils.addToMapSet(org.apache.karaf.features.internal.util.MapUtils.addToMapSet) HashMap(java.util.HashMap) TestDownloadManager(org.apache.karaf.features.internal.support.TestDownloadManager) RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) Test(org.junit.Test)

Example 8 with RepositoryImpl

use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.

the class SubsystemTest method testFeatureOptionalAlreadyProvided.

@Test
public void testFeatureOptionalAlreadyProvided() throws Exception {
    RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data5/features.xml").toURI());
    Map<String, Set<String>> features = new HashMap<>();
    addToMapSet(features, "root", "f1");
    addToMapSet(features, "root", "f3");
    Map<String, Set<String>> expected = new HashMap<>();
    addToMapSet(expected, "root", "a/1.0.0");
    addToMapSet(expected, "root", "c/1.0.0");
    SubsystemResolver resolver = new SubsystemResolver(this.resolver, new TestDownloadManager(getClass(), "data5"));
    resolver.prepare(Arrays.asList(repo.getFeatures()), features, Collections.emptyMap());
    resolver.resolve(Collections.emptySet(), FeaturesService.DEFAULT_FEATURE_RESOLUTION_RANGE, null, null, null);
    verify(resolver, expected);
}
Also used : Set(java.util.Set) MapUtils.addToMapSet(org.apache.karaf.features.internal.util.MapUtils.addToMapSet) HashMap(java.util.HashMap) TestDownloadManager(org.apache.karaf.features.internal.support.TestDownloadManager) RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) Test(org.junit.Test)

Example 9 with RepositoryImpl

use of org.apache.karaf.features.internal.service.RepositoryImpl in project karaf by apache.

the class SubsystemTest method testConditionalSatisfiedWithOptional.

@Test
public void testConditionalSatisfiedWithOptional() throws Exception {
    RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data4/features.xml").toURI());
    Map<String, Set<String>> features = new HashMap<>();
    addToMapSet(features, "root/apps1", "f1");
    addToMapSet(features, "root/apps1", "f2");
    Map<String, Set<String>> expected = new HashMap<>();
    addToMapSet(expected, "root/apps1", "a/1.0.0");
    addToMapSet(expected, "root/apps1", "b/1.0.0");
    SubsystemResolver resolver = new SubsystemResolver(this.resolver, new TestDownloadManager(getClass(), "data4"));
    resolver.prepare(Arrays.asList(repo.getFeatures()), features, Collections.emptyMap());
    resolver.resolve(Collections.emptySet(), FeaturesService.DEFAULT_FEATURE_RESOLUTION_RANGE, null, null, null);
    verify(resolver, expected);
}
Also used : Set(java.util.Set) MapUtils.addToMapSet(org.apache.karaf.features.internal.util.MapUtils.addToMapSet) HashMap(java.util.HashMap) TestDownloadManager(org.apache.karaf.features.internal.support.TestDownloadManager) RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) Test(org.junit.Test)

Example 10 with RepositoryImpl

use of org.apache.karaf.features.internal.service.RepositoryImpl in project ddf by codice.

the class ApplicationServiceImplTest method createRepo.

/**
     * Creates a {@code Repository} from a features.xml file
     *
     * @param featuresFile The features.xml file from which to create a
     *                     {@code Repository}
     * @return A {@link Repository} created from the received features.xml file
     * @throws Exception
     */
private static Repository createRepo(String featuresFile) throws Exception {
    RepositoryImpl repo = new RepositoryImpl(ApplicationServiceImplTest.class.getClassLoader().getResource(featuresFile).toURI());
    repo.load();
    return repo;
}
Also used : RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl)

Aggregations

RepositoryImpl (org.apache.karaf.features.internal.service.RepositoryImpl)27 Test (org.junit.Test)18 HashMap (java.util.HashMap)12 Set (java.util.Set)12 TestDownloadManager (org.apache.karaf.features.internal.support.TestDownloadManager)12 MapUtils.addToMapSet (org.apache.karaf.features.internal.util.MapUtils.addToMapSet)12 Application (org.codice.ddf.admin.application.service.Application)7 URI (java.net.URI)5 Feature (org.apache.karaf.features.Feature)2 ArrayList (java.util.ArrayList)1 Hashtable (java.util.Hashtable)1 Properties (java.util.Properties)1 Repository (org.apache.karaf.features.Repository)1 FeatureResource (org.apache.karaf.features.internal.resolver.FeatureResource)1 FeatureConfigInstaller (org.apache.karaf.features.internal.service.FeatureConfigInstaller)1 ApplicationNode (org.codice.ddf.admin.application.service.ApplicationNode)1 Resource (org.osgi.resource.Resource)1 Configuration (org.osgi.service.cm.Configuration)1 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)1