Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2010-12-16 20:36:34 -0500
committerPascal Rapicault2010-12-16 20:36:34 -0500
commit58fc582de8d471a3759198ca79b9987f51703ab8 (patch)
tree929eb9f537209bb5f0a5674ceb7223205fba78cd
parent17355628ebe5f7baacd606187c6dd84b1d1c06b5 (diff)
downloadrt.equinox.p2-58fc582de8d471a3759198ca79b9987f51703ab8.tar.gz
rt.equinox.p2-58fc582de8d471a3759198ca79b9987f51703ab8.tar.xz
rt.equinox.p2-58fc582de8d471a3759198ca79b9987f51703ab8.zip
Bug 332655 - Setting IU properties for missing IUs in a profile dirties the profile but does not persist the propert
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoUnecessaryIUProperty.java49
3 files changed, 54 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
index a42ac71c6..e8d6be1e7 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
@@ -51,7 +51,7 @@ public class SimplePlanner implements IPlanner {
private IProvisioningPlan generateProvisioningPlan(Collection<IInstallableUnit> fromState, Collection<IInstallableUnit> toState, ProfileChangeRequest changeRequest, IProvisioningPlan installerPlan, ProvisioningContext context) {
IProvisioningPlan plan = engine.createPlan(changeRequest.getProfile(), context);
planIUOperations(plan, fromState, toState);
- planPropertyOperations(plan, changeRequest);
+ planPropertyOperations(plan, changeRequest, toState);
if (DEBUG) {
Object[] operands = new Object[0];
@@ -164,7 +164,7 @@ public class SimplePlanner implements IPlanner {
return root;
}
- private void planPropertyOperations(IProvisioningPlan plan, ProfileChangeRequest profileChangeRequest) {
+ private void planPropertyOperations(IProvisioningPlan plan, ProfileChangeRequest profileChangeRequest, Collection<IInstallableUnit> toState) {
// First deal with profile properties to remove.
String[] toRemove = profileChangeRequest.getPropertiesToRemove();
@@ -181,6 +181,8 @@ public class SimplePlanner implements IPlanner {
Map<IInstallableUnit, Map<String, String>> allIUPropertyChanges = profileChangeRequest.getInstallableUnitProfilePropertiesToAdd();
for (Map.Entry<IInstallableUnit, Map<String, String>> entry : allIUPropertyChanges.entrySet()) {
IInstallableUnit iu = entry.getKey();
+ if (!toState.contains(iu))
+ continue;
for (Map.Entry<String, String> entry2 : entry.getValue().entrySet()) {
plan.setInstallableUnitProfileProperty(iu, entry2.getKey(), entry2.getValue());
}
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 396423f47..9f8a69652 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
@@ -93,6 +93,7 @@ public class AllTests extends TestCase {
// suite.addTestSuite(NegationTesting.class);
suite.addTestSuite(NonMinimalState.class);
suite.addTestSuite(NonMinimalState2.class);
+ suite.addTestSuite(NoUnecessaryIUProperty.class);
suite.addTestSuite(MultipleProvider.class);
suite.addTestSuite(MultipleSingleton.class);
suite.addTestSuite(NoRequirements.class);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoUnecessaryIUProperty.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoUnecessaryIUProperty.java
new file mode 100644
index 000000000..fd8320771
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoUnecessaryIUProperty.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Sonatype, Inc. 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:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.planner;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.p2.engine.ProvisioningPlan;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.planner.IPlanner;
+import org.eclipse.equinox.p2.planner.IProfileChangeRequest;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+
+public class NoUnecessaryIUProperty extends AbstractProvisioningTest {
+
+ IProfile profile1;
+ IPlanner planner;
+ IEngine engine;
+ IMetadataRepository repo;
+ IInstallableUnit iuA, iuB;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ profile1 = createProfile("TestProfile." + getName());
+ planner = createPlanner();
+ engine = createEngine();
+ iuA = createIU("A");
+ iuB = createIU("B");
+ }
+
+ //Confirm that the planner will not generate an IUProperty operand if the IU is not in the final profile.
+ public void testIUExtraneousPlanEntry() {
+ IProfileChangeRequest pcr = planner.createChangeRequest(profile1);
+ pcr.add(iuA);
+ pcr.setInstallableUnitProfileProperty(iuB, "theKey", "theValue"); // Try to set a property on an IU that does not end up in plan
+ IProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, new NullProgressMonitor());
+ assertEquals(2, ((ProvisioningPlan) plan).getOperands().length);
+
+ }
+}

Back to the top