diff options
author | Pascal Rapicault | 2009-12-17 15:22:54 +0000 |
---|---|---|
committer | Pascal Rapicault | 2009-12-17 15:22:54 +0000 |
commit | 05d2b20f5b78107ed8b356d8472f760449465d38 (patch) | |
tree | 57797b20c81de059201cd774128380c578c4735c /bundles | |
parent | 04f5301650b6282ba510b3d490dc1f185d842ff0 (diff) | |
download | rt.equinox.p2-05d2b20f5b78107ed8b356d8472f760449465d38.tar.gz rt.equinox.p2-05d2b20f5b78107ed8b356d8472f760449465d38.tar.xz rt.equinox.p2-05d2b20f5b78107ed8b356d8472f760449465d38.zip |
Remove code dependency on createCustomPlan
Diffstat (limited to 'bundles')
11 files changed, 160 insertions, 28 deletions
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 ede46a407..977715789 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 @@ -343,6 +343,8 @@ public class SimplePlanner implements IPlanner { } public IProvisioningPlan getProvisioningPlan(ProfileChangeRequest profileChangeRequest, ProvisioningContext context, IProgressMonitor monitor) { + if (profileChangeRequest.getAbsolute()) + return generateAbsoluteProvisioningPlan(profileChangeRequest, context, monitor); SubMonitor sub = SubMonitor.convert(monitor, ExpandWork); sub.setTaskName(Messages.Director_Task_Resolving_Dependencies); try { @@ -367,6 +369,28 @@ public class SimplePlanner implements IPlanner { } } + private IProvisioningPlan generateAbsoluteProvisioningPlan(ProfileChangeRequest profileChangeRequest, ProvisioningContext context, IProgressMonitor monitor) { + Collection toState = new HashSet(profileChangeRequest.getProfile().query(InstallableUnitQuery.ANY, null).toCollection()); + + toState.removeAll(Arrays.asList(profileChangeRequest.getRemovedInstallableUnits())); + toState.addAll(Arrays.asList(profileChangeRequest.getAddedInstallableUnits())); + + InstallableUnitOperand[] iuOperands = generateOperations(profileChangeRequest.getProfile().query(InstallableUnitQuery.ANY, null).toCollection(), toState); + PropertyOperand[] propertyOperands = generatePropertyOperations(profileChangeRequest); + + Operand[] operands = new Operand[iuOperands.length + propertyOperands.length]; + System.arraycopy(iuOperands, 0, operands, 0, iuOperands.length); + System.arraycopy(propertyOperands, 0, operands, iuOperands.length, propertyOperands.length); + + if (DEBUG) { + for (int i = 0; i < operands.length; i++) { + Tracing.debug(operands[i].toString()); + } + } + return new ProvisioningPlan(Status.OK_STATUS, operands, computeActualChangeRequest(toState, profileChangeRequest), null, null, profileChangeRequest.getProfile(), new QueryableArray((IInstallableUnit[]) toState.toArray(new IInstallableUnit[toState.size()])), context); + + } + //Verify that all the meta requirements necessary to perform the uninstallation (if necessary) and all t private Collection areMetaRequirementsSatisfied(IProfile oldProfile, Collection newProfile, IProvisioningPlan initialPlan) { Collection allMetaRequirements = extractMetaRequirements(newProfile, initialPlan); diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java index 0c74e6039..064bf1d01 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java @@ -26,6 +26,7 @@ public class ProfileChangeRequest implements Cloneable { private HashMap propertiesToAdd = null; // map of key->value for properties to be added private HashMap iuPropertiesToAdd = null; // map iu->map of key->value pairs for properties to be added for an iu private HashMap iuPropertiesToRemove = null; // map of iu->list of property keys to be removed for an iu + private boolean isAbsolute = false; //Indicate whether or not the request is an absolute one public static ProfileChangeRequest createByProfileId(String profileId) { IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(DirectorActivator.context, IProfileRegistry.SERVICE_NAME); @@ -171,6 +172,14 @@ public class ProfileChangeRequest implements Cloneable { keys.add(SimplePlanner.INCLUSION_RULES); } + public void setAbsoluteMode(boolean absolute) { + isAbsolute = absolute; + } + + public boolean getAbsolute() { + return isAbsolute; + } + public Object clone() { ProfileChangeRequest result = new ProfileChangeRequest(profile); result.iusToRemove = iusToRemove == null ? null : (ArrayList) iusToRemove.clone(); diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java index 7df20f566..0aa816050 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java @@ -21,6 +21,7 @@ import org.eclipse.equinox.internal.p2.operations.*; import org.eclipse.equinox.internal.provisional.configurator.Configurator; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; 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.query.*; import org.eclipse.equinox.p2.core.IAgentLocation; import org.eclipse.equinox.p2.core.IProvisioningAgent; @@ -201,8 +202,8 @@ public class ProvisioningSession { else set = phaseSet; - // 300 ticks for download, 100 to install handlers, 100 to install the rest - SubMonitor mon = SubMonitor.convert(monitor, 500); + // 300 ticks for download, 100 to install handlers, 100 to compute the plan, 100 to install the rest + SubMonitor mon = SubMonitor.convert(monitor, 600); int ticksUsed = 0; // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=272355 @@ -215,12 +216,12 @@ public class ProvisioningSession { // If the phase set calls for download and install, then we want to download everything atomically before // applying the install plan. This way, we can be sure to install the install handler only if we know // we will be able to get everything else. - List allOperands = new ArrayList(); - allOperands.addAll(Arrays.asList(plan.getOperands())); - allOperands.addAll(Arrays.asList(plan.getInstallerPlan().getOperands())); - Operand[] downloadOperands = (Operand[]) allOperands.toArray(new Operand[allOperands.size()]); + ProfileChangeRequest downloadRequest = new ProfileChangeRequest(profile); + downloadRequest.setAbsoluteMode(true); + downloadRequest.addInstallableUnits((IInstallableUnit[]) new CompoundQueryable(new IQueryable[] {plan.getAdditions(), plan.getInstallerPlan().getAdditions()}).query(InstallableUnitQuery.ANY, null).toArray(IInstallableUnit.class)); + PhaseSet download = new DownloadPhaseSet(); - IProvisioningPlan downloadPlan = getEngine().createCustomPlan(profile, downloadOperands, context); + IProvisioningPlan downloadPlan = getPlanner().getProvisioningPlan(downloadRequest, context, mon.newChild(100)); IStatus downloadStatus = getEngine().perform(downloadPlan, download, mon.newChild(300)); if (!downloadStatus.isOK()) { mon.done(); diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java index 7d3317abd..8b290e814 100644 --- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java +++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java @@ -81,8 +81,7 @@ public class ProfileSynchronizer { String updatedCacheExtensions = synchronizeCacheExtensions(); if (request == null) { if (updatedCacheExtensions != null) { - Operand operand = new PropertyOperand(CACHE_EXTENSIONS, null, updatedCacheExtensions); - IStatus engineResult = executeOperands(new Operand[] {operand}, context, null); + IStatus engineResult = setProperty(CACHE_EXTENSIONS, updatedCacheExtensions, context, null); if (engineResult.getSeverity() != IStatus.ERROR && engineResult.getSeverity() != IStatus.CANCEL) writeTimestamps(); return engineResult; @@ -424,16 +423,21 @@ public class ProfileSynchronizer { } } - private IStatus executeOperands(Operand[] operands, ProvisioningContext provisioningContext, IProgressMonitor monitor) { + private IStatus setProperty(String key, String value, ProvisioningContext provisioningContext, IProgressMonitor monitor) { BundleContext context = Activator.getContext(); ServiceReference reference = context.getServiceReference(IEngine.SERVICE_NAME); IEngine engine = (IEngine) context.getService(reference); + ServiceReference plannerReference = context.getServiceReference(IPlanner.SERVICE_NAME); + IPlanner planner = (IPlanner) context.getService(reference); try { + ProfileChangeRequest addPropertyRequest = new ProfileChangeRequest(profile); + addPropertyRequest.setProfileProperty(key, value); + IProvisioningPlan plan = planner.getProvisioningPlan(addPropertyRequest, provisioningContext, monitor); IPhaseSet phaseSet = engine.createPhaseSetExcluding(new String[] {IPhaseSet.PHASE_COLLECT, IPhaseSet.PHASE_CHECK_TRUST}); - IProvisioningPlan plan = engine.createCustomPlan(profile, operands, provisioningContext); return engine.perform(plan, phaseSet, monitor); } finally { context.ungetService(reference); + context.ungetService(plannerReference); } } 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 96a37a4f2..30434d6c8 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 @@ -21,6 +21,7 @@ Import-Package: org.eclipse.core.runtime;version="3.4.0", org.eclipse.equinox.internal.p2.repository.helpers, org.eclipse.equinox.internal.provisional.p2.artifact.repository, org.eclipse.equinox.internal.provisional.p2.core, + org.eclipse.equinox.internal.provisional.p2.director, org.eclipse.equinox.internal.provisional.p2.metadata, org.eclipse.equinox.internal.provisional.p2.metadata.query, org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository, diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java index c02fa614a..cf409e35e 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java @@ -18,6 +18,7 @@ public class Messages extends NLS { public static String exception_unableToRemoveRepo; public static String exception_notLocalFileRepo; public static String exception_noEngineService; + public static String exception_noPlannerService; public static String exception_needIUsOrNonEmptyRepo; public static String exception_needDestinationRepo; public static String exception_onlyOneComparator; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java index b432b2542..4772d6e44 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java @@ -19,6 +19,8 @@ import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.*; import org.eclipse.equinox.internal.p2.engine.phases.Collect; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +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.query.InstallableUnitQuery; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.engine.*; @@ -117,21 +119,21 @@ public class Repo2Runnable extends AbstractApplication implements IApplication { // figure out which IUs we need to process collectIUs(progress.newChild(1)); - // create the operands from the list of IUs - InstallableUnitOperand[] operands = new InstallableUnitOperand[processedIUs.size()]; - int i = 0; - for (Iterator iter = processedIUs.iterator(); iter.hasNext();) - operands[i++] = new InstallableUnitOperand(null, (IInstallableUnit) iter.next()); - // call the engine with only the "collect" phase so all we do is download IProfile profile = createProfile(); try { + ProfileChangeRequest request = new ProfileChangeRequest(profile); + request.setAbsoluteMode(true); + request.addInstallableUnits((IInstallableUnit[]) processedIUs.toArray(new IInstallableUnit[processedIUs.size()])); ProvisioningContext context = new ProvisioningContext(); IEngine engine = (IEngine) ServiceHelper.getService(Activator.getBundleContext(), IEngine.SERVICE_NAME); if (engine == null) throw new ProvisionException(Messages.exception_noEngineService); + IPlanner planner = (IPlanner) ServiceHelper.getService(Activator.getBundleContext(), IPlanner.SERVICE_NAME); + if (planner == null) + throw new ProvisionException(Messages.exception_noPlannerService); - IProvisioningPlan plan = engine.createCustomPlan(profile, operands, context); + IProvisioningPlan plan = planner.getProvisioningPlan(request, context, monitor); IStatus result = engine.perform(plan, getPhaseSet(), progress.newChild(1)); PhaseSet nativeSet = getNativePhase(); if (nativeSet != null) diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties index ce9f91e1b..0ad7c54a7 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties @@ -41,6 +41,7 @@ exception_invalidSource=Invalid source repository location: {0}. exception_unableToRemoveRepo=Unable to remove artifact repository file: {0}. exception_notLocalFileRepo= {0} is not a local file based repository. exception_noEngineService=Unable to acquire engine service. +exception_noPlannerService=Unable to acquire planner service. exception_needIUsOrNonEmptyRepo=Need to specify either a non-empty source metadata repository or a valid list of IUs. exception_needDestinationRepo=Need to set the destination artifact repository location. exception_onlyOneComparator=Only one comparator should be defined. diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java new file mode 100644 index 000000000..40b53d3e0 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java @@ -0,0 +1,80 @@ +package org.eclipse.equinox.p2.tests.planner; + +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +public class AbsolutePlanTest extends AbstractProvisioningTest { + public void testAddAndRemoveIU() { + IProfile profile = createProfile(getName()); + ProfileChangeRequest pcr = new ProfileChangeRequest(profile); + pcr.setAbsoluteMode(true); + IInstallableUnit iuA = createEclipseIU("A"); + pcr.addInstallableUnits(new IInstallableUnit[] {iuA, createEclipseIU("B"), createEclipseIU("C")}); + IPlanner planner = createPlanner(); + IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(), null); + assertEquals(3, countPlanElements(plan)); + createEngine().perform(plan, null); + + ProfileChangeRequest removeRequest = new ProfileChangeRequest(profile); + removeRequest.setAbsoluteMode(true); + removeRequest.removeInstallableUnits(new IInstallableUnit[] {iuA}); + assertEquals(1, countPlanElements(planner.getProvisioningPlan(removeRequest, new ProvisioningContext(), null))); + } + + public void testAddAndRemoveProperty() { + IInstallableUnit iuA = createEclipseIU("A"); + IProfile profile = createProfile(getName()); + + ProfileChangeRequest pcr = new ProfileChangeRequest(profile); + pcr.setAbsoluteMode(true); + pcr.addInstallableUnits(new IInstallableUnit[] {iuA}); + pcr.setInstallableUnitProfileProperty(iuA, "key", "value"); + + IPlanner planner = createPlanner(); + IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(), null); + assertEquals(1, countPlanElements(plan)); + createEngine().perform(plan, null); + + Operand[] ops = plan.getOperands(); + boolean found = false; + for (int i = 0; i < ops.length; i++) { + if (ops[i] instanceof InstallableUnitPropertyOperand) + found = true; + } + assertTrue(found); + + ProfileChangeRequest removeRequest = new ProfileChangeRequest(profile); + removeRequest.setAbsoluteMode(true); + removeRequest.removeInstallableUnits(new IInstallableUnit[] {iuA}); + removeRequest.removeInstallableUnitProfileProperty(iuA, "key"); + + assertEquals(1, countPlanElements(planner.getProvisioningPlan(removeRequest, new ProvisioningContext(), null))); + } + + public void testAddProperty() { + IProfile profile = createProfile(getName()); + + ProfileChangeRequest pcr = new ProfileChangeRequest(profile); + pcr.setAbsoluteMode(true); + pcr.setProfileProperty("foo", "bar"); + + IPlanner planner = createPlanner(); + IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(), null); + createEngine().perform(plan, null); + + assertEquals("bar", getProfileRegistry().getProfile(getName()).getProperty("foo")); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java index 248701c07..c2555de8d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java @@ -19,6 +19,7 @@ public class AllTests extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(AllTests.class.getName()); + suite.addTestSuite(AbsolutePlanTest.class); suite.addTestSuite(ActualChangeRequestTest.class); suite.addTestSuite(ActualChangeRequestTest2.class); suite.addTestSuite(AdditionalConstraints.class); 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 6d2d20e17..15f5b831c 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 @@ -46,23 +46,31 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest { } public void testRemoveUnresolvedIU() { - final Operand[] operands = new Operand[] {new InstallableUnitOperand(null, a1), new InstallableUnitPropertyOperand(a1, "org.eclipse.equinox.p2.internal.inclusion.rules", null, "STRICT")}; + ProfileChangeRequest request = new ProfileChangeRequest(profile); + request.setAbsoluteMode(true); + request.addInstallableUnits(new IInstallableUnit[] {a1}); + request.setInstallableUnitInclusionRules(a1, PlannerHelper.createStrictInclusionRule(a1)); final ProvisioningContext context = new ProvisioningContext(new URI[0]); - assertEquals(IStatus.OK, engine.perform(engine.createCustomPlan(profile, operands, context), new NullProgressMonitor()).getSeverity()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); + assertEquals(IStatus.OK, engine.perform(plan, new NullProgressMonitor()).getSeverity()); assertTrue(profile.query(InstallableUnitQuery.ANY, null).toCollection().contains(a1)); ProfileChangeRequest req = new ProfileChangeRequest(profile); req.removeInstallableUnits(new IInstallableUnit[] {a1}); - IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); - assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - assertEquals(IStatus.OK, PlanExecutionHelper.executePlan(plan, engine, context, new NullProgressMonitor()).getSeverity()); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req, null, null); + assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); + assertEquals(IStatus.OK, PlanExecutionHelper.executePlan(plan2, engine, context, new NullProgressMonitor()).getSeverity()); assertFalse(profile.query(InstallableUnitQuery.ANY, null).toCollection().contains(a1)); } public void testAvailableVsQueryInProfile() { - final Operand[] operands = new Operand[] {new InstallableUnitOperand(null, c1), new InstallableUnitPropertyOperand(c1, "org.eclipse.equinox.p2.internal.inclusion.rules", null, "STRICT")}; + ProfileChangeRequest request = new ProfileChangeRequest(profile); + request.setAbsoluteMode(true); + request.addInstallableUnits(new IInstallableUnit[] {c1}); + request.setInstallableUnitInclusionRules(c1, PlannerHelper.createStrictInclusionRule(c1)); final ProvisioningContext context = new ProvisioningContext(new URI[0]); - assertEquals(IStatus.OK, engine.perform(engine.createCustomPlan(profile, operands, context), new NullProgressMonitor()).getSeverity()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); + assertEquals(IStatus.OK, engine.perform(plan, new NullProgressMonitor()).getSeverity()); assertTrue(profile.query(InstallableUnitQuery.ANY, null).toCollection().contains(c1)); IProfile availableWrapper = new IProfile() { @@ -108,10 +116,10 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest { ProfileChangeRequest req = new ProfileChangeRequest(availableWrapper); req.addInstallableUnits(new IInstallableUnit[] {a1}); - IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); - assertEquals(IStatus.OK, plan.getStatus().getSeverity()); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req, null, null); + assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); //expect to have both (a1+inclusion rule) and b1 added - assertEquals(2, countPlanElements(plan)); + assertEquals(2, countPlanElements(plan2)); } } |