Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2010-02-16 21:36:36 -0500
committerSusan Franklin2010-02-16 21:36:36 -0500
commit88c975a9efc37539746c67801fcb0ac037db8f06 (patch)
treef2f8f79afe430b49b363b55c43212c0eeba7e3c4 /bundles/org.eclipse.equinox.p2.tests.ui
parentb5b9537dbd8ce719cd6bc650a762d0ac94bf8e86 (diff)
downloadrt.equinox.p2-88c975a9efc37539746c67801fcb0ac037db8f06.tar.gz
rt.equinox.p2-88c975a9efc37539746c67801fcb0ac037db8f06.tar.xz
rt.equinox.p2-88c975a9efc37539746c67801fcb0ac037db8f06.zip
Bug 233027 - [ui] Remembered licenses should be stored in the profile data area
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.ui')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java30
-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/misc/AllTests.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/misc/LicenseManagerTest.java82
5 files changed, 134 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF
index ee642ddbf..d9d22f2f0 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF
@@ -19,4 +19,5 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.100",
org.junit;bundle-version="3.8.0",
org.eclipse.equinox.p2.repository;bundle-version="1.0.0",
org.eclipse.equinox.p2.tests;bundle-version="1.2.0"
-Import-Package: org.eclipse.equinox.p2.operations
+Import-Package: org.eclipse.equinox.p2.operations,
+ org.eclipse.equinox.internal.p2.ui.sdk
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 e55c11708..d554c1115 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
@@ -12,23 +12,27 @@ package org.eclipse.equinox.p2.tests.ui;
import java.io.File;
import java.net.URI;
+import java.util.Dictionary;
+import java.util.Hashtable;
import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.ui.ColocatedRepositoryTracker;
import org.eclipse.equinox.internal.p2.ui.model.ProfileElement;
+import org.eclipse.equinox.internal.p2.ui.sdk.SimpleLicenseManager;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.operations.ProfileModificationJob;
-import org.eclipse.equinox.p2.operations.ProvisioningSession;
+import org.eclipse.equinox.p2.operations.*;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
-import org.eclipse.equinox.p2.ui.Policy;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
+import org.eclipse.equinox.p2.ui.*;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
/**
* Abstract class to set up the colocated UI test repo
@@ -56,15 +60,27 @@ public abstract class AbstractProvisioningUITest extends AbstractProvisioningTes
protected IInstallableUnit uninstalled;
protected IInstallableUnit category;
private ProvisioningUI ui;
+ private ServiceRegistration regLicenseManager, regTracker;
protected void setUp() throws Exception {
super.setUp();
+ // create test profile
+ profile = createProfile(TESTPROFILE);
+
+ // copy of provisioning UI that uses a different profile
ui = ProvisioningUI.getDefaultUI();
ui = new ProvisioningUI(ui.getSession(), TESTPROFILE, ui.getPolicy());
ui.getOperationRunner().suppressRestart(true);
- // to squelch repo error reporting
ui.getPolicy().setRepositoriesVisible(false);
- profile = createProfile(TESTPROFILE);
+
+ // register alternate services
+ SimpleLicenseManager manager = new SimpleLicenseManager(TESTPROFILE);
+ RepositoryTracker tracker = new ColocatedRepositoryTracker(ui);
+ Dictionary<String, Object> properties = new Hashtable<String, Object>(5);
+ properties.put(Constants.SERVICE_RANKING, new Integer(1));
+ regLicenseManager = TestActivator.getContext().registerService(LicenseManager.class.getName(), manager, properties);
+ regTracker = TestActivator.getContext().registerService(RepositoryTracker.class.getName(), tracker, properties);
+
profileElement = new ProfileElement(null, TESTPROFILE);
install((top1 = createIU(TOPLEVELIU, Version.create("1.0.0"))), true, false);
install((top2 = createIU(TOPLEVELIU2)), true, false);
@@ -89,6 +105,8 @@ public abstract class AbstractProvisioningUITest extends AbstractProvisioningTes
super.tearDown();
metaManager.removeRepository(testRepoLocation);
artifactManager.removeRepository(testRepoLocation);
+ regLicenseManager.unregister();
+ regTracker.unregister();
}
protected boolean managerContains(IRepositoryManager<?> manager, URI location) {
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 cb2b18403..98ff2020f 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
@@ -23,6 +23,7 @@ public class AutomatedTests extends TestCase {
suite.addTest(org.eclipse.equinox.p2.tests.ui.query.AllTests.suite());
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.misc.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/misc/AllTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/misc/AllTests.java
new file mode 100644
index 000000000..717130781
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/misc/AllTests.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.ui.misc;
+
+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(LicenseManagerTest.class);
+ return suite;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/misc/LicenseManagerTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/misc/LicenseManagerTest.java
new file mode 100644
index 000000000..b7ccedde1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/misc/LicenseManagerTest.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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.misc;
+
+import java.net.URI;
+import org.eclipse.equinox.internal.p2.ui.sdk.SimpleLicenseManager;
+import org.eclipse.equinox.p2.metadata.ILicense;
+import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
+import org.eclipse.equinox.p2.ui.LicenseManager;
+
+public class LicenseManagerTest extends AbstractProvisioningUITest {
+
+ class SimpleLicense implements ILicense {
+ String body;
+ String id;
+
+ SimpleLicense(String id, String body) {
+ this.id = id;
+ this.body = body;
+ }
+
+ public URI getLocation() {
+ return null;
+ }
+
+ public String getBody() {
+ return body;
+ }
+
+ public String getUUID() {
+ return id;
+ }
+
+ }
+
+ public void testLicenseAcceptAndReject() {
+ LicenseManager manager = getProvisioningUI().getLicenseManager();
+ SimpleLicense foo = new SimpleLicense("foo", "foo");
+ SimpleLicense bar = new SimpleLicense("bar", "bar");
+
+ manager.accept(foo);
+ manager.accept(bar);
+
+ assertTrue("1.0", manager.hasAcceptedLicenses());
+ manager.reject(foo);
+ manager.reject(bar);
+ assertFalse("1.1", manager.hasAcceptedLicenses());
+
+ manager.accept(foo);
+ manager.accept(bar);
+ assertTrue("1.2", manager.hasAcceptedLicenses());
+ }
+
+ public void testDifferentProfilesDifferentLicenses() {
+ LicenseManager manager = getProvisioningUI().getLicenseManager();
+ SimpleLicense foo = new SimpleLicense("foo", "foo");
+ SimpleLicense bar = new SimpleLicense("bar", "bar");
+
+ manager.accept(foo);
+ manager.accept(bar);
+
+ assertTrue("1.0", manager.hasAcceptedLicenses());
+
+ // Ensure that a newly created license manager with the same profile has the
+ // same licenses
+ SimpleLicenseManager manager2 = new SimpleLicenseManager(TESTPROFILE);
+ assertTrue("1.1", manager2.hasAcceptedLicenses());
+
+ // A manager with a different profile would not have the same licenses
+ profile = createProfile("ANOTHER");
+ manager2 = new SimpleLicenseManager("ANOTHER");
+ assertFalse("1.2", manager2.hasAcceptedLicenses());
+ }
+}

Back to the top