/******************************************************************************* * Copyright (c) 2013 Red Hat, 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: * Red Hat, Inc. - initial API and implementation *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.operations.RequestFlexer; import org.eclipse.equinox.p2.engine.*; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.planner.*; import org.eclipse.equinox.p2.tests.*; public class TestRequestFlexerSharedInstall extends AbstractProvisioningTest { @IUDescription(content = "package: sdk \n" + "singleton: true\n" + "version: 1 \n" + "depends: platform = 1") public IInstallableUnit sdk1; @IUDescription(content = "package: platform \n" + "singleton: true\n" + "version: 1 \n") public IInstallableUnit platform1; @IUDescription(content = "package: sdk \n" + "singleton: true\n" + "version: 2 \n" + "depends: platform = 2") public IInstallableUnit sdk2; @IUDescription(content = "package: platform \n" + "singleton: true\n" + "version: 2 \n") public IInstallableUnit platform2; @IUDescription(content = "package: egit \n" + "singleton: true\n" + "version: 1 \n" + "depends: platform = 1") public IInstallableUnit egit1; @IUDescription(content = "package: egit \n" + "singleton: true\n" + "version: 2 \n" + "depends: platform = 2") public IInstallableUnit egit2; @IUDescription(content = "package: svn1 \n" + "singleton: true\n" + "version: 1 \n" + "depends: platform = 1") public IInstallableUnit svn1; @IUDescription(content = "package: svn2 \n" + "singleton: true\n" + "version: 2 \n" + "depends: platform = 2") public IInstallableUnit svn2; IProfile profile; private IPlanner planner; private IEngine engine; private IProfileChangeRequest originalRequest; private ProvisioningContext context; @Override protected void setUp() throws Exception { super.setUp(); profile = createProfile("TestProfile." + getName()); IULoader.loadIUs(this); createTestMetdataRepository(new IInstallableUnit[] {sdk1, platform1, sdk2, platform2, egit1, egit2}); planner = createPlanner(); engine = createEngine(); assertOK(installAsRootsAndFlaggedAsBase(profile, new IInstallableUnit[] {sdk1}, true, planner, engine)); originalRequest = planner.createChangeRequest(profile); originalRequest.add(egit2); originalRequest.setInstallableUnitInclusionRules(egit2, ProfileInclusionRules.createStrictInclusionRule(egit2)); assertNotOK(planner.getProvisioningPlan(originalRequest, context, null).getStatus()); } @Override protected void tearDown() throws Exception { super.tearDown(); getProfileRegistry().removeProfile(profile.getProfileId()); } public void testBaseBlocked() { RequestFlexer av = new RequestFlexer(planner); av.setAllowPartialInstall(false); av.setAllowDifferentVersion(false); av.setAllowInstalledElementRemoval(true); av.setAllowInstalledElementChange(true); av.setProvisioningContext(context); IProfileChangeRequest realRequest = av.getChangeRequest(originalRequest, profile, new NullProgressMonitor()); //Even though we allow for the base to change (removal and change), there is no solution because it is a shared install //and thus the roots from the base are immutable assertNull(realRequest); } }