Search in sources :

Example 11 with TestDownloadManager

use of org.apache.karaf.features.internal.support.TestDownloadManager 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 12 with TestDownloadManager

use of org.apache.karaf.features.internal.support.TestDownloadManager 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 13 with TestDownloadManager

use of org.apache.karaf.features.internal.support.TestDownloadManager 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 14 with TestDownloadManager

use of org.apache.karaf.features.internal.support.TestDownloadManager 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 15 with TestDownloadManager

use of org.apache.karaf.features.internal.support.TestDownloadManager 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

TestDownloadManager (org.apache.karaf.features.internal.support.TestDownloadManager)17 Test (org.junit.Test)15 HashMap (java.util.HashMap)13 Set (java.util.Set)13 MapUtils.addToMapSet (org.apache.karaf.features.internal.util.MapUtils.addToMapSet)13 RepositoryImpl (org.apache.karaf.features.internal.service.RepositoryImpl)12 Feature (org.apache.karaf.features.Feature)6 TestBundle (org.apache.karaf.features.internal.support.TestBundle)5 IMocksControl (org.easymock.IMocksControl)5 Bundle (org.osgi.framework.Bundle)4 VersionRange (org.apache.felix.utils.version.VersionRange)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 HashSet (java.util.HashSet)1 Hashtable (java.util.Hashtable)1 Map (java.util.Map)1 Manifest (java.util.jar.Manifest)1