Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2010-01-13 12:55:40 +0000
committerThomas Hallgren2010-01-13 12:55:40 +0000
commitd743b627ab504ab6787a7cb560abdbe5d029e08e (patch)
tree21ee5bb25ff3ca089b5ac9fe41f776868bc5e72b
parent3f15df46bddcd3301ee0715c9e0b68cc11efbd3c (diff)
downloadrt.equinox.p2-d743b627ab504ab6787a7cb560abdbe5d029e08e.tar.gz
rt.equinox.p2-d743b627ab504ab6787a7cb560abdbe5d029e08e.tar.xz
rt.equinox.p2-d743b627ab504ab6787a7cb560abdbe5d029e08e.zip
298604 : Split the p2QL into one core simple Expression part and one Query part
-rw-r--r--bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PermissiveSlicer.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/QueryableArray.java52
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java31
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/MetadataGeneratorHelper.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/IFilterAdvice.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/QueryableFilterAdvice.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigCUsAction.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxLauncherCUAction.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/CategoryElementWrapperTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java46
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/AllTests.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/ExpressionTest.java67
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java267
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java48
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java39
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug207319.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DependencyOnSelf.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationDeepConflict.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForOptionalDependencies.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForPartialInstallation.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationLargeConflict.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationSeveralConflictingRoots.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUProperties.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUPropertyRemoval.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MinimalInstall.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleProvider.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleSingleton.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoRequirements.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest11.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java86
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxExecutableActionTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/AllTests.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java119
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/TestQueryReimplementation.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java15
78 files changed, 874 insertions, 573 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF
index 7435d6218..2f2feff92 100644
--- a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF
@@ -44,7 +44,8 @@ Export-Package: org.eclipse.equinox.internal.p2.core;x-friends:="org.eclipse.equ
org.eclipse.equinox.p2.extensionlocation,
org.eclipse.equinox.p2.publisher,
org.eclipse.equinox.p2.repository.tools,
- org.eclipse.equinox.p2.repository",
+ org.eclipse.equinox.p2.repository,
+ org.eclipse.equinox.p2.ql",
org.eclipse.equinox.internal.provisional.p2.core;
x-friends:="org.eclipse.equinox.p2.artifact.optimizers,
org.eclipse.equinox.p2.artifact.processors,
diff --git a/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
index 8cb563afc..2b7b838ec 100644
--- a/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.director/META-INF/MANIFEST.MF
@@ -5,7 +5,8 @@ Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-Version: 1.0.100.qualifier
-Import-Package: org.eclipse.equinox.internal.p2.core.helpers,
+Import-Package: org.eclipse.core.expressions,
+ org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.internal.p2.engine,
org.eclipse.equinox.internal.provisional.configurator,
org.eclipse.equinox.internal.provisional.p2.core,
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PermissiveSlicer.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PermissiveSlicer.java
index 762bc3015..25604cbb4 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PermissiveSlicer.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PermissiveSlicer.java
@@ -9,7 +9,7 @@
package org.eclipse.equinox.internal.p2.director;
import java.util.Dictionary;
-import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
+import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.query.IQueryable;
@@ -47,11 +47,8 @@ public class PermissiveSlicer extends Slicer {
return false;
if (considerOnlyStrictDependency) {
- if (req instanceof IRequiredCapability) {
- IRequiredCapability reqCap = (IRequiredCapability) req;
- if (!reqCap.getRange().getMinimum().equals(reqCap.getRange().getMaximum()))
- return false;
- }
+ if (!RequiredCapability.isVersionStrict(req.getMatches()))
+ return false;
}
//deal with filters
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
index 5dcf157c7..0388be5e3 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
@@ -19,13 +19,12 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.p2.metadata.query.PatchQuery;
-import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.metadata.query.*;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.Filter;
import org.sat4j.pb.IPBSolver;
import org.sat4j.pb.SolverFactory;
import org.sat4j.pb.tools.DependencyHelper;
@@ -249,7 +248,7 @@ public class Projector {
for (IRequirement req : reqs) {
if (req.getMin() > 0)
continue;
- IQueryResult<IInstallableUnit> matches = picker.query(req.getMatches(), null);
+ IQueryResult<IInstallableUnit> matches = picker.query(new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class, req.getMatches()), null);
for (Iterator<IInstallableUnit> iterator = matches.iterator(); iterator.hasNext();) {
IInstallableUnit match = iterator.next();
if (match instanceof IInstallableUnitPatch) {
@@ -305,27 +304,13 @@ public class Projector {
// Check whether the requirement is applicable
private boolean isApplicable(IRequirement req) {
- IQuery<Boolean> filter = req.getFilter();
- if (filter == null)
- return true;
- if (filter instanceof LDAPQuery)
- try {
- return DirectorActivator.context.createFilter(((LDAPQuery) filter).getFilter()).match(selectionContext);
- } catch (InvalidSyntaxException e) {
- return false;
- }
- throw new IllegalArgumentException();
+ Filter filter = req.getFilter();
+ return filter == null || filter.match(selectionContext);
}
private boolean isApplicable(IInstallableUnit iu) {
- LDAPQuery enablementFilter = (LDAPQuery) iu.getFilter();
- if (enablementFilter == null)
- return true;
- try {
- return DirectorActivator.context.createFilter(enablementFilter.getFilter()).match(selectionContext);
- } catch (InvalidSyntaxException e) {
- return false;
- }
+ Filter filter = iu.getFilter();
+ return filter == null || filter.match(selectionContext);
}
private void expandNegatedRequirement(IRequirement req, IInstallableUnit iu, List<AbstractVariable> optionalAbstractRequirements, boolean isRootIu) throws ContradictionException {
@@ -646,7 +631,7 @@ public class Projector {
*/
private List<IInstallableUnit> getApplicableMatches(IRequirement req) {
List<IInstallableUnit> target = new ArrayList<IInstallableUnit>();
- IQueryResult<IInstallableUnit> matches = picker.query(req.getMatches(), null);
+ IQueryResult<IInstallableUnit> matches = picker.query(new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class, req.getMatches()), null);
for (Iterator<IInstallableUnit> iterator = matches.iterator(); iterator.hasNext();) {
IInstallableUnit match = iterator.next();
if (isApplicable(match)) {
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/QueryableArray.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/QueryableArray.java
index 794c6e737..1a250b301 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/QueryableArray.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/QueryableArray.java
@@ -10,43 +10,34 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.director;
-import org.eclipse.equinox.p2.metadata.IProvidedCapability;
-
import java.util.*;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
+import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
+import org.eclipse.equinox.p2.metadata.query.ExpressionQuery;
import org.eclipse.equinox.p2.query.*;
public class QueryableArray implements IQueryable<IInstallableUnit> {
- static class IUCapability {
- final IInstallableUnit iu;
- final IProvidedCapability capability;
-
- public IUCapability(IInstallableUnit iu, IProvidedCapability capability) {
- this.iu = iu;
- this.capability = capability;
- }
- }
-
private final List<IInstallableUnit> dataSet;
- private Map<String, List<IUCapability>> namedCapabilityIndex;
+ private Map<String, List<IInstallableUnit>> namedCapabilityIndex;
public QueryableArray(IInstallableUnit[] ius) {
dataSet = Arrays.asList(ius);
}
public IQueryResult<IInstallableUnit> query(IQuery<IInstallableUnit> query, IProgressMonitor monitor) {
- if (query instanceof IRequiredCapability)
- return queryCapability((IRequiredCapability) query, new Collector<IInstallableUnit>(), monitor);
+ if (query instanceof ExpressionQuery)
+ return queryCapability((ExpressionQuery) query, new Collector<IInstallableUnit>(), monitor);
return query.perform(dataSet.iterator());
}
- private Collector<IInstallableUnit> queryCapability(IRequiredCapability query, Collector<IInstallableUnit> collector, IProgressMonitor monitor) {
+ private Collector<IInstallableUnit> queryCapability(ExpressionQuery query, Collector<IInstallableUnit> collector, IProgressMonitor monitor) {
generateNamedCapabilityIndex();
Collection<IInstallableUnit> resultIUs = null;
- Collection<IInstallableUnit> matchingIUs = findMatchingIUs(query);
+ Collection<IInstallableUnit> matchingIUs = findMatchingIUs(query.getExpression());
if (matchingIUs == null)
return collector;
if (resultIUs == null)
@@ -61,15 +52,16 @@ public class QueryableArray implements IQueryable<IInstallableUnit> {
return collector;
}
- private Collection<IInstallableUnit> findMatchingIUs(IRequiredCapability requiredCapability) {
- List<IUCapability> iuCapabilities = namedCapabilityIndex.get(requiredCapability.getName());
- if (iuCapabilities == null)
+ private Collection<IInstallableUnit> findMatchingIUs(IMatchExpression requirementMatch) {
+ // TODO: This is a hack. Should be replaced by use of proper indexes
+ List<IInstallableUnit> ius = namedCapabilityIndex.get(RequiredCapability.extractName(requirementMatch));
+ if (ius == null)
return null;
Set<IInstallableUnit> matchingIUs = new HashSet<IInstallableUnit>();
- for (IUCapability iuCapability : iuCapabilities) {
- if (iuCapability.iu.satisfies(requiredCapability))
- matchingIUs.add(iuCapability.iu);
+ for (IInstallableUnit iu : ius) {
+ if (requirementMatch.isMatch(iu))
+ matchingIUs.add(iu);
}
return matchingIUs;
}
@@ -78,18 +70,18 @@ public class QueryableArray implements IQueryable<IInstallableUnit> {
if (namedCapabilityIndex != null)
return;
- namedCapabilityIndex = new HashMap<String, List<IUCapability>>();
+ namedCapabilityIndex = new HashMap<String, List<IInstallableUnit>>();
for (IInstallableUnit iu : dataSet) {
Collection<IProvidedCapability> providedCapabilities = iu.getProvidedCapabilities();
for (IProvidedCapability pc : providedCapabilities) {
String name = pc.getName();
- List<IUCapability> iuCapabilities = namedCapabilityIndex.get(name);
- if (iuCapabilities == null) {
- iuCapabilities = new ArrayList<IUCapability>(5);
- namedCapabilityIndex.put(name, iuCapabilities);
+ List<IInstallableUnit> ius = namedCapabilityIndex.get(name);
+ if (ius == null) {
+ ius = new ArrayList<IInstallableUnit>(5);
+ namedCapabilityIndex.put(name, ius);
}
- iuCapabilities.add(new IUCapability(iu, pc));
+ ius.add(iu);
}
}
}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
index d29525728..71304c460 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
@@ -25,6 +25,7 @@ import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.query.ExpressionQuery;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
@@ -389,7 +390,7 @@ public class SimplePlanner implements IPlanner {
private Collection<IRequirement> areMetaRequirementsSatisfied(IProfile oldProfile, Collection<IInstallableUnit> newProfile, IProvisioningPlan initialPlan) {
Collection<IRequirement> allMetaRequirements = extractMetaRequirements(newProfile, initialPlan);
for (IRequirement requirement : allMetaRequirements) {
- if (oldProfile.query(new LimitQuery<IInstallableUnit>(requirement.getMatches(), 1), null).isEmpty())
+ if (oldProfile.query(new LimitQuery<IInstallableUnit>(new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class, requirement.getMatches()), 1), null).isEmpty())
return allMetaRequirements;
}
return null;
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java
index e0744d83c..0f84ef178 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java
@@ -14,11 +14,12 @@ import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.metadata.query.ExpressionQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.Filter;
public class Slicer {
private static boolean DEBUG = false;
@@ -87,27 +88,13 @@ public class Slicer {
// Check whether the requirement is applicable
protected boolean isApplicable(IRequirement req) {
- IQuery<Boolean> filter = req.getFilter();
- if (filter == null)
- return true;
- if (filter instanceof LDAPQuery)
- try {
- return DirectorActivator.context.createFilter(((LDAPQuery) filter).getFilter()).match(selectionContext);
- } catch (InvalidSyntaxException e) {
- return false;
- }
- throw new IllegalArgumentException();
+ Filter filter = req.getFilter();
+ return filter == null || filter.match(selectionContext);
}
protected boolean isApplicable(IInstallableUnit iu) {
- LDAPQuery enablementFilter = (LDAPQuery) iu.getFilter();
- if (enablementFilter == null)
- return true;
- try {
- return DirectorActivator.context.createFilter(enablementFilter.getFilter()).match(selectionContext);
- } catch (InvalidSyntaxException e) {
- return false;
- }
+ Filter filter = iu.getFilter();
+ return filter == null || filter.match(selectionContext);
}
protected void processIU(IInstallableUnit iu) {
@@ -172,7 +159,7 @@ public class Slicer {
private void expandRequirement(IInstallableUnit iu, IRequirement req) {
if (req.getMax() == 0)
return;
- IQueryResult<IInstallableUnit> matches = possibilites.query(req.getMatches(), null);
+ IQueryResult<IInstallableUnit> matches = possibilites.query(new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class, req.getMatches()), null);
int validMatches = 0;
for (Iterator<IInstallableUnit> iterator = matches.iterator(); iterator.hasNext();) {
IInstallableUnit match = iterator.next();
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF
index 97f51cbb6..264ed2f50 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF
@@ -21,6 +21,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.provisional.p2.metadata,
org.eclipse.equinox.internal.provisional.simpleconfigurator.manipulator,
org.eclipse.equinox.p2.metadata,
+ org.eclipse.equinox.p2.metadata.expression,
org.eclipse.equinox.p2.metadata.query,
org.eclipse.equinox.p2.query,
org.eclipse.equinox.p2.repository,
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
index dd2cd0b39..81cfd9e37 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
@@ -10,14 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata.generator;
-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.query.InstallableUnitQuery;
-
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
@@ -28,17 +20,19 @@ import org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxConstants;
import org.eclipse.equinox.internal.p2.core.helpers.*;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils.IPathComputer;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.internal.p2.metadata.generator.*;
import org.eclipse.equinox.internal.p2.metadata.generator.Messages;
import org.eclipse.equinox.internal.p2.metadata.generator.features.*;
import org.eclipse.equinox.internal.p2.metadata.query.LatestIUVersionQuery;
import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
-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.MetadataFactory.InstallableUnitFragmentDescription;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.artifact.*;
@@ -47,6 +41,7 @@ import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.osgi.service.environment.Constants;
import org.eclipse.osgi.service.resolver.*;
import org.eclipse.osgi.util.NLS;
+import org.osgi.framework.Filter;
public class Generator {
/**
@@ -241,7 +236,7 @@ public class Generator {
IInstallableUnit iu = (IInstallableUnit) iterator.next();
VersionRange range = new VersionRange(iu.getVersion(), true, iu.getVersion(), true);
// boolean isOptional = checkOptionalRootDependency(iu);
- reqsConfigurationUnits.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), range, ((LDAPQuery) iu.getFilter()).getFilter(), false, false));
+ reqsConfigurationUnits.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), range, iu.getFilter(), false, false));
}
if (requires != null)
reqsConfigurationUnits.addAll(requires);
@@ -665,8 +660,8 @@ public class Generator {
}
}
bundle.setVersion(configuredIU.getVersion().toString());
- LDAPQuery filter = (LDAPQuery) (configuredIU == null ? null : configuredIU.getFilter());
- IInstallableUnit cu = MetadataGeneratorHelper.createBundleConfigurationUnit(bundle.getSymbolicName(), Version.create(bundle.getVersion()), false, bundle, info.getFlavor(), filter == null ? null : filter.getFilter());
+ Filter filter = configuredIU == null ? null : configuredIU.getFilter();
+ IInstallableUnit cu = MetadataGeneratorHelper.createBundleConfigurationUnit(bundle.getSymbolicName(), Version.create(bundle.getVersion()), false, bundle, info.getFlavor(), filter == null ? null : filter.toString());
//the configuration unit should share the same platform filter as the IU being configured.
if (cu != null) {
result.rootIUs.add(cu);
@@ -714,7 +709,7 @@ public class Generator {
ArrayList required = new ArrayList(rootCategory.size());
for (Iterator iterator = rootCategory.iterator(); iterator.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iterator.next();
- required.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), VersionRange.emptyRange, ((LDAPQuery) iu.getFilter()).getFilter(), false, false));
+ required.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), VersionRange.emptyRange, iu.getFilter(), false, false));
}
cat.setRequiredCapabilities((IRequirement[]) required.toArray(new IRequirement[required.size()]));
cat.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, categoryId, Version.emptyVersion)});
@@ -807,9 +802,9 @@ public class Generator {
Version launcherVersion = Version.create(version);
iu.setVersion(launcherVersion);
iu.setSingleton(true);
- String filter = null;
+ Filter filter = null;
if (!ws.equals(CONFIG_ANY) && !os.equals(CONFIG_ANY) && !arch.equals(CONFIG_ANY)) {
- filter = "(& (osgi.ws=" + ws + ") (osgi.os=" + os + ") (osgi.arch=" + arch + "))"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ filter = ExpressionUtil.parseLDAP("(& (osgi.ws=" + ws + ") (osgi.os=" + os + ") (osgi.arch=" + arch + "))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
iu.setFilter(filter);
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/MetadataGeneratorHelper.java b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/MetadataGeneratorHelper.java
index 1b6ad0ea3..d3db5f58f 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/MetadataGeneratorHelper.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/MetadataGeneratorHelper.java
@@ -11,9 +11,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata.generator;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
@@ -26,14 +23,16 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.internal.p2.metadata.generator.Activator;
import org.eclipse.equinox.internal.p2.metadata.generator.LocalizationHelper;
import org.eclipse.equinox.internal.p2.metadata.generator.features.SiteCategory;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
-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.*;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor;
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
@@ -41,8 +40,7 @@ import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
import org.eclipse.osgi.service.resolver.*;
import org.eclipse.osgi.util.ManifestElement;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
+import org.osgi.framework.*;
/**
* @deprecated this class has been renamed to PublisherHelper and the vast majority
@@ -100,7 +98,7 @@ public class MetadataGeneratorHelper {
public static final String OSGI_BUNDLE_CLASSIFIER = "osgi.bundle"; //$NON-NLS-1$
public static final String BINARY_ARTIFACT_CLASSIFIER = "binary"; //$NON-NLS-1$
- public static final String INSTALL_FEATURES_FILTER = "(org.eclipse.update.install.features=true)"; //$NON-NLS-1$
+ public static final Filter INSTALL_FEATURES_FILTER = ExpressionUtil.parseLDAP("(org.eclipse.update.install.features=true)"); //$NON-NLS-1$
private static final String IU_NAMESPACE = IInstallableUnit.NAMESPACE_IU_ID;
@@ -484,11 +482,11 @@ public class MetadataGeneratorHelper {
for (Iterator iterator = featureIUs.iterator(); iterator.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iterator.next();
VersionRange range = new VersionRange(iu.getVersion(), true, iu.getVersion(), true);
- reqsConfigurationUnits.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), range, iu.getFilter() == null ? null : ((LDAPQuery) iu.getFilter()).getFilter(), false, false));
+ reqsConfigurationUnits.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), range, iu.getFilter() == null ? null : iu.getFilter(), false, false));
}
//note that update sites don't currently support nested categories, but it may be useful to add in the future
if (parentCategory != null) {
- reqsConfigurationUnits.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, parentCategory.getId(), VersionRange.emptyRange, parentCategory.getFilter() == null ? null : ((LDAPQuery) parentCategory.getFilter()).getFilter(), false, false));
+ reqsConfigurationUnits.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, parentCategory.getId(), VersionRange.emptyRange, parentCategory.getFilter() == null ? null : parentCategory.getFilter(), false, false));
}
cat.setRequiredCapabilities((IRequirement[]) reqsConfigurationUnits.toArray(new IRequirement[reqsConfigurationUnits.size()]));
@@ -1158,7 +1156,7 @@ public class MetadataGeneratorHelper {
/**
* @deprecated moved to FeaturesAction
*/
- public static String getFilter(FeatureEntry entry) {
+ public static Filter getFilter(FeatureEntry entry) {
StringBuffer result = new StringBuffer();
result.append("(&"); //$NON-NLS-1$
if (entry.getFilter() != null)
@@ -1174,7 +1172,7 @@ public class MetadataGeneratorHelper {
if (result.length() == 2)
return null;
result.append(')');
- return result.toString();
+ return ExpressionUtil.parseLDAP(result.toString());
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF
index 53e20a3ba..fcca9dedf 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF
@@ -28,6 +28,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.p2.core,
org.eclipse.equinox.p2.core.spi,
org.eclipse.equinox.p2.metadata,
+ org.eclipse.equinox.p2.metadata.expression,
org.eclipse.equinox.p2.metadata.query,
org.eclipse.equinox.p2.query,
org.eclipse.equinox.p2.repository,
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
index 067bcf741..e9eed98a8 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
@@ -12,21 +12,19 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository.io;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.net.URI;
import java.util.*;
import java.util.Map.Entry;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
import org.eclipse.equinox.internal.p2.persistence.XMLParser;
-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.*;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
@@ -568,20 +566,29 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
protected class RequiredCapabilityHandler extends AbstractHandler {
+ private List<IRequirement> capabilities;
- private IRequirement currentCapability = null;
+ private String namespace;
+ private String name;
+ private VersionRange range;
+ private int min;
+ private int max;
+ private boolean greedy;
private TextHandler filterHandler = null;
public RequiredCapabilityHandler(AbstractHandler parentHandler, Attributes attributes, List<IRequirement> capabilities) {
super(parentHandler, REQUIRED_CAPABILITY_ELEMENT);
+ this.capabilities = capabilities;
String[] values = parseAttributes(attributes, REQIURED_CAPABILITY_ATTRIBUTES, OPTIONAL_CAPABILITY_ATTRIBUTES);
- VersionRange range = checkVersionRange(REQUIRED_CAPABILITY_ELEMENT, VERSION_RANGE_ATTRIBUTE, values[2]);
+ namespace = values[0];
+ name = values[1];
+ range = checkVersionRange(REQUIRED_CAPABILITY_ELEMENT, VERSION_RANGE_ATTRIBUTE, values[2]);
boolean isOptional = checkBoolean(REQUIRED_CAPABILITY_ELEMENT, CAPABILITY_OPTIONAL_ATTRIBUTE, values[3], false).booleanValue();
+ min = isOptional ? 0 : 1;
boolean isMultiple = checkBoolean(REQUIRED_CAPABILITY_ELEMENT, CAPABILITY_MULTIPLE_ATTRIBUTE, values[4], false).booleanValue();
- boolean isGreedy = checkBoolean(REQUIRED_CAPABILITY_ELEMENT, CAPABILITY_GREED_ATTRIBUTE, values[5], true).booleanValue();
- currentCapability = MetadataFactory.createRequiredCapability(values[0], values[1], range, null, isOptional, isMultiple, isGreedy);
- capabilities.add(currentCapability);
+ max = isMultiple ? Integer.MAX_VALUE : 1;
+ greedy = checkBoolean(REQUIRED_CAPABILITY_ELEMENT, CAPABILITY_GREED_ATTRIBUTE, values[5], true).booleanValue();
}
public void startElement(String name, Attributes attributes) {
@@ -594,11 +601,10 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
protected void finished() {
if (isValidXML()) {
- if (currentCapability != null) {
- if (filterHandler != null) {
- ((RequiredCapability) currentCapability).setFilter(filterHandler.getText());
- }
- }
+ Filter filter = null;
+ if (filterHandler != null)
+ filter = ExpressionUtil.parseLDAP(filterHandler.getText());
+ capabilities.add(MetadataFactory.createRequiredCapability(namespace, name, range, filter, min, max, greedy));
}
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
index 77882af71..1a5801bb1 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
@@ -19,7 +19,6 @@ import java.util.Map.Entry;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
import org.eclipse.equinox.internal.p2.persistence.XMLWriter;
import org.eclipse.equinox.p2.metadata.*;
@@ -74,7 +73,7 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
writeMetaRequiredCapabilities(iu.getMetaRequiredCapabilities());
writeProvidedCapabilities(iu.getProvidedCapabilities());
writeRequiredCapabilities(iu.getRequiredCapabilities());
- writeTrimmedCdata(IU_FILTER_ELEMENT, iu.getFilter() == null ? null : ((LDAPQuery) iu.getFilter()).getFilter());
+ writeTrimmedCdata(IU_FILTER_ELEMENT, iu.getFilter() == null ? null : iu.getFilter().toString());
writeArtifactKeys(iu.getArtifacts());
writeTouchpointType(iu.getTouchpointType());
@@ -194,9 +193,10 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
attribute(NAME_ATTRIBUTE, reqCapability.getName());
attribute(VERSION_RANGE_ATTRIBUTE, reqCapability.getRange());
attribute(CAPABILITY_OPTIONAL_ATTRIBUTE, requirement.getMin() == 0, false);
+ attribute(CAPABILITY_MULTIPLE_ATTRIBUTE, requirement.getMax() > 1, false);
attribute(CAPABILITY_GREED_ATTRIBUTE, requirement.isGreedy(), true);
if (requirement.getFilter() != null)
- writeTrimmedCdata(CAPABILITY_FILTER_ELEMENT, ((LDAPQuery) requirement.getFilter()).getFilter());
+ writeTrimmedCdata(CAPABILITY_FILTER_ELEMENT, requirement.getFilter().toString());
end(REQUIRED_CAPABILITY_ELEMENT);
} else {
throw new IllegalStateException();
diff --git a/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF
index 03feca51c..ef79934b2 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF
@@ -26,6 +26,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.provisional.simpleconfigurator.manipulator,
org.eclipse.equinox.p2.core,
org.eclipse.equinox.p2.metadata,
+ org.eclipse.equinox.p2.metadata.expression,
org.eclipse.equinox.p2.metadata.query,
org.eclipse.equinox.p2.query,
org.eclipse.equinox.p2.repository,
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java
index 74d3cccdf..4674bd3ba 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java
@@ -18,7 +18,6 @@ import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifact
import org.eclipse.equinox.internal.p2.core.helpers.*;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils.IPathComputer;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.internal.p2.metadata.query.LatestIUVersionQuery;
import org.eclipse.equinox.internal.p2.publisher.Activator;
import org.eclipse.equinox.internal.p2.publisher.QuotedTokenizer;
@@ -26,6 +25,7 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.publisher.actions.*;
import org.eclipse.equinox.p2.query.*;
@@ -34,7 +34,6 @@ import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
public abstract class AbstractPublisherAction implements IPublisherAction {
public static final String CONFIG_ANY = "ANY"; //$NON-NLS-1$
@@ -104,7 +103,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction {
* @return the LDAP filter for the given spec. <code>null</code> if the given spec does not
* parse into a filter.
*/
- protected String createFilterSpec(String configSpec) {
+ protected Filter createFilterSpec(String configSpec) {
String[] config = parseConfigSpec(configSpec);
if (config[0] != null || config[1] != null || config[2] != null) {
String filterWs = config[0] != null && config[0] != CONFIG_ANY ? "(osgi.ws=" + config[0] + ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -112,29 +111,21 @@ public abstract class AbstractPublisherAction implements IPublisherAction {
String filterArch = config[2] != null && config[2] != CONFIG_ANY ? "(osgi.arch=" + config[2] + ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (filterWs.length() == 0 && filterOs.length() == 0 && filterArch.length() == 0)
return null;
- return "(& " + filterWs + filterOs + filterArch + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return ExpressionUtil.parseLDAP("(& " + filterWs + filterOs + filterArch + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
return null;
}
- protected boolean filterMatches(String filter, String configSpec) {
+ protected boolean filterMatches(Filter filter, String configSpec) {
if (filter == null)
return true;
- Filter ldapFilter = null;
- try {
- ldapFilter = Activator.context.createFilter(filter);
- } catch (InvalidSyntaxException e) {
- // TODO true or false on error?
- return true;
- }
-
String[] config = parseConfigSpec(configSpec);
Dictionary<String, String> environment = new Hashtable<String, String>(3);
environment.put("osgi.ws", config[0]); //$NON-NLS-1$
environment.put("osgi.os", config[1]); //$NON-NLS-1$
environment.put("osgi.arch", config[2]); //$NON-NLS-1$
- return ldapFilter.match(environment);
+ return filter.match(environment);
}
/**
@@ -166,23 +157,23 @@ public abstract class AbstractPublisherAction implements IPublisherAction {
if (next instanceof IInstallableUnit) {
IInstallableUnit iu = (IInstallableUnit) next;
VersionRange range = new VersionRange(iu.getVersion(), true, iu.getVersion(), true);
- result.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), range, iu.getFilter() == null ? null : ((LDAPQuery) iu.getFilter()).getFilter(), false, false));
+ result.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), range, iu.getFilter() == null ? null : iu.getFilter(), false, false));
} else {
Version version = next.getVersion();
VersionRange range = (version == null || Version.emptyVersion.equals(version)) ? VersionRange.emptyRange : new VersionRange(version, true, version, true);
- String filter = getFilterAdvice(next);
+ Filter filter = getFilterAdvice(next);
result.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, next.getId(), range, filter, false, false));
}
}
return result;
}
- private String getFilterAdvice(IVersionedId name) {
+ private Filter getFilterAdvice(IVersionedId name) {
if (info == null)
return null;
Collection<IFilterAdvice> filterAdvice = info.getAdvice(CONFIG_ANY, true, name.getId(), name.getVersion(), IFilterAdvice.class);
for (IFilterAdvice advice : filterAdvice) {
- String result = advice.getFilter(name.getId(), name.getVersion(), false);
+ Filter result = advice.getFilter(name.getId(), name.getVersion(), false);
if (result != null)
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/IFilterAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/IFilterAdvice.java
index 49b4a41f7..8e7d376ad 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/IFilterAdvice.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/IFilterAdvice.java
@@ -11,6 +11,7 @@ package org.eclipse.equinox.p2.publisher.actions;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.publisher.IPublisherAdvice;
+import org.osgi.framework.Filter;
/**
* Filter advice helps actions figure out where an IU with a given id and version
@@ -34,6 +35,6 @@ public interface IFilterAdvice extends IPublisherAdvice {
* @return the filter to use when depending on the given IU or <code>null</code>
* if none.
*/
- public String getFilter(String id, Version version, boolean exact);
+ public Filter getFilter(String id, Version version, boolean exact);
}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/QueryableFilterAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/QueryableFilterAdvice.java
index fff7ef0df..9a068b790 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/QueryableFilterAdvice.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/QueryableFilterAdvice.java
@@ -9,12 +9,12 @@
******************************************************************************/
package org.eclipse.equinox.p2.publisher.actions;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
+import org.osgi.framework.Filter;
/**
* An IFilterAdvice that looks up the desired IU in the publisher's input metadata
@@ -28,18 +28,18 @@ public class QueryableFilterAdvice implements IFilterAdvice {
this.queryable = queryable;
}
- public String getFilter(String id, Version version, boolean exact) {
+ public Filter getFilter(String id, Version version, boolean exact) {
InstallableUnitQuery query = new InstallableUnitQuery(id, version);
IQueryResult<IInstallableUnit> result = queryable.query(query, null);
if (!result.isEmpty())
- return ((LDAPQuery) result.iterator().next().getFilter()).getFilter();
+ return result.iterator().next().getFilter();
if (exact)
return null;
query = new InstallableUnitQuery(id);
result = queryable.query(query, null);
if (!result.isEmpty())
- return ((LDAPQuery) result.iterator().next().getFilter()).getFilter();
+ return result.iterator().next().getFilter();
return null;
}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java
index 9ac9462ee..5ce821f25 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java
@@ -21,6 +21,7 @@ import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
+import org.osgi.framework.Filter;
public class RootFilesAction extends AbstractPublisherAction {
private String idBase;
@@ -89,7 +90,7 @@ public class RootFilesAction extends AbstractPublisherAction {
String iuId = idPrefix + '.' + createIdString(configSpec);
iu.setId(iuId);
iu.setVersion(version);
- String filter = createFilterSpec(configSpec);
+ Filter filter = createFilterSpec(configSpec);
iu.setFilter(filter);
IArtifactKey key = PublisherHelper.createBinaryArtifactKey(iuId, version);
iu.setArtifacts(new IArtifactKey[] {key});
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
index a0d58bff4..e1a2683d6 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
@@ -20,7 +20,6 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.p2.publisher.Activator;
import org.eclipse.equinox.internal.p2.publisher.Messages;
import org.eclipse.equinox.internal.p2.publisher.eclipse.GeneratorBundleInfo;
@@ -104,7 +103,7 @@ public class BundlesAction extends AbstractPublisherAction {
return new ArtifactKey(OSGI_BUNDLE_CLASSIFIER, bsn, Version.parseVersion(version));
}
- public static IInstallableUnit createBundleConfigurationUnit(String hostId, Version cuVersion, boolean isBundleFragment, GeneratorBundleInfo configInfo, String configurationFlavor, String filter) {
+ public static IInstallableUnit createBundleConfigurationUnit(String hostId, Version cuVersion, boolean isBundleFragment, GeneratorBundleInfo configInfo, String configurationFlavor, Filter filter) {
if (configInfo == null)
return null;
@@ -154,7 +153,7 @@ public class BundlesAction extends AbstractPublisherAction {
//Process the required bundles
BundleSpecification requiredBundles[] = bd.getRequiredBundles();
- ArrayList<IRequiredCapability> reqsDeps = new ArrayList<IRequiredCapability>();
+ ArrayList<IRequirement> reqsDeps = new ArrayList<IRequirement>();
// if (requiresAFragment)
// reqsDeps.add(MetadataFactory.createRequiredCapability(CAPABILITY_TYPE_OSGI_FRAGMENTS, bd.getSymbolicName(), VersionRange.emptyRange, null, false, false));
if (isFragment)
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigCUsAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigCUsAction.java
index 91c0d6722..7f795640f 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigCUsAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigCUsAction.java
@@ -14,17 +14,16 @@ import java.io.File;
import java.util.*;
import java.util.Map.Entry;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.internal.p2.publisher.eclipse.GeneratorBundleInfo;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
import org.eclipse.osgi.util.ManifestElement;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
+import org.osgi.framework.*;
/**
* Publish CUs for all the configuration data in the current result.
@@ -307,7 +306,7 @@ public class ConfigCUsAction extends AbstractPublisherAction {
return;
String cuIdPrefix = ""; //$NON-NLS-1$
- String filter = null;
+ Filter filter = null;
if (configSpec != null) {
cuIdPrefix = createIdString(configSpec);
filter = createFilterSpec(configSpec);
@@ -321,7 +320,7 @@ public class ConfigCUsAction extends AbstractPublisherAction {
IInstallableUnit iu = bundle.getIU();
// If there is no host, or the filters don't match, skip this one.
- if (iu == null || !filterMatches(iu.getFilter() == null ? null : ((LDAPQuery) iu.getFilter()).getFilter(), configSpec))
+ if (iu == null || !filterMatches(iu.getFilter() == null ? null : iu.getFilter(), configSpec))
continue;
// TODO need to factor this out into its own action
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java
index c2d48d1cd..c76156368 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java
@@ -24,6 +24,7 @@ import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
import org.eclipse.osgi.service.environment.Constants;
+import org.osgi.framework.Filter;
/**
* Given the description of an executable, this action publishes optionally
@@ -85,10 +86,7 @@ public class EquinoxExecutableAction extends AbstractPublisherAction {
iud.setVersion(version);
iud.setTouchpointType(PublisherHelper.TOUCHPOINT_OSGI);
iud.setCapabilities(new IProvidedCapability[] {createSelfCapability(id, version)});
-
- String filter = createFilterSpec(configSpec);
- if (filter.length() > 0)
- iud.setFilter(filter);
+ iud.setFilter(createFilterSpec(configSpec));
Map<String, String> touchpointData = new HashMap<String, String>();
touchpointData.put("configure", "setLauncherName(name:" + executableName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
touchpointData.put("unconfigure", "setLauncherName()"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -106,7 +104,7 @@ public class EquinoxExecutableAction extends AbstractPublisherAction {
String id = getExecutableId();
iu.setId(id);
iu.setVersion(version);
- String filter = createFilterSpec(configSpec);
+ Filter filter = createFilterSpec(configSpec);
iu.setFilter(filter);
iu.setSingleton(true);
iu.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE);
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxLauncherCUAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxLauncherCUAction.java
index e757d9e2c..271f874c6 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxLauncherCUAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxLauncherCUAction.java
@@ -17,6 +17,7 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.publisher.actions.IVersionAdvice;
+import org.osgi.framework.Filter;
/**
* Create CUs for all Equinox launcher related IUs for the given set of configurations
@@ -79,7 +80,7 @@ public class EquinoxLauncherCUAction extends AbstractPublisherAction {
bundle.setSpecialConfigCommands("addProgramArg(programArg:--launcher.library);addProgramArg(programArg:@artifact);"); //$NON-NLS-1$
bundle.setSpecialUnconfigCommands("removeProgramArg(programArg:--launcher.library);removeProgramArg(programArg:@artifact);"); //$NON-NLS-1$
}
- String filter = configSpec == null ? null : createFilterSpec(configSpec);
+ Filter filter = configSpec == null ? null : createFilterSpec(configSpec);
IInstallableUnit cu = BundlesAction.createBundleConfigurationUnit(id, version, false, bundle, flavor, filter);
if (cu != null)
results.addIU(cu, IPublisherResult.ROOT);
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java
index 717b44d96..543047155 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java
@@ -19,14 +19,14 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils.IPathComputer;
-import org.eclipse.equinox.internal.p2.metadata.*;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.p2.publisher.*;
-import org.eclipse.equinox.internal.p2.publisher.Messages;
import org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureParser;
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.MetadataFactory.InstallableUnitPatchDescription;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.publisher.actions.IFeatureRootAdvice;
import org.eclipse.equinox.p2.repository.IRepository;
@@ -35,6 +35,7 @@ import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
import org.eclipse.osgi.util.NLS;
+import org.osgi.framework.Filter;
/**
* Publish IUs for all of the features in the given set of locations. The locations can
@@ -237,7 +238,7 @@ public class FeaturesAction extends AbstractPublisherAction {
iu.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor(id, BundlesAction.computeUpdateRange(new org.osgi.framework.Version(feature.getVersion())), IUpdateDescriptor.NORMAL, null));
FeatureEntry entries[] = feature.getEntries();
- List<IRequiredCapability> required = new ArrayList<IRequiredCapability>(entries.length + (childIUs == null ? 0 : childIUs.size()));
+ List<IRequirement> required = new ArrayList<IRequirement>(entries.length + (childIUs == null ? 0 : childIUs.size()));
for (int i = 0; i < entries.length; i++) {
VersionRange range = getVersionRange(entries[i]);
String requiredId = getTransformedId(entries[i].getId(), entries[i].isPlugin(), /*isGroup*/true);
@@ -249,7 +250,7 @@ public class FeaturesAction extends AbstractPublisherAction {
if (childIUs != null) {
for (int i = 0; i < childIUs.size(); i++) {
IInstallableUnit child = childIUs.get(i);
- String filter = (child.getFilter() instanceof LDAPQuery) ? ((LDAPQuery) child.getFilter()).getFilter() : null;
+ Filter filter = child.getFilter();
required.add(MetadataFactory.createRequiredCapability(PublisherHelper.IU_NAMESPACE, child.getId(), new VersionRange(child.getVersion(), true, child.getVersion(), true), filter, false, false));
}
}
@@ -262,9 +263,7 @@ public class FeaturesAction extends AbstractPublisherAction {
//Create a fake entry to reuse the logic to create the filters
FeatureEntry entry = new FeatureEntry("fake", "0.0.0", false); //$NON-NLS-1$ //$NON-NLS-2$
entry.setEnvironment(feature.getOS(), feature.getWS(), feature.getArch(), feature.getNL());
- String filter = getFilter(entry);
- if (filter != null)
- iu.setFilter(filter);
+ iu.setFilter(getFilter(entry));
// Create set of provided capabilities
ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<IProvidedCapability>();
@@ -336,7 +335,7 @@ public class FeaturesAction extends AbstractPublisherAction {
if (childIUs != null) {
for (int i = 0; i < childIUs.size(); i++) {
IInstallableUnit child = childIUs.get(i);
- patchRequirements.add(MetadataFactory.createRequiredCapability(PublisherHelper.IU_NAMESPACE, child.getId(), new VersionRange(child.getVersion(), true, child.getVersion(), true), child.getFilter() == null ? null : ((LDAPQuery) child.getFilter()).getFilter(), false, false));
+ patchRequirements.add(MetadataFactory.createRequiredCapability(PublisherHelper.IU_NAMESPACE, child.getId(), new VersionRange(child.getVersion(), true, child.getVersion(), true), child.getFilter(), false, false));
}
}
iu.setRequiredCapabilities(patchRequirements.toArray(new IRequirement[patchRequirements.size()]));
@@ -516,7 +515,7 @@ public class FeaturesAction extends AbstractPublisherAction {
return result.toArray(new Feature[result.size()]);
}
- private String getFilter(FeatureEntry entry) {
+ private Filter getFilter(FeatureEntry entry) {
StringBuffer result = new StringBuffer();
result.append("(&"); //$NON-NLS-1$
if (entry.getFilter() != null)
@@ -528,7 +527,7 @@ public class FeaturesAction extends AbstractPublisherAction {
if (result.length() == 2)
return null;
result.append(')');
- return result.toString();
+ return ExpressionUtil.parseLDAP(result.toString());
}
private void expandFilter(String filter, String osgiFilterValue, StringBuffer result) {
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.repository.tools/META-INF/MANIFEST.MF
index 5279dc775..1fc3ed3de 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/META-INF/MANIFEST.MF
@@ -28,6 +28,7 @@ Import-Package: org.eclipse.core.runtime;version="3.4.0",
org.eclipse.equinox.p2.engine,
org.eclipse.equinox.p2.engine.spi,
org.eclipse.equinox.p2.metadata,
+ org.eclipse.equinox.p2.metadata.expression,
org.eclipse.equinox.p2.metadata.query,
org.eclipse.equinox.p2.query,
org.eclipse.equinox.p2.repository,
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java
index c9e16d070..ed9125b23 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java
@@ -9,12 +9,10 @@
******************************************************************************/
package org.eclipse.equinox.p2.internal.repository.tools.analyzer;
-import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment;
-
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IRequirement;
+import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
@@ -33,13 +31,14 @@ public class HostCheckAnalyzer extends IUAnalyzer {
IInstallableUnitFragment fragment = (IInstallableUnitFragment) iu;
IRequirement[] hosts = fragment.getHost();
for (int i = 0; i < hosts.length; i++) {
- IRequiredCapability theHost = null;
- if (hosts[i] instanceof IRequiredCapability)
- theHost = (IRequiredCapability) hosts[i];
- if (theHost.getNamespace().equals("osgi.bundle")) {
- IQueryResult<IInstallableUnit> results = repository.query(new InstallableUnitQuery(theHost.getName(), theHost.getRange()), new NullProgressMonitor());
+ IMatchExpression<IInstallableUnit> hostMatch = hosts[i].getMatches();
+ String namespace = RequiredCapability.extractNamespace(hostMatch);
+ if ("osgi.bundle".equals(namespace)) {
+ String name = RequiredCapability.extractName(hostMatch);
+ VersionRange range = RequiredCapability.extractRange(hostMatch);
+ IQueryResult<IInstallableUnit> results = repository.query(new InstallableUnitQuery(name, range), new NullProgressMonitor());
if (results.isEmpty()) {
- error(iu, "IU Fragment: " + iu.getId() + " cannot find host" + theHost.getName() + " : " + theHost.getRange());
+ error(iu, "IU Fragment: " + iu.getId() + " cannot find host" + name + " : " + range);
return;
}
}
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 6e78924dc..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
@@ -17,6 +17,7 @@ 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;
@@ -30,7 +31,7 @@ public class AnyRequiredCapabilityTest extends AbstractQueryTest {
List items = new ArrayList();
items.add(match);
items.add(noMatch);
- IQueryResult result = requires.getMatches().perform(items.iterator());
+ IQueryResult result = new ExpressionQuery(IInstallableUnit.class, requires.getMatches()).perform(items.iterator());
assertEquals("1.0", 1, queryResultSize(result));
assertEquals("1.1", match, result.iterator().next());
}
@@ -47,7 +48,7 @@ public class AnyRequiredCapabilityTest extends AbstractQueryTest {
metadataRepositoryManager.addRepository(location);
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(requires.getMatches(), getMonitor());
+ 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/CategoryElementWrapperTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/CategoryElementWrapperTest.java
index 7270675cb..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
@@ -86,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/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF
index 7fbb139cc..438d9ea7c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF
@@ -20,6 +20,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.p2.jarprocessor,
org.eclipse.equinox.internal.p2.jarprocessor.verifier,
org.eclipse.equinox.internal.p2.metadata,
+ org.eclipse.equinox.internal.p2.metadata.expression,
org.eclipse.equinox.internal.p2.metadata.query,
org.eclipse.equinox.internal.p2.metadata.repository,
org.eclipse.equinox.internal.p2.metadata.repository.io,
@@ -41,6 +42,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.p2.internal.repository.comparator,
org.eclipse.equinox.p2.internal.repository.tools,
org.eclipse.equinox.p2.metadata,
+ org.eclipse.equinox.p2.metadata.expression,
org.eclipse.equinox.p2.metadata.query,
org.eclipse.equinox.p2.ql,
org.eclipse.equinox.p2.query,
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
index d39564b0d..1b6ef6158 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
@@ -8,9 +8,6 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.*;
import java.lang.reflect.Field;
import java.net.URI;
@@ -23,15 +20,16 @@ import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.internal.provisional.p2.director.*;
-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.*;
import org.eclipse.equinox.p2.core.*;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.metadata.query.FragmentQuery;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
@@ -43,8 +41,7 @@ import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
+import org.osgi.framework.*;
/**
* Base class for provisioning tests with convenience methods used by multiple tests.
@@ -273,8 +270,8 @@ public abstract class AbstractProvisioningTest extends TestCase {
/**
* Creates and returns a correctly formatted LDAP filter with the given key and value.
*/
- protected static String createFilter(String filterKey, String filterValue) {
- return "(" + filterKey + '=' + filterValue + ')';
+ protected static Filter createFilter(String filterKey, String filterValue) {
+ return ExpressionUtil.parseLDAP("(" + filterKey + '=' + filterValue + ')');
}
/**
@@ -314,6 +311,10 @@ public abstract class AbstractProvisioningTest extends TestCase {
* assume default values, and the default self capability is also added to the IU.
*/
public static IInstallableUnit createIU(String name, String filter, IProvidedCapability[] additionalProvides) {
+ return createIU(name, ExpressionUtil.parseLDAP(filter), additionalProvides);
+ }
+
+ public static IInstallableUnit createIU(String name, Filter filter, IProvidedCapability[] additionalProvides) {
return createIU(name, DEFAULT_VERSION, filter, NO_REQUIRES, additionalProvides, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false);
}
@@ -366,6 +367,10 @@ public abstract class AbstractProvisioningTest extends TestCase {
* assume default values, and the default self capability is also added to the IU.
*/
public static IInstallableUnit createIU(String name, Version version, String filter, IProvidedCapability[] additionalProvides) {
+ return createIU(name, version, ExpressionUtil.parseLDAP(filter), additionalProvides);
+ }
+
+ public static IInstallableUnit createIU(String name, Version version, Filter filter, IProvidedCapability[] additionalProvides) {
return createIU(name, version, filter, NO_REQUIRES, additionalProvides, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false);
}
@@ -373,7 +378,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
* Create a basic InstallableUnit with the given attributes. All other attributes
* assume default values, and the default self capability is also added to the IU.
*/
- public static IInstallableUnit createIU(String name, Version version, String filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton) {
+ public static IInstallableUnit createIU(String name, Version version, Filter filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton) {
return createIU(name, version, filter, required, additionalProvides, properties, tpType, tpData, singleton, null, null);
}
@@ -381,7 +386,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
return createIUPatch(name, version, null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, singleton, null, changes, scope, lifeCycle, NO_REQUIRES);
}
- public static IInstallableUnitPatch createIUPatch(String name, Version version, String filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequirementChange[] reqChanges, IRequiredCapability[][] scope, IRequiredCapability lifeCycle, IRequiredCapability[] metaRequirements) {
+ public static IInstallableUnitPatch createIUPatch(String name, Version version, Filter filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequirementChange[] reqChanges, IRequiredCapability[][] scope, IRequiredCapability lifeCycle, IRequiredCapability[] metaRequirements) {
InstallableUnitPatchDescription iu = new MetadataFactory.InstallableUnitPatchDescription();
iu.setId(name);
iu.setVersion(version);
@@ -410,7 +415,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
return MetadataFactory.createInstallableUnitPatch(iu);
}
- public static IInstallableUnit createIU(String name, Version version, String filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequiredCapability[] metaRequirements) {
+ public static IInstallableUnit createIU(String name, Version version, Filter filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequiredCapability[] metaRequirements) {
InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
iu.setId(name);
iu.setVersion(version);
@@ -485,7 +490,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
Collection<IProvidedCapability> originalCapabilities = prototype.getProvidedCapabilities();
desc.setCapabilities(originalCapabilities.toArray(new IProvidedCapability[originalCapabilities.size()]));
desc.setCopyright(prototype.getCopyright());
- desc.setFilter(prototype.getFilter() == null ? null : ((LDAPQuery) prototype.getFilter()).getFilter());
+ desc.setFilter(prototype.getFilter());
desc.setId(prototype.getId());
Collection<ILicense> originalLicenses = prototype.getLicenses();
desc.setLicenses(originalLicenses.toArray(new ILicense[originalLicenses.size()]));
@@ -513,14 +518,23 @@ public abstract class AbstractProvisioningTest extends TestCase {
/**
* Creates and returns a required capability with the provided attributes.
*/
+ protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name) {
+ return createRequiredCapabilities(namespace, name, ANY_VERSION, (Filter) null);
+ }
+
protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, String filter) {
return createRequiredCapabilities(namespace, name, ANY_VERSION, filter);
}
- /**
- * Creates and returns a required capability with the provided attributes.
- */
+ protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, VersionRange range) {
+ return createRequiredCapabilities(namespace, name, range, (Filter) null);
+ }
+
protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, VersionRange range, String filter) {
+ return createRequiredCapabilities(namespace, name, range, ExpressionUtil.parseLDAP(filter));
+ }
+
+ protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, VersionRange range, Filter filter) {
return new IRequiredCapability[] {MetadataFactory.createRequiredCapability(namespace, name, range, filter, false, false)};
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java
index 513bbeaa1..da38e98f9 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java
@@ -35,11 +35,13 @@ public class AutomatedTests extends TestCase {
suite.addTest(org.eclipse.equinox.p2.tests.installer.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.jarprocessor.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.metadata.AllTests.suite());
+ suite.addTest(org.eclipse.equinox.p2.tests.metadata.expression.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.metadata.repository.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.mirror.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.omniVersion.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.planner.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.publisher.AllTests.suite());
+ suite.addTest(org.eclipse.equinox.p2.tests.ql.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.repository.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.simpleconfigurator.SimpleConfiguratorTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.simpleconfigurator.manipulator.AllTests.suite());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java
index c9069754c..cabde3bcb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java
@@ -22,6 +22,7 @@ import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.osgi.framework.Filter;
/**
* Various automated tests of the {@link IDirector} API.
@@ -52,7 +53,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
IInstallableUnit requiredIU = createIU("required." + getName());
// The IU to be installed
- String filter = createFilter("FilterKey", "true");
+ Filter filter = createFilter("FilterKey", "true");
IRequiredCapability capability = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), ANY_VERSION, filter, false, false);
IInstallableUnit toInstallIU = createIU("toInstall." + getName(), new IRequiredCapability[] {capability});
@@ -132,7 +133,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
IProvidedCapability[] provides = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("test.capability", capabilityId, DEFAULT_VERSION)};
IInstallableUnit requiredIU = createIU("required." + getName(), createFilter("osgi.os", "blort"), provides);
- IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, null));
+ IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, (Filter) null));
IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU};
IInstallableUnit[] toInstallArray = new IInstallableUnit[] {toInstallIU};
@@ -191,7 +192,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
//The IU that exports the capability
IInstallableUnit requiredIU = createIU("required." + getName(), new IProvidedCapability[] {MetadataFactory.createProvidedCapability("test.capability", capabilityId, DEFAULT_VERSION)});
- IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, null));
+ IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, (Filter) null));
IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU};
IInstallableUnit[] toInstallArray = new IInstallableUnit[] {toInstallIU};
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java
index ae7dd3b16..40088c1a0 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java
@@ -31,15 +31,15 @@ public class OracleTest extends AbstractProvisioningTest {
IProfile profile;
protected void setUp() throws Exception {
- IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)"), null);
+ IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)"));
a1 = createIU("A", requires, true);
- requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 3.0.0)"), null);
+ requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 3.0.0)"));
c1 = createIU("C", requires, true);
d1 = createIU("D", DEFAULT_VERSION, true);
- requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[2.0.0, 3.0.0)"), null);
+ requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[2.0.0, 3.0.0)"));
b1 = createIU("B", requires, true);
d2 = createIU("D", Version.createOSGi(2, 0, 0), true);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java
index a9920cd3a..11aeff973 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java
@@ -33,12 +33,12 @@ public class OracleTest2 extends AbstractProvisioningTest {
IProfile profile;
protected void setUp() throws Exception {
- IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)"), null);
+ IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)"));
a1 = createIU("A", requires, true);
c1 = createIU("C", DEFAULT_VERSION, true);
- requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[2.0.0, 3.0.0)"), null);
+ requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[2.0.0, 3.0.0)"));
InstallableUnitDescription desc = new MetadataFactory.InstallableUnitDescription();
desc.setRequiredCapabilities(requires);
desc.setId("A");
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java
index 5a4134e78..9efa4f8e3 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java
@@ -49,9 +49,9 @@ public class ReplacePlanTest extends AbstractProvisioningTest {
frag1_4 = createIUFragment(f1, "frag1", f1_4.getVersion());
//IUs that require base IU
- IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.3.0)"), null);
+ IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.3.0)"));
fa = createIU("fa", requires, false);
- requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.4.0)"), null);
+ requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.4.0)"));
fap = createIU("fa", Version.createOSGi(1, 1, 0), requires, NO_PROPERTIES, false);
createTestMetdataRepository(new IInstallableUnit[] {f1, fa, frag1});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java
index ff50717bb..cb08ac8f5 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java
@@ -36,11 +36,11 @@ public class UpdateTest extends AbstractProvisioningTest {
f1_1 = createIU(f1Id, Version.createOSGi(1, 1, 0), true);
f1_4 = createIU(f1Id, Version.createOSGi(1, 4, 0), true);
- IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.3.0)"), null);
+ IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.3.0)"));
String faId = getName() + ".fa";
fa = createIU(faId, requires, false);
- requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.4.0)"), null);
+ requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.4.0)"));
fap = createIU(faId, Version.createOSGi(1, 1, 0), requires, NO_PROPERTIES, false);
createTestMetdataRepository(new IInstallableUnit[] {f1, fa});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java
index 678d05193..fb301060c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java
@@ -10,9 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.*;
import java.util.*;
import javax.xml.parsers.ParserConfigurationException;
@@ -20,11 +17,13 @@ import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
import org.eclipse.equinox.internal.p2.metadata.*;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataParser;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataWriter;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
import org.xml.sax.*;
public class IUPatchPersistenceTest extends AbstractProvisioningTest {
@@ -35,7 +34,7 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
private static String id = "org.eclipse.osgi.services";
private static Version version = Version.create("3.1.200.v20070605");
- private static String filter = "(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"; // not really
+ private static Filter filter = ExpressionUtil.parseLDAP("(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"); // not really
private static String[][] properties = new String[][] {new String[] {"equinox.p2.name", "OSGi Release 4.0.1 Services"}, //
new String[] {"equinox.p2.description", "OSGi Service Platform Release 4.0.1 Service Interfaces and Classes"}, //
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
index 80ffac0d4..3f7989298 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
@@ -10,9 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.*;
import java.net.URI;
import java.util.*;
@@ -21,12 +18,14 @@ import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
import org.eclipse.equinox.internal.p2.metadata.*;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataParser;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataWriter;
-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.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
import org.xml.sax.*;
public class IUPersistenceTest extends AbstractProvisioningTest {
@@ -136,7 +135,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
}
}
- private static String filter = "(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"; // not really
+ private static Filter filter = ExpressionUtil.parseLDAP("(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"); // not really
private static String id = "org.eclipse.osgi.services";
private static String[][] instructions = new String[][] {new String[] {"manifest", "Manifest-Version: 1.0\\Bundle-Vendor: Eclipse.org\\Bundle-ContactAddress: www.eclipse.org\\...a whole bunch of other manifest content..."}, new String[] {"zipped", "true"}, //
@@ -411,7 +410,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
private void validateIU(IInstallableUnit iu) {
assertTrue("Installable unit id is not correct", id.equals(iu.getId()));
assertTrue("Installable unit version is not correct", version.equals(iu.getVersion()));
- assertTrue("Installable unit filter is not correct", filter.equals(iu.getFilter() == null ? null : ((LDAPQuery) iu.getFilter()).getFilter()));
+ assertTrue("Installable unit filter is not correct", filter.equals(iu.getFilter() == null ? null : iu.getFilter()));
assertEquals("Installable unit properties are not correct", propertyMap, iu.getProperties());
assertTrue("Installable unit provided capabilities are not correct", equal(addSelfCapability(iu, provides), extractProvides(iu)));
assertTrue("Installable unit required capabilities are not correct", equal(requires, extractRequires(iu)));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/AllTests.java
new file mode 100644
index 000000000..39fed0b38
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/AllTests.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 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.metadata.expression;
+
+import junit.framework.*;
+
+/**
+ * Performs all automated director tests.
+ */
+public class AllTests extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ suite.addTestSuite(ExpressionTest.class);
+ suite.addTestSuite(FilterTest.class);
+ return suite;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/ExpressionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/ExpressionTest.java
new file mode 100644
index 000000000..9c7407c63
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/ExpressionTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Cloudsmith Inc. 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:
+ * Cloudsmith Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.metadata.expression;
+
+import org.eclipse.equinox.p2.metadata.expression.*;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+
+public class ExpressionTest extends AbstractProvisioningTest {
+ private static final IExpressionFactory factory = ExpressionUtil.getFactory();
+
+ protected void testExpression(String exprStr, Object expectedOutcome) throws Exception {
+ IExpression expr = ExpressionUtil.parse(exprStr);
+ assertEquals(expr.evaluate(factory.createContext()), expectedOutcome);
+ }
+
+ protected void testMatch(String expr, boolean expectedOutcome) throws Exception {
+ testExpression(expr, Boolean.valueOf(expectedOutcome));
+ }
+
+ public void testCompare() throws Exception {
+ testMatch("'foo' == 'foo'", true);
+ testMatch("'foo' == 'fooo'", false);
+ testMatch("'foo' != 'foo'", false);
+ testMatch("'foo' != 'fooo'", true);
+ testMatch("2 < 1", false);
+ testMatch("2 <= 1", false);
+ testMatch("2 < 2", false);
+ testMatch("2 <= 2", true);
+ testMatch("2 < 3", true);
+ testMatch("2 <= 3", true);
+ testMatch("1 > 2", false);
+ testMatch("1 >= 2", false);
+ testMatch("2 > 2", false);
+ testMatch("2 >= 2", true);
+ testMatch("3 > 2", true);
+ testMatch("3 >= 2", true);
+ }
+
+ public void testAutoCoerce() throws Exception {
+ testMatch("'12' == 12", true);
+ testMatch("'012' == 12", true);
+ testMatch("'2' > '10'", true);
+ testMatch("'2' > 10", false);
+ testMatch("true == 'true'", true);
+ testMatch("true == 'True'", true);
+ testMatch("false == 'false'", true);
+ testMatch("false == 'False'", true);
+ }
+
+ public void testLeftToRigthAssociativity() throws Exception {
+ testMatch("2 < 10 == true", true);
+ try {
+ testMatch("true == 2 < 10", false);
+ fail("Auto coercion from boolean to integer succeded");
+ } catch (IllegalArgumentException e) {
+ // OK
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java
new file mode 100644
index 000000000..cf3cba552
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java
@@ -0,0 +1,267 @@
+package org.eclipse.equinox.p2.tests.metadata.expression;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.*;
+import junit.framework.*;
+import org.eclipse.equinox.p2.metadata.expression.*;
+import org.osgi.framework.*;
+
+public class FilterTest extends TestCase {
+ private static class DictionaryServiceReference implements ServiceReference {
+ private final Map<String, ? extends Object> dictionary;
+
+ private final String[] keys;
+
+ DictionaryServiceReference(Map<String, ? extends Object> dictionary) {
+ if (dictionary == null) {
+ this.dictionary = null;
+ this.keys = new String[] {};
+ return;
+ }
+ this.dictionary = dictionary;
+ List<String> keyList = new ArrayList<String>(dictionary.size());
+ for (Iterator<String> e = dictionary.keySet().iterator(); e.hasNext();) {
+ String key = e.next();
+ for (Iterator i = keyList.iterator(); i.hasNext();) {
+ if (key.equalsIgnoreCase((String) i.next())) {
+ throw new IllegalArgumentException();
+ }
+ }
+ keyList.add(key);
+ }
+ this.keys = keyList.toArray(new String[keyList.size()]);
+ }
+
+ public int compareTo(Object reference) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Bundle getBundle() {
+ return null;
+ }
+
+ public Object getProperty(String k) {
+ for (int i = 0, length = keys.length; i < length; i++) {
+ String key = keys[i];
+ if (key.equalsIgnoreCase(k)) {
+ return dictionary.get(key);
+ }
+ }
+ return null;
+ }
+
+ public String[] getPropertyKeys() {
+ return keys.clone();
+ }
+
+ public Bundle[] getUsingBundles() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isAssignableTo(Bundle bundle, String className) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private static class SampleComparable implements Comparable {
+ private int value = -1;
+
+ public SampleComparable(String value) {
+ this.value = Integer.parseInt(value);
+ }
+
+ public boolean equals(Object o) {
+ return o instanceof SampleComparable && value == ((SampleComparable) o).value;
+ }
+
+ public int compareTo(Object o) {
+ return value - ((SampleComparable) o).value;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(value);
+ }
+ }
+
+ static final int ISTRUE = 1;
+
+ static final int ISFALSE = 2;
+
+ static final int ISILLEGAL = 3;
+
+ public static Test suite() {
+ return new TestSuite(FilterTest.class);
+ }
+
+ public void testComparable() throws Exception {
+ IFilterExpression f1 = ExpressionUtil.parseLDAP("(comparable=42)"); //$NON-NLS-1$
+ Object comp;
+ Map<String, Object> hash = new HashMap<String, Object>();
+
+ comp = new SampleComparable("42"); //$NON-NLS-1$
+ hash.put("comparable", comp); //$NON-NLS-1$
+ assertTrue("does not match filter", f1.match(hash)); //$NON-NLS-1$
+ assertTrue("does not match filter", f1.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$
+
+ comp = new Long(42);
+ hash.put("comparable", comp); //$NON-NLS-1$
+ assertTrue("does not match filter", f1.match(hash)); //$NON-NLS-1$
+ assertTrue("does not match filter", f1.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$
+
+ IFilterExpression f2 = ExpressionUtil.parseLDAP("(comparable=42)"); //$NON-NLS-1$
+ hash = new Hashtable<String, Object>();
+
+ comp = new SampleComparable("42"); //$NON-NLS-1$
+ hash.put("comparable", comp); //$NON-NLS-1$
+ assertTrue("does not match filter", f2.match(hash)); //$NON-NLS-1$
+ assertTrue("does not match filter", f2.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$
+
+ comp = new Long(42);
+ hash.put("comparable", comp); //$NON-NLS-1$
+ assertTrue("does not match filter", f2.match(hash)); //$NON-NLS-1$
+ assertTrue("does not match filter", f2.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$
+
+ assertEquals("not equal", f1, f2); //$NON-NLS-1$
+ }
+
+ public void testFilter() {
+ Properties props = new Properties();
+ props.put("room", "bedroom"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.put("channel", new Integer(34)); //$NON-NLS-1$
+ props.put("status", "(on\\)*"); //$NON-NLS-1$//$NON-NLS-2$
+ props.put("max record time", new Long(150)); //$NON-NLS-1$
+ props.put("canrecord", "true(x)"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.put("shortvalue", new Short((short) 1000)); //$NON-NLS-1$
+ props.put("bytevalue", new Byte((byte) 10)); //$NON-NLS-1$
+ props.put("floatvalue", new Float(1.01)); //$NON-NLS-1$
+ props.put("doublevalue", new Double(2.01)); //$NON-NLS-1$
+ props.put("charvalue", new Character('A')); //$NON-NLS-1$
+ props.put("booleanvalue", new Boolean(false)); //$NON-NLS-1$
+ props.put("weirdvalue", new Hashtable()); //$NON-NLS-1$
+ try {
+ props.put("bigintvalue", new BigInteger("4123456")); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (NoClassDefFoundError e) {
+ // ignore
+ }
+ try {
+ props.put("bigdecvalue", new BigDecimal("4.123456")); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (NoClassDefFoundError e) {
+ // ignore
+ }
+
+ testFilter("(room=*)", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(rooom=*)", props, ISFALSE); //$NON-NLS-1$
+ testFilter("(room=bedroom)", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(room~= B E D R O O M )", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(room=abc)", props, ISFALSE); //$NON-NLS-1$
+ testFilter(" ( room >=aaaa)", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(room <=aaaa)", props, ISFALSE); //$NON-NLS-1$
+ testFilter(" ( room =b*) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter(" ( room =*m) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(room=bed*room)", props, ISTRUE); //$NON-NLS-1$
+ testFilter(" ( room =b*oo*m) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter(" ( room =*b*oo*m*) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter(" ( room =b*b* *m*) ", props, ISFALSE); //$NON-NLS-1$
+ testFilter(" (& (room =bedroom) (channel = 34))", props, ISTRUE); //$NON-NLS-1$
+ testFilter(" (& (room =b*) (room =*x) (channel=34))", props, ISFALSE); //$NON-NLS-1$
+ testFilter("(| (room =bed*)(channel=222)) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(| (room =boom*)(channel=34)) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter(" (! (room =ab*b*oo*m*) ) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter(" (status =\\(o*\\\\\\)\\*) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter(" (status =\\28o*\\5c\\29\\2a) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter(" (status =\\28o*\\5C\\29\\2A) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter(" (canRecord =true\\(x\\)) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(max Record Time <=150) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(shortValue >= 100) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter(" ( & ( byteValue <= 100 ) ( byteValue >= 10 ) ) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(bigIntValue = 4123456) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(bigDecValue = 4.123456) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(floatValue >= 1.0) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(doubleValue <= 2.011) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(charValue ~= a) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(booleanValue = false) ", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(& (| (room =d*m) (room =bed*) (room=abc)) (! (channel=999)))", props, ISTRUE); //$NON-NLS-1$
+ testFilter("(room=bedroom)", null, ISFALSE); //$NON-NLS-1$
+
+ testFilter("()", props, ISILLEGAL); //$NON-NLS-1$
+ testFilter("(=foo)", props, ISILLEGAL); //$NON-NLS-1$
+ testFilter("(", props, ISILLEGAL); //$NON-NLS-1$
+ testFilter("(abc = ))", props, ISILLEGAL); //$NON-NLS-1$
+ testFilter("(& (abc = xyz) (& (345))", props, ISILLEGAL); //$NON-NLS-1$
+ testFilter(" (room = b**oo!*m*) ) ", props, ISILLEGAL); //$NON-NLS-1$
+ testFilter(" (room = b**oo)*m*) ) ", props, ISILLEGAL); //$NON-NLS-1$
+ testFilter(" (room = *=b**oo*m*) ) ", props, ISILLEGAL); //$NON-NLS-1$
+ testFilter(" (room = =b**oo*m*) ) ", props, ISILLEGAL); //$NON-NLS-1$
+
+ try {
+ Filter f1 = ExpressionUtil.parseLDAP("( a = bedroom )"); //$NON-NLS-1$
+ Filter f2 = ExpressionUtil.parseLDAP(" (a= bedroom ) "); //$NON-NLS-1$
+ assertEquals("not equal", "(a= bedroom )", f1.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("not equal", "(a= bedroom )", f2.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("not equal", f1, f2); //$NON-NLS-1$
+ assertEquals("not equal", f2, f1); //$NON-NLS-1$
+ assertEquals("not equal", f1.hashCode(), f2.hashCode()); //$NON-NLS-1$
+
+ f1 = ExpressionUtil.parseLDAP("(status =\\28o*\\5c\\29\\2a)");
+ assertEquals("not equal", "(status=\\28o*\\5c\\29\\2a)", f1.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+
+ f1 = ExpressionUtil.parseLDAP("(|(a=1)(&(a=1)(b=1)))"); //$NON-NLS-1$
+ f2 = ExpressionUtil.parseLDAP("(a=1)"); //$NON-NLS-1$
+ System.out.println(f2.toString());
+ System.out.println(f1.toString());
+
+ f1 = ExpressionUtil.parseLDAP("(|(&(os=macos)(ws=cocoa)(arch=x86))(&(ws=cocoa)(os=macos)(arch=ppc)))"); //$NON-NLS-1$
+ f2 = ExpressionUtil.parseLDAP("(&(os=macos)(ws=cocoa)(|(arch=x86)(arch=ppc)))"); //$NON-NLS-1$
+ System.out.println(f2.toString());
+ System.out.println(f1.toString());
+ assertEquals("not equal", f1, f2); //$NON-NLS-1$
+
+ f1 = ExpressionUtil.parseLDAP("(&(|(x=a)(y=b)(z=a))(|(x=a)(y=b)(z=b)))"); //$NON-NLS-1$
+ f2 = ExpressionUtil.parseLDAP("(|(x=a)(y=b)(&(z=a)(z=b)))"); //$NON-NLS-1$
+ System.out.println(f2.toString());
+ System.out.println(f1.toString());
+ assertEquals("not equal", f1, f2); //$NON-NLS-1$
+
+ f1 = ExpressionUtil.parseLDAP("(&(a=1)(|(a=1)(b=1)))"); //$NON-NLS-1$
+ f2 = ExpressionUtil.parseLDAP("(a=1)"); //$NON-NLS-1$
+ System.out.println(f2.toString());
+ System.out.println(f1.toString());
+
+ f1 = ExpressionUtil.parseLDAP("(|(a=1)(&(a=1)(b=1)))"); //$NON-NLS-1$
+ f2 = ExpressionUtil.parseLDAP("(a=1)"); //$NON-NLS-1$
+ System.out.println(f2.toString());
+ System.out.println(f1.toString());
+ assertEquals("not equal", f1, f2); //$NON-NLS-1$
+ } catch (IllegalArgumentException e) {
+ fail("unexpected invalid syntax: " + e); //$NON-NLS-1$
+ }
+ testFilter("(weirdValue = 100) ", props, ISFALSE); //$NON-NLS-1$
+
+ }
+
+ private void testFilter(String query, Dictionary<?, ?> props, int expect) {
+ final ServiceReference ref = new DictionaryServiceReference((Map) props);
+ Filter f1;
+ try {
+ f1 = ExpressionUtil.parseLDAP(query);
+
+ if (expect == ISILLEGAL) {
+ fail("expected exception"); //$NON-NLS-1$
+ }
+ } catch (ExpressionParseException e) {
+ System.out.println(e.toString());
+ if (expect != ISILLEGAL) {
+ fail("exception: " + e.toString()); //$NON-NLS-1$
+ }
+ return;
+ }
+
+ boolean val = f1.match(props);
+ assertEquals("wrong result", expect == ISTRUE, val); //$NON-NLS-1$
+
+ val = f1.match(ref);
+ assertEquals("wrong result", expect == ISTRUE, val); //$NON-NLS-1$
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
index dbff38cee..6d64263a4 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
@@ -9,9 +9,6 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata.repository;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
@@ -23,16 +20,20 @@ import java.util.*;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.metadata.*;
-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.MetadataFactory.InstallableUnitPatchDescription;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
+import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.query.MatchQuery;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.osgi.framework.Filter;
/**
* Test API of the metadata interfaces with an SPI implementation.
@@ -55,7 +56,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
}
class SPIRequiredCapability extends MatchQuery<IInstallableUnit> implements IRequiredCapability {
- LDAPQuery filter;
+ Filter filter;
String name;
String namespace;
VersionRange versionRange;
@@ -79,7 +80,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
this.versionRange = versionRange;
}
- public IQuery getFilter() {
+ public Filter getFilter() {
return this.filter;
}
@@ -100,9 +101,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
}
public void setFilter(String filter) {
- if (filter != null) {
- this.filter = new LDAPQuery(filter);
- }
+ this.filter = filter == null ? null : ExpressionUtil.parseLDAP(filter);
}
public boolean equals(Object obj) {
@@ -151,15 +150,20 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
return max;
}
- public IQuery getMatches() {
- return this;
- }
-
public boolean isMatch(IInstallableUnit candidate) {
if (!candidate.satisfies(this))
return false;
return true;
}
+
+ public boolean isVersionStrict() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public IMatchExpression<IInstallableUnit> getMatches() {
+ return ExpressionUtil.getFactory().matchExpression(ExpressionUtil.parse("providedCapabilities.exists(x | x.name == $0 && x.namespace == $1 && x.version ~= $2"), name, namespace, versionRange);
+ }
}
class SPIProvidedCapability implements IProvidedCapability {
@@ -213,7 +217,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
List providedCapabilities = new ArrayList();
List touchpointData = new ArrayList();
ICopyright copyright = null;
- LDAPQuery filter = null;
+ Filter filter = null;
String id = null;
ILicense[] license = null;
Map properties = new HashMap();
@@ -241,7 +245,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
return this.copyright;
}
- public IQuery getFilter() {
+ public Filter getFilter() {
return this.filter;
}
@@ -304,11 +308,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
}
public boolean satisfies(IRequirement candidate) {
- List<IProvidedCapability> provides = getProvidedCapabilities();
- for (int i = 0; i < provides.size(); i++)
- if (provides.get(i).satisfies(candidate))
- return true;
- return false;
+ return candidate.isMatch(this);
}
public IInstallableUnit unresolved() {
@@ -753,13 +753,13 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
iuDescription.setId("foo");
iuDescription.setVersion(Version.createOSGi(1, 1, 1));
- SPIRequiredCapability spiRequiredCapability1 = new SPIRequiredCapability("com.example", "bar", new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), true), "bar", true, true, true);
- IRequiredCapability requiredCapability1 = MetadataFactory.createRequiredCapability("com.example2", "foo", new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), true), "bar", false, false, false);
+ SPIRequiredCapability spiRequiredCapability1 = new SPIRequiredCapability("com.example", "bar", new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), true), "(bar=foo)", true, true, true);
+ IRequiredCapability requiredCapability1 = MetadataFactory.createRequiredCapability("com.example2", "foo", new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), true), "(bar=foo)", false, false, false);
SPIRequirementChange spiRequirementChange = new SPIRequirementChange(spiRequiredCapability1, requiredCapability1);
iuPatchDescription.setRequirementChanges(new IRequirementChange[] {spiRequirementChange});
- IRequiredCapability spiRequiredCapability = new SPIRequiredCapability("com.example", "bar", new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), true), "bar", true, true, true);
+ IRequiredCapability spiRequiredCapability = new SPIRequiredCapability("com.example", "bar", new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), true), "(bar=foo)", true, true, true);
IProvidedCapability spiProvidedCapability = new SPIProvidedCapability("bar", "foo", Version.createOSGi(1, 1, 1));
ITouchpointData spiTouchpointData = new SPITouchpointData();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java
index 131a80ae7..848b6bc8d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java
@@ -34,7 +34,7 @@ public class AdditionalConstraints extends AbstractProvisioningTest {
protected void setUp() throws Exception {
super.setUp();
- a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 4.0.0)"), null));
+ a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 4.0.0)")));
b1 = createIU("B", Version.create("1.0.0"), true);
@@ -42,7 +42,7 @@ public class AdditionalConstraints extends AbstractProvisioningTest {
b3 = createIU("B", Version.create("3.0.0"), true);
- x1 = createIU("X", Version.createOSGi(2, 0, 0), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 2.0.0]"), null));
+ x1 = createIU("X", Version.createOSGi(2, 0, 0), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 2.0.0]")));
createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, b3, x1});
@@ -55,7 +55,7 @@ public class AdditionalConstraints extends AbstractProvisioningTest {
ProfileChangeRequest req = new ProfileChangeRequest(profile);
req.addInstallableUnits(new IInstallableUnit[] {a1});
ProvisioningContext ctx = new ProvisioningContext();
- ctx.setAdditionalRequirements(Arrays.<IRequirement> asList(createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 2.0.0]"), null)[0]));
+ ctx.setAdditionalRequirements(Arrays.<IRequirement> asList(createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 2.0.0]"))[0]));
IProvisioningPlan plan = planner.getProvisioningPlan(req, ctx, null);
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
assertInstallOperand(plan, a1);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java
index 7c22a4364..bc8a9681c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java
@@ -8,9 +8,6 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.planner;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.lang.reflect.Field;
import java.net.URI;
import java.util.Properties;
@@ -19,10 +16,9 @@ import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.IPlanner;
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;
import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
@@ -62,7 +58,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
}
public void testGetAgentPlanActionNeededButUnavailable() {
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProfile profile = getProfile("installation");
@@ -80,7 +76,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
createTestMetdataRepository(new IInstallableUnit[] {a, act1});
@@ -99,8 +95,8 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
//This tests the case where the action is in conflict with the thing being installed
//The action needs another version of A which is singleton
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
- IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]"), null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]")), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IInstallableUnit a2 = createIU("A", Version.createOSGi(2, 0, 0));
@@ -120,7 +116,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IInstallableUnit b = createEclipseIU("B");
@@ -152,10 +148,10 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
public void testWithOveralInDependency() {
IInstallableUnit common = createEclipseIU("Common");
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
- IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
+ IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
- IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), metaReq);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
+ IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), metaReq);
createTestMetdataRepository(new IInstallableUnit[] {a, act1, common});
@@ -177,13 +173,13 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION);
IInstallableUnit act2 = createIU("Action2", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2);
createTestMetdataRepository(new IInstallableUnit[] {a, b, act1, act2,});
@@ -215,13 +211,13 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProvidedCapability act1bCap = MetadataFactory.createProvidedCapability("p2.action", "action1b", DEFAULT_VERSION);
IInstallableUnit act1b = createIU("Action1b", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1bCap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a111 = createIUWithMetaRequirement("A", Version.createOSGi(1, 1, 1), true, NO_REQUIRES, metaReqb);
IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION);
@@ -230,10 +226,10 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", Version.createOSGi(2, 0, 0));
IInstallableUnit act1v2 = createIU("Action1", Version.create("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"), null);
+ IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"));
IInstallableUnit d = createIUWithMetaRequirement("D", DEFAULT_VERSION, true, NO_REQUIRES, metaReqd);
- IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2);
IInstallableUnit c = createEclipseIU("C");
@@ -317,13 +313,13 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", Version.createOSGi(2, 0, 0));
IInstallableUnit act1v2 = createIU("Action1", Version.create("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"), null);
+ IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"));
IInstallableUnit d = createIUWithMetaRequirement("D", DEFAULT_VERSION, true, NO_REQUIRES, metaReqd);
createTestMetdataRepository(new IInstallableUnit[] {a, act1, d, act1v2});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java
index bea0d8abb..0b100dc04 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java
@@ -8,9 +8,6 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.planner;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.lang.reflect.Field;
import java.net.URI;
import java.util.Properties;
@@ -19,10 +16,9 @@ import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.IPlanner;
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;
import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
@@ -62,7 +58,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
}
public void testGetAgentPlanActionNeededButUnavailable() {
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProfile profile = getProfile("installation");
@@ -80,7 +76,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
createTestMetdataRepository(new IInstallableUnit[] {a, act1});
@@ -99,8 +95,8 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
//This tests the case where the action is in conflict with the thing being installed
//The action needs another version of A which is singleton
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
- IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]"), null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]")), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IInstallableUnit a2 = createIU("A", Version.createOSGi(2, 0, 0));
@@ -120,7 +116,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IInstallableUnit b = createEclipseIU("B");
@@ -152,10 +148,10 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
public void testWithOveralInDependency() {
IInstallableUnit common = createEclipseIU("Common");
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
- IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
+ IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
- IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), metaReq);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
+ IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), metaReq);
createTestMetdataRepository(new IInstallableUnit[] {a, act1, common});
@@ -177,13 +173,13 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION);
IInstallableUnit act2 = createIU("Action2", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2);
createTestMetdataRepository(new IInstallableUnit[] {a, b, act1, act2,});
@@ -215,13 +211,13 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProvidedCapability act1bCap = MetadataFactory.createProvidedCapability("p2.action", "action1b", DEFAULT_VERSION);
IInstallableUnit act1b = createIU("Action1b", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1bCap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a111 = createIUWithMetaRequirement("A", Version.createOSGi(1, 1, 1), true, NO_REQUIRES, metaReqb);
IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION);
@@ -230,10 +226,10 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", Version.createOSGi(2, 0, 0));
IInstallableUnit act1v2 = createIU("Action1", Version.create("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"), null);
+ IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"));
IInstallableUnit d = createIUWithMetaRequirement("D", DEFAULT_VERSION, true, NO_REQUIRES, metaReqd);
- IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2);
IInstallableUnit c = createEclipseIU("C");
@@ -317,13 +313,13 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", Version.createOSGi(2, 0, 0));
IInstallableUnit act1v2 = createIU("Action1", Version.create("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"), null);
+ IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"));
IInstallableUnit d = createIUWithMetaRequirement("D", DEFAULT_VERSION, true, NO_REQUIRES, metaReqd);
createTestMetdataRepository(new IInstallableUnit[] {a, act1, d, act1v2});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java
index 43db79f70..61af3ee7a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java
@@ -8,22 +8,19 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.planner;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.net.URI;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
private IProfile initialProfile = null;
+
public void setUp() throws Exception {
super.setUp();
@@ -48,7 +45,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
}
public void testGetAgentPlanActionNeededButUnavailable() {
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProfile profile = getProfile(IProfileRegistry.SELF);
@@ -66,7 +63,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
createTestMetdataRepository(new IInstallableUnit[] {a, act1});
@@ -85,9 +82,9 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
//This tests the case where the action is in conflict with the thing being installed
//The action needs another version of A which is singleton
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
- IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]"), null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
+ IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]")), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IInstallableUnit a2 = createIU("A", Version.createOSGi(2, 0, 0));
createTestMetdataRepository(new IInstallableUnit[] {a, a2, act1});
@@ -106,7 +103,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IInstallableUnit b = createEclipseIU("B");
@@ -137,10 +134,10 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
public void testWithOveralInDependency() {
IInstallableUnit common = createEclipseIU("Common");
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
- IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
+ IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
- IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), metaReq);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
+ IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), metaReq);
createTestMetdataRepository(new IInstallableUnit[] {a, act1, common});
@@ -162,13 +159,13 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION);
IInstallableUnit act2 = createIU("Action2", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2);
createTestMetdataRepository(new IInstallableUnit[] {a, b, act1, act2,});
@@ -201,19 +198,19 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProvidedCapability act1bCap = MetadataFactory.createProvidedCapability("p2.action", "action1b", DEFAULT_VERSION);
IInstallableUnit act1b = createIU("Action1b", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1bCap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a111 = createIUWithMetaRequirement("A", Version.createOSGi(1, 1, 1), true, NO_REQUIRES, metaReqb);
IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION);
IInstallableUnit act2 = createIU("Action2", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2);
IInstallableUnit c = createEclipseIU("C");
@@ -277,13 +274,13 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", Version.createOSGi(2, 0, 0));
IInstallableUnit act1v2 = createIU("Action1", Version.create("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"), null);
+ IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"));
IInstallableUnit d = createIUWithMetaRequirement("D", DEFAULT_VERSION, true, NO_REQUIRES, metaReqd);
createTestMetdataRepository(new IInstallableUnit[] {a, act1, d, act1v2});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug207319.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug207319.java
index 1c83060dc..6e24f9294 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug207319.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug207319.java
@@ -8,16 +8,12 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.planner;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
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;
import org.eclipse.equinox.p2.engine.IProfile;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
@@ -31,7 +27,7 @@ public class Bug207319 extends AbstractProvisioningTest {
super.setUp();
a = createIU("A", Version.create("1.0.0"));
b = createIU("B", Version.create("1.0.0"), new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", Version.create("1.0.0"))});
- c = createIU("C", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null));
+ c = createIU("C", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]")));
createTestMetdataRepository(new IInstallableUnit[] {a, b, c});
profile = createProfile(Bug207319.class.getName());
director = createDirector();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DependencyOnSelf.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DependencyOnSelf.java
index 1f20a8cd2..7edb4168f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DependencyOnSelf.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DependencyOnSelf.java
@@ -28,7 +28,7 @@ public class DependencyOnSelf extends AbstractProvisioningTest {
protected void setUp() throws Exception {
super.setUp();
- a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null));
+ a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]")));
createTestMetdataRepository(new IInstallableUnit[] {a1});
profile = createProfile(DependencyOnSelf.class.getName());
planner = createPlanner();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationDeepConflict.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationDeepConflict.java
index 8e59846dc..72090cd34 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationDeepConflict.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationDeepConflict.java
@@ -27,9 +27,9 @@ public class ExplanationDeepConflict extends AbstractProvisioningTest {
@Override
protected void setUp() throws Exception {
super.setUp();
- sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"), null));
- IInstallableUnit sdkPart = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerSDKPart", new VersionRange("[1.0.0, 1.0.0]"), null));
- IInstallableUnit innerSdkPart = createIU("InnerSDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerInnerSDKPart", new VersionRange("[1.0.0, 1.0.0]"), null));
+ sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]")));
+ IInstallableUnit sdkPart = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerSDKPart", new VersionRange("[1.0.0, 1.0.0]")));
+ IInstallableUnit innerSdkPart = createIU("InnerSDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerInnerSDKPart", new VersionRange("[1.0.0, 1.0.0]")));
IInstallableUnit innerInnerSDKPart = createIU("InnerInnerSDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true);
createTestMetdataRepository(new IInstallableUnit[] {sdk, sdkPart, innerSdkPart, innerInnerSDKPart});
@@ -46,8 +46,8 @@ public class ExplanationDeepConflict extends AbstractProvisioningTest {
public void testDeepSingletonConflict() {
//CDT will have a singleton conflict with SDK
- IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "CDTPart", new VersionRange("[1.0.0, 1.0.0]"), null));
- IInstallableUnit cdtPart = createIU("CDTPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerInnerSDKPart", new VersionRange("[2.0.0, 2.0.0]"), null));
+ IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "CDTPart", new VersionRange("[1.0.0, 1.0.0]")));
+ IInstallableUnit cdtPart = createIU("CDTPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerInnerSDKPart", new VersionRange("[2.0.0, 2.0.0]")));
IInstallableUnit innerInnerSDKPart2 = createIU("InnerInnerSDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("2.0.0")), true);
createTestMetdataRepository(new IInstallableUnit[] {cdt, cdtPart, innerInnerSDKPart2});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForOptionalDependencies.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForOptionalDependencies.java
index eff798cdf..a7aa0e159 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForOptionalDependencies.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForOptionalDependencies.java
@@ -29,7 +29,7 @@ public class ExplanationForOptionalDependencies extends AbstractProvisioningTest
@Override
protected void setUp() throws Exception {
super.setUp();
- sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"), null));
+ sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]")));
IInstallableUnit sdkPart = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true);
IInstallableUnit sdkPart2 = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("2.0.0")), true);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForPartialInstallation.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForPartialInstallation.java
index 20b74f21b..0addc22a9 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForPartialInstallation.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForPartialInstallation.java
@@ -27,7 +27,7 @@ public class ExplanationForPartialInstallation extends AbstractProvisioningTest
@Override
protected void setUp() throws Exception {
super.setUp();
- sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"), null));
+ sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]")));
IInstallableUnit sdkPart = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true);
IInstallableUnit sdkPart2 = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("2.0.0")), true);
@@ -46,7 +46,7 @@ public class ExplanationForPartialInstallation extends AbstractProvisioningTest
public void testPartialProblemSingleton() {
//CDT will have a singleton conflict with SDK
//EMF will be good
- IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]"), null));
+ IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]")));
IInstallableUnit emf = createIU("EMF", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true);
@@ -74,7 +74,7 @@ public class ExplanationForPartialInstallation extends AbstractProvisioningTest
public void testPartialProblemRequirement() {
//CDT will be missing a requirement
//EMF will be good
- IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "MissingPart", new VersionRange("[2.0.0, 2.0.0]"), null));
+ IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "MissingPart", new VersionRange("[2.0.0, 2.0.0]")));
IInstallableUnit emf = createIU("EMF", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationLargeConflict.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationLargeConflict.java
index 5af040677..4d4fa7477 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationLargeConflict.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationLargeConflict.java
@@ -10,9 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.planner;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.File;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
@@ -21,7 +18,7 @@ import org.eclipse.equinox.internal.provisional.p2.director.IPlanner;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
@@ -75,7 +72,7 @@ public class ExplanationLargeConflict extends AbstractProvisioningTest {
public void testMissingRequirement() {
long sTime = System.currentTimeMillis();
//Test the case of a missing requirement in the IU being installed
- IRequiredCapability[] cap = createRequiredCapabilities("missing", "missing", new VersionRange("[0.0.0, 1.0.0)"), null);
+ IRequiredCapability[] cap = createRequiredCapabilities("missing", "missing", new VersionRange("[0.0.0, 1.0.0)"));
IInstallableUnit otherIU2 = createIU("foo", Version.create("0.9.0"), null, cap, BUNDLE_CAPABILITY, NO_PROPERTIES, TOUCHPOINT_OSGI, NO_TP_DATA, true);
ProfileChangeRequest pcr3 = new ProfileChangeRequest(SDKprofile);
pcr3.addInstallableUnits(new IInstallableUnit[] {otherIU2});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationSeveralConflictingRoots.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationSeveralConflictingRoots.java
index 785aca2ba..39f734da3 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationSeveralConflictingRoots.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationSeveralConflictingRoots.java
@@ -29,7 +29,7 @@ public class ExplanationSeveralConflictingRoots extends AbstractProvisioningTest
@Override
protected void setUp() throws Exception {
super.setUp();
- sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"), null));
+ sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]")));
IInstallableUnit sdkPart = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true);
IInstallableUnit sdkPart2 = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("2.0.0")), true);
@@ -48,9 +48,9 @@ public class ExplanationSeveralConflictingRoots extends AbstractProvisioningTest
public void testConflictingSingletonAndMissingDependency() {
//CDT will have a singleton conflict with SDK
//EMF will be missing a dependency
- IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]"), null));
+ IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]")));
- IInstallableUnit emf = createIU("EMF", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "EMFPart", new VersionRange("[1.0.0, 1.0.0]"), null));
+ IInstallableUnit emf = createIU("EMF", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "EMFPart", new VersionRange("[1.0.0, 1.0.0]")));
createTestMetdataRepository(new IInstallableUnit[] {cdt, emf});
ProfileChangeRequest pcr = new ProfileChangeRequest(profile);
@@ -70,7 +70,7 @@ public class ExplanationSeveralConflictingRoots extends AbstractProvisioningTest
public void testConflictingSingletonAndMissingDependency2() {
//CDT will have a singleton conflict EMF
//EMF will be missing a dependency and will be in conflict with CDT
- IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "ASingleton", new VersionRange("[2.0.0, 2.0.0]"), null));
+ IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "ASingleton", new VersionRange("[2.0.0, 2.0.0]")));
IInstallableUnit aSingleton1 = createIU("ASingleton", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true);
IInstallableUnit aSingleton2 = createIU("ASingleton", Version.fromOSGiVersion(new org.osgi.framework.Version("2.0.0")), true);
@@ -95,7 +95,7 @@ public class ExplanationSeveralConflictingRoots extends AbstractProvisioningTest
public void testConflictingSingletonAndMissingDependency3() {
//CDT will have a singleton conflict EMF and with the SDK
//EMF will be conflicting with CDT
- IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]"), null));
+ IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]")));
IInstallableUnit sdkPart3 = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("3.0.0")), true);
IRequiredCapability emfOnSingleton = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"), null, false, false);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUProperties.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUProperties.java
index c0eac0d90..091cc8fc2 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUProperties.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUProperties.java
@@ -33,11 +33,11 @@ public class IUProperties extends AbstractProvisioningTest {
protected void setUp() throws Exception {
super.setUp();
- a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"), null));
+ a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)")));
b1 = createIU("B1", Version.create("1.0.0"), true);
- b11 = createIU("B1", Version.create("1.1.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 3.0.0)"), null), NO_PROPERTIES, true);
+ b11 = createIU("B1", Version.create("1.1.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 3.0.0)")), NO_PROPERTIES, true);
c = createIU("C", Version.createOSGi(2, 0, 0), true);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUPropertyRemoval.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUPropertyRemoval.java
index 1c7cf1848..814ae8c98 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUPropertyRemoval.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUPropertyRemoval.java
@@ -30,7 +30,7 @@ public class IUPropertyRemoval extends AbstractProvisioningTest {
protected void setUp() throws Exception {
super.setUp();
- a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"), null));
+ a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)")));
b1 = createIU("B1", Version.create("1.0.0"), true);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter.java
index f5e3134ab..83e7701a4 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter.java
@@ -32,7 +32,7 @@ public class IUWithFilter extends AbstractProvisioningTest {
MetadataFactory.InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
iud.setId("A");
iud.setVersion(Version.create("1.0.0"));
- iud.setRequiredCapabilities(createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null));
+ iud.setRequiredCapabilities(createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]")));
iud.setFilter("(invalid=true)");
a1 = MetadataFactory.createInstallableUnit(iud);
createTestMetdataRepository(new IInstallableUnit[] {a1});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MinimalInstall.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MinimalInstall.java
index fc57767f0..72c232e0b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MinimalInstall.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MinimalInstall.java
@@ -31,11 +31,11 @@ public class MinimalInstall extends AbstractProvisioningTest {
protected void setUp() throws Exception {
super.setUp();
- a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"), null));
+ a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)")));
b1 = createIU("B1", Version.create("1.0.0"), true);
- b11 = createIU("B1", Version.create("1.1.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 3.0.0)"), null), NO_PROPERTIES, true);
+ b11 = createIU("B1", Version.create("1.1.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 3.0.0)")), NO_PROPERTIES, true);
c = createIU("C", Version.createOSGi(2, 0, 0), true);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleProvider.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleProvider.java
index 77cba805c..84665e854 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleProvider.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleProvider.java
@@ -33,7 +33,7 @@ public class MultipleProvider extends AbstractProvisioningTest {
protected void setUp() throws Exception {
super.setUp();
- a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"), null));
+ a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)")));
b1 = createIU("B1", Version.create("1.0.0"), true);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleSingleton.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleSingleton.java
index e38ce56bb..081cc6f78 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleSingleton.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleSingleton.java
@@ -10,18 +10,15 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.planner;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.util.Set;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.director.Explanation;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.ProvisioningPlan;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
@@ -45,7 +42,7 @@ public class MultipleSingleton extends AbstractProvisioningTest {
a4 = createIU("A", Version.create("4.0.0"), false);
- x = createIU("X", Version.createOSGi(2, 0, 0), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 4.1.0)"), null));
+ x = createIU("X", Version.createOSGi(2, 0, 0), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 4.1.0)")));
IRequiredCapability c1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null, false, false);
IRequiredCapability c2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]"), null, false, false);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoRequirements.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoRequirements.java
index c376668c0..7b6dc4d68 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoRequirements.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoRequirements.java
@@ -28,7 +28,7 @@ public class NoRequirements extends AbstractProvisioningTest {
protected void setUp() throws Exception {
super.setUp();
- a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null));
+ a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]")));
createTestMetdataRepository(new IInstallableUnit[] {a1});
profile = createProfile(NoRequirements.class.getName());
planner = createPlanner();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java
index bb92c1569..b9d58f27a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java
@@ -20,6 +20,7 @@ import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.query.ExpressionQuery;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
@@ -97,7 +98,7 @@ public class NonMinimalState extends AbstractProvisioningTest {
}
private boolean expandRequirement(IInstallableUnit iu, IRequirement req) {
- IQueryResult matches = profile.query(req.getMatches(), null);
+ IQueryResult matches = profile.query(new ExpressionQuery(IInstallableUnit.class, req.getMatches()), null);
for (Iterator iterator = matches.iterator(); iterator.hasNext();) {
IInstallableUnit match = (IInstallableUnit) iterator.next();
if (match.getId().equals(searchedId))
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest11.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest11.java
index b26fd069c..694599a00 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest11.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest11.java
@@ -36,7 +36,7 @@ public class PatchTest11 extends AbstractProvisioningTest {
a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true, true)});
b1 = createIU("B", Version.createOSGi(1, 0, 0), true);
b2 = createIU("B", Version.createOSGi(1, 2, 0), true);
- 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)"), "foo=bar", false, false, true));
+ 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)"), "(foo=bar)", false, false, true));
p1 = 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)}}, null);
createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, p1});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java
index 2d4c729ed..77f5e0f35 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java
@@ -10,16 +10,13 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.planner;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.File;
import java.util.Properties;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.director.PermissiveSlicer;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
@@ -119,7 +116,7 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest {
IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION);
IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true);
- IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq);
PermissiveSlicer slicer = new PermissiveSlicer(createTestMetdataRepository(new IInstallableUnit[] {a, act1}), new Properties(), true, false, false, false, false);
@@ -140,7 +137,7 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest {
}
public void testMissingNecessaryPiece() {
- IRequiredCapability[] req = createRequiredCapabilities("B", "B", new VersionRange("[0.0.0, 1.0.0]"), null);
+ IRequiredCapability[] req = createRequiredCapabilities("B", "B", new VersionRange("[0.0.0, 1.0.0]"));
IInstallableUnit iuA = createIU("A", DEFAULT_VERSION, null, req, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, true);
PermissiveSlicer slicer = new PermissiveSlicer(createTestMetdataRepository(new IInstallableUnit[] {iuA}), new Properties(), true, false, false, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iuA}, new NullProgressMonitor());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java
index 52d533862..97f93aa7d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java
@@ -10,24 +10,20 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.planner;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.IPlanner;
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;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.query.Collector;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class SWTFragment extends AbstractProvisioningTest {
public void testFragmentPickedByCapability() {
- IRequiredCapability[] reqs = createRequiredCapabilities("swt.fragment", "swt.fragment", new VersionRange("[1.0.0, 2.0.0)"), null);
+ IRequiredCapability[] reqs = createRequiredCapabilities("swt.fragment", "swt.fragment", new VersionRange("[1.0.0, 2.0.0)"));
IInstallableUnit swt = createIU("SWT", reqs);
MetadataFactory.InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java
index def09161b..170c79a24 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java
@@ -10,17 +10,14 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.planner;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.net.URI;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
@@ -37,7 +34,7 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest {
protected void setUp() throws Exception {
super.setUp();
- a1 = createIU("A", Version.parseVersion("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"), null));
+ a1 = createIU("A", Version.parseVersion("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]")));
b1 = createIU("B", Version.parseVersion("1.0.0"));
// Note: C has an "optional" dependency on "B"
c1 = createIU("C", Version.parseVersion("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"), null, true, false)});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java
index d3405f2fc..d62123d01 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java
@@ -11,9 +11,6 @@ package org.eclipse.equinox.p2.tests.publisher.actions;
import static org.easymock.EasyMock.*;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.*;
import java.util.*;
import junit.framework.Assert;
@@ -21,10 +18,11 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.osgi.framework.Filter;
@SuppressWarnings({"cast", "restriction", "unchecked"})
public abstract class ActionTest extends AbstractProvisioningTest {
@@ -118,13 +116,14 @@ public abstract class ActionTest extends AbstractProvisioningTest {
fail();
}
- protected void contains(Collection<IRequirement> capabilities, String namespace, String name, VersionRange range, String filter, boolean optional, boolean multiple) {
+ protected void contains(Collection<IRequirement> capabilities, String namespace, String name, VersionRange range, String filterStr, boolean optional, boolean multiple) {
+ Filter filter = ExpressionUtil.parseLDAP(filterStr);
for (Iterator iterator = capabilities.iterator(); iterator.hasNext();) {
IRequiredCapability capability = (IRequiredCapability) iterator.next();
if (filter == null) {
if (capability.getFilter() != null)
continue;
- } else if (!new LDAPQuery(filter).equals(capability.getFilter()))
+ } else if (!filter.equals(capability.getFilter()))
continue;
if (!name.equals(capability.getName()))
continue;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
index b904ec973..538fcee07 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
@@ -15,8 +15,7 @@ import org.eclipse.equinox.p2.metadata.VersionRange;
import java.util.*;
import junit.framework.TestCase;
-import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
+import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.*;
@@ -106,9 +105,9 @@ public class AdviceFileParserTest extends TestCase {
parser.parse();
IRequirement[] reqs = parser.getRequiredCapabilities();
assertEquals(1, reqs.length);
- assertEquals("testNamespace1", ((IRequiredCapability) reqs[0].getMatches()).getNamespace());
- assertEquals("testName1", ((IRequiredCapability) reqs[0].getMatches()).getName());
- assertEquals(new VersionRange("[1.2.3.v20090909, 2)"), ((IRequiredCapability) reqs[0].getMatches()).getRange());
+ assertEquals("testNamespace1", RequiredCapability.extractNamespace(reqs[0].getMatches()));
+ assertEquals("testName1", RequiredCapability.extractName(reqs[0].getMatches()));
+ assertEquals(new VersionRange("[1.2.3.v20090909, 2)"), RequiredCapability.extractRange(reqs[0].getMatches()));
map.put("requires.1.namespace", "testNamespace2");
map.put("requires.1.name", "testName2");
@@ -122,14 +121,14 @@ public class AdviceFileParserTest extends TestCase {
parser.parse();
reqs = parser.getRequiredCapabilities();
assertEquals(2, reqs.length);
- assertEquals("testNamespace1", ((IRequiredCapability) reqs[0].getMatches()).getNamespace());
- assertEquals("testName1", ((IRequiredCapability) reqs[0].getMatches()).getName());
- assertEquals(new VersionRange("[1.2.3, 2)"), ((IRequiredCapability) reqs[0].getMatches()).getRange());
- assertEquals(true, ((IRequiredCapability) reqs[0].getMatches()).isGreedy());
+ assertEquals("testNamespace1", RequiredCapability.extractNamespace(reqs[0].getMatches()));
+ assertEquals("testName1", RequiredCapability.extractName(reqs[0].getMatches()));
+ assertEquals(new VersionRange("[1.2.3, 2)"), RequiredCapability.extractRange(reqs[0].getMatches()));
+ assertEquals(true, reqs[0].isGreedy());
assertEquals(0, reqs[0].getMin());
- assertEquals("testNamespace2", ((IRequiredCapability) reqs[1].getMatches()).getNamespace());
- assertEquals("testName2", ((IRequiredCapability) reqs[1].getMatches()).getName());
- assertEquals(new VersionRange(Version.emptyVersion.toString()), ((IRequiredCapability) reqs[1].getMatches()).getRange());
+ assertEquals("testNamespace2", RequiredCapability.extractNamespace(reqs[1].getMatches()));
+ assertEquals("testName2", RequiredCapability.extractName(reqs[1].getMatches()));
+ assertEquals(new VersionRange(Version.emptyVersion.toString()), RequiredCapability.extractRange(reqs[1].getMatches()));
assertEquals(false, reqs[1].isGreedy());
assertEquals(1, reqs[1].getMin());
}
@@ -147,9 +146,9 @@ public class AdviceFileParserTest extends TestCase {
parser.parse();
IRequirement[] reqs = parser.getMetaRequiredCapabilities();
assertEquals(1, reqs.length);
- assertEquals("testNamespace1", ((IRequiredCapability) reqs[0].getMatches()).getNamespace());
- assertEquals("testName1", ((IRequiredCapability) reqs[0].getMatches()).getName());
- assertEquals(new VersionRange("[1.2.3.v20090909, 2)"), ((IRequiredCapability) reqs[0].getMatches()).getRange());
+ assertEquals("testNamespace1", RequiredCapability.extractNamespace(reqs[0].getMatches()));
+ assertEquals("testName1", RequiredCapability.extractName(reqs[0].getMatches()));
+ assertEquals(new VersionRange("[1.2.3.v20090909, 2)"), RequiredCapability.extractRange(reqs[0].getMatches()));
map.put("metaRequirements.1.namespace", "testNamespace2");
map.put("metaRequirements.1.name", "testName2");
@@ -163,14 +162,14 @@ public class AdviceFileParserTest extends TestCase {
parser.parse();
reqs = parser.getMetaRequiredCapabilities();
assertEquals(2, reqs.length);
- assertEquals("testNamespace1", ((IRequiredCapability) reqs[0].getMatches()).getNamespace());
- assertEquals("testName1", ((IRequiredCapability) reqs[0].getMatches()).getName());
- assertEquals(new VersionRange("[1.2.3, 2)"), ((IRequiredCapability) reqs[0].getMatches()).getRange());
- assertEquals(true, ((IRequiredCapability) reqs[0].getMatches()).isGreedy());
+ assertEquals("testNamespace1", RequiredCapability.extractNamespace(reqs[0].getMatches()));
+ assertEquals("testName1", RequiredCapability.extractName(reqs[0].getMatches()));
+ assertEquals(new VersionRange("[1.2.3, 2)"), RequiredCapability.extractRange(reqs[0].getMatches()));
+ assertEquals(true, reqs[0].isGreedy());
assertEquals(0, reqs[0].getMin());
- assertEquals("testNamespace2", ((IRequiredCapability) reqs[1].getMatches()).getNamespace());
- assertEquals("testName2", ((IRequiredCapability) reqs[1].getMatches()).getName());
- assertEquals(new VersionRange(Version.emptyVersion.toString()), ((IRequiredCapability) reqs[1].getMatches()).getRange());
+ assertEquals("testNamespace2", RequiredCapability.extractNamespace(reqs[1].getMatches()));
+ assertEquals("testName2", RequiredCapability.extractName(reqs[1].getMatches()));
+ assertEquals(new VersionRange(Version.emptyVersion.toString()), RequiredCapability.extractRange(reqs[1].getMatches()));
assertEquals(false, reqs[1].isGreedy());
assertEquals(1, reqs[1].getMin());
}
@@ -203,7 +202,7 @@ public class AdviceFileParserTest extends TestCase {
map.put("units.1.singleton", "true");
map.put("units.1.copyright", "testCopyright");
map.put("units.1.copyright.location", "http://localhost/test");
- map.put("units.1.filter", "test=testFilter");
+ map.put("units.1.filter", "(test=testFilter)");
map.put("units.1.touchpoint.id", "testTouchpointId");
map.put("units.1.touchpoint.version", "1.2.5");
map.put("units.1.update.id", "testid1");
@@ -302,7 +301,7 @@ public class AdviceFileParserTest extends TestCase {
assertEquals("testClassifier2", key1.getClassifier());
assertEquals("testCopyright", iu1.getCopyright().getBody());
assertEquals("http://localhost/test", iu1.getCopyright().getLocation().toString());
- assertEquals("test=testFilter", ((LDAPQuery) iu1.getFilter()).getFilter());
+ assertEquals("(test=testFilter)", iu1.getFilter().toString());
assertEquals("testLicense", iu1.getLicenses().iterator().next().getBody());
assertEquals("http://localhost/license", iu1.getLicenses().iterator().next().getLocation().toString());
assertEquals("testValue1", iu1.getProperty("testName1"));
@@ -313,14 +312,14 @@ public class AdviceFileParserTest extends TestCase {
IRequirement req0 = (IRequirement) it2.next();
IRequirement req1 = (IRequirement) it2.next();
assertEquals(2, reqs.size());
- assertEquals("testNamespace1", ((IRequiredCapability) req0.getMatches()).getNamespace());
- assertEquals("testName1", ((IRequiredCapability) req0.getMatches()).getName());
- assertEquals(new VersionRange("[1.2.3, 2)"), ((IRequiredCapability) req0.getMatches()).getRange());
- assertEquals(true, ((IRequiredCapability) req0.getMatches()).isGreedy());
+ assertEquals("testNamespace1", RequiredCapability.extractNamespace(req0.getMatches()));
+ assertEquals("testName1", RequiredCapability.extractName(req0.getMatches()));
+ assertEquals(new VersionRange("[1.2.3, 2)"), RequiredCapability.extractRange(req0.getMatches()));
+ assertEquals(true, req0.isGreedy());
assertEquals(0, req0.getMin());
- assertEquals("testNamespace2", ((IRequiredCapability) req1.getMatches()).getNamespace());
- assertEquals("testName2", ((IRequiredCapability) req1.getMatches()).getName());
- assertEquals(new VersionRange(Version.emptyVersion.toString()), ((IRequiredCapability) req1.getMatches()).getRange());
+ assertEquals("testNamespace2", RequiredCapability.extractNamespace(req1.getMatches()));
+ assertEquals("testName2", RequiredCapability.extractName(req1.getMatches()));
+ assertEquals(new VersionRange(Version.emptyVersion.toString()), RequiredCapability.extractRange(req1.getMatches()));
assertEquals(false, req1.isGreedy());
assertEquals(1, req1.getMin());
@@ -341,14 +340,15 @@ public class AdviceFileParserTest extends TestCase {
Iterator it3 = metarequirements.iterator();
IRequirement metaReq0 = (IRequirement) it3.next();
IRequirement metaReq1 = (IRequirement) it3.next();
- assertEquals("testNamespace1", ((IRequiredCapability) metaReq0.getMatches()).getNamespace());
- assertEquals("testName1", ((IRequiredCapability) metaReq0.getMatches()).getName());
- assertEquals(new VersionRange("[1.2.3, 2)"), ((IRequiredCapability) metaReq0.getMatches()).getRange());
+
+ assertEquals("testNamespace1", RequiredCapability.extractNamespace(metaReq0.getMatches()));
+ assertEquals("testName1", RequiredCapability.extractName(metaReq0.getMatches()));
+ assertEquals(new VersionRange("[1.2.3, 2)"), RequiredCapability.extractRange(metaReq0.getMatches()));
assertEquals(true, metaReq0.isGreedy());
assertEquals(0, metaReq0.getMin());
- assertEquals("testNamespace2", ((IRequiredCapability) metaReq1.getMatches()).getNamespace());
- assertEquals("testName2", ((IRequiredCapability) metaReq1.getMatches()).getName());
- assertEquals(new VersionRange(Version.emptyVersion.toString()), ((IRequiredCapability) metaReq1.getMatches()).getRange());
+ assertEquals("testNamespace2", RequiredCapability.extractNamespace(metaReq1.getMatches()));
+ assertEquals("testName2", RequiredCapability.extractName(metaReq1.getMatches()));
+ assertEquals(new VersionRange(Version.emptyVersion.toString()), RequiredCapability.extractRange(metaReq1.getMatches()));
assertEquals(false, metaReq1.isGreedy());
assertEquals(1, metaReq1.getMin());
@@ -370,14 +370,14 @@ public class AdviceFileParserTest extends TestCase {
assertTrue(FragmentQuery.isFragment(iu1));
IRequirement[] hostRequired = ((IInstallableUnitFragment) iu1).getHost();
assertEquals(2, hostRequired.length);
- assertEquals("testNamespace1", ((IRequiredCapability) hostRequired[0].getMatches()).getNamespace());
- assertEquals("testName1", ((IRequiredCapability) hostRequired[0].getMatches()).getName());
- assertEquals(new VersionRange("[1.2.3, 2)"), ((IRequiredCapability) hostRequired[0].getMatches()).getRange());
+ assertEquals("testNamespace1", RequiredCapability.extractNamespace(hostRequired[0].getMatches()));
+ assertEquals("testName1", RequiredCapability.extractName(hostRequired[0].getMatches()));
+ assertEquals(new VersionRange("[1.2.3, 2)"), RequiredCapability.extractRange(hostRequired[0].getMatches()));
assertEquals(true, hostRequired[0].isGreedy());
assertEquals(0, hostRequired[0].getMin());
- assertEquals("testNamespace2", ((IRequiredCapability) hostRequired[1].getMatches()).getNamespace());
- assertEquals("testName2", ((IRequiredCapability) hostRequired[1].getMatches()).getName());
- assertEquals(new VersionRange(Version.emptyVersion.toString()), ((IRequiredCapability) hostRequired[1].getMatches()).getRange());
+ assertEquals("testNamespace2", RequiredCapability.extractNamespace(hostRequired[1].getMatches()));
+ assertEquals("testName2", RequiredCapability.extractName(hostRequired[1].getMatches()));
+ assertEquals(new VersionRange(Version.emptyVersion.toString()), RequiredCapability.extractRange(hostRequired[1].getMatches()));
assertEquals(false, hostRequired[1].isGreedy());
assertEquals(1, hostRequired[1].getMin());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java
index 69a1af3b7..9c896acdf 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java
@@ -12,19 +12,16 @@ package org.eclipse.equinox.p2.tests.publisher.actions;
import static org.easymock.EasyMock.expect;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.File;
import java.util.*;
import org.easymock.EasyMock;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.internal.p2.publisher.eclipse.DataLoader;
import org.eclipse.equinox.internal.provisional.frameworkadmin.ConfigData;
import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.publisher.IPublisherResult;
import org.eclipse.equinox.p2.publisher.eclipse.*;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
@@ -82,7 +79,7 @@ public class ConfigCUsActionTest extends ActionTest {
for (int i = 0; i < IUs.size(); i++) {
InstallableUnit iu = (InstallableUnit) IUs.get(i);
if (iu.getId().equals(flavor + id + "." + cuType + "." + configSpec)) { //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue(((LDAPQuery) iu.getFilter()).getFilter().equals("(& (osgi.ws=win32)(osgi.os=win32)(osgi.arch=x86))")); //$NON-NLS-1$
+ assertTrue(iu.getFilter().equals(ExpressionUtil.parseLDAP("(& (osgi.ws=win32)(osgi.os=win32)(osgi.arch=x86))"))); //$NON-NLS-1$
assertTrue(iu.getVersion().equals(version));
assertFalse(iu.isSingleton());
Collection<IProvidedCapability> providedCapabilities = iu.getProvidedCapabilities();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxExecutableActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxExecutableActionTest.java
index 6f434e7fe..90d6155c7 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxExecutableActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxExecutableActionTest.java
@@ -18,9 +18,9 @@ import org.eclipse.equinox.p2.metadata.VersionRange;
import java.io.File;
import java.util.*;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.internal.p2.publisher.eclipse.ExecutablesDescriptor;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.publisher.eclipse.EquinoxExecutableAction;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
@@ -100,7 +100,7 @@ public class EquinoxExecutableActionTest extends ActionTest {
Collection<IRequirement> requiredCapability = fragment.getRequiredCapabilities();
verifyRequiredCapability(requiredCapability, IInstallableUnit.NAMESPACE_IU_ID, idBase + ".executable." + configSpec, new VersionRange(version, true, version, true)); //$NON-NLS-1$
assertTrue(requiredCapability.size() == 1);
- assertTrue(((LDAPQuery) fragment.getFilter()).getFilter().equals("(& (osgi.ws=" + ws + ")(osgi.os=" + os + ")(osgi.arch=" + arch + "))")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
+ assertTrue(fragment.getFilter().equals(ExpressionUtil.parseLDAP("(& (osgi.ws=" + ws + ")(osgi.os=" + os + ")(osgi.arch=" + arch + "))"))); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
assertTrue(fragment.getProperty("org.eclipse.equinox.p2.type.fragment").equals("true")); //$NON-NLS-1$ //$NON-NLS-2$
return;//pass
}
@@ -135,7 +135,7 @@ public class EquinoxExecutableActionTest extends ActionTest {
IInstallableUnit possibleExec = (IInstallableUnit) iuList.get(i);
if (possibleExec.getId().equals(idBase + ".executable." + configSpec)) { //$NON-NLS-1$
//keep checking
- assertTrue(((LDAPQuery) possibleExec.getFilter()).getFilter().equals("(& (osgi.ws=" + ws + ")(osgi.os=" + os + ")(osgi.arch=" + arch + "))")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
+ assertTrue(possibleExec.getFilter().equals(ExpressionUtil.parseLDAP("(& (osgi.ws=" + ws + ")(osgi.os=" + os + ")(osgi.arch=" + arch + "))"))); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
IArtifactKey eKey = possibleExec.getArtifacts().iterator().next();
assertTrue(eKey.getClassifier().equals("binary")); //$NON-NLS-1$
assertTrue(eKey.getId().equals(idBase + ".executable." + configSpec)); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java
index cb12b5e13..4f2b41dd8 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java
@@ -12,9 +12,6 @@ package org.eclipse.equinox.p2.tests.publisher.actions;
import static org.easymock.EasyMock.*;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.File;
import java.io.IOException;
import java.util.*;
@@ -24,9 +21,9 @@ import org.easymock.EasyMock;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.publisher.IPublisherInfo;
import org.eclipse.equinox.p2.publisher.IPublisherResult;
import org.eclipse.equinox.p2.publisher.actions.*;
@@ -90,7 +87,7 @@ public class FeaturesActionTest extends ActionTest {
assertTrue(foo.getProperty("key1").equals("value1")); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue(foo.getProperty("key2").equals("value2")); //$NON-NLS-1$//$NON-NLS-2$
assertTrue(foo.getArtifacts().iterator().next().equals(FOO_KEY));
- assertTrue(((LDAPQuery) foo.getFilter()).getFilter().equalsIgnoreCase("(org.eclipse.update.install.features=true)")); //$NON-NLS-1$
+ assertTrue(foo.getFilter().equals(ExpressionUtil.parseLDAP("(org.eclipse.update.install.features=true)"))); //$NON-NLS-1$
//check touchpointType
assertTrue(foo.getTouchpointType().getId().equalsIgnoreCase("org.eclipse.equinox.p2.osgi")); //$NON-NLS-1$
@@ -133,7 +130,7 @@ public class FeaturesActionTest extends ActionTest {
assertTrue(bar.getProperties().containsKey("org.eclipse.update.installHandler")); //$NON-NLS-1$
assertTrue(bar.getProperties().containsValue("handler=bar handler")); //$NON-NLS-1$
assertTrue(bar.getArtifacts().iterator().next().equals(BAR_KEY));
- assertTrue(((LDAPQuery) bar.getFilter()).getFilter().equalsIgnoreCase("(org.eclipse.update.install.features=true)")); //$NON-NLS-1$
+ assertTrue(bar.getFilter().equals(ExpressionUtil.parseLDAP("(org.eclipse.update.install.features=true)"))); //$NON-NLS-1$
assertTrue(bar.isSingleton());
barIUs = new ArrayList(publisherResult.getIUs("bar.feature.group", IPublisherResult.ROOT)); //$NON-NLS-1$
@@ -143,7 +140,7 @@ public class FeaturesActionTest extends ActionTest {
//contains(barRequiredCapabilities, IInstallableUnit.NAMESPACE_IU_ID, "bar_root", new VersionRange(barVersion, true, barVersion, true), null, false /*multiple*/, false /*optional*/); //$NON-NLS-1$//$NON-NLS-2$
contains(barRequiredCapabilities, IInstallableUnit.NAMESPACE_IU_ID, "bar.feature.jar", new VersionRange(barVersion, true, barVersion, true), "(org.eclipse.update.install.features=true)", false /*multiple*/, false /*optional*/); //$NON-NLS-1$//$NON-NLS-2$
contains(barRequiredCapabilities, IInstallableUnit.NAMESPACE_IU_ID, "org.bar.feature.feature.group", VersionRange.emptyRange, "(&(|(osgi.nl=de)(osgi.nl=en)(osgi.nl=fr)))", false /*multiple*/, false /*optional*/); //$NON-NLS-1$//$NON-NLS-2$
- assertTrue(((LDAPQuery) barGroup.getFilter()).getFilter().equalsIgnoreCase("(&(|(osgi.os=macosx)(osgi.os=win32))(|(osgi.ws=carbon)(osgi.ws=win32))(|(osgi.arch=ppc)(osgi.arch=x86))(osgi.nl=en))"));
+ assertTrue(barGroup.getFilter().equals(ExpressionUtil.parseLDAP("(&(|(osgi.os=macosx)(osgi.os=win32))(|(osgi.ws=carbon)(osgi.ws=win32))(|(osgi.arch=ppc)(osgi.arch=x86))(osgi.nl=en))")));
//check zipped=true in touchpointData
String barValue = ((ITouchpointInstruction) bar.getTouchpointData().get(0).getInstructions().get("zipped")).getBody(); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java
index 6f632185f..3900d2b3e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java
@@ -12,8 +12,6 @@ package org.eclipse.equinox.p2.tests.publisher.actions;
import static org.easymock.EasyMock.*;
-import org.eclipse.equinox.p2.metadata.Version;
-
import java.io.File;
import java.io.IOException;
import java.util.Collection;
@@ -21,13 +19,12 @@ import java.util.Collections;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
+import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.publisher.actions.RootIUAdvice;
@@ -309,8 +306,8 @@ public class ProductActionTest extends ActionTest {
IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
assertEquals("1.0", 1, queryResultSize(queryResult));
IInstallableUnitFragment fragment = (IInstallableUnitFragment) queryResult.iterator().next();
- assertEquals("1.1", "org.eclipse.core.runtime", ((IRequiredCapability) fragment.getHost()[0].getMatches()).getName());
- assertEquals("1.2", Version.create("4.0.0"), ((IRequiredCapability) fragment.getHost()[0].getMatches()).getRange().getMinimum());
+ assertEquals("1.1", "org.eclipse.core.runtime", RequiredCapability.extractName(fragment.getHost()[0].getMatches()));
+ assertEquals("1.2", Version.create("4.0.0"), RequiredCapability.extractRange(fragment.getHost()[0].getMatches()).getMinimum());
assertEquals("1.3", Version.create("1.0.0"), fragment.getVersion());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java
index 9174c5ddc..a30a3d39f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java
@@ -17,7 +17,6 @@ import java.net.URI;
import java.util.*;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
@@ -95,7 +94,7 @@ public class ProductActionWithAdviceFileTest extends ActionTest {
}
}
assertTrue("1.1", capability != null);
- assertEquals("1.2", "(org.eclipse.update.install.features=true)", ((LDAPQuery) capability.getFilter()).getFilter());
+ assertEquals("1.2", "(org.eclipse.update.install.features=true)", capability.getFilter().toString());
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/AllTests.java
new file mode 100644
index 000000000..78b7fb83d
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/AllTests.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 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.ql;
+
+import junit.framework.*;
+
+/**
+ * Performs all automated director tests.
+ */
+public class AllTests extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ suite.addTestSuite(EvaluatorTest.class);
+ suite.addTestSuite(PerformanceTest.class);
+ suite.addTestSuite(TestQueryReimplementation.class);
+ return suite;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java
index 8aa369e14..facafa400 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java
@@ -10,9 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ql;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.File;
import java.net.URI;
import java.util.*;
@@ -21,8 +18,9 @@ import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.director.QueryableArray;
import org.eclipse.equinox.internal.p2.director.app.Activator;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.*;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.equinox.p2.publisher.PublisherResult;
@@ -38,37 +36,39 @@ import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.Filter;
public class EvaluatorTest extends AbstractProvisioningTest {
- private static final IExpressionParser parser = QL.newParser();
+ private static final IQLParser parser = QL.newParser();
+ private static final IQLFactory factory = QL.getFactory();
public void testArguments() throws Exception {
- IMatchExpression expr = parser.parsePredicate("'a' == $0 && 'b' == $1 && 'c' == $2");
- assertEquals(Boolean.TRUE, expr.evaluate(expr.createContext(new Object[] {"a", "b", "c"})));
+ IExpression expr = parser.parse("'a' == $0 && 'b' == $1 && 'c' == $2");
+ assertEquals(Boolean.TRUE, expr.evaluate(factory.createContext("a", "b", "c")));
}
public void testAnonymousMember() throws Exception {
- IMatchExpression expr = parser.parsePredicate("$0.class == $1");
- assertEquals(Boolean.TRUE, expr.evaluate(expr.createContext(new Object[] {"a", String.class})));
+ IExpression expr = parser.parse("$0.class == $1");
+ assertEquals(Boolean.TRUE, expr.evaluate(factory.createContext("a", String.class)));
}
public void testInstanceOf() throws Exception {
// Explicit instanceof when rhs is a class
- IMatchExpression expr = parser.parsePredicate("$0 ~= $1");
- assertEquals(Boolean.TRUE, expr.evaluate(expr.createContext(new Object[] {new Integer(4), Number.class})));
+ IExpression expr = parser.parse("$0 ~= $1");
+ assertEquals(Boolean.TRUE, expr.evaluate(factory.createContext(new Integer(4), Number.class)));
}
public void testArray() throws Exception {
- IMatchExpression expr = parser.parsePredicate("['a', 'b', 'c'].exists(x | x == 'b') && ['a', 'b', 'c'].all(x | 'd' > x)");
- assertEquals(Boolean.TRUE, expr.evaluate(expr.createContext(null)));
- expr = parser.parsePredicate("['d', 'e', 'f'].exists(x | ['a', 'b', 'c'].exists(y | x > y))");
- assertEquals(Boolean.TRUE, expr.evaluate(expr.createContext(null)));
- expr = parser.parsePredicate("[['d', 'e', 'f'], ['h', 'i', 'j']].exists(x | x.all(y | ['a', 'b', 'c'].all(z | y > z)))");
- assertEquals(Boolean.TRUE, expr.evaluate(expr.createContext(null)));
- expr = parser.parsePredicate("[['d', 'e', 'f'], ['h', '3', 'j']].exists(x | x.all(y | ['a', 'b', 'c'].exists(z | y > z)))");
- assertEquals(Boolean.TRUE, expr.evaluate(expr.createContext(null)));
- expr = parser.parsePredicate("[['d', 'e', 'f'], ['h', 'i', 'j']].all(x | x.all(y | ['a', 'b', 'c'].all(z | y > z)))");
- assertEquals(Boolean.TRUE, expr.evaluate(expr.createContext(null)));
- expr = parser.parsePredicate("[['d', 'e', 'f'], ['h', '3', 'j']].all(x | x.all(y | ['a', 'b', 'c'].all(z | y > z)))");
- assertEquals(Boolean.FALSE, expr.evaluate(expr.createContext(null))); // 3 < 'b'
+ IExpression expr = parser.parse("['a', 'b', 'c'].exists(x | x == 'b') && ['a', 'b', 'c'].all(x | 'd' > x)");
+ IEvaluationContext ctx = factory.createContext();
+ assertEquals(Boolean.TRUE, expr.evaluate(ctx));
+ expr = parser.parse("['d', 'e', 'f'].exists(x | ['a', 'b', 'c'].exists(y | x > y))");
+ assertEquals(Boolean.TRUE, expr.evaluate(ctx));
+ expr = parser.parse("[['d', 'e', 'f'], ['h', 'i', 'j']].exists(x | x.all(y | ['a', 'b', 'c'].all(z | y > z)))");
+ assertEquals(Boolean.TRUE, expr.evaluate(ctx));
+ expr = parser.parse("[['d', 'e', 'f'], ['h', '3', 'j']].exists(x | x.all(y | ['a', 'b', 'c'].exists(z | y > z)))");
+ assertEquals(Boolean.TRUE, expr.evaluate(ctx));
+ expr = parser.parse("[['d', 'e', 'f'], ['h', 'i', 'j']].all(x | x.all(y | ['a', 'b', 'c'].all(z | y > z)))");
+ assertEquals(Boolean.TRUE, expr.evaluate(ctx));
+ expr = parser.parse("[['d', 'e', 'f'], ['h', '3', 'j']].all(x | x.all(y | ['a', 'b', 'c'].all(z | y > z)))");
+ assertEquals(Boolean.FALSE, expr.evaluate(ctx)); // 3 < 'b'
}
public void testLatest() throws Exception {
@@ -102,7 +102,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
"parent.requiredCapabilities.unique(requirementsCache).select(rc | rc.filter == null || $2 ~= filter(rc.filter)), _, " + //
"{rcs, child | rcs.exists(rc | child ~= rc)})}).limit(10)";
- IContextExpression expr = parser.parseQuery(IInstallableUnit.class, exprString);
+ IContextExpression expr = factory.contextExpression(IInstallableUnit.class, parser.parseQuery(exprString));
System.out.println(expr.toString());
assertEquals(exprString, expr.toString());
}
@@ -111,32 +111,24 @@ public class EvaluatorTest extends AbstractProvisioningTest {
// Create some expressions. Note the use of identifiers instead of
// indexes for the parameters
- IExpressionFactory factory = QL.getFactory();
IExpression item = factory.variable("item");
- IExpression cmp1 = factory.equals(factory.member(item, "id"), factory.keyedParameter("id"));
- IExpression cmp2 = factory.equals(factory.at(factory.member(item, "properties"), factory.keyedParameter("propKey")), factory.keyedParameter("propValue"));
-
- IExpression everything = factory.variable("everything");
- IExpression lambda = factory.lambda(item, factory.and(new IExpression[] {cmp1, cmp2}));
- IExpression latest = factory.latest(factory.select(everything, lambda));
- IContextExpression e3 = factory.contextExpression(IInstallableUnit.class, latest);
+ IExpression cmp1 = factory.equals(factory.member(item, "id"), factory.indexedParameter(0));
+ IExpression cmp2 = factory.equals(factory.at(factory.member(item, "properties"), factory.indexedParameter(1)), factory.indexedParameter(2));
- // Put the parameters in a map
- Map args = new HashMap();
- args.put("id", "test.bundle");
- args.put("propKey", "org.eclipse.equinox.p2.type.group");
- args.put("propValue", "true");
+ IExpression lambda = factory.lambda(item, factory.and(cmp1, cmp2));
+ IExpression latest = factory.latest(factory.select(factory.variable("everything"), lambda));
// Create the query
+ IContextExpression e3 = factory.contextExpression(IInstallableUnit.class, latest, "test.bundle", "org.eclipse.equinox.p2.type.group", "true");
IMetadataRepository repo = getMDR("/testData/metadataRepo/multipleversions1");
- IQueryResult result = repo.query(new QLContextQuery(e3, args), new NullProgressMonitor());
+ IQueryResult result = repo.query(new QLContextQuery(e3), new NullProgressMonitor());
assertEquals(queryResultSize(result), 1);
}
public void testMember() throws Exception {
IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo");
IProvidedCapability pc = MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.eclipse.type", "source", null);
- IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnitFragment.class, "host.exists(h | $0 ~= h)", new Object[] {pc}), new NullProgressMonitor());
+ IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnitFragment.class, "host.exists(h | $0.name == h.name && $0.namespace == h.namespace)", new Object[] {pc}), new NullProgressMonitor());
assertEquals(queryResultSize(result), 1);
}
@@ -148,7 +140,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
applicability[1][1] = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.flavor", "tooling", null, null, false, false);
IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo");
- IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnit.class, "$0.exists(rcs | rcs.all(rc | item ~= rc))", (Object) applicability), new NullProgressMonitor());
+ IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnit.class, "$0.exists(rcs | rcs.all(rc | this ~= rc))", (Object) applicability), new NullProgressMonitor());
assertEquals(queryResultSize(result), 3);
}
@@ -187,7 +179,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
while (itor.hasNext())
assertTrue(itor.next() instanceof IArtifactKey);
- result = repo.query(new QLMatchQuery(IArtifactDescriptor.class, "artifactKey.classifier ~= /*/"), new NullProgressMonitor());
+ result = repo.descriptorQueryable().query(new QLMatchQuery(IArtifactDescriptor.class, "artifactKey.classifier ~= /*/"), new NullProgressMonitor());
assertTrue(queryResultSize(result) > 1);
itor = result.iterator();
while (itor.hasNext())
@@ -197,7 +189,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
public void testClassConstructor() throws Exception {
IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo");
IQueryResult result = repo.query(new QLContextQuery(IInstallableUnit.class, //
- "select(x | x ~= class('org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnitFragment'))"), new NullProgressMonitor());
+ "select(x | x ~= class('org.eclipse.equinox.p2.metadata.IInstallableUnitFragment'))"), new NullProgressMonitor());
assertEquals(queryResultSize(result), 4);
repo = getMDR("/testData/galileoM7");
}
@@ -225,16 +217,16 @@ public class EvaluatorTest extends AbstractProvisioningTest {
public void testTraverseWithIndexAndFilter() throws Exception {
// Add some filtering of requirements
- IContextExpression expr = parser.parseQuery(IInstallableUnit.class, "" + //
- "select(x | x.id == $0 && x.version == $1).traverse(capabilityIndex(everything), _, { index, parent |" + //
- "index.satisfiesAny(parent.requiredCapabilities.select(rc | rc.filter == null || $2 ~= filter(rc.filter)))})");
-
Map env = new Hashtable();
env.put("osgi.os", "linux");
env.put("osgi.ws", "gtk");
env.put("osgi.arch", "x86");
- QLContextQuery query = new QLContextQuery(expr, "org.eclipse.sdk.feature.group", Version.create("3.5.0.v20090423-7Q7bA7DPR-wM38__Q4iRsmx9z0KOjbpx3AbyvXd-Uq7J2"), env);
+ IContextExpression expr = factory.contextExpression(IInstallableUnit.class, parser.parseQuery("" + //
+ "select(x | x.id == $0 && x.version == $1).traverse(capabilityIndex(everything), _, { index, parent |" + //
+ "index.satisfiesAny(parent.requiredCapabilities.select(rc | rc.filter == null || $2 ~= rc.filter))})"), "org.eclipse.sdk.feature.group", Version.create("3.5.0.v20090423-7Q7bA7DPR-wM38__Q4iRsmx9z0KOjbpx3AbyvXd-Uq7J2"), env);
+
+ QLContextQuery query = new QLContextQuery(expr);
IMetadataRepository repo = getMDR("/testData/galileoM7");
IQueryResult result = repo.query(query, new NullProgressMonitor());
assertEquals(queryResultSize(result), 411);
@@ -247,18 +239,16 @@ public class EvaluatorTest extends AbstractProvisioningTest {
QLContextQuery indexQuery = new QLContextQuery(IInstallableUnit.class, "capabilityIndex(everything)");
Object index = indexQuery.query(QL.newQueryContext(repo));
- IContextExpression expr = parser.parseQuery(IInstallableUnit.class, "" + //
- "select(x | x.id == $0 && x.version == $1).traverse(parent |" + //
- "$5.satisfiesAny(parent.requiredCapabilities.select(rc | rc.filter == null || $4 ~= filter(rc.filter)))) && " + //
- "select(x | x.id == $2 && x.version == $3).traverse(parent |" + //
- "$5.satisfiesAny(parent.requiredCapabilities.select(rc | rc.filter == null || $4 ~= filter(rc.filter))))");
-
Map env = new Hashtable();
env.put("osgi.os", "linux");
env.put("osgi.ws", "gtk");
env.put("osgi.arch", "x86");
- QLContextQuery query = new QLContextQuery(expr, //
+ IContextExpression expr = factory.contextExpression(IInstallableUnit.class, parser.parseQuery("" + //
+ "select(x | x.id == $0 && x.version == $1).traverse(parent |" + //
+ "$5.satisfiesAny(parent.requiredCapabilities.select(rc | rc.filter == null || $4 ~= rc.filter))).intersect(" + //
+ "select(x | x.id == $2 && x.version == $3).traverse(parent |" + //
+ "$5.satisfiesAny(parent.requiredCapabilities.select(rc | rc.filter == null || $4 ~= rc.filter))))"), //
"org.eclipse.pde.feature.group", //
Version.create("3.5.0.v20090123-7Z7YF8NFE-z0VXhWU26Hu8gY"), //
"org.eclipse.gmf.feature.group", //
@@ -266,45 +256,42 @@ public class EvaluatorTest extends AbstractProvisioningTest {
env,//
index);
+ QLContextQuery query = new QLContextQuery(expr);
IQueryResult result = repo.query(query, new NullProgressMonitor());
assertEquals(queryResultSize(result), 184);
}
public void testMatchQueryInjectionInPredicate() throws Exception {
IMetadataRepository repo = getMDR("/testData/galileoM7");
- IMatchExpression expr = parser.parsePredicate("iquery($0) || iquery($1)");
- MatchQuery q1 = new MatchQuery() {
+ IMatchExpression expr = factory.matchExpression(parser.parse("iquery($0) || iquery($1)"), new MatchQuery() {
@Override
public boolean isMatch(Object candidate) {
return "true".equals(((IInstallableUnit) candidate).getProperty("org.eclipse.equinox.p2.type.category"));
}
- };
- MatchQuery q2 = new MatchQuery() {
+ }, new MatchQuery() {
@Override
public boolean isMatch(Object candidate) {
return "true".equals(((IInstallableUnit) candidate).getProperty("org.eclipse.equinox.p2.type.group"));
}
- };
- IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnit.class, expr, new Object[] {q1, q2}), new NullProgressMonitor());
+ });
+ IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnit.class, expr), new NullProgressMonitor());
assertEquals(queryResultSize(result), 497);
}
public void testMatchQueryInjectionInContext() throws Exception {
IMetadataRepository repo = getMDR("/testData/galileoM7");
- IContextExpression expr = parser.parseQuery(IInstallableUnit.class, "select(x | iquery($0, x) || iquery($1, x)).latest()");
- MatchQuery q1 = new MatchQuery() {
+ IContextExpression expr = factory.contextExpression(IInstallableUnit.class, parser.parseQuery("select(x | iquery($0, x) || iquery($1, x)).latest()"), new MatchQuery() {
@Override
public boolean isMatch(Object candidate) {
return "true".equals(((IInstallableUnit) candidate).getProperty("org.eclipse.equinox.p2.type.category"));
}
- };
- MatchQuery q2 = new MatchQuery() {
+ }, new MatchQuery() {
@Override
public boolean isMatch(Object candidate) {
return "true".equals(((IInstallableUnit) candidate).getProperty("org.eclipse.equinox.p2.type.group"));
}
- };
- IQueryResult result = repo.query(new QLContextQuery(expr, q1, q2), new NullProgressMonitor());
+ });
+ IQueryResult result = repo.query(new QLContextQuery(expr), new NullProgressMonitor());
assertEquals(queryResultSize(result), 497);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java
index 424c959ff..bcc264b43 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java
@@ -10,9 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ql;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.net.URI;
import java.util.*;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -20,10 +17,10 @@ import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.director.QueryableArray;
import org.eclipse.equinox.internal.p2.director.Slicer;
import org.eclipse.equinox.internal.p2.director.app.Activator;
-import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.p2.metadata.query.IUPropertyQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.query.ExpressionQuery;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.ql.*;
import org.eclipse.equinox.p2.query.*;
@@ -36,8 +33,9 @@ public class PerformanceTest extends AbstractProvisioningTest {
IMetadataRepository repo = getMDR("/testData/galileoM7");
- IRequiredCapability capability = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.eclipse.type", "feature", new VersionRange("[1.0.0,2.0.0)"), null, false, false);
- QLMatchQuery predicateQuery = new QLMatchQuery(IInstallableUnit.class, "item ~= $0", capability);
+ IRequirement capability = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.eclipse.type", "feature", new VersionRange("[1.0.0,2.0.0)"), null, false, false);
+ QLMatchQuery predicateQuery = new QLMatchQuery(IInstallableUnit.class, "this ~= $0", capability);
+ IQuery capabilityQuery = new ExpressionQuery(IInstallableUnit.class, capability.getMatches());
IQueryResult result;
long tradQueryMS = 0;
long exprQueryMS = 0;
@@ -45,7 +43,7 @@ public class PerformanceTest extends AbstractProvisioningTest {
for (int i = 0; i < 5; ++i) {
long start = System.currentTimeMillis();
for (int idx = 0; idx < 80; ++idx) {
- result = repo.query(capability, new NullProgressMonitor());
+ result = repo.query(capabilityQuery, new NullProgressMonitor());
assertEquals(queryResultSize(result), 487);
}
tradQueryMS += (System.currentTimeMillis() - start);
@@ -67,8 +65,9 @@ public class PerformanceTest extends AbstractProvisioningTest {
IMetadataRepository repo = getMDR("/testData/galileoM7");
IQueryable qaRepo = new QueryableArray(gatherAvailableInstallableUnits(repo));
- IRequiredCapability capability = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.eclipse.type", "feature", new VersionRange("[1.0.0,2.0.0)"), null, false, false);
+ IRequirement capability = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.eclipse.type", "feature", new VersionRange("[1.0.0,2.0.0)"), null, false, false);
QLContextQuery exprQuery = new QLContextQuery(IInstallableUnit.class, "capabilityIndex(everything)");
+ IQuery capabilityQuery = new ExpressionQuery(IInstallableUnit.class, capability.getMatches());
exprQuery = new QLContextQuery(IInstallableUnit.class, "$0.satisfiesAny([$1])", exprQuery.query(QL.newQueryContext(qaRepo)), capability);
IQueryResult result;
long tradQueryMS = 0;
@@ -77,7 +76,7 @@ public class PerformanceTest extends AbstractProvisioningTest {
for (int i = 0; i < 5; ++i) {
long start = System.currentTimeMillis();
for (int idx = 0; idx < 80; ++idx) {
- result = qaRepo.query(capability, new NullProgressMonitor());
+ result = qaRepo.query(capabilityQuery, new NullProgressMonitor());
assertEquals(queryResultSize(result), 487);
}
tradQueryMS += (System.currentTimeMillis() - start);
@@ -138,7 +137,7 @@ public class PerformanceTest extends AbstractProvisioningTest {
IQuery query = new QLContextQuery(IInstallableUnit.class, "" + //
"$0.traverse(set(), capabilityIndex(everything), _, {rqCache, index, parent | " + //
- "index.satisfiesAny(parent.requiredCapabilities.unique(rqCache).select(rc | rc.filter == null || $1 ~= filter(rc.filter)))})", roots, env);
+ "index.satisfiesAny(parent.requiredCapabilities.unique(rqCache).select(rc | rc.filter == null || $1 ~= rc.filter))})", roots, env);
long sliceTime = 0;
long traverseTime = 0;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/TestQueryReimplementation.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/TestQueryReimplementation.java
index 824602060..9a51eda88 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/TestQueryReimplementation.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/TestQueryReimplementation.java
@@ -10,11 +10,10 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ql;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.IExpression;
+import org.eclipse.equinox.p2.metadata.expression.IExpressionParser;
import org.eclipse.equinox.p2.ql.*;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
@@ -23,34 +22,34 @@ import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class TestQueryReimplementation extends AbstractProvisioningTest {
public static class UpdateQuery extends QLMatchQuery {
- private static final IMatchExpression expr1;
- private static final IMatchExpression expr2;
+ private static final IExpression expr1;
+ private static final IExpression expr2;
static {
- IExpressionParser parser = QL.newParser();
+ IQLParser parser = QL.newParser();
// This expression is used in case the updateFrom is an IInstallableUnitPatch
//
- expr1 = parser.parsePredicate("$0 ~= updateDescriptor && ($0.id != id || $0.version < version)");
+ expr1 = parser.parse("$0 ~= updateDescriptor && ($0.id != id || $0.version < version)");
// When updateFrom is not an IInstallableUnitPatch, we need to do one of two things depending
// on if the current item is an InstallableUnitPatch or not.
//
- expr2 = parser.parsePredicate("item ~= class('org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnitPatch')" + //
+ expr2 = parser.parse("this ~= class('org.eclipse.equinox.p2.metadata.IInstallableUnitPatch')" + //
"? $0 ~= lifeCycle" + //
": $0 ~= updateDescriptor && ($0.id != id || $0.version < version)");
}
public UpdateQuery(IInstallableUnit updateFrom) {
- super(IInstallableUnit.class, updateFrom instanceof IInstallableUnitPatch ? expr1 : expr2, new Object[] {updateFrom, IInstallableUnitPatch.class});
+ super(IInstallableUnit.class, QL.getFactory().matchExpression(updateFrom instanceof IInstallableUnitPatch ? expr1 : expr2, updateFrom, IInstallableUnitPatch.class));
}
}
public static class IUPropertyQuery extends QLMatchQuery {
- private static final IMatchExpression expr = QL.newParser().parsePredicate("properties[$0] == $1");
+ private static final IExpression expr = QL.newParser().parse("properties[$0] == $1");
public IUPropertyQuery(String propertyName, String propertyValue) {
- super(IInstallableUnit.class, expr, new Object[] {propertyName, propertyValue});
+ super(IInstallableUnit.class, QL.getFactory().matchExpression(expr, propertyName, propertyValue));
}
}
@@ -61,13 +60,13 @@ public class TestQueryReimplementation extends AbstractProvisioningTest {
*/
public static final QLMatchQuery ANY = new QLMatchQuery(IInstallableUnit.class, "");
- private static final IMatchExpression idVersionQuery;
- private static final IMatchExpression idRangeQuery;
+ private static final IExpression idVersionQuery;
+ private static final IExpression idRangeQuery;
static {
IExpressionParser parser = QL.newParser();
- idVersionQuery = parser.parsePredicate("($0 == null || $0 == id) && ($1 == null || $1 == version)");
- idRangeQuery = parser.parsePredicate("($0 == null || $0 == id) && ($1 == null || version ~= $1)");
+ idVersionQuery = parser.parse("($0 == null || $0 == id) && ($1 == null || $1 == version)");
+ idRangeQuery = parser.parse("($0 == null || $0 == id) && ($1 == null || version ~= $1)");
}
/**
@@ -88,7 +87,7 @@ public class TestQueryReimplementation extends AbstractProvisioningTest {
* @param range The version range to match
*/
public InstallableUnitQuery(String id, VersionRange range) {
- super(IInstallableUnit.class, idRangeQuery, new Object[] {id, range});
+ super(IInstallableUnit.class, QL.getFactory().matchExpression(idRangeQuery, id, range));
}
/**
@@ -99,7 +98,7 @@ public class TestQueryReimplementation extends AbstractProvisioningTest {
* @param version The precise version that a matching unit must have
*/
public InstallableUnitQuery(String id, Version version) {
- super(IInstallableUnit.class, idVersionQuery, new Object[] {id, version});
+ super(IInstallableUnit.class, QL.getFactory().matchExpression(idVersionQuery, id, version));
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF
index 9163524db..cf41929b8 100644
--- a/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF
@@ -27,6 +27,7 @@ Import-Package: com.ibm.icu.text,
org.eclipse.equinox.p2.engine,
org.eclipse.equinox.p2.engine.query,
org.eclipse.equinox.p2.metadata,
+ org.eclipse.equinox.p2.metadata.expression,
org.eclipse.equinox.p2.metadata.query,
org.eclipse.equinox.p2.operations,
org.eclipse.equinox.p2.query,
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java
index 4b09e7a8e..51e516a01 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java
@@ -19,8 +19,8 @@ import org.eclipse.equinox.internal.p2.ui.query.*;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IRequirement;
-import org.eclipse.equinox.p2.metadata.query.CategoryMemberQuery;
-import org.eclipse.equinox.p2.metadata.query.CategoryQuery;
+import org.eclipse.equinox.p2.metadata.expression.*;
+import org.eclipse.equinox.p2.metadata.query.*;
import org.eclipse.equinox.p2.operations.RepositoryTracker;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
@@ -153,15 +153,16 @@ public class QueryProvider {
// Querying of IU's. We are drilling down into the requirements.
if (element instanceof IIUElement && context.getShowInstallChildren()) {
Collection<IRequirement> reqs = ((IIUElement) element).getRequirements();
- @SuppressWarnings("unchecked")
- IQuery<IInstallableUnit>[] meetsAnyRequirementQuery = new IQuery[reqs.size()];
+ IExpression[] requirementExpressions = new IExpression[reqs.size()];
int i = 0;
for (IRequirement req : reqs) {
- meetsAnyRequirementQuery[i++] = req.getMatches();
+ requirementExpressions[i++] = req.getMatches();
}
+ IExpressionFactory factory = ExpressionUtil.getFactory();
+ IQuery<IInstallableUnit> meetsAnyRequirementQuery = new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class, factory.or(requirementExpressions));
IQuery<IInstallableUnit> visibleAsAvailableQuery = policy.getVisibleAvailableIUQuery();
@SuppressWarnings("unchecked")
- CompoundQuery<IInstallableUnit> createCompoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {visibleAsAvailableQuery, CompoundQuery.createCompoundQuery(meetsAnyRequirementQuery, false)}, true);
+ CompoundQuery<IInstallableUnit> createCompoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {visibleAsAvailableQuery, meetsAnyRequirementQuery}, true);
return new ElementQueryDescriptor(queryable, createCompoundQuery, new Collector<IInstallableUnit>(), new InstalledIUElementWrapper(queryable, element));
}
profile = ProvUI.getAdapter(element, IProfile.class);
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
index 27643bd17..dc12af6cc 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
@@ -10,11 +10,6 @@
******************************************************************************/
package org.eclipse.equinox.internal.p2.updatesite;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
-import org.eclipse.equinox.p2.metadata.IProvidedCapability;
-
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
@@ -22,10 +17,8 @@ import java.util.*;
import java.util.Map.Entry;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
-import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
-import org.eclipse.equinox.internal.p2.metadata.LDAPQuery;
import org.eclipse.equinox.internal.p2.metadata.query.LatestIUVersionQuery;
-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.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.*;
@@ -279,14 +272,14 @@ public class SiteXMLAction extends AbstractPublisherAction {
cat.setProperty(IInstallableUnit.PROP_NAME, label != null ? label : category.getName());
cat.setProperty(IInstallableUnit.PROP_DESCRIPTION, category.getDescription());
- ArrayList<IRequiredCapability> reqsConfigurationUnits = new ArrayList<IRequiredCapability>(featureIUs.size());
+ ArrayList<IRequirement> reqsConfigurationUnits = new ArrayList<IRequirement>(featureIUs.size());
for (IInstallableUnit iu : featureIUs) {
VersionRange range = new VersionRange(iu.getVersion(), true, iu.getVersion(), true);
- reqsConfigurationUnits.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), range, iu.getFilter() == null ? null : ((LDAPQuery) iu.getFilter()).getFilter(), false, false));
+ reqsConfigurationUnits.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), range, iu.getFilter(), false, false));
}
//note that update sites don't currently support nested categories, but it may be useful to add in the future
if (parentCategory != null) {
- reqsConfigurationUnits.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, parentCategory.getId(), VersionRange.emptyRange, parentCategory.getFilter() == null ? null : ((LDAPQuery) parentCategory.getFilter()).getFilter(), false, false));
+ reqsConfigurationUnits.add(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, parentCategory.getId(), VersionRange.emptyRange, parentCategory.getFilter(), false, false));
}
cat.setRequiredCapabilities(reqsConfigurationUnits.toArray(new IRequirement[reqsConfigurationUnits.size()]));

Back to the top