blob: 2663678a866f1164ecc79ab00f5f778d2a4521c6 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.p2.tests.planner;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
import org.eclipse.equinox.internal.provisional.p2.core.VersionRange;
import org.eclipse.equinox.internal.provisional.p2.director.*;
import org.eclipse.equinox.internal.provisional.p2.engine.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class PatchTestUpdate4 extends AbstractProvisioningTest {
//The patch only changes one plug-in and its lifecycle is bound to its version
private static final String P2_FEATURE = "p2.feature";
private static final String PP1 = "PatchForIUP1";
private static final String P1 = "P1";
private static final String P2 = "P2";
private IInstallableUnit p2Feature;
private IInstallableUnit p2Feature20;
private IInstallableUnit p1;
private IInstallableUnit p2;
private IInstallableUnitPatch pp1;
private IInstallableUnit p2b;
private IInstallableUnit p1b;
private IProfile profile1;
private IPlanner planner;
private IEngine engine;
protected void setUp() throws Exception {
super.setUp();
p2Feature = createIU(P2_FEATURE, new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)});
p1 = createIU(P1, new Version(1, 0, 0), true);
p2 = createIU(P2, new Version(1, 0, 0), true);
p1b = createIU(P1, new Version(1, 1, 1), true);
p2b = createIU(P2, new Version(1, 1, 1), true);
IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true));
IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, true);
IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 3.0.0]"), null, false, false)}};
pp1 = createIUPatch(PP1, new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1);
p2Feature20 = createIU(P2_FEATURE, new Version(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)});
createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1, p2Feature20});
profile1 = createProfile("TestProfile." + getName());
planner = createPlanner();
engine = createEngine();
if (!install(profile1, new IInstallableUnit[] {p2Feature}, true, planner, engine).isOK())
fail("Setup failed");
if (!install(profile1, new IInstallableUnit[] {pp1}, false, planner, engine).isOK())
fail("Setup failed");
assertProfileContainsAll("Profile setup incorrectly", profile1, new IInstallableUnit[] {p2Feature, pp1, p1b, p2});
}
public void testUpdate() {
//The update will *not* remove the patch because the lifecycle is wide open (VersionRange.emptyRange)
ProfileChangeRequest req1 = new ProfileChangeRequest(profile1);
req1.addInstallableUnits(new IInstallableUnit[] {p2Feature20});
req1.setInstallableUnitInclusionRules(p2Feature20, PlannerHelper.createStrictInclusionRule(p2Feature20));
req1.removeInstallableUnits(new IInstallableUnit[] {p2Feature});
ProvisioningPlan plan = planner.getProvisioningPlan(req1, null, null);
assertEquals(true, IStatus.ERROR != plan.getStatus().getSeverity());
engine.perform(profile1, new DefaultPhaseSet(), plan.getOperands(), null, null);
assertProfileContains("The profile contains unexpected IUs", profile1, new IInstallableUnit[] {p2Feature20, p1b, p2, pp1});
}
}