Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2009-04-29 18:07:39 -0400
committerSusan Franklin2009-04-29 18:07:39 -0400
commitd6b5b26d5760c1cc7fa9a354f894f79a98e1a073 (patch)
tree807097448c7114498df3ead8c224b71fbbaa7af4 /bundles/org.eclipse.equinox.p2.tests.ui
parent104eb7ce3d97c720ab6c71e64f07ce26ea1b7abf (diff)
downloadrt.equinox.p2-d6b5b26d5760c1cc7fa9a354f894f79a98e1a073.tar.gz
rt.equinox.p2-d6b5b26d5760c1cc7fa9a354f894f79a98e1a073.tar.xz
rt.equinox.p2-d6b5b26d5760c1cc7fa9a354f894f79a98e1a073.zip
Bug 273966 - [ui] Invalid plan created when an update and a patch are available at the same time
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.ui')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AutomatedTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/planning/AllTests.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/planning/UpdatePlanning.java128
4 files changed, 160 insertions, 5 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java
index 4397138d1..a6ef2ab68 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java
@@ -15,13 +15,11 @@ import java.net.URI;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.eclipse.equinox.internal.provisional.p2.core.*;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.internal.provisional.p2.director.ProvisioningPlan;
import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
@@ -69,8 +67,11 @@ public abstract class AbstractProvisioningUITest extends AbstractProvisioningTes
install((nested = createIU(NESTEDIU)), false, false);
install((locked = createIU(LOCKEDIU)), true, true);
uninstalled = createIU(UNINSTALLEDIU);
- upgrade = createIU(TOPLEVELIU, new Version("2.0.0"));
+ IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor(TOPLEVELIU, new VersionRange("[1.0.0, 1.0.0]"), 0, "update description");
+ upgrade = createIU(TOPLEVELIU, new Version(2, 0, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES);
+
category = createNamedIU(CATEGORYIU, CATEGORYIU, new Version("1.0.0"), true);
+ createTestMetdataRepository(new IInstallableUnit[] {top1, top2, uninstalled, upgrade});
metaManager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.context, IMetadataRepositoryManager.class.getName());
artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.class.getName());
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AutomatedTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AutomatedTests.java
index 2355afd76..74601e4d9 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AutomatedTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AutomatedTests.java
@@ -24,6 +24,7 @@ public class AutomatedTests extends TestCase {
suite.addTest(org.eclipse.equinox.p2.tests.ui.actions.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.ui.dialogs.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.ui.repohandling.AllTests.suite());
+ suite.addTest(org.eclipse.equinox.p2.tests.ui.planning.AllTests.suite());
return suite;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/planning/AllTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/planning/AllTests.java
new file mode 100644
index 000000000..45aee5d57
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/planning/AllTests.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.ui.planning;
+
+import junit.framework.*;
+
+/**
+ * Performs all UI action tests.
+ */
+public class AllTests extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ suite.addTestSuite(UpdatePlanning.class);
+ return suite;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/planning/UpdatePlanning.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/planning/UpdatePlanning.java
new file mode 100644
index 000000000..dd6e5b2e7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/planning/UpdatePlanning.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 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.ui.planning;
+
+import java.util.*;
+import org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement;
+import org.eclipse.equinox.internal.provisional.p2.core.*;
+import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
+import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.UpdateWizard;
+import org.eclipse.equinox.internal.provisional.p2.ui.model.IUElementListRoot;
+import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
+
+public class UpdatePlanning extends AbstractProvisioningUITest {
+ IInstallableUnit a1;
+ IInstallableUnit a120WithDifferentId;
+ IInstallableUnit a130;
+ IInstallableUnit a140WithDifferentId;
+ IInstallableUnitPatch firstPatchForA1, secondPatchForA1, thirdPatchForA1, patchFora2;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ a1 = createIU("A", new Version("1.0.0"));
+ IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor("A", new VersionRange("[1.0.0, 1.0.0]"), 0, "update description");
+ a120WithDifferentId = createIU("UpdateA", new Version(1, 2, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES);
+ a130 = createIU("A", new Version(1, 3, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES);
+ a140WithDifferentId = createIU("UpdateForA", new Version(1, 4, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES);
+ IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true));
+ IRequiredCapability lifeCycle = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null, false, false);
+ firstPatchForA1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle);
+ secondPatchForA1 = createIUPatch("P", new Version("2.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle);
+ thirdPatchForA1 = createIUPatch("P2", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle);
+
+ IRequirementChange change2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true));
+ IRequiredCapability lifeCycle2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 3.2.0]"), null, false, false);
+ patchFora2 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change2}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle2);
+
+ // Ensure that all versions, not just the latest, are considered by the UI
+ Policy.getDefault().getQueryContext().setShowLatestVersionsOnly(false);
+ }
+
+ public void testChooseUpdateOverPatch() throws ProvisionException {
+ createTestMetdataRepository(new IInstallableUnit[] {a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2});
+ install(a1, true, false);
+ ProfileChangeRequest request = UpdateWizard.createProfileChangeRequest(new IInstallableUnit[] {a1}, profile.getProfileId(), null, null, getMonitor());
+ assertTrue("1.0", request.getAddedInstallableUnits().length == 1);
+ assertTrue("1.1", request.getAddedInstallableUnits()[0].equals(a130));
+ assertTrue("1.2", request.getRemovedInstallableUnits().length == 1);
+ assertTrue("1.3", request.getRemovedInstallableUnits()[0].equals(a1));
+ }
+
+ public void testForcePatchOverUpdate() throws ProvisionException {
+ createTestMetdataRepository(new IInstallableUnit[] {a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2});
+ install(a1, true, false);
+ AvailableUpdateElement patch = new AvailableUpdateElement(null, firstPatchForA1, a1, profile.getProfileId(), false);
+ ArrayList initialSelections = new ArrayList(1);
+ initialSelections.add(patch);
+ ProfileChangeRequest request = UpdateWizard.createProfileChangeRequest(new IInstallableUnit[] {a1}, profile.getProfileId(), null, initialSelections, getMonitor());
+ assertTrue("1.0", request.getAddedInstallableUnits().length == 1);
+ assertTrue("1.1", request.getAddedInstallableUnits()[0].equals(firstPatchForA1));
+ assertTrue("1.2", request.getRemovedInstallableUnits().length == 0);
+ }
+
+ public void testRecognizePatchIsInstalled() throws ProvisionException {
+ createTestMetdataRepository(new IInstallableUnit[] {a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2});
+ install(a1, true, false);
+ install(firstPatchForA1, true, false);
+ IUElementListRoot root = new IUElementListRoot();
+ ProfileChangeRequest request = UpdateWizard.createProfileChangeRequest(new IInstallableUnit[] {a1}, profile.getProfileId(), root, null, getMonitor());
+ // update was favored, that would happen even if patch was not installed
+ assertTrue("1.0", request.getAddedInstallableUnits().length == 1);
+ assertTrue("1.1", request.getAddedInstallableUnits()[0].equals(a130));
+ // the patch is not being shown to the user because we figured out it was already installed
+ // The elements showing are a130 and a120WithDifferentId
+ assertEquals("1.2", 2, root.getChildren(root).length);
+ }
+
+ public void testChooseNotTheNewest() throws ProvisionException {
+ createTestMetdataRepository(new IInstallableUnit[] {a1, a120WithDifferentId, a130, firstPatchForA1, patchFora2});
+ install(a1, true, false);
+ AvailableUpdateElement notTheNewest = new AvailableUpdateElement(null, a120WithDifferentId, a1, profile.getProfileId(), false);
+ ArrayList initialSelections = new ArrayList(1);
+ initialSelections.add(notTheNewest);
+ IUElementListRoot root = new IUElementListRoot();
+ ProfileChangeRequest request = UpdateWizard.createProfileChangeRequest(new IInstallableUnit[] {a1}, profile.getProfileId(), root, initialSelections, getMonitor());
+ // selected was favored
+ assertTrue("1.0", request.getAddedInstallableUnits().length == 1);
+ assertTrue("1.1", request.getAddedInstallableUnits()[0].equals(a120WithDifferentId));
+ // The two updates and the patch were recognized
+ assertEquals("1.2", 3, root.getChildren(root).length);
+ }
+
+ public void testChooseLatestPatches() throws ProvisionException {
+ createTestMetdataRepository(new IInstallableUnit[] {a1, firstPatchForA1, secondPatchForA1, thirdPatchForA1});
+ install(a1, true, false);
+ IUElementListRoot root = new IUElementListRoot();
+ ProfileChangeRequest request = UpdateWizard.createProfileChangeRequest(new IInstallableUnit[] {a1}, profile.getProfileId(), root, null, getMonitor());
+ // the latest two patches were selected
+ HashSet chosen = new HashSet();
+ assertTrue("1.0", request.getAddedInstallableUnits().length == 2);
+ chosen.addAll(Arrays.asList(request.getAddedInstallableUnits()));
+ assertTrue("1.1", chosen.contains(secondPatchForA1));
+ assertTrue("1.2", chosen.contains(thirdPatchForA1));
+
+ assertEquals("1.2", 3, root.getChildren(root).length);
+ }
+
+ public void testLatestHasDifferentId() throws ProvisionException {
+ createTestMetdataRepository(new IInstallableUnit[] {a1, firstPatchForA1, secondPatchForA1, thirdPatchForA1, a120WithDifferentId, a130, a140WithDifferentId});
+ install(a1, true, false);
+ IUElementListRoot root = new IUElementListRoot();
+ ProfileChangeRequest request = UpdateWizard.createProfileChangeRequest(new IInstallableUnit[] {a1}, profile.getProfileId(), root, null, getMonitor());
+ // update 140 was recognized as the latest even though it had a different id
+ assertTrue("1.0", request.getAddedInstallableUnits().length == 1);
+ assertTrue("1.1", request.getAddedInstallableUnits()[0].equals(a140WithDifferentId));
+ // All three patches and all three updates can be chosen
+ assertEquals("1.2", 6, root.getChildren(root).length);
+ }
+}

Back to the top