use of org.apache.karaf.features.internal.support.TestDownloadManager 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);
}
use of org.apache.karaf.features.internal.support.TestDownloadManager 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);
}
use of org.apache.karaf.features.internal.support.TestDownloadManager 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);
}
use of org.apache.karaf.features.internal.support.TestDownloadManager in project karaf by apache.
the class DeployerTest method testInstallSimpleFeature.
@Test
public void testInstallSimpleFeature() throws Exception {
IMocksControl c = EasyMock.createControl();
String dataDir = "data1";
TestDownloadManager manager = new TestDownloadManager(getClass(), dataDir);
RepositoryImpl repo = new RepositoryImpl(getClass().getResource(dataDir + "/features.xml").toURI());
repo.load(true);
Feature f100 = repo.getFeatures()[0];
Feature f101 = repo.getFeatures()[1];
Deployer.DeployCallback callback = c.createMock(Deployer.DeployCallback.class);
BundleInstallSupport installSupport = c.createMock(BundleInstallSupportImpl.class);
Deployer deployer = new Deployer(manager, resolver, installSupport, callback);
callback.print(EasyMock.anyString(), EasyMock.anyBoolean());
EasyMock.expectLastCall().anyTimes();
callback.callListeners(DeploymentEvent.DEPLOYMENT_STARTED);
EasyMock.expectLastCall();
installSupport.replaceDigraph(EasyMock.anyObject(), EasyMock.anyObject());
EasyMock.expectLastCall();
callback.saveState(EasyMock.anyObject());
EasyMock.expectLastCall();
installSupport.installConfigs(f100);
EasyMock.expectLastCall();
installSupport.installLibraries(f100);
EasyMock.expectLastCall();
callback.callListeners(DeploymentEvent.BUNDLES_INSTALLED);
EasyMock.expectLastCall();
installSupport.resolveBundles(EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject());
EasyMock.expectLastCall();
callback.callListeners(DeploymentEvent.BUNDLES_RESOLVED);
EasyMock.expectLastCall();
callback.callListeners(EasyMock.<FeatureEvent>anyObject());
EasyMock.expectLastCall();
callback.callListeners(DeploymentEvent.DEPLOYMENT_FINISHED);
EasyMock.expectLastCall();
Bundle bundleA = createTestBundle(1, Bundle.ACTIVE, dataDir, "a100");
EasyMock.expect(installSupport.installBundle(EasyMock.eq(ROOT_REGION), EasyMock.eq("a100"), EasyMock.anyObject())).andReturn(bundleA);
c.replay();
Deployer.DeploymentState dstate = new Deployer.DeploymentState();
dstate.state = new State();
dstate.bundles = new HashMap<>();
dstate.bundlesPerRegion = new HashMap<>();
dstate.features = new HashMap<>();
dstate.features.put(f100.getId(), f100);
dstate.features.put(f101.getId(), f101);
dstate.filtersPerRegion = new HashMap<>();
dstate.filtersPerRegion.put(ROOT_REGION, new HashMap<>());
Deployer.DeploymentRequest request = new Deployer.DeploymentRequest();
request.bundleUpdateRange = DEFAULT_BUNDLE_UPDATE_RANGE;
request.featureResolutionRange = DEFAULT_FEATURE_RESOLUTION_RANGE;
request.globalRepository = null;
request.options = EnumSet.noneOf(Option.class);
request.overrides = Collections.emptySet();
request.stateChanges = Collections.emptyMap();
request.updateSnaphots = UPDATE_SNAPSHOTS_NONE;
request.requirements = new HashMap<>();
addToMapSet(request.requirements, ROOT_REGION, f100.getName() + "/" + new VersionRange(f100.getVersion(), true));
deployer.deploy(dstate, request);
c.verify();
}
use of org.apache.karaf.features.internal.support.TestDownloadManager in project karaf by apache.
the class SubsystemTest method test1.
@Test
public void test1() throws Exception {
RepositoryImpl repo = new RepositoryImpl(getClass().getResource("data1/features.xml").toURI());
Map<String, Set<String>> features = new HashMap<>();
addToMapSet(features, "root", "f1");
addToMapSet(features, "root/apps1", "f2");
Map<String, Set<String>> expected = new HashMap<>();
addToMapSet(expected, "root", "a/1.0.0");
addToMapSet(expected, "root", "c/1.0.0");
addToMapSet(expected, "root/apps1", "b/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);
}
Aggregations