Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2010-01-13 12:29:41 -0500
committerPascal Rapicault2010-01-13 12:29:41 -0500
commit18189f0d42f7375660762dc6c885cf31683ae562 (patch)
tree17775d847bed9a33f3c68b74db2df75a2139c0bc /bundles/org.eclipse.equinox.p2.tests.ui
parentc363f2984a09b73c422e38f4556fd3b23eafe958 (diff)
downloadrt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.gz
rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.xz
rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.zip
Merging api branch back to HEADv20100113
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.ui')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/All p2 UI tests.launch16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java75
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java57
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/InstallActionTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ProfileModificationActionTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/RemoveColocatedRepositoryActionTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/UninstallActionTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/UpdateActionTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/IUPropertyPagesTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java117
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallationHistoryPageTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstalledSoftwarePageTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/RepositoryManipulationPageTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UninstallWizardTest.java57
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java157
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/WizardTest.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddColocatedRepositoryOperationTest.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddProfileOperationTest.java55
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AllTests.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/ProvisioningUtilTest.java60
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveColocatedRepositoryOperationTest.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveProfilesOperationTest.java67
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java52
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/planning/UpdatePlanning.java104
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AbstractQueryTest.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AvailableIUWrapperTest.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/CategoryElementWrapperTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementWrapperTest.java53
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/MockQueryProvider.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryDescriptorTest.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java107
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/TranslationSupportTests.java (renamed from bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/IUPropertyUtilsTest.java)103
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/repohandling/SiteImportExportTest.java2
37 files changed, 570 insertions, 843 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/All p2 UI tests.launch b/bundles/org.eclipse.equinox.p2.tests.ui/All p2 UI tests.launch
index 319a62192..3d7b444d3 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/All p2 UI tests.launch
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/All p2 UI tests.launch
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<booleanAttribute key="append.args" value="true"/>
<booleanAttribute key="askclear" value="false"/>
@@ -39,7 +39,9 @@
<listEntry value="/org.eclipse.equinox.p2.touchpoint.eclipse/bin"/>
</listAttribute>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
-<booleanAttribute key="default" value="true"/>
+<booleanAttribute key="default" value="false"/>
+<stringAttribute key="deselected_workspace_plugins" value="org.eclipse.equinox.p2.ui.admin,org.eclipse.equinox.http,org.eclipse.equinox.p2.tests.optimizers,org.eclipse.equinox.p2.ui.admin.rcp,org.eclipse.equinox.p2.testserver"/>
+<booleanAttribute key="generateProfile" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
@@ -51,18 +53,20 @@
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/ibm5sr4"/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-1.6.0-openjdk-1.6.0.0.x86_64"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.equinox.p2.tests.ui.AutomatedTests"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -console -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.equinox.p2.tests.ui"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
+<stringAttribute key="selected_target_plugins" value="org.objectweb.asm@default:default,org.eclipse.ui.ide.application@default:default,org.eclipse.core.resources@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.equinox.security.ui@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.databinding.beans@default:default,org.eclipse.debug.core@default:default,com.ibm.icu@default:default,org.eclipse.core.commands@default:default,org.eclipse.compare.core@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.help.webapp@default:default,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ecf.ssl@default:false,org.apache.jasper@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.pde.core@default:default,org.eclipse.pde.doc.user@default:default,javax.servlet@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.pde.launching@default:default,org.eclipse.jface@default:default,org.eclipse.swt@default:default,org.eclipse.core.externaltools@default:default,org.eclipse.ui.externaltools@default:default,org.apache.commons.httpclient@default:default,org.eclipse.ui.navigator@default:default,org.apache.commons.codec@default:default,org.eclipse.ui.intro@default:default,javax.servlet.jsp@default:default,org.eclipse.ui.browser@default:default,org.eclipse.equinox.jsp.jasper.registry@default:default,org.eclipse.pde.ui.templates@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.debug.ui@default:default,org.eclipse.equinox.http.registry@default:default,org.eclipse.core.boot@default:default,org.apache.lucene@default:default,org.eclipse.jdt.core@default:default,org.eclipse.jdt.launching@default:default,org.eclipse.team.ui@default:default,org.eclipse.equinox.app@default:default,org.apache.lucene.analysis@default:default,org.eclipse.jdt.debug@default:default,org.eclipse.team.cvs.ssh2@default:default,org.eclipse.update.configurator@3:true,org.sat4j.pb@default:default,org.eclipse.osgi.services@default:default,org.eclipse.jdt.apt.pluggable.core@default:default,org.eclipse.jdt.junit4.runtime@default:default,org.mortbay.jetty.util@default:default,org.apache.ant@default:default,org.eclipse.core.jobs@default:default,org.eclipse.pde.ua.core@default:default,org.eclipse.help.appserver@default:default,org.eclipse.cvs@default:default,org.eclipse.ui.net@default:default,org.eclipse.pde.api.tools.ui@default:default,org.eclipse.team.core@default:default,org.eclipse.jdt.junit.runtime@default:default,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,org.eclipse.equinox.security@default:default,org.junit4@default:default,org.eclipse.ecf@default:default,org.eclipse.jdt.apt.core@default:default,org.eclipse.ant.ui@default:default,org.eclipse.jdt.junit.core@default:default,org.eclipse.help.ui@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.search@default:default,org.eclipse.help.base@default:default,org.eclipse.pde.build@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime.compatibility@default:default,org.eclipse.pde.ui@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.ui@default:default,org.eclipse.ui.ide@default:default,com.jcraft.jsch@default:default,org.eclipse.team.cvs.ui@default:default,org.eclipse.team.cvs.core@default:default,org.hamcrest.core@default:default,org.sat4j.core@default:default,org.eclipse.jdt.compiler.apt@default:false,org.eclipse.jdt.core.manipulation@default:default,org.eclipse.osgi.util@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.equinox.jsp.jasper@default:default,org.eclipse.ui.views.log@default:default,org.junit*4.7.0.v20091118-1515@default:default,org.eclipse.pde.api.tools@default:default,org.eclipse.swt.gtk.linux.x86_64@default:false,org.eclipse.pde.runtime@default:default,org.eclipse.text@default:default,org.eclipse.jdt.junit@default:default,org.eclipse.ui.workbench.compatibility@default:false,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.core.net@default:default,org.eclipse.ui.navigator.resources@default:default,org.eclipse.ui.views@default:default,org.eclipse.pde.ds.core@default:default,org.eclipse.update.scheduler@default:default,org.eclipse.pde.ua.ui@default:default,org.eclipse.core.filebuffers@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.ui.intro.universal@default:default,org.eclipse.ui.presentations.r21@default:default,org.eclipse.jface.text@default:default,org.eclipse.equinox.http.jetty@default:default,org.eclipse.equinox.util@default:default,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.osgi@-1:true,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.ui.console@default:default,org.eclipse.equinox.event@default:default,org.eclipse.core.databinding@default:default,org.apache.commons.logging@default:default,org.eclipse.rcp@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.ui.forms@default:default,org.eclipse.compare@default:default,org.eclipse.jsch.core@default:default,org.eclipse.equinox.common@2:true,org.eclipse.ant.launching@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.jdt@default:default,org.eclipse.jsch.ui@default:default,org.apache.commons.el@default:default,org.eclipse.jdt.compiler.tool@default:false,org.eclipse.update.ui@default:default,org.eclipse.core.variables@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.core.expressions@default:default,org.eclipse.update.core@default:default,org.eclipse.jdt.ui@default:default,org.eclipse.ui.editors@default:default,org.junit*3.8.2.v20090203-1005@default:default,org.eclipse.jdt.debug.ui@default:default,org.eclipse.ui.cheatsheets@default:default,org.eclipse.pde.ds.ui@default:default,org.eclipse.jdt.doc.isv@default:default,org.eclipse.ant.core@default:default,org.mortbay.jetty.server@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.sdk@default:default,org.eclipse.help@default:default,org.eclipse.pde.junit.runtime@default:default,org.eclipse.pde@default:default,org.eclipse.jdt.doc.user@default:default,org.eclipse.jdt.apt.ui@default:default,org.eclipse.platform@default:default"/>
+<stringAttribute key="selected_workspace_plugins" value="org.eclipse.equinox.p2.tests.verifier@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.pde.core@default:default,org.eclipse.ui.ide@default:default,org.eclipse.equinox.p2.directorywatcher@default:default,org.eclipse.equinox.p2.ui.sdk@default:default,org.eclipse.pde.ui@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.p2.afterthefact@default:default,org.eclipse.equinox.p2.ui.sdk.scheduler@default:default,org.eclipse.equinox.p2.common@default:default,org.eclipse.equinox.p2.ql@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,ie.wombat.jbdiff.test@default:default,org.eclipse.core.tests.harness@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.artifact.optimizers@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.equinox.p2.updatesite@default:default,org.eclipse.equinox.p2.tests.ui@default:default,org.eclipse.equinox.p2.repository.tools@default:default,org.eclipse.equinox.p2.touchpoint.osgi@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.extensionlocation@default:default,org.eclipse.equinox.frameworkadmin.test@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.easymock@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.p2.artifact.processors@default:default,org.eclipse.equinox.p2.sar@default:default,org.eclipse.test.performance@default:default,org.eclipse.equinox.p2.engine@default:default,ie.wombat.jbdiff@default:default,org.eclipse.equinox.p2.ui@default:default,org.eclipse.equinox.p2.examples.rcp.cloud@default:default,org.eclipse.equinox.p2.examples.rcp.prestartupdate@default:default,org.eclipse.pde.build.tests@default:default,org.eclipse.equinox.p2.diagnostic@default:default,org.eclipse.equinox.p2.weblistener@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.p2.exemplarysetup@default:default,org.eclipse.equinox.p2.updatechecker@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.equinox.p2.installer@default:default,org.eclipse.equinox.p2.operations@default:default,org.eclipse.equinox.p2.tests@default:default,org.eclipse.equinox.p2.reconciler.dropins@default:default,org.eclipse.pde.build@default:default,org.eclipse.pde.ui.tests@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.p2.director.app@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="false"/>
-<booleanAttribute key="useProduct" value="true"/>
+<booleanAttribute key="useProduct" value="false"/>
</launchConfiguration>
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 e6da76398..36f1650b0 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
@@ -6,8 +6,7 @@ Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.equinox.p2.tests.ui
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.4
-Require-Bundle: org.eclipse.equinox.p2.tests;bundle-version="1.1.0",
- org.eclipse.core.runtime;bundle-version="3.4.100",
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.100",
org.eclipse.ui;bundle-version="3.5.0",
org.eclipse.equinox.p2.metadata;bundle-version="1.0.0",
org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.100",
@@ -18,4 +17,6 @@ Require-Bundle: org.eclipse.equinox.p2.tests;bundle-version="1.1.0",
org.eclipse.equinox.p2.director;bundle-version="1.0.100",
org.eclipse.equinox.p2.artifact.repository;bundle-version="1.0.100",
org.junit;bundle-version="3.8.0",
- org.eclipse.equinox.p2.repository;bundle-version="1.0.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
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 152aa9cf3..1c763fe31 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
@@ -10,29 +10,31 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
+
+import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
import java.io.File;
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.*;
+import org.eclipse.equinox.internal.p2.ui.model.ProfileElement;
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.*;
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;
-import org.eclipse.equinox.internal.provisional.p2.ui.ProvisioningOperationRunner;
-import org.eclipse.equinox.internal.provisional.p2.ui.model.ProfileElement;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProfileModificationOperation;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.operations.ProfileModificationJob;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
+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;
/**
* Abstract class to set up the colocated UI test repo
@@ -59,25 +61,30 @@ public abstract class AbstractProvisioningUITest extends AbstractProvisioningTes
protected IInstallableUnit upgrade;
protected IInstallableUnit uninstalled;
protected IInstallableUnit category;
+ private ProvisioningUI ui;
protected void setUp() throws Exception {
super.setUp();
- ProvisioningOperationRunner.suppressRestart(true);
+ 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);
profileElement = new ProfileElement(null, TESTPROFILE);
- install((top1 = createIU(TOPLEVELIU, new Version("1.0.0"))), true, false);
+ install((top1 = createIU(TOPLEVELIU, Version.create("1.0.0"))), true, false);
install((top2 = createIU(TOPLEVELIU2)), true, false);
install((nested = createIU(NESTEDIU)), false, false);
install((locked = createIU(LOCKEDIU)), true, true);
uninstalled = createIU(UNINSTALLEDIU);
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);
+ upgrade = createIU(TOPLEVELIU, Version.createOSGi(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);
+ category = createNamedIU(CATEGORYIU, CATEGORYIU, Version.create("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());
+ metaManager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.context, IMetadataRepositoryManager.SERVICE_NAME);
+ artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.SERVICE_NAME);
File site = new File(TestActivator.getTestDataFolder().toString(), TEST_REPO_PATH);
testRepoLocation = site.toURI();
metaManager.addRepository(testRepoLocation);
@@ -99,22 +106,32 @@ public abstract class AbstractProvisioningUITest extends AbstractProvisioningTes
return false;
}
+ protected ProvisioningSession getSession() {
+ return ui.getSession();
+ }
+
+ protected ProvisioningUI getProvisioningUI() {
+ return ui;
+ }
+
+ protected Policy getPolicy() {
+ return ui.getPolicy();
+ }
+
protected IStatus install(IInstallableUnit iu, boolean root, boolean lock) throws ProvisionException {
ProfileChangeRequest req = new ProfileChangeRequest(profile);
req.addInstallableUnits(new IInstallableUnit[] {iu});
if (root) {
- String rootProp = Policy.getDefault().getQueryContext().getVisibleInstalledIUProperty();
- if (rootProp != null)
- req.setInstallableUnitProfileProperty(iu, rootProp, Boolean.toString(true));
+ req.setInstallableUnitProfileProperty(iu, IProfile.PROP_PROFILE_ROOT_IU, Boolean.toString(true));
}
if (lock) {
- req.setInstallableUnitProfileProperty(iu, IInstallableUnit.PROP_PROFILE_LOCKED_IU, new Integer(IInstallableUnit.LOCK_UNINSTALL | IInstallableUnit.LOCK_UPDATE).toString());
+ req.setInstallableUnitProfileProperty(iu, IProfile.PROP_PROFILE_LOCKED_IU, new Integer(IProfile.LOCK_UNINSTALL | IProfile.LOCK_UPDATE).toString());
}
// Use an empty provisioning context to prevent repo access
- ProvisioningPlan plan = ProvisioningUtil.getProvisioningPlan(req, new ProvisioningContext(new URI[] {}), getMonitor());
+ IProvisioningPlan plan = getSession().getPlanner().getProvisioningPlan(req, new ProvisioningContext(new URI[] {}), getMonitor());
if (plan.getStatus().getSeverity() == IStatus.ERROR || plan.getStatus().getSeverity() == IStatus.CANCEL)
return plan.getStatus();
- return ProvisioningUtil.performProvisioningPlan(plan, new DefaultPhaseSet(), profile, new ProvisioningContext(), getMonitor());
+ return getSession().performProvisioningPlan(plan, new DefaultPhaseSet(), new ProvisioningContext(), getMonitor());
}
protected IInstallableUnit createNamedIU(String id, String name, Version version, boolean isCategory) {
@@ -123,13 +140,13 @@ public abstract class AbstractProvisioningUITest extends AbstractProvisioningTes
iu.setVersion(version);
iu.setProperty(IInstallableUnit.PROP_NAME, name);
if (isCategory)
- iu.setProperty(IInstallableUnit.PROP_TYPE_CATEGORY, Boolean.toString(true));
+ iu.setProperty(InstallableUnitDescription.PROP_TYPE_CATEGORY, Boolean.toString(true));
return MetadataFactory.createInstallableUnit(iu);
}
- protected ProfileModificationOperation getLongTestOperation() {
- return new ProfileModificationOperation("Test Operation", TESTPROFILE, null, null) {
- protected IStatus doExecute(IProgressMonitor monitor) {
+ protected ProfileModificationJob getLongTestOperation() {
+ return new ProfileModificationJob("Test Operation", getSession(), TESTPROFILE, null, null) {
+ public IStatus runModal(IProgressMonitor monitor) {
while (true) {
// spin unless cancelled
if (monitor.isCanceled())
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java
index 81260cd65..c15ef96f2 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java
@@ -13,19 +13,17 @@ package org.eclipse.equinox.p2.tests.ui.actions;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
-import org.eclipse.equinox.internal.p2.ui.model.ElementUtils;
-import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.model.MetadataRepositories;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.internal.p2.ui.model.*;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
@@ -59,34 +57,37 @@ public class ElementUtilsTest extends ProfileModificationActionTest {
assertEquals(getMixedIUsAndElements().length, ElementUtils.elementsToIUs(getMixedIUsAndElements()).length);
}
- public void testUpdateUsingElements() throws ProvisionException, URISyntaxException {
+ public void testUpdateUsingElements() throws URISyntaxException {
+ ProvisioningSession session = getSession();
// Two visible repos, one is added, the other is not
URI known1 = new URI("http://example.com/known1");
URI known2 = new URI("http://example.com/known2");
- ProvisioningUtil.addMetadataRepository(known1, false);
+ IMetadataRepositoryManager manager = session.getMetadataRepositoryManager();
+ manager.addRepository(known1);
// Add system repos that should not be known or affected by ElementUtils
// One is an enabled system repo, one is disabled system repo
URI uri = new URI("http://example.com/1");
URI uri2 = new URI("http://example.com/2");
- ProvisioningUtil.addMetadataRepository(uri, false);
- ProvisioningUtil.setMetadataRepositoryProperty(uri, IRepository.PROP_SYSTEM, Boolean.toString(true));
- ProvisioningUtil.addMetadataRepository(uri2, false);
- ProvisioningUtil.addArtifactRepository(uri2, false);
- ProvisioningUtil.setMetadataRepositoryProperty(uri2, IRepository.PROP_SYSTEM, Boolean.toString(true));
- ProvisioningUtil.setColocatedRepositoryEnablement(uri2, false);
+ manager.addRepository(uri);
+ manager.setRepositoryProperty(uri, IRepository.PROP_SYSTEM, Boolean.toString(true));
+ manager.addRepository(uri2);
+ session.getArtifactRepositoryManager().addRepository(uri2);
+ manager.setRepositoryProperty(uri2, IRepository.PROP_SYSTEM, Boolean.toString(true));
+ manager.setEnabled(uri2, false);
+ session.getArtifactRepositoryManager().setEnabled(uri2, false);
// The elements reflect all visible sites, but not system sites
- MetadataRepositories root = new MetadataRepositories(Policy.getDefault());
+ MetadataRepositories root = new MetadataRepositories(getProvisioningUI());
List children = new ArrayList();
- children.addAll(Arrays.asList(root.getChildren(root)));
+ children.add(new MetadataRepositoryElement(null, known1, true));
// Add known2, this is as if a user added it in the pref page
children.add(new MetadataRepositoryElement(null, known2, true));
MetadataRepositoryElement[] elements = (MetadataRepositoryElement[]) children.toArray(new MetadataRepositoryElement[children.size()]);
// Add a visible repo not known by the elements
URI uri3 = new URI("http://example.com/3");
- ProvisioningUtil.addMetadataRepository(uri3, false);
+ manager.addRepository(uri3);
// Now update the repo using the elements.
// We expect known2 to get added because it was in the elements
@@ -140,8 +141,8 @@ public class ElementUtilsTest extends ProfileModificationActionTest {
display.sleep();
}
- URI[] enabled = ProvisioningUtil.getMetadataRepositories(IRepositoryManager.REPOSITORIES_ALL);
- URI[] disabled = ProvisioningUtil.getMetadataRepositories(IRepositoryManager.REPOSITORIES_DISABLED);
+ URI[] enabled = session.getMetadataRepositoryManager().getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
+ URI[] disabled = session.getMetadataRepositoryManager().getKnownRepositories(IRepositoryManager.REPOSITORIES_DISABLED);
boolean foundKnown1 = false;
boolean foundKnown2 = false;
@@ -180,11 +181,11 @@ public class ElementUtilsTest extends ProfileModificationActionTest {
assertTrue("1.4", foundKnown2); // Enabled visible repo in elements was added
// cleanup
- ProvisioningUtil.removeMetadataRepository(known1);
- ProvisioningUtil.removeMetadataRepository(known2);
- ProvisioningUtil.removeMetadataRepository(uri);
- ProvisioningUtil.removeMetadataRepository(uri2);
- ProvisioningUtil.removeArtifactRepository(uri2);
- ProvisioningUtil.removeMetadataRepository(uri3);
+ manager.removeRepository(known1);
+ manager.removeRepository(known2);
+ manager.removeRepository(uri);
+ manager.removeRepository(uri2);
+ session.getArtifactRepositoryManager().removeRepository(uri2);
+ manager.removeRepository(uri3);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/InstallActionTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/InstallActionTest.java
index 8a61940ec..aea471405 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/InstallActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/InstallActionTest.java
@@ -11,11 +11,10 @@
package org.eclipse.equinox.p2.tests.ui.actions;
+import org.eclipse.equinox.internal.p2.ui.actions.InstallAction;
import org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement;
import org.eclipse.equinox.internal.p2.ui.model.IIUElement;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.ui.actions.InstallAction;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
/**
* @since 3.5
@@ -25,7 +24,7 @@ public class InstallActionTest extends ProfileModificationActionTest {
class TestInstallAction extends InstallAction {
TestInstallAction(Object[] sel) {
- super(Policy.getDefault(), InstallActionTest.this.getSelectionProvider(sel), profile.getProfileId());
+ super(InstallActionTest.this.getProvisioningUI(), InstallActionTest.this.getSelectionProvider(sel), profile.getProfileId());
}
public IInstallableUnit[] getSelectedIUs() {
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ProfileModificationActionTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ProfileModificationActionTest.java
index 7f487e0bb..5600fb3cb 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ProfileModificationActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ProfileModificationActionTest.java
@@ -11,8 +11,7 @@
package org.eclipse.equinox.p2.tests.ui.actions;
import org.eclipse.equinox.internal.p2.ui.model.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.ui.model.InstalledIUElement;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
/**
* Abstract class to set up different IU selection combinations
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/RemoveColocatedRepositoryActionTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/RemoveColocatedRepositoryActionTest.java
index 0f7f2c5b5..687fe0952 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/RemoveColocatedRepositoryActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/RemoveColocatedRepositoryActionTest.java
@@ -10,16 +10,16 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.actions;
-import org.eclipse.equinox.internal.provisional.p2.ui.actions.RemoveColocatedRepositoryAction;
+import org.eclipse.equinox.internal.p2.ui.actions.RemoveColocatedRepositoryAction;
public class RemoveColocatedRepositoryActionTest extends ColocatedRepositoryActionTest {
public void testEmptySelection() {
- RemoveColocatedRepositoryAction action = new RemoveColocatedRepositoryAction(getSelectionProvider(getEmptySelection()));
+ RemoveColocatedRepositoryAction action = new RemoveColocatedRepositoryAction(getProvisioningUI(), getSelectionProvider(getEmptySelection()));
assertFalse("Should not be enabled with empty selection", action.isEnabled());
}
public void testInvalidSelection() {
- RemoveColocatedRepositoryAction action = new RemoveColocatedRepositoryAction(getSelectionProvider(getInvalidSelection()));
+ RemoveColocatedRepositoryAction action = new RemoveColocatedRepositoryAction(getProvisioningUI(), getSelectionProvider(getInvalidSelection()));
assertFalse("Should not be enabled with invalid selection", action.isEnabled());
}
@@ -27,7 +27,7 @@ public class RemoveColocatedRepositoryActionTest extends ColocatedRepositoryActi
assertTrue(managerContains(metaManager, testRepoLocation));
assertTrue(managerContains(artifactManager, testRepoLocation));
- RemoveColocatedRepositoryAction action = new RemoveColocatedRepositoryAction(getSelectionProvider(getValidRepoSelection()));
+ RemoveColocatedRepositoryAction action = new RemoveColocatedRepositoryAction(getProvisioningUI(), getSelectionProvider(getValidRepoSelection()));
assertTrue("Should be enabled", action.isEnabled());
action.run();
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/UninstallActionTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/UninstallActionTest.java
index 655eb85df..8a7f9d9aa 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/UninstallActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/UninstallActionTest.java
@@ -11,9 +11,8 @@
package org.eclipse.equinox.p2.tests.ui.actions;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.ui.actions.UninstallAction;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.internal.p2.ui.actions.UninstallAction;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
/**
* @since 3.5
@@ -22,7 +21,7 @@ import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
public class UninstallActionTest extends ProfileModificationActionTest {
class TestUninstallAction extends UninstallAction {
TestUninstallAction(Object[] sel) {
- super(Policy.getDefault(), UninstallActionTest.this.getSelectionProvider(sel), profile.getProfileId());
+ super(UninstallActionTest.this.getProvisioningUI(), UninstallActionTest.this.getSelectionProvider(sel), profile.getProfileId());
}
public IInstallableUnit[] getSelectedIUs() {
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/UpdateActionTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/UpdateActionTest.java
index 6901e2fd5..fa3ca5e56 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/UpdateActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/UpdateActionTest.java
@@ -11,9 +11,8 @@
package org.eclipse.equinox.p2.tests.ui.actions;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.ui.actions.UpdateAction;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.internal.p2.ui.actions.UpdateAction;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
/**
* @since 3.5
@@ -22,7 +21,7 @@ import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
public class UpdateActionTest extends ProfileModificationActionTest {
class TestUpdateAction extends UpdateAction {
TestUpdateAction(Object[] sel) {
- super(Policy.getDefault(), UpdateActionTest.this.getSelectionProvider(sel), profile.getProfileId(), true);
+ super(UpdateActionTest.this.getProvisioningUI(), UpdateActionTest.this.getSelectionProvider(sel), profile.getProfileId(), true);
}
public IInstallableUnit[] getSelectedIUs() {
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/IUPropertyPagesTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/IUPropertyPagesTest.java
index 0965029a8..52b85ae92 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/IUPropertyPagesTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/IUPropertyPagesTest.java
@@ -10,13 +10,15 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.dialogs;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
+
+import org.eclipse.equinox.p2.metadata.ILicense;
import java.net.URI;
import java.net.URISyntaxException;
-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.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.dialogs.PropertyDialog;
@@ -66,11 +68,11 @@ public class IUPropertyPagesTest extends AbstractProvisioningUITest {
private IInstallableUnit getIU() throws URISyntaxException {
InstallableUnitDescription iuDescription = new InstallableUnitDescription();
iuDescription.setId("TestIU");
- iuDescription.setVersion(new Version(1, 0, 0));
+ iuDescription.setVersion(Version.createOSGi(1, 0, 0));
iuDescription.setProperty(IInstallableUnit.PROP_PROVIDER, "Test Cases");
iuDescription.setProperty(IInstallableUnit.PROP_DESCRIPTION, "A description");
iuDescription.setProperty(IInstallableUnit.PROP_NAME, "The Biggest Baddest Test IU");
- iuDescription.setLicense(MetadataFactory.createLicense(new URI("http://example.com"), "This is an example license"));
+ iuDescription.setLicenses(new ILicense[] {MetadataFactory.createLicense(new URI("http://example.com"), "This is an example license")});
iuDescription.setCopyright(MetadataFactory.createCopyright(new URI("http://example.com"), "This is an example copyright"));
return MetadataFactory.createInstallableUnit(iuDescription);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java
index ac51fb301..107e3ec19 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java
@@ -10,23 +10,23 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.dialogs;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
+
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+
+import org.eclipse.equinox.p2.metadata.ILicense;
-import java.util.HashSet;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.internal.p2.metadata.License;
+import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.internal.p2.ui.dialogs.*;
import org.eclipse.equinox.internal.p2.ui.model.IIUElement;
import org.eclipse.equinox.internal.p2.ui.viewers.DeferredQueryContentProvider;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
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.ui.*;
-import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.*;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.PlannerResolutionOperation;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.operations.InstallOperation;
+import org.eclipse.equinox.p2.operations.ProfileModificationJob;
+import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardDialog;
@@ -40,24 +40,31 @@ public class InstallWizardTest extends WizardTest {
private static final String SELECTION_PAGE = "IUSelectionPage";
private static final String AVAILABLE_SOFTWARE_PAGE = "AvailableSoftwarePage";
- private static final String BROKEN_IU = "RCP_Browser_Example.feature.group";
private static final String MAIN_IU = "MainIU";
- public void testInstallWizardResolved() throws ProvisionException {
+ IInstallableUnit toInstall;
+
+ protected void setUp() throws Exception {
+ super.setUp();
InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
iu.setId(MAIN_IU);
- iu.setVersion(new Version(1, 0, 0));
+ iu.setProperty(InstallableUnitDescription.PROP_TYPE_GROUP, "true");
+ iu.setVersion(Version.createOSGi(1, 0, 0));
iu.setSingleton(true);
- iu.setLicense(new License(null, "There is a license to accept!"));
+ iu.setLicenses(new ILicense[] {new License(null, "There is a license to accept!", null)});
iu.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, MAIN_IU, iu.getVersion())});
- IInstallableUnit toInstall = MetadataFactory.createInstallableUnit(iu);
- ProfileChangeRequest request = new ProfileChangeRequest(profile);
- request.addInstallableUnits(new IInstallableUnit[] {toInstall});
- PlannerResolutionOperation op = getResolvedOperation(request);
- PreselectedIUInstallWizard wizard = new PreselectedIUInstallWizard(Policy.getDefault(), TESTPROFILE, new IInstallableUnit[] {toInstall}, op, null);
+ toInstall = MetadataFactory.createInstallableUnit(iu);
+ createTestMetdataRepository(new IInstallableUnit[] {toInstall});
+ }
+
+ public void testInstallWizardResolved() {
+ InstallOperation op = new InstallOperation(getSession(), new IInstallableUnit[] {toInstall});
+ op.setProfileId(TESTPROFILE);
+ PreselectedIUInstallWizard wizard = new PreselectedIUInstallWizard(getProvisioningUI(), op, new IInstallableUnit[] {toInstall}, null);
ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.open();
+ ProfileModificationJob longOp = null;
try {
SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE);
@@ -66,16 +73,31 @@ public class InstallWizardTest extends WizardTest {
// simulate the next button by getting next page and showing
IWizardPage page = page1.getNextPage();
dialog.showPage(page);
+ // we should be ok
+ assertTrue("1.1", page.isPageComplete());
+
+ // if another operation is scheduled for this profile, we should not be allowed to proceed
+ longOp = getLongTestOperation();
+ getProvisioningUI().schedule(longOp, StatusManager.LOG);
+ // causes recalculation of plan and status
+ wizard.recomputePlan(dialog);
+ // can't move to next page while op is running
+ assertFalse("1.2", page.isPageComplete());
+ longOp.cancel();
+
+ // op is no longer running, recompute plan
+ wizard.recomputePlan(dialog);
+
// license needs approval
- assertFalse("1.1", wizard.canFinish());
+ assertFalse("1.4", wizard.canFinish());
// finish button should be disabled
- while (dialog.getShell().getDisplay().readAndDispatch()) {
- // run event loop
- }
+ dialog.updateButtons();
Button finishButton = dialog.testGetButton(IDialogConstants.FINISH_ID);
- assertFalse("1.2", finishButton.isEnabled());
+ assertFalse("1.5", finishButton.isEnabled());
} finally {
dialog.getShell().close();
+ if (longOp != null)
+ longOp.cancel();
}
}
@@ -83,66 +105,63 @@ public class InstallWizardTest extends WizardTest {
* Tests the wizard
*/
public void testInstallWizardUnresolved() {
- Policy policy = Policy.getDefault();
- IUViewQueryContext context = policy.getQueryContext();
- context.setViewType(IUViewQueryContext.AVAILABLE_VIEW_FLAT);
- QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(context, false);
- manager.loadAll(getMonitor());
- InstallWizard wizard = new InstallWizard(policy, TESTPROFILE, null, null, manager);
+ LoadMetadataRepositoryJob job = new LoadMetadataRepositoryJob(getProvisioningUI());
+ getPolicy().setGroupByCategory(false);
+ job.runModal(getMonitor());
+ InstallWizard wizard = new InstallWizard(getProvisioningUI(), null, null, job);
WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.create();
dialog.setBlockOnOpen(false);
dialog.open();
+ ProfileModificationJob longOp = null;
+
try {
AvailableIUsPage page1 = (AvailableIUsPage) wizard.getPage(AVAILABLE_SOFTWARE_PAGE);
// test initial wizard state
- assertTrue(page1.getSelectedIUs().length == 0);
- assertFalse(page1.isPageComplete());
+ assertTrue("1.0", page1.getSelectedIUs().length == 0);
+ assertFalse("1.1", page1.isPageComplete());
// Start reaching in...
AvailableIUGroup group = page1.testGetAvailableIUGroup();
group.setRepositoryFilter(AvailableIUGroup.AVAILABLE_ALL, null);
// Now manipulate the tree itself. we are reaching way in.
+ // We are trying to select everything in the repo apart from the IU we know is broken
DeferredQueryContentProvider provider = (DeferredQueryContentProvider) group.getCheckboxTreeViewer().getContentProvider();
provider.setSynchronous(true);
group.getCheckboxTreeViewer().refresh();
group.getCheckboxTreeViewer().expandAll();
Tree tree = (Tree) group.getCheckboxTreeViewer().getControl();
TreeItem[] items = tree.getItems();
- HashSet ids = new HashSet();
- ids.add(BROKEN_IU);
for (int i = 0; i < items.length; i++) {
Object element = items[i].getData();
if (element != null && element instanceof IIUElement) {
IInstallableUnit iu = ((IIUElement) element).getIU();
- if (iu != null && !ids.contains(iu.getId())) {
- ids.add(iu.getId());
+ if (iu != null && iu.getId().equals(MAIN_IU)) {
group.getCheckboxTreeViewer().setChecked(element, true);
}
}
}
// must be done this way to force notification of listeners
group.setChecked(group.getCheckboxTreeViewer().getCheckedElements());
+ assertTrue("2.0", group.getCheckedLeafIUs().length > 0);
+ assertTrue("2.1", page1.isPageComplete());
+ // simulate the user clicking next
IWizardPage page = wizard.getNextPage(page1);
- assertTrue(page instanceof IResolutionErrorReportingPage);
- IResolutionErrorReportingPage page2 = (IResolutionErrorReportingPage) page;
- assertTrue(group.getCheckedLeafIUs().length > 0);
- dialog.showPage(page2);
+ dialog.showPage(page);
+ assertTrue("3.0", page.isPageComplete());
// if another operation is scheduled for this profile, we should not be allowed to proceed
- Job job = ProvisioningOperationRunner.schedule(getLongTestOperation(), StatusManager.LOG);
- assertTrue(page1.isPageComplete());
-
+ longOp = getLongTestOperation();
+ getProvisioningUI().schedule(longOp, StatusManager.LOG);
// causes recalculation of plan and status
- dialog.showPage(page1);
- wizard.getNextPage(page1);
- assertTrue(page1.isPageComplete());
- assertFalse(page2.isPageComplete());
- job.cancel();
+ wizard.recomputePlan(dialog);
+ // can't move to next page while op is running
+ assertFalse("3.1", page.isPageComplete());
+ longOp.cancel();
// this doesn't test much, it's just calling group API to flesh out NPE's, etc.
group.getCheckedLeafIUs();
@@ -152,6 +171,8 @@ public class InstallWizardTest extends WizardTest {
} finally {
dialog.close();
+ if (longOp != null)
+ longOp.cancel();
}
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallationHistoryPageTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallationHistoryPageTest.java
index c52dfb8b7..dbaaac69b 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallationHistoryPageTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallationHistoryPageTest.java
@@ -13,10 +13,10 @@ package org.eclipse.equinox.p2.tests.ui.dialogs;
import java.lang.reflect.Field;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.*;
-import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.RevertProfilePage;
-import org.eclipse.equinox.internal.provisional.p2.ui.viewers.ProvElementContentProvider;
+import org.eclipse.equinox.internal.p2.ui.ProvUI;
+import org.eclipse.equinox.internal.p2.ui.viewers.ProvElementContentProvider;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
+import org.eclipse.equinox.p2.ui.RevertProfilePage;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.AbstractTableViewer;
import org.eclipse.swt.SWT;
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstalledSoftwarePageTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstalledSoftwarePageTest.java
index ba43c86bc..cc4e0b7bf 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstalledSoftwarePageTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstalledSoftwarePageTest.java
@@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.dialogs;
-import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.InstalledSoftwarePage;
+import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
+import org.eclipse.equinox.p2.ui.InstalledSoftwarePage;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/RepositoryManipulationPageTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/RepositoryManipulationPageTest.java
index c607fad49..6336fb8dc 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/RepositoryManipulationPageTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/RepositoryManipulationPageTest.java
@@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.dialogs;
-import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.RepositoryManipulationPage;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
+import org.eclipse.equinox.p2.ui.RepositoryManipulationPage;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UninstallWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UninstallWizardTest.java
index 3509da276..079a8bccc 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UninstallWizardTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UninstallWizardTest.java
@@ -10,18 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.dialogs;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.equinox.internal.p2.ui.dialogs.ResolutionResultsWizardPage;
-import org.eclipse.equinox.internal.p2.ui.dialogs.SelectableIUsPage;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.provisional.p2.ui.ProvisioningOperationRunner;
-import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.ProvisioningWizardDialog;
-import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.UninstallWizard;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.PlannerResolutionOperation;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.internal.p2.ui.ProvUI;
+import org.eclipse.equinox.internal.p2.ui.dialogs.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.operations.ProfileModificationJob;
+import org.eclipse.equinox.p2.operations.UninstallOperation;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.statushandlers.StatusManager;
@@ -36,17 +29,17 @@ public class UninstallWizardTest extends WizardTest {
* Tests the wizard when the uninstall is preresolved.
* This is the normal SDK workflow.
*/
- public void testUninstallWizardResolved() throws ProvisionException {
+ public void testUninstallWizardResolved() {
- ProfileChangeRequest req = new ProfileChangeRequest(profile);
IInstallableUnit[] iusInvolved = new IInstallableUnit[] {top1, top2};
- req.removeInstallableUnits(iusInvolved);
- PlannerResolutionOperation op = getResolvedOperation(req);
- UninstallWizard wizard = new UninstallWizard(Policy.getDefault(), TESTPROFILE, iusInvolved, op);
+ UninstallOperation op = getProvisioningUI().getUninstallOperation(iusInvolved, null);
+ op.resolveModal(getMonitor());
+ UninstallWizard wizard = new UninstallWizard(getProvisioningUI(), op, iusInvolved, null);
WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.create();
dialog.open();
+ ProfileModificationJob longOp = null;
try {
SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE);
@@ -57,16 +50,18 @@ public class UninstallWizardTest extends WizardTest {
assertTrue(page2.isPageComplete());
// if another operation is scheduled for this profile, we should not be allowed to proceed
- Job job = ProvisioningOperationRunner.schedule(getLongTestOperation(), StatusManager.LOG);
+ longOp = getLongTestOperation();
+ getProvisioningUI().schedule(longOp, StatusManager.LOG);
assertTrue(page1.isPageComplete());
// causes recalculation of plan and status
- wizard.getNextPage(page1);
+ wizard.recomputePlan(dialog);
// can't move to next page while op is running
assertFalse(page1.isPageComplete());
- job.cancel();
-
+ longOp.cancel();
} finally {
dialog.getShell().close();
+ if (longOp != null)
+ longOp.cancel();
}
}
@@ -76,7 +71,8 @@ public class UninstallWizardTest extends WizardTest {
*/
public void testUninstallWizardUnresolved() {
// This test is pretty useless right now but at least it opens the wizard
- UninstallWizard wizard = new UninstallWizard(Policy.getDefault(), TESTPROFILE, new IInstallableUnit[] {top1, top2}, null);
+ UninstallOperation operation = getProvisioningUI().getUninstallOperation(new IInstallableUnit[] {top1, top2}, null);
+ UninstallWizard wizard = new UninstallWizard(getProvisioningUI(), operation, new IInstallableUnit[] {top1, top2}, null);
WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.create();
@@ -84,20 +80,11 @@ public class UninstallWizardTest extends WizardTest {
try {
SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE);
- assertFalse(page1.isPageComplete());
- // Will cause computation of a plan.
- ResolutionResultsWizardPage page2 = (ResolutionResultsWizardPage) wizard.getNextPage(page1);
- dialog.showPage(page2);
- assertTrue(page2.isPageComplete());
-
- // if another operation is scheduled for this profile, we should not be allowed to proceed
- Job job = ProvisioningOperationRunner.schedule(getLongTestOperation(), StatusManager.LOG);
assertTrue(page1.isPageComplete());
- // causes recalculation of plan and status
- wizard.getNextPage(page1);
- // can't move to next page while op is running
- assertFalse(page1.isPageComplete());
- job.cancel();
+ // Should be able to resolve a plan
+ wizard.recomputePlan(dialog);
+ // Still ok
+ assertTrue(page1.isPageComplete());
} finally {
dialog.getShell().close();
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java
index 7ec1dc401..e7a51619c 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java
@@ -10,25 +10,21 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.dialogs;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
+
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
+
+import org.eclipse.equinox.p2.metadata.ILicense;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.internal.p2.metadata.License;
-import org.eclipse.equinox.internal.p2.ui.dialogs.ResolutionResultsWizardPage;
-import org.eclipse.equinox.internal.p2.ui.dialogs.SelectableIUsPage;
-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.p2.ui.ProvUI;
+import org.eclipse.equinox.internal.p2.ui.dialogs.*;
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.ui.ProvUI;
-import org.eclipse.equinox.internal.provisional.p2.ui.ProvisioningOperationRunner;
-import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.ProvisioningWizardDialog;
-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.operations.PlannerResolutionOperation;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.operations.*;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardDialog;
@@ -49,41 +45,39 @@ public class UpdateWizardTest extends WizardTest {
super.setUp();
InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
iu.setId(MAIN_IU);
- iu.setVersion(new Version(1, 0, 0));
+ iu.setVersion(Version.createOSGi(1, 0, 0));
iu.setSingleton(true);
iu.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, MAIN_IU, iu.getVersion())});
main = MetadataFactory.createInstallableUnit(iu);
install(main, true, false);
IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor(MAIN_IU, new VersionRange("[1.0.0, 1.0.0]"), 0, "update description");
- mainUpgrade1 = createIU(MAIN_IU, new Version(2, 0, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, true, update, NO_REQUIRES);
+ mainUpgrade1 = createIU(MAIN_IU, Version.createOSGi(2, 0, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, true, update, NO_REQUIRES);
update = MetadataFactory.createUpdateDescriptor(MAIN_IU, new VersionRange("[1.0.0, 1.0.0]"), 0, "update description");
- mainUpgrade2 = createIU(MAIN_IU, new Version(3, 0, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, true, update, NO_REQUIRES);
+ mainUpgrade2 = createIU(MAIN_IU, Version.createOSGi(3, 0, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, true, update, NO_REQUIRES);
iu = new MetadataFactory.InstallableUnitDescription();
iu.setId(MAIN_IU);
- iu.setVersion(new Version(4, 0, 0));
+ iu.setVersion(Version.createOSGi(4, 0, 0));
iu.setSingleton(true);
iu.setUpdateDescriptor(update);
- iu.setLicense(new License(null, "Update Wizard Test License to Accept"));
+ iu.setLicenses(new ILicense[] {new License(null, "Update Wizard Test License to Accept", null)});
iu.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, MAIN_IU, iu.getVersion())});
mainUpgradeWithLicense = MetadataFactory.createInstallableUnit(iu);
+ createTestMetdataRepository(new IInstallableUnit[] {main, mainUpgrade1, mainUpgrade2, mainUpgradeWithLicense});
+
}
/**
* Tests the wizard when a prior resolution has been done.
* This is the SDK
*/
- public void testUpdateWizardResolved() throws ProvisionException {
- IUElementListRoot root = new IUElementListRoot();
- AvailableUpdateElement element = new AvailableUpdateElement(root, upgrade, top1, TESTPROFILE, true);
- root.setChildren(new Object[] {element});
- ProfileChangeRequest request = new ProfileChangeRequest(profile);
- request.removeInstallableUnits(new IInstallableUnit[] {top1});
- request.addInstallableUnits(new IInstallableUnit[] {upgrade});
- PlannerResolutionOperation op = getResolvedOperation(request);
- UpdateWizard wizard = new UpdateWizard(Policy.getDefault(), TESTPROFILE, root, new Object[] {element}, op, null);
+ public void testUpdateWizardResolved() {
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {main}, null);
+ op.resolveModal(getMonitor());
+ UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), op, op.getSelectedUpdates(), null);
WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.open();
+ ProfileModificationJob longOp = null;
try {
SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE);
@@ -94,28 +88,25 @@ public class UpdateWizardTest extends WizardTest {
assertTrue(page2.isPageComplete());
// if another operation is scheduled for this profile, we should not be allowed to proceed
- Job job = ProvisioningOperationRunner.schedule(getLongTestOperation(), StatusManager.LOG);
- assertTrue(page1.isPageComplete());
+ longOp = getLongTestOperation();
+ getProvisioningUI().schedule(longOp, StatusManager.LOG);
+ assertTrue(page2.isPageComplete());
// causes recalculation of plan and status
- wizard.getNextPage(page1);
+ wizard.recomputePlan(dialog);
// can't move to next page while op is running
- assertFalse(page1.isPageComplete());
- job.cancel();
-
+ assertFalse(page2.isPageComplete());
+ longOp.cancel();
} finally {
dialog.getShell().close();
+ if (longOp != null)
+ longOp.cancel();
}
}
- public void testUpdateWizardResolvedWithLicense() throws ProvisionException {
- IUElementListRoot root = new IUElementListRoot();
- AvailableUpdateElement element = new AvailableUpdateElement(root, mainUpgradeWithLicense, main, TESTPROFILE, true);
- root.setChildren(new Object[] {element});
- ProfileChangeRequest request = new ProfileChangeRequest(profile);
- request.removeInstallableUnits(new IInstallableUnit[] {main});
- request.addInstallableUnits(new IInstallableUnit[] {mainUpgradeWithLicense});
- PlannerResolutionOperation op = getResolvedOperation(request);
- UpdateWizard wizard = new UpdateWizard(Policy.getDefault(), TESTPROFILE, root, new Object[] {element}, op, null);
+ public void testUpdateWizardResolvedWithLicense() {
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {main}, null);
+ op.resolveModal(getMonitor());
+ UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), op, op.getSelectedUpdates(), null);
ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.open();
@@ -143,18 +134,12 @@ public class UpdateWizardTest extends WizardTest {
/**
* Tests the wizard when a prior resolution has been done, but is in error.
*/
- public void testUpdateWizardResolvedError() throws ProvisionException {
- IUElementListRoot root = new IUElementListRoot();
- AvailableUpdateElement element = new AvailableUpdateElement(root, mainUpgrade1, main, TESTPROFILE, true);
- AvailableUpdateElement element2 = new AvailableUpdateElement(root, mainUpgrade2, main, TESTPROFILE, true);
- root.setChildren(new Object[] {element, element2});
- ProfileChangeRequest request = new ProfileChangeRequest(profile);
- request.removeInstallableUnits(new IInstallableUnit[] {main});
- request.addInstallableUnits(new IInstallableUnit[] {mainUpgrade1, mainUpgrade2});
- PlannerResolutionOperation op = getResolvedOperation(request);
- UpdateWizard wizard = new UpdateWizard(Policy.getDefault(), TESTPROFILE, root, new Object[] {element, element2}, op, null);
- wizard.setSkipSelectionsPage(true);
- WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
+ public void testUpdateWizardResolvedError() {
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {main}, null);
+ op.resolveModal(getMonitor());
+ op.setSelectedUpdates(op.getPossibleUpdates());
+ UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), op, op.getSelectedUpdates(), null);
+ ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.open();
@@ -169,17 +154,12 @@ public class UpdateWizardTest extends WizardTest {
* Tests the wizard when we have a successful resolution and want to open
* directly on the resolution page
*/
- public void testUpdateWizardResolvedSkipSelections() throws ProvisionException {
- IUElementListRoot root = new IUElementListRoot();
- AvailableUpdateElement element = new AvailableUpdateElement(root, mainUpgrade1, main, TESTPROFILE, true);
- root.setChildren(new Object[] {element});
- ProfileChangeRequest request = new ProfileChangeRequest(profile);
- request.removeInstallableUnits(new IInstallableUnit[] {main});
- request.addInstallableUnits(new IInstallableUnit[] {mainUpgrade1});
- PlannerResolutionOperation op = getResolvedOperation(request);
- UpdateWizard wizard = new UpdateWizard(Policy.getDefault(), TESTPROFILE, root, new Object[] {element}, op, null);
+ public void testUpdateWizardResolvedSkipSelections() {
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {main}, null);
+ op.resolveModal(getMonitor());
+ UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), op, op.getSelectedUpdates(), null);
wizard.setSkipSelectionsPage(true);
- WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
+ ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.open();
@@ -196,31 +176,21 @@ public class UpdateWizardTest extends WizardTest {
* This is not the SDK workflow, but should be supported.
*/
public void testUpdateWizardUnresolved() {
- IUElementListRoot root = new IUElementListRoot();
- AvailableUpdateElement element = new AvailableUpdateElement(root, upgrade, top1, TESTPROFILE, true);
- root.setChildren(new Object[] {element});
-
- UpdateWizard wizard = new UpdateWizard(Policy.getDefault(), TESTPROFILE, root, new Object[] {element}, null, null);
+ Update update = new Update(main, mainUpgrade1);
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {main}, null);
+ UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), op, new Object[] {update}, null);
WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.open();
try {
SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE);
- assertFalse(page1.isPageComplete());
- // Will cause computation of a plan.
- ResolutionResultsWizardPage page2 = (ResolutionResultsWizardPage) wizard.getNextPage(page1);
- dialog.showPage(page2);
- assertTrue(page2.isPageComplete());
-
- // if another operation is scheduled for this profile, we should not be allowed to proceed
- Job job = ProvisioningOperationRunner.schedule(getLongTestOperation(), StatusManager.LOG);
+ // Page 1 should have selections
+ assertTrue(page1.isPageComplete());
+ // Should be able to resolve an unresolved operation
+ wizard.recomputePlan(dialog);
+ // Everything is still good
assertTrue(page1.isPageComplete());
- // causes recalculation of plan and status
- wizard.getNextPage(page1);
- // can't move to next page while op is running
- assertFalse(page1.isPageComplete());
- job.cancel();
} finally {
dialog.getShell().close();
@@ -230,17 +200,12 @@ public class UpdateWizardTest extends WizardTest {
/**
* Tests the wizard when multiple versions are available.
*/
- public void testBug277554MultipleVersions() throws ProvisionException {
- IUElementListRoot root = new IUElementListRoot();
- AvailableUpdateElement element = new AvailableUpdateElement(root, mainUpgrade1, main, TESTPROFILE, true);
- AvailableUpdateElement element2 = new AvailableUpdateElement(root, mainUpgrade2, main, TESTPROFILE, true);
- root.setChildren(new Object[] {element, element2});
- ProfileChangeRequest request = new ProfileChangeRequest(profile);
- request.removeInstallableUnits(new IInstallableUnit[] {main});
- request.addInstallableUnits(new IInstallableUnit[] {mainUpgrade2});
- PlannerResolutionOperation op = getResolvedOperation(request);
- UpdateWizard wizard = new UpdateWizard(Policy.getDefault(), TESTPROFILE, root, new Object[] {element2}, op, null);
- WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
+ public void testBug277554MultipleVersions() {
+
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {main}, null);
+ op.resolveModal(getMonitor());
+ UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), op, op.getSelectedUpdates(), null);
+ ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.open();
@@ -248,7 +213,7 @@ public class UpdateWizardTest extends WizardTest {
SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE);
// should already have a plan
assertTrue("1.0", page1.isPageComplete());
- assertEquals("1.1", page1.getCheckedIUElements().length, 1);
+ assertEquals("1.1", 1, page1.getCheckedIUElements().length);
ResolutionResultsWizardPage page2 = (ResolutionResultsWizardPage) wizard.getNextPage(page1);
dialog.showPage(page2);
// should only have one root item in the resolution page
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/WizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/WizardTest.java
index f312c6b0a..630b6c789 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/WizardTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/WizardTest.java
@@ -10,22 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.dialogs;
-import java.net.URI;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.PlannerResolutionOperation;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
/**
- * Tests for the install wizard
+ * Generic wizard test methods
*/
public abstract class WizardTest extends AbstractProvisioningUITest {
- protected PlannerResolutionOperation getResolvedOperation(ProfileChangeRequest request) throws ProvisionException {
- PlannerResolutionOperation op = new PlannerResolutionOperation("Test resolve operation", request.getProfile().getProfileId(), request, new ProvisioningContext(new URI[] {}), new MultiStatus(ProvUIActivator.PLUGIN_ID, 0, "This is just a test multistatus", null), true);
- op.execute(getMonitor());
- return op;
- }
+
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddColocatedRepositoryOperationTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddColocatedRepositoryOperationTest.java
deleted file mode 100644
index 9dc820ded..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddColocatedRepositoryOperationTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * 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.operations;
-
-import java.net.URI;
-import java.util.Arrays;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.AddColocatedRepositoryOperation;
-import org.eclipse.equinox.p2.tests.TestData;
-import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
-
-/**
- * Tests for {@link AddColocatedRepositoryOperation}.
- */
-public class AddColocatedRepositoryOperationTest extends AbstractProvisioningUITest {
- public void testAddSingleRepository() {
- URI repoLocation = null;
- try {
- repoLocation = TestData.getFile("artifactRepo", "").toURI();
- } catch (Exception e) {
- fail("0.99", e);
- }
- AddColocatedRepositoryOperation op = new AddColocatedRepositoryOperation("label", repoLocation);
- assertTrue("1.0", op.runInBackground());
-
- try {
- IStatus result = op.execute(getMonitor());
- assertTrue("1.1", result.isOK());
- } catch (ProvisionException e) {
- fail("1.99", e);
- }
-
- URI[] repos = metaManager.getKnownRepositories(0);
- assertTrue("2.0", Arrays.asList(repos).contains(repoLocation));
- assertTrue("2.1", metaManager.isEnabled(repoLocation));
-
- repos = artifactManager.getKnownRepositories(0);
- assertTrue("3.0", Arrays.asList(repos).contains(repoLocation));
- assertTrue("3.1", artifactManager.isEnabled(repoLocation));
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddProfileOperationTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddProfileOperationTest.java
deleted file mode 100644
index e03afd230..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/AddProfileOperationTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * 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.operations;
-
-import java.util.HashMap;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.AddProfileOperation;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
-import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
-
-/**
- * Tests for {@link AddProfileOperation}.
- */
-public class AddProfileOperationTest extends AbstractProvisioningUITest {
- public static final String TEST_PROP_KEY = "TEST_PROP_KEY";
- public static final String TEST_PROP_VALUE = "TEST_PROP_VALUE";
-
- /**
- * Tests a simple profile addition that should succeed
- */
- public void testAddSimple() {
- HashMap properties = new HashMap();
- properties.put(TEST_PROP_KEY, TEST_PROP_VALUE);
- String profileId = "add-simple";
- profilesToRemove.add(profileId);
- AddProfileOperation op = new AddProfileOperation("label", profileId, properties);
-
- try {
- IStatus result = op.execute(getMonitor());
- assertTrue("1.2", result.isOK());
- } catch (ProvisionException e) {
- fail("0.99", e);
- }
-
- IProfile p = null;
- try {
- p = ProvisioningUtil.getProfile(profileId);
- } catch (ProvisionException e) {
- fail("2.99", e);
- return;
- }
- assertNotNull("3.0", p);
- assertEquals("3.1", TEST_PROP_VALUE, p.getProperty(TEST_PROP_KEY));
- }
-}
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 b5a272419..49a26d748 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
@@ -19,11 +19,7 @@ public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AllTests.class.getName());
- suite.addTestSuite(AddColocatedRepositoryOperationTest.class);
- suite.addTestSuite(AddProfileOperationTest.class);
- suite.addTestSuite(RemoveProfilesOperationTest.class);
suite.addTestSuite(SizingTest.class);
- suite.addTestSuite(ProvisioningUtilTest.class);
return suite;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/ProvisioningUtilTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/ProvisioningUtilTest.java
deleted file mode 100644
index 8ad4f121d..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/ProvisioningUtilTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * 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.operations;
-
-import java.net.URI;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
-import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
-
-/**
- *
- */
-public class ProvisioningUtilTest extends AbstractProvisioningUITest {
- public void testArtifactRepos() throws ProvisionException {
- URI[] artifactRepos = ProvisioningUtil.getArtifactRepositories(IRepositoryManager.REPOSITORIES_ALL);
- for (int i = 0; i < artifactRepos.length; i++)
- assertTrue(artifactRepos[i].toString() + " should be enabled", ProvisioningUtil.getArtifactRepositoryEnablement(artifactRepos[i]));
-
- artifactRepos = ProvisioningUtil.getArtifactRepositories(IRepositoryManager.REPOSITORIES_DISABLED);
- for (int i = 0; i < artifactRepos.length; i++)
- assertFalse(artifactRepos[i].toString() + " should be disabled", ProvisioningUtil.getArtifactRepositoryEnablement(artifactRepos[i]));
-
- artifactRepos = ProvisioningUtil.getArtifactRepositories(IRepositoryManager.REPOSITORIES_NON_SYSTEM);
- for (int i = 0; i < artifactRepos.length; i++)
- assertEquals("Expected non system repo " + artifactRepos[i].toString(), ProvisioningUtil.getArtifactRepositoryProperty(artifactRepos[i], IRepository.PROP_SYSTEM), Boolean.toString(false));
-
- artifactRepos = ProvisioningUtil.getArtifactRepositories(IRepositoryManager.REPOSITORIES_LOCAL);
- // TODO need to understand why this is failing
- // ProvisioningUtil.refreshArtifactRepositories(artifactRepos, getMonitor());
-
- }
-
- public void testMetadataRepos() throws ProvisionException {
- URI[] metadataRepos = ProvisioningUtil.getMetadataRepositories(IRepositoryManager.REPOSITORIES_ALL);
- for (int i = 0; i < metadataRepos.length; i++)
- assertTrue(metadataRepos[i].toString() + " should be enabled", ProvisioningUtil.getMetadataRepositoryEnablement(metadataRepos[i]));
-
- metadataRepos = ProvisioningUtil.getMetadataRepositories(IRepositoryManager.REPOSITORIES_DISABLED);
- for (int i = 0; i < metadataRepos.length; i++)
- assertFalse(metadataRepos[i].toString() + " should be disabled", ProvisioningUtil.getMetadataRepositoryEnablement(metadataRepos[i]));
-
- metadataRepos = ProvisioningUtil.getMetadataRepositories(IRepositoryManager.REPOSITORIES_NON_SYSTEM);
- for (int i = 0; i < metadataRepos.length; i++)
- assertEquals("Expected non system repo " + metadataRepos[i].toString(), ProvisioningUtil.getMetadataRepositoryProperty(metadataRepos[i], IRepository.PROP_SYSTEM), Boolean.toString(false));
-
- metadataRepos = ProvisioningUtil.getMetadataRepositories(IRepositoryManager.REPOSITORIES_LOCAL);
- ProvisioningUtil.refreshMetadataRepositories(metadataRepos, getMonitor());
-
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveColocatedRepositoryOperationTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveColocatedRepositoryOperationTest.java
deleted file mode 100644
index 46ef3f618..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveColocatedRepositoryOperationTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * 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.operations;
-
-import java.net.URI;
-import java.util.Arrays;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.AddColocatedRepositoryOperation;
-import org.eclipse.equinox.p2.tests.TestData;
-import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
-
-/**
- * Tests for {@link AddColocatedRepositoryOperation}.
- */
-public class RemoveColocatedRepositoryOperationTest extends AbstractProvisioningUITest {
- public void testRemoveSingleRepository() {
- URI repoLocation = null;
- try {
- repoLocation = TestData.getFile("artifactRepo", "").toURI();
- } catch (Exception e) {
- fail("0.99", e);
- }
- AddColocatedRepositoryOperation op = new AddColocatedRepositoryOperation("label", repoLocation);
- assertTrue("1.1", op.runInBackground());
-
- try {
- IStatus result = op.execute(getMonitor());
- assertTrue("1.2", result.isOK());
- } catch (ProvisionException e) {
- fail("1.99", e);
- }
-
- URI[] repos = metaManager.getKnownRepositories(0);
- assertTrue("2.0", Arrays.asList(repos).contains(repoLocation));
- assertTrue("2.1", metaManager.isEnabled(repoLocation));
-
- repos = artifactManager.getKnownRepositories(0);
- assertTrue("3.0", Arrays.asList(repos).contains(repoLocation));
- assertTrue("3.1", artifactManager.isEnabled(repoLocation));
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveProfilesOperationTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveProfilesOperationTest.java
deleted file mode 100644
index cdef7d3c2..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/RemoveProfilesOperationTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * 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.operations;
-
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.RemoveProfilesOperation;
-import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
-
-/**
- * Tests for {@link RemoveProfilesOperation}
- */
-public class RemoveProfilesOperationTest extends AbstractProvisioningUITest {
- public void testRemoveExisting() {
- String profileId = "testRemoveNonExisting";
- IProfile p = createProfile(profileId);
- RemoveProfilesOperation op = new RemoveProfilesOperation("label", new String[] {profileId});
-
- try {
- op.execute(getMonitor());
- } catch (ProvisionException e) {
- fail("0.99", e);
- }
-
- try {
- p = ProvisioningUtil.getProfile(profileId);
- } catch (ProvisionException e) {
- fail("1.99", e);
- }
- assertNull("2.0", p);
- }
-
- public void testRemoveNonExisting() {
- String profileId = "testRemoveNonExisting";
- IProfile p = createProfile(profileId);
- try {
- ProvisioningUtil.removeProfile(profileId, getMonitor());
- } catch (ProvisionException e) {
- fail("0.99", e);
- }
- RemoveProfilesOperation op = new RemoveProfilesOperation("label", new String[] {profileId});
-
- //Currently the profile registry does not mind if we try to delete a profile that doesn't exist, so
- //the UI classes don't test for it.
- try {
- op.execute(getMonitor());
- } catch (ProvisionException e) {
- //expected
- }
-
- try {
- p = ProvisioningUtil.getProfile(profileId);
- } catch (ProvisionException e) {
- fail("2.99", e);
- }
- assertNull("1.0", p);
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java
index 669c7b3b8..8b605be07 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java
@@ -10,14 +10,10 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.operations;
-import org.eclipse.equinox.internal.p2.ui.model.IIUElement;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
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.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
/**
@@ -26,21 +22,12 @@ import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
public class SizingTest extends AbstractProvisioningUITest {
public void testEmptySizing() {
String profileId = "testEmptySizing";
- IProfile profile = createProfile(profileId);
- ProfileChangeRequest request = new ProfileChangeRequest(profile);
- ProvisioningPlan plan = null;
- try {
- plan = ProvisioningUtil.getProvisioningPlan(request, new ProvisioningContext(), getMonitor());
- } catch (ProvisionException e) {
- fail("0.99", e);
- return;
- }
- long size = IIUElement.SIZE_NOTAPPLICABLE;
- try {
- size = ProvisioningUtil.getSize(plan, profileId, new ProvisioningContext(), getMonitor());
- } catch (ProvisionException e) {
- fail("1.99", e);
- }
+ IProfile testProfile = createProfile(profileId);
+ ProfileChangeRequest request = new ProfileChangeRequest(testProfile);
+ IProvisioningPlan plan = null;
+ plan = getSession().getPlanner().getProvisioningPlan(request, new ProvisioningContext(), getMonitor());
+ long size = ProvisioningSession.SIZE_NOTAPPLICABLE;
+ size = getSession().getSize(plan, new ProvisioningContext(), getMonitor());
assertEquals("1.0", 0, size);
}
@@ -50,22 +37,13 @@ public class SizingTest extends AbstractProvisioningUITest {
public void testSimpleSizing() {
IInstallableUnit f1 = createIU("f1", DEFAULT_VERSION, true);
String profileId = "testSimpleSizing";
- IProfile profile = createProfile(profileId);
- ProfileChangeRequest request = new ProfileChangeRequest(profile);
+ IProfile testProfile = createProfile(profileId);
+ ProfileChangeRequest request = new ProfileChangeRequest(testProfile);
request.addInstallableUnits(new IInstallableUnit[] {f1});
- ProvisioningPlan plan = null;
- try {
- plan = ProvisioningUtil.getProvisioningPlan(request, new ProvisioningContext(), getMonitor());
- } catch (ProvisionException e) {
- fail("0.99", e);
- return;
- }
- long size = IIUElement.SIZE_NOTAPPLICABLE;
- try {
- size = ProvisioningUtil.getSize(plan, profileId, new ProvisioningContext(), getMonitor());
- } catch (ProvisionException e) {
- fail("1.99", e);
- }
+ IProvisioningPlan plan = null;
+ plan = getSession().getPlanner().getProvisioningPlan(request, new ProvisioningContext(), getMonitor());
+ long size = ProvisioningSession.SIZE_NOTAPPLICABLE;
+ size = getSession().getSize(plan, new ProvisioningContext(), getMonitor());
assertEquals("1.0", 0, size);
}
}
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
index 6a65a2d7c..827dabf0c 100644
--- 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
@@ -10,17 +10,23 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.planning;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
-import java.util.*;
-import org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement;
-import org.eclipse.equinox.internal.provisional.p2.core.*;
+import org.eclipse.equinox.p2.metadata.IRequirementChange;
+import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
+
+import org.eclipse.equinox.p2.metadata.IInstallableUnitPatch;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
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.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.operations.Update;
+import org.eclipse.equinox.p2.operations.UpdateOperation;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
public class UpdatePlanning extends AbstractProvisioningUITest {
@@ -32,29 +38,31 @@ public class UpdatePlanning extends AbstractProvisioningUITest {
protected void setUp() throws Exception {
super.setUp();
- a1 = createIU("A", new Version("1.0.0"));
+ a1 = createIU("A", Version.create("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);
+ a120WithDifferentId = createIU("UpdateA", Version.createOSGi(1, 2, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES);
+ a130 = createIU("A", Version.createOSGi(1, 3, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES);
+ a140WithDifferentId = createIU("UpdateForA", Version.createOSGi(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);
+ firstPatchForA1 = createIUPatch("P", Version.create("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", Version.create("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", Version.create("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);
+ patchFora2 = createIUPatch("P", Version.create("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);
+ getPolicy().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());
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {a1}, null);
+ op.resolveModal(getMonitor());
+ ProfileChangeRequest request = op.getProfileChangeRequest();
assertTrue("1.0", request.getAddedInstallableUnits().length == 1);
assertTrue("1.1", request.getAddedInstallableUnits()[0].equals(a130));
assertTrue("1.2", request.getRemovedInstallableUnits().length == 1);
@@ -64,10 +72,20 @@ public class UpdatePlanning extends AbstractProvisioningUITest {
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());
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {a1}, null);
+ op.resolveModal(getMonitor());
+ Update[] updates = op.getPossibleUpdates();
+ Update firstPatch = null;
+ for (int i = 0; i < updates.length; i++) {
+ if (updates[i].replacement.equals(firstPatchForA1)) {
+ firstPatch = updates[i];
+ break;
+ }
+ }
+ assertNotNull(".99", firstPatch);
+ op.setSelectedUpdates(new Update[] {firstPatch});
+ op.resolveModal(getMonitor());
+ ProfileChangeRequest request = op.getProfileChangeRequest();
assertTrue("1.0", request.getAddedInstallableUnits().length == 1);
assertTrue("1.1", request.getAddedInstallableUnits()[0].equals(firstPatchForA1));
assertTrue("1.2", request.getRemovedInstallableUnits().length == 0);
@@ -77,36 +95,47 @@ public class UpdatePlanning extends AbstractProvisioningUITest {
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());
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {a1}, null);
+ op.resolveModal(getMonitor());
+ ProfileChangeRequest request = op.getProfileChangeRequest();
// 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);
+ assertEquals("1.2", 2, op.getPossibleUpdates().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());
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {a1}, null);
+ op.resolveModal(getMonitor());
+ Update[] updates = op.getPossibleUpdates();
+ Update notNewest = null;
+ for (int i = 0; i < updates.length; i++) {
+ if (updates[i].replacement.equals(a120WithDifferentId)) {
+ notNewest = updates[i];
+ break;
+ }
+ }
+ assertNotNull(".99", notNewest);
+ op.setSelectedUpdates(new Update[] {notNewest});
+ op.resolveModal(getMonitor());
+ ProfileChangeRequest request = op.getProfileChangeRequest();
// 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);
+ assertEquals("1.2", 3, op.getPossibleUpdates().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());
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {a1}, null);
+ op.resolveModal(getMonitor());
+ ProfileChangeRequest request = op.getProfileChangeRequest();
// the latest two patches were selected
HashSet chosen = new HashSet();
assertTrue("1.0", request.getAddedInstallableUnits().length == 2);
@@ -114,18 +143,19 @@ public class UpdatePlanning extends AbstractProvisioningUITest {
assertTrue("1.1", chosen.contains(secondPatchForA1));
assertTrue("1.2", chosen.contains(thirdPatchForA1));
- assertEquals("1.2", 3, root.getChildren(root).length);
+ assertEquals("1.2", 3, op.getPossibleUpdates().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());
+ UpdateOperation op = getProvisioningUI().getUpdateOperation(new IInstallableUnit[] {a1}, null);
+ op.resolveModal(getMonitor());
+ ProfileChangeRequest request = op.getProfileChangeRequest();
// 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);
+ assertEquals("1.2", 6, op.getPossibleUpdates().length);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AbstractQueryTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AbstractQueryTest.java
index 9724a889e..0b8edfe2a 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AbstractQueryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AbstractQueryTest.java
@@ -10,12 +10,13 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.query;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.MatchQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Query;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.internal.p2.ui.ProvUI;
+import org.eclipse.equinox.p2.operations.RepositoryTracker;
+import org.eclipse.equinox.p2.query.IQuery;
+import org.eclipse.equinox.p2.query.MatchQuery;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
* Abstract class to set up the mock query provider
@@ -26,24 +27,25 @@ public abstract class AbstractQueryTest extends AbstractProvisioningTest {
// use test query provider
// This is really not how the default policy should be used in practice,
// but we need to reset it for the tests.
- Policy.getDefault().setQueryProvider(new MockQueryProvider(getMockQuery()));
+ ProvUI.setQueryProvider(new MockQueryProvider(getMockQuery(), ProvisioningUI.getDefaultUI()));
// some of the test repos are set up as system repos so we need to
// query all repos, not just non-system repos
// TODO consider evolving these tests to distinguish between system
// and non-system
- IUViewQueryContext queryContext = new IUViewQueryContext(IUViewQueryContext.AVAILABLE_VIEW_BY_REPO);
- queryContext.setArtifactRepositoryFlags(IRepositoryManager.REPOSITORIES_ALL);
- queryContext.setMetadataRepositoryFlags(IRepositoryManager.REPOSITORIES_ALL);
- Policy.getDefault().setQueryContext(queryContext);
+ RepositoryTracker manipulator = ProvisioningUI.getDefaultUI().getRepositoryTracker();
+ manipulator.setArtifactRepositoryFlags(IRepositoryManager.REPOSITORIES_ALL);
+ manipulator.setMetadataRepositoryFlags(IRepositoryManager.REPOSITORIES_ALL);
}
protected void tearDown() throws Exception {
super.tearDown();
- Policy.getDefault().setQueryProvider(null);
- Policy.getDefault().setQueryContext(null);
+ RepositoryTracker manipulator = ProvisioningUI.getDefaultUI().getRepositoryTracker();
+ manipulator.setArtifactRepositoryFlags(IRepositoryManager.REPOSITORIES_NON_SYSTEM);
+ manipulator.setMetadataRepositoryFlags(IRepositoryManager.REPOSITORIES_NON_SYSTEM);
+ ProvUI.setQueryProvider(null);
}
- protected Query getMockQuery() {
+ protected IQuery getMockQuery() {
return new MatchQuery() {
public boolean isMatch(Object candidate) {
return true;
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java
index e81fbde80..0fd24d7c5 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java
@@ -22,7 +22,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(AnyRequiredCapabilityTest.class);
suite.addTestSuite(AvailableIUWrapperTest.class);
suite.addTestSuite(CategoryElementWrapperTest.class);
- suite.addTestSuite(IUPropertyUtilsTest.class);
+ suite.addTestSuite(TranslationSupportTests.class);
suite.addTestSuite(LatestIUVersionElementWrapperTest.class);
suite.addTestSuite(QueryDescriptorTest.class);
suite.addTestSuite(QueryableMetadataRepositoryManagerTest.class);
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java
index 61b6f2d98..b07ca1574 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java
@@ -13,31 +13,26 @@ package org.eclipse.equinox.p2.tests.ui.query;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.equinox.internal.p2.ui.query.AnyRequiredCapabilityQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.QueryableMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.internal.p2.ui.QueryableMetadataRepositoryManager;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IRequirement;
+import org.eclipse.equinox.p2.metadata.query.ExpressionQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.TestData;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
-/**
- * Tests for {@link AnyRequiredCapabilityQuery}.
- */
public class AnyRequiredCapabilityTest extends AbstractQueryTest {
public void testMatchOtherObjects() {
- IRequiredCapability[] requires = createRequiredCapabilities("org.eclipse.equinox.p2.iu", "test.bundle", null);
- AnyRequiredCapabilityQuery query = new AnyRequiredCapabilityQuery(requires);
+ IRequirement requires = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.iu", "test.bundle", ANY_VERSION, null, false, false);
IInstallableUnit match = createIU("test.bundle");
IInstallableUnit noMatch = createIU("another.bundle");
List items = new ArrayList();
items.add(match);
items.add(noMatch);
- items.add(new Object());
- items.add(requires);
- Collector result = query.perform(items.iterator(), new Collector());
- assertEquals("1.0", 1, result.size());
+ IQueryResult result = new ExpressionQuery(IInstallableUnit.class, requires.getMatches()).perform(items.iterator());
+ assertEquals("1.0", 1, queryResultSize(result));
assertEquals("1.1", match, result.iterator().next());
}
@@ -51,11 +46,10 @@ public class AnyRequiredCapabilityTest extends AbstractQueryTest {
}
IMetadataRepositoryManager metadataRepositoryManager = getMetadataRepositoryManager();
metadataRepositoryManager.addRepository(location);
- QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(Policy.getDefault().getQueryContext(), false);
- IRequiredCapability[] requires = createRequiredCapabilities("org.eclipse.equinox.p2.iu", "test.bundle", null);
- AnyRequiredCapabilityQuery query = new AnyRequiredCapabilityQuery(requires);
- Collector result = manager.query(query, new Collector(), getMonitor());
- assertEquals("1.0", 1, result.size());
+ QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(ProvisioningUI.getDefaultUI(), false);
+ IRequirement requires = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.iu", "test.bundle", ANY_VERSION, null, false, false);
+ IQueryResult result = manager.query(new ExpressionQuery(IInstallableUnit.class, requires.getMatches()), getMonitor());
+ assertEquals("1.0", 1, queryResultSize(result));
IInstallableUnit iu = (IInstallableUnit) result.iterator().next();
assertEquals("1.1", "test.bundle", iu.getId());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AvailableIUWrapperTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AvailableIUWrapperTest.java
index 7c7a0a127..79e3f86c1 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AvailableIUWrapperTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AvailableIUWrapperTest.java
@@ -11,15 +11,18 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.query;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.util.*;
+import org.eclipse.equinox.internal.p2.metadata.query.IUPropertyQuery;
import org.eclipse.equinox.internal.p2.ui.model.CategoryElement;
import org.eclipse.equinox.internal.p2.ui.model.IIUElement;
import org.eclipse.equinox.internal.p2.ui.query.AvailableIUWrapper;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.Collector;
+import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.tests.MockQueryable;
/**
@@ -75,8 +78,8 @@ public class AvailableIUWrapperTest extends AbstractQueryTest {
AvailableIUWrapper wrapper = createWrapper(true);
Collector collector = new Collector();
Map properties = new HashMap();
- properties.put(IInstallableUnit.PROP_TYPE_CATEGORY, "true");
- IInstallableUnit category = createIU("category", new Version(1, 0, 0), NO_REQUIRES, properties, false);
+ properties.put(InstallableUnitDescription.PROP_TYPE_CATEGORY, "true");
+ IInstallableUnit category = createIU("category", Version.createOSGi(1, 0, 0), NO_REQUIRES, properties, false);
IInstallableUnit unit = createIU("basicIU");
collector.accept(category);
collector.accept(unit);
@@ -104,8 +107,8 @@ public class AvailableIUWrapperTest extends AbstractQueryTest {
AvailableIUWrapper wrapper = createWrapper(false);
Collector collector = new Collector();
Map properties = new HashMap();
- properties.put(IInstallableUnit.PROP_TYPE_CATEGORY, "true");
- IInstallableUnit category = createIU("category", new Version(1, 0, 0), NO_REQUIRES, properties, false);
+ properties.put(InstallableUnitDescription.PROP_TYPE_CATEGORY, "true");
+ IInstallableUnit category = createIU("category", Version.createOSGi(1, 0, 0), NO_REQUIRES, properties, false);
IInstallableUnit unit = createIU("basicIU");
collector.accept(category);
collector.accept(unit);
@@ -149,7 +152,7 @@ public class AvailableIUWrapperTest extends AbstractQueryTest {
assertEquals("1.2", notInstalled, getIU(iuElement));
}
- protected Query getMockQuery() {
+ protected IQuery getMockQuery() {
return new IUPropertyQuery("key", "value");
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/CategoryElementWrapperTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/CategoryElementWrapperTest.java
index 8e5378257..4a2470e71 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/CategoryElementWrapperTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/CategoryElementWrapperTest.java
@@ -10,16 +10,18 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.query;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.util.Collection;
import java.util.Iterator;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.p2.ui.model.CategoryElement;
import org.eclipse.equinox.internal.p2.ui.model.EmptyElementExplanation;
import org.eclipse.equinox.internal.p2.ui.query.CategoryElementWrapper;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.Collector;
import org.eclipse.equinox.p2.tests.MockQueryable;
/**
@@ -36,7 +38,7 @@ public class CategoryElementWrapperTest extends AbstractQueryTest {
iu.setId(id);
iu.setVersion(version);
iu.setProperty(IInstallableUnit.PROP_NAME, name);
- iu.setProperty(IInstallableUnit.PROP_TYPE_CATEGORY, Boolean.toString(true));
+ iu.setProperty(InstallableUnitDescription.PROP_TYPE_CATEGORY, Boolean.toString(true));
return MetadataFactory.createInstallableUnit(iu);
}
@@ -84,7 +86,7 @@ public class CategoryElementWrapperTest extends AbstractQueryTest {
assertEquals("1.6", 1, results.size());
//adding a nested category shouldn't affected size
- IRequiredCapability[] required = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "category1", null);
+ IRequiredCapability[] required = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "category1");
IInstallableUnit nested = createIU("Nested", required);
collector.accept(nested);
results = wrapper.getElements(collector);
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementWrapperTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementWrapperTest.java
index 28a540bf6..a98519434 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementWrapperTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementWrapperTest.java
@@ -11,13 +11,14 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.query;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.equinox.internal.p2.metadata.query.LatestIUVersionQuery;
import org.eclipse.equinox.internal.p2.ui.model.IIUElement;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.LatestIUVersionQuery;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.IQueryResult;
/**
* Tests for {@link LatestIUVersionQuery}. This has all the tests of the superclass,
@@ -35,41 +36,28 @@ public class LatestIUVersionElementWrapperTest extends AvailableIUWrapperTest {
}
/**
- * Tests collecting items that LatestIUVersionElementQuery should
- * discard.
- */
- public void testCollectObject() {
- LatestIUVersionQuery latestIuVersionElementQuery = new LatestIUVersionQuery();
- Object object = new Object();
- List list = new ArrayList();
- list.add(object);
- Collector collector = latestIuVersionElementQuery.perform(list.iterator(), new Collector());
- assertEquals("1.0", 0, collector.size());
- }
-
- /**
* Tests that only the latest version is collected.
*/
public void testCollectLatestIU() {
LatestIUVersionQuery latestIuVersionElementQuery = new LatestIUVersionQuery();
- IInstallableUnit unit1 = createIU("f1", new Version(1, 0, 0));
- IInstallableUnit unit2 = createIU("f1", new Version(1, 0, 1));
+ IInstallableUnit unit1 = createIU("f1", Version.createOSGi(1, 0, 0));
+ IInstallableUnit unit2 = createIU("f1", Version.createOSGi(1, 0, 1));
List listOfIUs = new ArrayList();
listOfIUs.add(unit1);
listOfIUs.add(unit2);
- Collector collector = latestIuVersionElementQuery.perform(listOfIUs.iterator(), new Collector());
- assertEquals("1.0", 1, collector.size());
+ IQueryResult collector = latestIuVersionElementQuery.perform(listOfIUs.iterator());
+ assertEquals("1.0", 1, queryResultSize(collector));
IInstallableUnit collectedIU = getIU(collector.iterator().next());
assertEquals("1.1", unit2, collectedIU);
}
public void testMultipleIUsAndVersions() {
LatestIUVersionQuery latestIuVersionElementQuery = new LatestIUVersionQuery();
- IInstallableUnit unit1 = createIU("A", new Version(1, 0, 0));
- IInstallableUnit unit2 = createIU("A", new Version(1, 0, 1));
- IInstallableUnit unit3 = createIU("B", new Version(1, 0, 1));
- IInstallableUnit unit4 = createIU("B", new Version(0, 1, 1));
- IInstallableUnit unit5 = createIU("C", new Version(0, 1, 1));
+ IInstallableUnit unit1 = createIU("A", Version.createOSGi(1, 0, 0));
+ IInstallableUnit unit2 = createIU("A", Version.createOSGi(1, 0, 1));
+ IInstallableUnit unit3 = createIU("B", Version.createOSGi(1, 0, 1));
+ IInstallableUnit unit4 = createIU("B", Version.createOSGi(0, 1, 1));
+ IInstallableUnit unit5 = createIU("C", Version.createOSGi(0, 1, 1));
// We should get unit 2, unit 3 and unit 5
List listOfIUs = new ArrayList();
@@ -78,14 +66,13 @@ public class LatestIUVersionElementWrapperTest extends AvailableIUWrapperTest {
listOfIUs.add(unit3);
listOfIUs.add(unit4);
listOfIUs.add(unit5);
- Collector collector = latestIuVersionElementQuery.perform(listOfIUs.iterator(), new Collector());
+ IQueryResult collector = latestIuVersionElementQuery.perform(listOfIUs.iterator());
// Should be 3 units
- assertEquals("1.0", 3, collector.size());
- Collection reslts = collector.toCollection();
- assertTrue("1.2", reslts.contains(unit2));
- assertTrue("1.3", reslts.contains(unit3));
- assertTrue("1.4", reslts.contains(unit5));
+ assertEquals("1.0", 3, queryResultSize(collector));
+ assertContains("1.2", collector, unit2);
+ assertContains("1.3", collector, unit3);
+ assertContains("1.4", collector, unit5);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/MockQueryProvider.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/MockQueryProvider.java
index 56469c088..e00efe369 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/MockQueryProvider.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/MockQueryProvider.java
@@ -10,22 +10,22 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.query;
-import org.eclipse.equinox.internal.p2.ui.DefaultQueryProvider;
+import org.eclipse.equinox.internal.p2.ui.ElementQueryDescriptor;
+import org.eclipse.equinox.internal.p2.ui.QueryProvider;
import org.eclipse.equinox.internal.p2.ui.model.QueriedElement;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Query;
-import org.eclipse.equinox.internal.provisional.p2.ui.ElementQueryDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.p2.query.Collector;
+import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.tests.MockQueryable;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
* A fake query provider for unit testing.
*/
-public class MockQueryProvider extends DefaultQueryProvider {
- private Query query;
+public class MockQueryProvider extends QueryProvider {
+ private IQuery query;
- public MockQueryProvider(Query query) {
- super(Policy.getDefault());
+ public MockQueryProvider(IQuery query, ProvisioningUI ui) {
+ super(ui);
this.query = query;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryDescriptorTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryDescriptorTest.java
index 4cd2be85b..745e45f88 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryDescriptorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryDescriptorTest.java
@@ -12,9 +12,9 @@ package org.eclipse.equinox.p2.tests.ui.query;
import java.util.*;
import junit.framework.TestCase;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-import org.eclipse.equinox.internal.provisional.p2.ui.ElementQueryDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.ui.ElementWrapper;
+import org.eclipse.equinox.internal.p2.ui.ElementQueryDescriptor;
+import org.eclipse.equinox.internal.p2.ui.ElementWrapper;
+import org.eclipse.equinox.p2.query.*;
/**
* Tests the Query Descriptor
@@ -24,8 +24,9 @@ public class QueryDescriptorTest extends TestCase {
class SimpleQueryable implements IQueryable {
List elements = Arrays.asList(new String[] {"a", "b", "c", "d", "e"});
- public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
- return query.perform(elements.iterator(), collector);
+ public IQueryResult query(IQuery query, IProgressMonitor monitor) {
+ Collector collector = new Collector();
+ return query.perform(elements.iterator());
}
}
@@ -98,7 +99,7 @@ public class QueryDescriptorTest extends TestCase {
}
public void testCompoundDescriptorAND() {
- Query query = CompoundQuery.createCompoundQuery(new Query[] {new SimpleMatchQuery(), new SimpleMatchQuery2()}, true);
+ IQuery query = CompoundQuery.createCompoundQuery(new IQuery[] {new SimpleMatchQuery(), new SimpleMatchQuery2()}, true);
ElementQueryDescriptor eqDescriptor = new ElementQueryDescriptor(new SimpleQueryable(), query, new Collector(), new StringWrapper());
Collection collection = eqDescriptor.performQuery(null);
assertEquals("1.0", 1, collection.size());
@@ -106,7 +107,7 @@ public class QueryDescriptorTest extends TestCase {
}
public void testCompoundDescriptorOR() {
- Query query = CompoundQuery.createCompoundQuery(new Query[] {new SimpleMatchQuery(), new SimpleMatchQuery2()}, false);
+ IQuery query = CompoundQuery.createCompoundQuery(new IQuery[] {new SimpleMatchQuery(), new SimpleMatchQuery2()}, false);
ElementQueryDescriptor eqDescriptor = new ElementQueryDescriptor(new SimpleQueryable(), query, new Collector(), new StringWrapper());
Collection collection = eqDescriptor.performQuery(null);
assertEquals("1.0", 3, collection.size());
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java
index 11094605e..4f2fd7e7e 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java
@@ -11,11 +11,11 @@
package org.eclipse.equinox.p2.tests.ui.query;
import org.eclipse.core.runtime.URIUtil;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.ui.QueryableArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.RepositoryLocationQuery;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.internal.p2.ui.QueryableArtifactRepositoryManager;
+import org.eclipse.equinox.internal.p2.ui.RepositoryLocationQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
public class QueryableArtifactRepositoryManagerTest extends AbstractQueryTest {
private static final String repositoryOne = "http://one.lan";
@@ -43,12 +43,11 @@ public class QueryableArtifactRepositoryManagerTest extends AbstractQueryTest {
public void testQuery() {
QueryableArtifactRepositoryManager manager = getQueryableManager();
- Collector result = new Collector();
- manager.query(new RepositoryLocationQuery(), result, getMonitor());
- assertTrue(result.size() == repoCount);
+ IQueryResult result = manager.locationsQueriable().query(new RepositoryLocationQuery(), getMonitor());
+ assertTrue(queryResultSize(result) == repoCount);
}
private QueryableArtifactRepositoryManager getQueryableManager() {
- return new QueryableArtifactRepositoryManager(Policy.getDefault().getQueryContext(), false);
+ return new QueryableArtifactRepositoryManager(ProvisioningUI.getDefaultUI(), false);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java
index 71e545d20..7d9d033f5 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java
@@ -10,22 +10,29 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.query;
+import org.eclipse.equinox.p2.metadata.Version;
+
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+
import java.io.File;
import java.net.URI;
import java.util.Collection;
import org.eclipse.core.tests.harness.CancelingProgressMonitor;
-import org.eclipse.equinox.internal.p2.ui.DefaultQueryProvider;
+import org.eclipse.equinox.internal.p2.metadata.query.IUPropertyQuery;
+import org.eclipse.equinox.internal.p2.ui.*;
import org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.p2.ui.*;
-import org.eclipse.equinox.internal.provisional.p2.ui.model.MetadataRepositories;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositories;
+import org.eclipse.equinox.internal.p2.ui.query.IUViewQueryContext;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.operations.ProvisioningJob;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.TestData;
+import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
* Tests for {@link QueryableMetadataRepositoryManager}.
@@ -34,6 +41,16 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
/**
* Tests querying against a non-existent repository
*/
+
+ ProvisioningUI ui;
+ ProvisioningSession session;
+
+ protected void setUp() throws Exception {
+ ui = ProvisioningUI.getDefaultUI();
+ session = ui.getSession();
+ super.setUp();
+ }
+
public void testBrokenRepository() {
URI brokenRepo;
try {
@@ -47,7 +64,8 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
QueryableMetadataRepositoryManager manager = getQueryableManager();
assertTrue("1.0", !manager.areRepositoriesLoaded());
- manager.loadAll(getMonitor());
+ ProvisioningJob loadJob = new LoadMetadataRepositoryJob(ui);
+ loadJob.runModal(getMonitor());
//false because the broken repository is not loaded
assertTrue("1.1", !manager.areRepositoriesLoaded());
@@ -69,7 +87,8 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
QueryableMetadataRepositoryManager manager = getQueryableManager();
assertTrue("1.0", !manager.areRepositoriesLoaded());
- manager.loadAll(new CancelingProgressMonitor());
+ ProvisioningJob loadJob = new LoadMetadataRepositoryJob(ui);
+ loadJob.runModal(new CancelingProgressMonitor());
//should not be loaded due to cancelation
assertTrue("1.1", !manager.areRepositoriesLoaded());
@@ -91,12 +110,8 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
metadataRepositoryManager.addRepository(broken);
QueryableMetadataRepositoryManager manager = getQueryableManager();
- Collector result = manager.query(new InstallableUnitQuery("test.bundle", new Version(1, 0, 0)), new Collector(), new CancelingProgressMonitor());
- assertEquals("1.0", 0, result.size());
-
- //null query collects repository URLs
- result = manager.query(null, new Collector(), new CancelingProgressMonitor());
- assertEquals("2.0", 0, result.size());
+ IQueryResult result = manager.query(new InstallableUnitQuery("test.bundle", Version.createOSGi(1, 0, 0)), new CancelingProgressMonitor());
+ assertTrue("1.0", result.isEmpty());
}
public void testExistingRepository() {
@@ -112,10 +127,12 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
QueryableMetadataRepositoryManager manager = getQueryableManager();
assertTrue("1.0", !manager.areRepositoriesLoaded());
- manager.loadAll(getMonitor());
+ ProvisioningJob loadJob = new LoadMetadataRepositoryJob(ui);
+ loadJob.runModal(getMonitor());
- //we can never be sure that repositories are loaded because the repository manager cache can be flushed at any time
- // assertTrue("1.1", manager.areRepositoriesLoaded());
+ // the provisioning job retains references to the repos so they should
+ // not get garbage collected.
+ assertTrue("1.1", manager.areRepositoriesLoaded());
}
/**
@@ -137,7 +154,8 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
// not loaded yet
assertFalse("1.0", manager.areRepositoriesLoaded());
- manager.loadAll(getMonitor());
+ ProvisioningJob loadJob = new LoadMetadataRepositoryJob(ui);
+ loadJob.runModal(getMonitor());
// the repositories have been loaded. Because the non-existent
// repository has been noticed and recorded as missing, it
@@ -161,24 +179,23 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
metadataRepositoryManager.addRepository(broken);
QueryableMetadataRepositoryManager manager = getQueryableManager();
- Collector result = manager.query(new InstallableUnitQuery("test.bundle", new Version(1, 0, 0)), new Collector(), getMonitor());
- assertEquals("1.0", 1, result.size());
+ IQueryResult result = manager.query(new InstallableUnitQuery("test.bundle", Version.createOSGi(1, 0, 0)), getMonitor());
+ assertEquals("1.0", 1, queryResultSize(result));
IInstallableUnit iu = (IInstallableUnit) result.iterator().next();
assertEquals("1.1", "test.bundle", iu.getId());
//RepoLocationQuery collects repository URLs
- result = manager.query(new RepositoryLocationQuery(), new Collector(), getMonitor());
- assertEquals("2.0", 3, result.size());
- Collection resultCollection = result.toCollection();
- assertTrue("2.1", resultCollection.contains(existing));
- assertTrue("2.1", resultCollection.contains(nonExisting));
- assertTrue("2.1", resultCollection.contains(broken));
+ result = manager.locationsQueriable().query(new RepositoryLocationQuery(), getMonitor());
+ assertEquals("2.0", 3, queryResultSize(result));
+ assertContains("2.1", result, existing);
+ assertContains("2.1", result, nonExisting);
+ assertContains("2.1", result, broken);
// null IUPropertyQuery collects all IUs
- result = manager.query(new InstallableUnitQuery((String) null), new Collector(), getMonitor());
- int iuCount = result.size();
- result = manager.query(new IUPropertyQuery(null, null), new Collector(), getMonitor());
- assertEquals("2.2", iuCount, result.size());
+ result = manager.query(new InstallableUnitQuery((String) null), getMonitor());
+ int iuCount = queryResultSize(result);
+ result = manager.query(new IUPropertyQuery(null, null), getMonitor());
+ assertEquals("2.2", iuCount, queryResultSize(result));
}
public void testNonLatestInMultipleRepositories() {
@@ -198,8 +215,8 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
IUViewQueryContext context = new IUViewQueryContext(IUViewQueryContext.AVAILABLE_VIEW_FLAT);
context.setShowLatestVersionsOnly(false);
- MetadataRepositories rootElement = new MetadataRepositories(context, Policy.getDefault(), manager);
- DefaultQueryProvider queryProvider = new DefaultQueryProvider(Policy.getDefault());
+ MetadataRepositories rootElement = new MetadataRepositories(context, ui, manager);
+ QueryProvider queryProvider = new QueryProvider(ui);
ElementQueryDescriptor queryDescriptor = queryProvider.getQueryDescriptor(rootElement);
Collection collection = queryDescriptor.performQuery(null);
assertEquals("1.0", 5, collection.size());
@@ -222,14 +239,13 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
IUViewQueryContext context = new IUViewQueryContext(IUViewQueryContext.AVAILABLE_VIEW_FLAT);
context.setShowLatestVersionsOnly(true);
- MetadataRepositories rootElement = new MetadataRepositories(context, Policy.getDefault(), manager);
- manager.setQueryContext(context);
- DefaultQueryProvider queryProvider = new DefaultQueryProvider(Policy.getDefault());
+ MetadataRepositories rootElement = new MetadataRepositories(context, ui, manager);
+ QueryProvider queryProvider = new QueryProvider(ui);
ElementQueryDescriptor queryDescriptor = queryProvider.getQueryDescriptor(rootElement);
Collection collection = queryDescriptor.performQuery(null);
assertEquals("1.0", 1, collection.size());
AvailableIUElement next = (AvailableIUElement) collection.iterator().next();
- assertEquals("1.1", new Version(3, 0, 0), next.getIU().getVersion());
+ assertEquals("1.1", Version.createOSGi(3, 0, 0), next.getIU().getVersion());
}
/**
@@ -240,19 +256,22 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
try {
location = TestData.getFile("metadataRepo", "good").toURI();
} catch (Exception e) {
- fail("0.99", e);
+ fail("0.98", e);
return;
}
IMetadataRepositoryManager metadataRepositoryManager = getMetadataRepositoryManager();
metadataRepositoryManager.removeRepository(location);
metadataRepositoryManager.addRepository(location);
- QueryableMetadataRepositoryManager manager = getQueryableManager();
- manager.loadAll(getMonitor());
+ try {
+ ui.loadMetadataRepository(location, false, getMonitor());
+ } catch (ProvisionException e) {
+ fail("0.99", e);
+ }
assertEquals("1.0", "Good Test Repository", metadataRepositoryManager.getRepositoryProperty(location, IRepository.PROP_NICKNAME));
}
private QueryableMetadataRepositoryManager getQueryableManager() {
- return new QueryableMetadataRepositoryManager(Policy.getDefault().getQueryContext(), false);
+ return new QueryableMetadataRepositoryManager(ui, false);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/IUPropertyUtilsTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/TranslationSupportTests.java
index 2d4980245..e7600a856 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/IUPropertyUtilsTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/TranslationSupportTests.java
@@ -11,35 +11,55 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.query;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
+
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+
+import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment;
+import org.eclipse.equinox.p2.metadata.ILicense;
+
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Locale;
+import java.util.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.engine.Profile;
-import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
-import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
+import org.eclipse.equinox.internal.p2.metadata.TranslationSupport;
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.MetadataFactory.InstallableUnitFragmentDescription;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.IUPropertyUtils;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.ICopyright;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.query.IQueryable;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.TestActivator;
/**
- * Tests for {@link IUPropertyUtils}.
+ * Tests for {@link TranslationSupport}.
*/
-public class IUPropertyUtilsTest extends AbstractQueryTest {
+public class TranslationSupportTests extends AbstractQueryTest {
+ Profile profile;
+ IQueryable oldTranslationSource;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ profile = (Profile) createProfile("testLocalizedLicense");
+ oldTranslationSource = TranslationSupport.getInstance().setTranslationSource(profile);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ TranslationSupport.getInstance().setTranslationSource(oldTranslationSource);
+ }
+
public void testFeatureProperties() {
- IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName());
+ IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
File site = getTestData("0.1", "/testData/metadataRepo/externalized");
URI location = site.toURI();
IMetadataRepository repository;
@@ -49,27 +69,24 @@ public class IUPropertyUtilsTest extends AbstractQueryTest {
fail("1.99", e);
return;
}
- Collector result = repository.query(new InstallableUnitQuery("test.feature.feature.group"), new Collector(), getMonitor());
+ IQueryResult result = repository.query(new InstallableUnitQuery("test.feature.feature.group"), getMonitor());
assertTrue("1.0", !result.isEmpty());
IInstallableUnit unit = (IInstallableUnit) result.iterator().next();
- ICopyright copyright = org.eclipse.equinox.internal.provisional.p2.ui.IUPropertyUtils.getCopyright(unit);
+ ICopyright copyright = unit.getCopyright(null);
assertEquals("1.1", "Test Copyright", copyright.getBody());
- ILicense license = IUPropertyUtils.getLicense(unit);
+ ILicense license = unit.getLicenses(null)[0];
assertEquals("1.2", "Test License", license.getBody());
// assertEquals("1.3", "license.html", license.getURL().toExternalForm());
- String name = IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_NAME);
+ String name = unit.getProperty(IInstallableUnit.PROP_NAME, null);
assertEquals("1.4", "Test Feature Name", name);
- String description = IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_DESCRIPTION);
+ String description = unit.getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
assertEquals("1.5", "Test Description", description);
- String provider = IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_PROVIDER);
+ String provider = unit.getProperty(IInstallableUnit.PROP_PROVIDER, null);
assertEquals("1.6", "Test Provider Name", provider);
}
public void testLocalizedLicense() throws URISyntaxException {
- SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(ProvUIActivator.getContext(), IProfileRegistry.class.getName());
- Profile profile = (Profile) profileRegistry.getProfile(IProfileRegistry.SELF);
- profileRegistry.lockProfile(profile);
String germanLicense = "German License";
String canadianFRLicense = "Canadian French License";
@@ -77,8 +94,9 @@ public class IUPropertyUtilsTest extends AbstractQueryTest {
// a fragment
InstallableUnitDescription iuDescription = new InstallableUnitDescription();
iuDescription.setId("some IU");
- iuDescription.setVersion(new Version(1, 0, 0));
- iuDescription.setLicense(MetadataFactory.createLicense(new URI("http://example.com"), "%license"));
+ iuDescription.setVersion(Version.createOSGi(1, 0, 0));
+ iuDescription.setLicenses(new ILicense[] {MetadataFactory.createLicense(new URI("http://example.com"), "%license")});
+ iuDescription.addProvidedCapabilities(Collections.singleton(MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "some IU", Version.createOSGi(1, 0, 0))));
IInstallableUnit iu = MetadataFactory.createInstallableUnit(iuDescription);
// Create a bunch of fragments which spec our IU as their host
@@ -86,59 +104,56 @@ public class IUPropertyUtilsTest extends AbstractQueryTest {
for (int i = 0; i < 10; i++) {
InstallableUnitFragmentDescription installableUnitFragmentDescription = new InstallableUnitFragmentDescription();
installableUnitFragmentDescription.setId("fragment number: " + i);
- installableUnitFragmentDescription.setVersion(new Version(1, 0, 0));
+ installableUnitFragmentDescription.setVersion(Version.createOSGi(1, 0, 0));
installableUnitFragmentDescription.setHost(new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "some IU", ANY_VERSION, null, false, false)});
- installableUnitFragmentDescription.setProperty(IInstallableUnit.PROP_TYPE_FRAGMENT, "true");
+ installableUnitFragmentDescription.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, "true");
IInstallableUnitFragment iuFragment = MetadataFactory.createInstallableUnitFragment(installableUnitFragmentDescription);
profile.addInstallableUnit(iuFragment);
}
// Create fragment with a German license
InstallableUnitFragmentDescription installableUnitFragmentDescription = new InstallableUnitFragmentDescription();
- IProvidedCapability providedCapability = MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.localization", "de", new Version(1, 0, 0));
+ IProvidedCapability providedCapability = MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.localization", "de", Version.createOSGi(1, 0, 0));
ArrayList list = new ArrayList();
list.add(providedCapability);
installableUnitFragmentDescription.addProvidedCapabilities(list);
installableUnitFragmentDescription.setId("german fragment");
- installableUnitFragmentDescription.setVersion(new Version(1, 0, 0));
+ installableUnitFragmentDescription.setVersion(Version.createOSGi(1, 0, 0));
installableUnitFragmentDescription.setHost(new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "some IU", ANY_VERSION, null, false, false)});
- installableUnitFragmentDescription.setProperty(IInstallableUnit.PROP_TYPE_FRAGMENT, "true");
+ installableUnitFragmentDescription.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, "true");
installableUnitFragmentDescription.setProperty("de.license", germanLicense);
IInstallableUnitFragment iuFragment = MetadataFactory.createInstallableUnitFragment(installableUnitFragmentDescription);
profile.addInstallableUnit(iuFragment);
// Create a French fragment with an fr_CA license
installableUnitFragmentDescription = new InstallableUnitFragmentDescription();
- providedCapability = MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.localization", "fr", new Version(1, 0, 0));
+ providedCapability = MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.localization", "fr", Version.createOSGi(1, 0, 0));
list = new ArrayList();
list.add(providedCapability);
installableUnitFragmentDescription.addProvidedCapabilities(list);
installableUnitFragmentDescription.setId("cnd french fragment");
- installableUnitFragmentDescription.setVersion(new Version(1, 0, 0));
+ installableUnitFragmentDescription.setVersion(Version.createOSGi(1, 0, 0));
installableUnitFragmentDescription.setHost(new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "some IU", ANY_VERSION, null, false, false)});
- installableUnitFragmentDescription.setProperty(IInstallableUnit.PROP_TYPE_FRAGMENT, "true");
+ installableUnitFragmentDescription.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, "true");
installableUnitFragmentDescription.setProperty("fr_CA.license", canadianFRLicense);
iuFragment = MetadataFactory.createInstallableUnitFragment(installableUnitFragmentDescription);
profile.addInstallableUnit(iuFragment);
profile.addInstallableUnit(iu);
- profileRegistry.updateProfile(profile);
- profileRegistry.unlockProfile(profile);
-
- ILicense license = IUPropertyUtils.getLicense(iu, Locale.GERMAN);
+ ILicense license = iu.getLicenses(Locale.GERMAN.toString())[0];
assertEquals("1.0", germanLicense, license.getBody());
- license = IUPropertyUtils.getLicense(iu, Locale.CANADA_FRENCH);
+ license = iu.getLicenses(Locale.CANADA_FRENCH.toString())[0];
assertEquals("1.1", canadianFRLicense, license.getBody());
}
public void testBasicIU() {
IInstallableUnit unit = createIU("f1");
- assertNull("1.1", IUPropertyUtils.getCopyright(unit));
- assertNull("1.2", IUPropertyUtils.getLicense(unit));
- assertNull("1.3", IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_NAME));
- assertNull("1.4", IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_DESCRIPTION));
- assertNull("1.5", IUPropertyUtils.getIUProperty(unit, IInstallableUnit.PROP_PROVIDER));
+ assertNull("1.1", unit.getCopyright(null));
+ assertEquals("1.2", 0, unit.getLicenses(null).length);;
+ assertNull("1.3", unit.getProperty(IInstallableUnit.PROP_NAME, null));
+ assertNull("1.4", unit.getProperty(IInstallableUnit.PROP_DESCRIPTION, null));
+ assertNull("1.5", unit.getProperty(IInstallableUnit.PROP_PROVIDER, null));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/repohandling/SiteImportExportTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/repohandling/SiteImportExportTest.java
index 48c8c6c76..1948e5a87 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/repohandling/SiteImportExportTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/repohandling/SiteImportExportTest.java
@@ -11,8 +11,8 @@
package org.eclipse.equinox.p2.tests.ui.repohandling;
import java.io.File;
+import org.eclipse.equinox.internal.p2.ui.UpdateManagerCompatibility;
import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
-import org.eclipse.equinox.internal.provisional.p2.ui.UpdateManagerCompatibility;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
public class SiteImportExportTest extends AbstractProvisioningUITest {

Back to the top