Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2010-04-22 18:51:29 -0400
committerSusan Franklin2010-04-22 18:51:29 -0400
commitb3748ee2e855e58ac1d07ad02a207af6cca35a92 (patch)
treea5ea7d92b23b2a1ad034f428d3940cde004a5c16 /bundles/org.eclipse.equinox.p2.tests.ui
parent08b71bdfc31827113ada7f5f2530cf6e9320a2e9 (diff)
downloadrt.equinox.p2-b3748ee2e855e58ac1d07ad02a207af6cca35a92.tar.gz
rt.equinox.p2-b3748ee2e855e58ac1d07ad02a207af6cca35a92.tar.xz
rt.equinox.p2-b3748ee2e855e58ac1d07ad02a207af6cca35a92.zip
Bug 310206 - [ui] how and when does UI make use of ProvisioningContext repo referencing?
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/operations/AllTests.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallOperationTests.java94
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallerPlanTest.java41
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UninstallOperationTests.java (renamed from bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UninstallTest.java)2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UpdateOperationTests.java (renamed from bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UpdatePlanning.java)2
5 files changed, 99 insertions, 46 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AllTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AllTests.java
index d79be131f..2b7664727 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AllTests.java
@@ -20,9 +20,9 @@ public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AllTests.class.getName());
suite.addTestSuite(SizingTest.class);
- suite.addTestSuite(InstallerPlanTest.class);
- suite.addTestSuite(UpdatePlanning.class);
- suite.addTestSuite(UninstallTest.class);
+ suite.addTestSuite(InstallOperationTests.class);
+ suite.addTestSuite(UpdateOperationTests.class);
+ suite.addTestSuite(UninstallOperationTests.class);
return suite;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallOperationTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallOperationTests.java
new file mode 100644
index 000000000..fc0c29ee5
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallOperationTests.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.operations;
+
+import java.net.URI;
+import java.util.Collections;
+import java.util.Set;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.ProvisioningContext;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.operations.InstallOperation;
+import org.eclipse.equinox.p2.query.QueryUtil;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
+import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
+
+/**
+ * Tests various aspects of install operations
+ */
+public class InstallOperationTests extends AbstractProvisioningUITest {
+ public void testInstallerPlan() throws ProvisionException {
+ URI uri = getTestData("InstallHandler", "testData/installPlan").toURI();
+ Set<IInstallableUnit> ius = getMetadataRepositoryManager().loadRepository(uri, getMonitor()).query(QueryUtil.createIUQuery("A"), getMonitor()).toSet();
+ assertTrue("One IU", ius.size() == 1);
+ InstallOperation op = new InstallOperation(getSession(), ius);
+ op.setProfileId(TESTPROFILE);
+ ProvisioningContext pc = new ProvisioningContext(getAgent());
+ pc.setArtifactRepositories(new URI[] {uri});
+ pc.setMetadataRepositories(new URI[] {uri});
+ op.setProvisioningContext(pc);
+ assertTrue("Should resolve", op.resolveModal(getMonitor()).isOK());
+ assertTrue("Should install", op.getProvisioningJob(null).runModal(getMonitor()).isOK());
+ assertFalse("Action1 should have been installed", getProfile(TESTPROFILE).query(QueryUtil.createIUQuery("Action1"), getMonitor()).isEmpty());
+ }
+
+ public void testDetectMissingRequirement() throws ProvisionException, OperationCanceledException {
+ URI uriA, uriB, uriC;
+ IMetadataRepository repoA, repoB, repoC;
+ String testDataFileLocation = "testData/provisioningContextTests/";
+ uriA = getTestData("A", testDataFileLocation + "A").toURI();
+ uriB = getTestData("B", testDataFileLocation + "B").toURI();
+ uriC = getTestData("C", testDataFileLocation + "C").toURI();
+
+ repoA = getMetadataRepositoryManager().loadRepository(uriA, getMonitor());
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=305565
+ repoA.addReferences(Collections.singletonList(new RepositoryReference(uriA, null, IRepository.TYPE_ARTIFACT, IRepository.ENABLED)));
+
+ // now create a second set of repos and refer from the first
+ repoB = getMetadataRepositoryManager().loadRepository(uriB, getMonitor());
+ repoB.addReferences(Collections.singletonList(new RepositoryReference(uriB, null, IRepository.TYPE_ARTIFACT, IRepository.ENABLED)));
+ repoA.addReferences(Collections.singletonList(new RepositoryReference(repoB.getLocation(), null, IRepository.TYPE_METADATA, IRepository.ENABLED)));
+
+ // this repo is referred by the previous one
+ repoC = getMetadataRepositoryManager().loadRepository(uriC, getMonitor());
+ repoC.addReferences(Collections.singletonList(new RepositoryReference(uriC, null, IRepository.TYPE_ARTIFACT, IRepository.ENABLED)));
+ repoB.addReferences(Collections.singletonList(new RepositoryReference(repoC.getLocation(), null, IRepository.TYPE_METADATA, IRepository.ENABLED)));
+
+ String id = "TestProfileIDForMissingRequirement";
+ createProfile(id);
+ ProvisioningContext context = new ProvisioningContext(getAgent());
+ context.setMetadataRepositories(new URI[] {repoA.getLocation()});
+ context.setArtifactRepositories(new URI[0]);
+ IInstallableUnit[] units = repoA.query(QueryUtil.createIUQuery("A"), getMonitor()).toArray(IInstallableUnit.class);
+ assertTrue("should find A in main repo", units.length > 0);
+
+ // NOW WE CAN TEST!
+ assertNull("ProvisioningContext does not follow by default", context.getProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES));
+
+ InstallOperation op = new InstallOperation(getSession(), Collections.singleton(units[0]));
+ op.setProvisioningContext(context);
+ op.setProfileId(id);
+ assertTrue("Should resolve", op.resolveModal(getMonitor()).isOK());
+
+ assertNotNull("Context was reset to follow", context.getProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES));
+
+ getArtifactRepositoryManager().removeRepository(uriA);
+ getArtifactRepositoryManager().removeRepository(uriB);
+ getArtifactRepositoryManager().removeRepository(uriC);
+ getMetadataRepositoryManager().removeRepository(uriA);
+ getMetadataRepositoryManager().removeRepository(uriB);
+ getMetadataRepositoryManager().removeRepository(uriC);
+
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallerPlanTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallerPlanTest.java
deleted file mode 100644
index 6f2b9f159..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/InstallerPlanTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.operations;
-
-import java.net.URI;
-import java.util.Set;
-import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.engine.ProvisioningContext;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.operations.InstallOperation;
-import org.eclipse.equinox.p2.query.QueryUtil;
-import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
-
-/**
- * Tests for the ability to install an IU that has an installer plan by
- * using the operation API.
- */
-public class InstallerPlanTest extends AbstractProvisioningUITest {
- public void testInstallerPlan() throws ProvisionException {
- URI uri = getTestData("InstallHandler", "testData/installPlan").toURI();
- Set<IInstallableUnit> ius = getMetadataRepositoryManager().loadRepository(uri, getMonitor()).query(QueryUtil.createIUQuery("A"), getMonitor()).toSet();
- assertTrue("One IU", ius.size() == 1);
- InstallOperation op = new InstallOperation(getSession(), ius);
- op.setProfileId(TESTPROFILE);
- ProvisioningContext pc = new ProvisioningContext(getAgent());
- pc.setArtifactRepositories(new URI[] {uri});
- pc.setMetadataRepositories(new URI[] {uri});
- op.setProvisioningContext(pc);
- assertTrue("Should resolve", op.resolveModal(getMonitor()).isOK());
- assertTrue("Should install", op.getProvisioningJob(null).runModal(getMonitor()).isOK());
- assertFalse("Action1 should have been installed", getProfile(TESTPROFILE).query(QueryUtil.createIUQuery("Action1"), getMonitor()).isEmpty());
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UninstallTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UninstallOperationTests.java
index 6622e783a..76b3f403c 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UninstallTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UninstallOperationTests.java
@@ -26,7 +26,7 @@ import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
* Tests for the ability to install an IU that has an installer plan by
* using the operation API.
*/
-public class UninstallTest extends AbstractProvisioningUITest {
+public class UninstallOperationTests extends AbstractProvisioningUITest {
public void testUninstallContactsNoRepositories() throws ProvisionException, URISyntaxException {
HashSet<IInstallableUnit> ius = new HashSet<IInstallableUnit>();
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UpdatePlanning.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UpdateOperationTests.java
index 5b39df82e..8feaa50a6 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UpdatePlanning.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/UpdateOperationTests.java
@@ -20,7 +20,7 @@ import org.eclipse.equinox.p2.operations.*;
import org.eclipse.equinox.p2.planner.IProfileChangeRequest;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
-public class UpdatePlanning extends AbstractProvisioningUITest {
+public class UpdateOperationTests extends AbstractProvisioningUITest {
IInstallableUnit a1, b1;
IInstallableUnit b12;
IInstallableUnit a120WithDifferentId;

Back to the top