Search in sources :

Example 16 with RepositoryImpl

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

the class SubsystemTest method testMultipleVersionsForFeatureDependency.

@Test
public void testMultipleVersionsForFeatureDependency() throws Exception {
    RepositoryImpl repo1 = new RepositoryImpl(getClass().getResource("data9/pax-web-6.0.3.xml").toURI());
    RepositoryImpl repo2 = new RepositoryImpl(getClass().getResource("data9/pax-web-6.0.4.xml").toURI());
    List<Feature> allFeatures = new ArrayList<>();
    allFeatures.addAll(Arrays.asList(repo1.getFeatures()));
    allFeatures.addAll(Arrays.asList(repo2.getFeatures()));
    Map<String, Set<String>> features = new HashMap<>();
    addToMapSet(features, "root", "pax-war-tomcat");
    Map<String, Set<String>> expected = new HashMap<>();
    addToMapSet(expected, "root", "pax-url-war/2.5.0");
    addToMapSet(expected, "root", "pax-web-extender-war/6.0.4");
    addToMapSet(expected, "root", "pax-web-tomcat/6.0.4");
    addToMapSet(expected, "root", "pax-web-api/6.0.4");
    SubsystemResolver resolver = new SubsystemResolver(this.resolver, new TestDownloadManager(getClass(), "data9"));
    resolver.prepare(allFeatures, 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) ArrayList(java.util.ArrayList) Feature(org.apache.karaf.features.Feature) Test(org.junit.Test)

Example 17 with RepositoryImpl

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

the class SubsystemTest method testBundle.

@Test
public void testBundle() throws Exception {
    RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data1/features.xml").toURI());
    Map<String, Set<String>> features = new HashMap<>();
    addToMapSet(features, "root/apps1", "bundle:a");
    addToMapSet(features, "root/apps1", "bundle:c;dependency=true");
    Map<String, Set<String>> expected = new HashMap<>();
    addToMapSet(expected, "root/apps1", "a/1.0.0");
    addToMapSet(expected, "root/apps1", "c/1.0.0");
    SubsystemResolver resolver = new SubsystemResolver(this.resolver, new TestDownloadManager(getClass(), "data1"));
    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 18 with RepositoryImpl

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

the class SubsystemTest method testOverrides.

@Test
public void testOverrides() throws Exception {
    RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data3/features.xml").toURI());
    Map<String, Set<String>> features = new HashMap<>();
    addToMapSet(features, "root/apps1", "f1");
    Map<String, Set<String>> expected = new HashMap<>();
    addToMapSet(expected, "root/apps1", "a/1.0.1");
    SubsystemResolver resolver = new SubsystemResolver(this.resolver, new TestDownloadManager(getClass(), "data3"));
    resolver.prepare(Arrays.asList(repo.getFeatures()), features, Collections.emptyMap());
    resolver.resolve(Collections.singleton("b"), 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 19 with RepositoryImpl

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

the class SubsystemTest method testFeatureOptionalAlreadyProvided2.

@Test
public void testFeatureOptionalAlreadyProvided2() throws Exception {
    RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data6/features.xml").toURI());
    Map<String, Set<String>> features = new HashMap<>();
    addToMapSet(features, "root", "pax-http");
    addToMapSet(features, "root", "pax-http-tomcat");
    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(), "data6"));
    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 20 with RepositoryImpl

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

the class SubsystemTest method test2.

@Test
public void test2() throws Exception {
    RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data2/features.xml").toURI());
    Map<String, Set<String>> features = new HashMap<>();
    addToMapSet(features, "root/apps1", "f1");
    addToMapSet(features, "root/apps1", "f3");
    addToMapSet(features, "root/apps2", "f1");
    Map<String, Set<String>> expected = new HashMap<>();
    addToMapSet(expected, "root/apps1", "c/1.0.0");
    addToMapSet(expected, "root/apps1", "b/1.0.0");
    addToMapSet(expected, "root/apps1", "e/1.0.0");
    addToMapSet(expected, "root/apps1#f1", "a/1.0.0");
    addToMapSet(expected, "root/apps1#f1", "d/1.0.0");
    addToMapSet(expected, "root/apps2", "b/1.0.0");
    addToMapSet(expected, "root/apps2", "c/1.0.0");
    addToMapSet(expected, "root/apps2#f1", "a/1.0.0");
    SubsystemResolver resolver = new SubsystemResolver(this.resolver, new TestDownloadManager(getClass(), "data2"));
    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)

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