diff options
author | Pascal Rapicault | 2011-06-18 21:10:18 +0000 |
---|---|---|
committer | Pascal Rapicault | 2011-06-18 21:10:18 +0000 |
commit | 8baf009818d946c0c8374c5919c0979b201d29b5 (patch) | |
tree | 79861e6b1c72522575d9b0179ed77f2d46391b97 | |
parent | 3be78dff22781da612807364c825fa6ba91f7bc5 (diff) | |
download | rt.equinox.p2-8baf009818d946c0c8374c5919c0979b201d29b5.tar.gz rt.equinox.p2-8baf009818d946c0c8374c5919c0979b201d29b5.tar.xz rt.equinox.p2-8baf009818d946c0c8374c5919c0979b201d29b5.zip |
Test to show the usage of a negative requirement in a patch
2 files changed, 63 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java index 4d60cfffe..0ec488de4 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java @@ -130,6 +130,7 @@ public class AllTests extends TestCase { suite.addTestSuite(PatchTestUpdate3.class); suite.addTestSuite(PatchTestUpdate4.class); suite.addTestSuite(PatchTestUpdate5.class); + suite.addTestSuite(PatchTestUsingNegativeRequirement.class); suite.addTestSuite(PermissiveSlicerTest.class); suite.addTestSuite(PP2ShouldFailToInstall.class); // suite.addTestSuite(ProvisioningPlanQueryTest.class); disabled, see bug 313812 diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUsingNegativeRequirement.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUsingNegativeRequirement.java new file mode 100644 index 000000000..2fcf9bc52 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUsingNegativeRequirement.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2011 Sonatype, Inc 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: + * Sonatype, Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.planner; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.internal.p2.metadata.RequiredCapability; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.planner.IPlanner; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.query.QueryUtil; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +public class PatchTestUsingNegativeRequirement extends AbstractProvisioningTest { + IInstallableUnit a1; + IInstallableUnit b1; + IInstallableUnit c1; + IInstallableUnitPatch p1; + + IProfile profile1; + IPlanner planner; + IEngine engine; + + protected void setUp() throws Exception { + super.setUp(); + a1 = createIU("A", Version.create("1.0.0"), new IRequirement[] {MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true), MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 1.0.0]"), null, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 2, 0), true); + c1 = createIU("C", Version.createOSGi(1, 0, 0), true); + RequiredCapability negativeRequirementForPatch = new RequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, 0, 0, false, null); + IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), negativeRequirementForPatch); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequirement[][] {{MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + + createTestMetdataRepository(new IInstallableUnit[] {a1, b1, c1, p1}); + + profile1 = createProfile("TestProfile." + getName()); + planner = createPlanner(); + engine = createEngine(); + } + + public void testInstall() { + //The requirement from A to B is broken because there is no B satisifying. Therefore A can only install if the P is installed as well + ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); + req1.addInstallableUnits(new IInstallableUnit[] {a1, p1}); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); + IQueryResult<IInstallableUnit> res = plan1.getAdditions().query(QueryUtil.ALL_UNITS, new NullProgressMonitor()); + assertEquals(3, res.toUnmodifiableSet().size()); + assertContains(res, p1); + assertContains(res, a1); + assertContains(res, c1); + } +} |