summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault (JBoss)2013-05-24 12:14:01 (EDT)
committerPascal Rapicault2013-05-27 17:06:46 (EDT)
commit8790c9065bb0d12eb6ff26c02b4da43e86a73e2d (patch)
tree020b2c1f6a341a7d25df6d8b46ff37ac6e29a4bd
parent51ac489b776bbc5eecf11f366ae1297c23d395ca (diff)
downloadrt.equinox.p2-8790c9065bb0d12eb6ff26c02b4da43e86a73e2d.zip
rt.equinox.p2-8790c9065bb0d12eb6ff26c02b4da43e86a73e2d.tar.gz
rt.equinox.p2-8790c9065bb0d12eb6ff26c02b4da43e86a73e2d.tar.bz2
Bug 408996 - Product detection should go over all IUsI20130527-2000
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllRequestFlexerTests.java (renamed from bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllAnyVersionTests.java)9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProduct.java45
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProduct2.java105
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProductWithLegacyMarkup.java120
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProductWithMixedMarkup.java120
7 files changed, 399 insertions, 17 deletions
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java
index fc1b1a3..f12067d 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java
@@ -16,7 +16,6 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery;
-import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
@@ -414,11 +413,22 @@ public class RequestFlexer {
if (!hasProduct())
return true;
//At this point we know we had a product installed and we want to make sure there is one in the resulting solution
- return !intermediaryPlan.getFutureState().query(QueryUtil.createIUProductQuery(), new NullProgressMonitor()).isEmpty();
+ if (!intermediaryPlan.getFutureState().query(QueryUtil.createIUProductQuery(), new NullProgressMonitor()).isEmpty())
+ return true;
+ //Support for legacy identification of product using the lineUp.
+ if (!intermediaryPlan.getFutureState().query(QueryUtil.createIUPropertyQuery("lineUp", "true"), new NullProgressMonitor()).isEmpty()) //$NON-NLS-1$//$NON-NLS-2$
+ return true;
+ return false;
}
private boolean hasProduct() {
- return !profile.available(new UserVisibleRootQuery(), new NullProgressMonitor()).query(QueryUtil.createIUPropertyQuery(MetadataFactory.InstallableUnitDescription.PROP_TYPE_PRODUCT, Boolean.TRUE.toString()), new NullProgressMonitor()).isEmpty();
+ if (!profile.available(QueryUtil.createIUProductQuery(), new NullProgressMonitor()).isEmpty()) {
+ return true;
+ }
+ //Support for legacy identification of product using the lineUp.
+ if (!profile.available(QueryUtil.createIUPropertyQuery("lineUp", "true"), new NullProgressMonitor()).isEmpty()) //$NON-NLS-1$//$NON-NLS-2$
+ return true;
+ return false;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllAnyVersionTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllRequestFlexerTests.java
index b3c3175..0d78d63 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllAnyVersionTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllRequestFlexerTests.java
@@ -12,15 +12,18 @@ package org.eclipse.equinox.p2.tests.planner;
import junit.framework.*;
-public class AllAnyVersionTests extends TestCase {
+public class AllRequestFlexerTests extends TestCase {
public static Test suite() {
- TestSuite suite = new TestSuite(AllAnyVersionTests.class.getName());
+ TestSuite suite = new TestSuite(AllRequestFlexerTests.class.getName());
suite.addTestSuite(TestRequestFlexerIUProperties.class);
suite.addTestSuite(TestRequestFlexerOneInstalledOneBeingInstalled.class);
suite.addTestSuite(TestRequestFlexerOneInstalledReplacingIt.class);
suite.addTestSuite(TestRequestFlexerOneInstalledTwoBeingInstalled.class);
- // suite.addTestSuite(TestRequestFlexerProduct.class);
+ suite.addTestSuite(TestRequestFlexerProduct.class);
+ suite.addTestSuite(TestRequestFlexerProduct2.class);
+ suite.addTestSuite(TestRequestFlexerProductWithLegacyMarkup.class);
+ suite.addTestSuite(TestRequestFlexerProductWithMixedMarkup.class);
suite.addTestSuite(TestRequestFlexerRequestWithOptionalInstall.class);
suite.addTestSuite(TestRequestFlexerRequestWithRemoval.class);
suite.addTestSuite(TestRequestFlexerSharedInstall.class);
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 f4196a7..4188b94 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
@@ -29,6 +29,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(AgentPlanTestInExternalInstanceForCohostedMode.class);
suite.addTestSuite(AllOptional.class);
suite.addTestSuite(AllOrbit.class);
+ suite.addTest(AllRequestFlexerTests.suite());
suite.addTestSuite(AnotherSingleton.class);
suite.addTestSuite(Bug207319.class);
suite.addTestSuite(Bug249605.class);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProduct.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProduct.java
index a1ab360..4d98fcd 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProduct.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProduct.java
@@ -35,11 +35,8 @@ public class TestRequestFlexerProduct extends AbstractProvisioningTest {
@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;
+ @IUDescription(content = "package: eppPackage \n" + "singleton: true\n" + "version: 2 \n" + "depends: SDK = 2")
+ public IInstallableUnit eppPackage;
IProfile profile;
@@ -53,24 +50,30 @@ public class TestRequestFlexerProduct extends AbstractProvisioningTest {
private void setupSDK1() {
IRequirement[] reqPlatform1 = new IRequirement[1];
- reqPlatform1[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "platform", new VersionRange("[1.0.0,1.0.0]"), null, true, false, true);
- sdk1 = createIU("SDK", Version.create("1.0.0"), null, reqPlatform1, new IProvidedCapability[0], new Properties(), null, null, true);
+ reqPlatform1[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "platform", new VersionRange("[1.0.0,1.0.0]"), null, false, false, true);
+ Properties p = new Properties();
+ p.setProperty(MetadataFactory.InstallableUnitDescription.PROP_TYPE_PRODUCT, Boolean.TRUE.toString());
+ sdk1 = createIU("SDK", Version.create("1.0.0"), null, reqPlatform1, new IProvidedCapability[0], p, null, null, true);
}
private void setupSDK2() {
IRequirement[] reqPlatform1 = new IRequirement[1];
- reqPlatform1[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "platform", new VersionRange("[2.0.0,2.0.0]"), null, true, false, true);
- sdk2 = createIU("SDK", Version.create("2.0.0"), null, reqPlatform1, new IProvidedCapability[0], new Properties(), null, null, true);
+ reqPlatform1[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "platform", new VersionRange("[2.0.0,2.0.0]"), null, false, false, true);
+ Properties p = new Properties();
+ p.setProperty(MetadataFactory.InstallableUnitDescription.PROP_TYPE_PRODUCT, Boolean.TRUE.toString());
+ IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor("SDK", new VersionRange("[1.0.0,2.0.0)"), 0, "description");
+ sdk2 = createIU("SDK", Version.create("2.0.0"), null, reqPlatform1, new IProvidedCapability[0], p, null, null, true, update, null);
}
@Override
protected void setUp() throws Exception {
super.setUp();
+ context = new ProvisioningContext(getAgent());
profile = createProfile("TestProfile." + getName());
IULoader.loadIUs(this);
setupSDK1();
setupSDK2();
- createTestMetdataRepository(new IInstallableUnit[] {sdk1, platform1, sdk2, platform2, egit1, egit2});
+ createTestMetdataRepository(new IInstallableUnit[] {sdk1, platform1, sdk2, platform2, egit1, egit2, eppPackage});
planner = createPlanner();
engine = createEngine();
assertOK(installAsRoots(profile, new IInstallableUnit[] {sdk1}, true, planner, engine));
@@ -105,7 +108,7 @@ public class TestRequestFlexerProduct extends AbstractProvisioningTest {
RequestFlexer av = new RequestFlexer(planner);
av.setAllowPartialInstall(false);
av.setAllowDifferentVersion(false);
- av.setAllowInstalledElementRemoval(true);
+ av.setAllowInstalledElementRemoval(false);
av.setAllowInstalledElementChange(true);
av.setProvisioningContext(context);
IProfileChangeRequest realRequest = av.getChangeRequest(originalRequest, profile, new NullProgressMonitor());
@@ -114,4 +117,24 @@ public class TestRequestFlexerProduct extends AbstractProvisioningTest {
assertTrue(realRequest.getAdditions().contains(egit2));
assertTrue(realRequest.getAdditions().contains(sdk2));
}
+
+ public void testProductNotAsRoot() {
+ RequestFlexer av = new RequestFlexer(planner);
+ av.setAllowPartialInstall(false);
+ av.setAllowDifferentVersion(false);
+ av.setAllowInstalledElementRemoval(true);
+ av.setAllowInstalledElementChange(true);
+ av.setProvisioningContext(context);
+
+ //Here we don't use the originalPRofileChangeRequest
+ IProfileChangeRequest specialRequest = planner.createChangeRequest(profile);
+ specialRequest.add(eppPackage);
+ specialRequest.setInstallableUnitInclusionRules(eppPackage, ProfileInclusionRules.createStrictInclusionRule(eppPackage));
+
+ IProfileChangeRequest realRequest = av.getChangeRequest(specialRequest, profile, new NullProgressMonitor());
+
+ //Check that we can update to something that is not flagged as product
+ assertTrue(realRequest.getAdditions().contains(eppPackage));
+ assertTrue(realRequest.getAdditions().contains(sdk2));
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProduct2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProduct2.java
new file mode 100644
index 0000000..d8a7502
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProduct2.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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 java.util.Properties;
+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.*;
+import org.eclipse.equinox.p2.planner.*;
+import org.eclipse.equinox.p2.query.QueryUtil;
+import org.eclipse.equinox.p2.tests.*;
+
+public class TestRequestFlexerProduct2 extends AbstractProvisioningTest {
+ public IInstallableUnit sdk1;
+
+ @IUDescription(content = "package: platform \n" + "singleton: true\n" + "version: 1 \n")
+ public IInstallableUnit platform1;
+
+ public IInstallableUnit sdk2;
+
+ @IUDescription(content = "package: platform \n" + "singleton: true\n" + "version: 2 \n")
+ public IInstallableUnit platform2;
+
+ @IUDescription(content = "package: eppPackage \n" + "singleton: true\n" + "version: 1 \n" + "depends: SDK = 1")
+ public IInstallableUnit eppPackage1;
+
+ @IUDescription(content = "package: eppPackage \n" + "singleton: true\n" + "version: 2 \n" + "depends: SDK = 2")
+ public IInstallableUnit eppPackage2;
+
+ IProfile profile;
+
+ private IPlanner planner;
+
+ private IEngine engine;
+
+ private ProvisioningContext context;
+
+ private void setupSDK1() {
+ IRequirement[] reqPlatform1 = new IRequirement[1];
+ reqPlatform1[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "platform", new VersionRange("[1.0.0,1.0.0]"), null, false, false, true);
+ Properties p = new Properties();
+ p.setProperty(MetadataFactory.InstallableUnitDescription.PROP_TYPE_PRODUCT, Boolean.TRUE.toString());
+ sdk1 = createIU("SDK", Version.create("1.0.0"), null, reqPlatform1, new IProvidedCapability[0], p, null, null, true);
+ }
+
+ private void setupSDK2() {
+ IRequirement[] reqPlatform1 = new IRequirement[1];
+ reqPlatform1[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "platform", new VersionRange("[2.0.0,2.0.0]"), null, false, false, true);
+ Properties p = new Properties();
+ p.setProperty(MetadataFactory.InstallableUnitDescription.PROP_TYPE_PRODUCT, Boolean.TRUE.toString());
+ IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor("SDK", new VersionRange("[1.0.0,2.0.0)"), 0, "description");
+ sdk2 = createIU("SDK", Version.create("2.0.0"), null, reqPlatform1, new IProvidedCapability[0], p, null, null, true, update, null);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ context = new ProvisioningContext(getAgent());
+ profile = createProfile("TestProfile." + getName());
+ IULoader.loadIUs(this);
+ setupSDK1();
+ setupSDK2();
+ createTestMetdataRepository(new IInstallableUnit[] {sdk1, platform1, sdk2, platform2, eppPackage1, eppPackage2});
+ planner = createPlanner();
+ engine = createEngine();
+ assertOK(installAsRoots(profile, new IInstallableUnit[] {eppPackage1}, true, planner, engine));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ getProfileRegistry().removeProfile(profile.getProfileId());
+ }
+
+ public void testReplaceNonRootProduct() {
+ RequestFlexer av = new RequestFlexer(planner);
+ av.setAllowPartialInstall(false);
+ av.setAllowDifferentVersion(false);
+ av.setAllowInstalledElementRemoval(true);
+ av.setAllowInstalledElementChange(true);
+ av.setProvisioningContext(context);
+
+ //Here we don't use the originalPRofileChangeRequest
+ IProfileChangeRequest specialRequest = planner.createChangeRequest(profile);
+ specialRequest.add(eppPackage2);
+ specialRequest.setInstallableUnitInclusionRules(eppPackage2, ProfileInclusionRules.createStrictInclusionRule(eppPackage2));
+
+ IProfileChangeRequest realRequest = av.getChangeRequest(specialRequest, profile, new NullProgressMonitor());
+
+ //Check that we can update to something that is not flagged as product
+ assertTrue(realRequest.getAdditions().contains(eppPackage2));
+
+ assertFalse(getPlanner(getAgent()).getProvisioningPlan(realRequest, context, new NullProgressMonitor()).getAdditions().query(QueryUtil.createIUQuery("SDK", Version.create("2.0.0")), new NullProgressMonitor()).isEmpty());
+
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProductWithLegacyMarkup.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProductWithLegacyMarkup.java
new file mode 100644
index 0000000..c4a9fed
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProductWithLegacyMarkup.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * 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 java.util.Properties;
+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.*;
+import org.eclipse.equinox.p2.planner.*;
+import org.eclipse.equinox.p2.tests.*;
+
+public class TestRequestFlexerProductWithLegacyMarkup extends AbstractProvisioningTest {
+ public IInstallableUnit sdk1;
+
+ @IUDescription(content = "package: platform \n" + "singleton: true\n" + "version: 1 \n")
+ public IInstallableUnit platform1;
+
+ 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: eppPackage \n" + "singleton: true\n" + "version: 2 \n" + "depends: SDK = 2")
+ public IInstallableUnit eppPackage;
+
+ IProfile profile;
+
+ private IPlanner planner;
+
+ private IEngine engine;
+
+ private IProfileChangeRequest originalRequest;
+
+ private ProvisioningContext context;
+
+ private void setupSDK1() {
+ IRequirement[] reqPlatform1 = new IRequirement[1];
+ reqPlatform1[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "platform", new VersionRange("[1.0.0,1.0.0]"), null, false, false, true);
+ Properties p = new Properties();
+ p.setProperty("lineUp", Boolean.TRUE.toString());
+ sdk1 = createIU("SDK", Version.create("1.0.0"), null, reqPlatform1, new IProvidedCapability[0], p, null, null, true);
+ }
+
+ private void setupSDK2() {
+ IRequirement[] reqPlatform1 = new IRequirement[1];
+ reqPlatform1[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "platform", new VersionRange("[2.0.0,2.0.0]"), null, false, false, true);
+ Properties p = new Properties();
+ p.setProperty(MetadataFactory.InstallableUnitDescription.PROP_TYPE_PRODUCT, Boolean.TRUE.toString());
+ IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor("SDK", new VersionRange("[1.0.0,2.0.0)"), 0, "description");
+ sdk2 = createIU("SDK", Version.create("2.0.0"), null, reqPlatform1, new IProvidedCapability[0], p, null, null, true, update, null);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ context = new ProvisioningContext(getAgent());
+ profile = createProfile("TestProfile." + getName());
+ IULoader.loadIUs(this);
+ setupSDK1();
+ setupSDK2();
+ createTestMetdataRepository(new IInstallableUnit[] {sdk1, platform1, sdk2, platform2, egit1, egit2, eppPackage});
+ planner = createPlanner();
+ engine = createEngine();
+ assertOK(installAsRoots(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());
+
+ }
+
+ public void testProductRemovalIsDetected() {
+ RequestFlexer av = new RequestFlexer(planner);
+ av.setAllowPartialInstall(false);
+ av.setAllowDifferentVersion(false);
+ av.setAllowInstalledElementRemoval(true);
+ av.setAllowInstalledElementChange(false);
+ av.setProvisioningContext(context);
+ IProfileChangeRequest realRequest = av.getChangeRequest(originalRequest, profile, new NullProgressMonitor());
+
+ //There is no solution because with the given criteria, it would remove the product
+ assertNull(realRequest);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ getProfileRegistry().removeProfile(profile.getProfileId());
+ }
+
+ public void testProductNewProduct() {
+ RequestFlexer av = new RequestFlexer(planner);
+ av.setAllowPartialInstall(false);
+ av.setAllowDifferentVersion(false);
+ av.setAllowInstalledElementRemoval(false);
+ av.setAllowInstalledElementChange(true);
+ av.setProvisioningContext(context);
+ IProfileChangeRequest realRequest = av.getChangeRequest(originalRequest, profile, new NullProgressMonitor());
+
+ //In this case we can update the base, so we will find sdk2
+ assertTrue(realRequest.getAdditions().contains(egit2));
+ assertTrue(realRequest.getAdditions().contains(sdk2));
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProductWithMixedMarkup.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProductWithMixedMarkup.java
new file mode 100644
index 0000000..2876c81
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TestRequestFlexerProductWithMixedMarkup.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * 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 java.util.Properties;
+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.*;
+import org.eclipse.equinox.p2.planner.*;
+import org.eclipse.equinox.p2.tests.*;
+
+public class TestRequestFlexerProductWithMixedMarkup extends AbstractProvisioningTest {
+ public IInstallableUnit sdk1;
+
+ @IUDescription(content = "package: platform \n" + "singleton: true\n" + "version: 1 \n")
+ public IInstallableUnit platform1;
+
+ 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: eppPackage \n" + "singleton: true\n" + "version: 2 \n" + "depends: SDK = 2")
+ public IInstallableUnit eppPackage;
+
+ IProfile profile;
+
+ private IPlanner planner;
+
+ private IEngine engine;
+
+ private IProfileChangeRequest originalRequest;
+
+ private ProvisioningContext context;
+
+ private void setupSDK1() {
+ IRequirement[] reqPlatform1 = new IRequirement[1];
+ reqPlatform1[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "platform", new VersionRange("[1.0.0,1.0.0]"), null, false, false, true);
+ Properties p = new Properties();
+ p.setProperty("lineUp", Boolean.TRUE.toString());
+ sdk1 = createIU("SDK", Version.create("1.0.0"), null, reqPlatform1, new IProvidedCapability[0], p, null, null, true);
+ }
+
+ private void setupSDK2() {
+ IRequirement[] reqPlatform1 = new IRequirement[1];
+ reqPlatform1[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "platform", new VersionRange("[2.0.0,2.0.0]"), null, false, false, true);
+ Properties p = new Properties();
+ p.setProperty("lineUp", Boolean.TRUE.toString());
+ IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor("SDK", new VersionRange("[1.0.0,2.0.0)"), 0, "description");
+ sdk2 = createIU("SDK", Version.create("2.0.0"), null, reqPlatform1, new IProvidedCapability[0], p, null, null, true, update, null);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ context = new ProvisioningContext(getAgent());
+ profile = createProfile("TestProfile." + getName());
+ IULoader.loadIUs(this);
+ setupSDK1();
+ setupSDK2();
+ createTestMetdataRepository(new IInstallableUnit[] {sdk1, platform1, sdk2, platform2, egit1, egit2, eppPackage});
+ planner = createPlanner();
+ engine = createEngine();
+ assertOK(installAsRoots(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());
+
+ }
+
+ public void testProductRemovalIsDetected() {
+ RequestFlexer av = new RequestFlexer(planner);
+ av.setAllowPartialInstall(false);
+ av.setAllowDifferentVersion(false);
+ av.setAllowInstalledElementRemoval(true);
+ av.setAllowInstalledElementChange(false);
+ av.setProvisioningContext(context);
+ IProfileChangeRequest realRequest = av.getChangeRequest(originalRequest, profile, new NullProgressMonitor());
+
+ //There is no solution because with the given criteria, it would remove the product
+ assertNull(realRequest);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ getProfileRegistry().removeProfile(profile.getProfileId());
+ }
+
+ public void testProductNewProduct() {
+ RequestFlexer av = new RequestFlexer(planner);
+ av.setAllowPartialInstall(false);
+ av.setAllowDifferentVersion(false);
+ av.setAllowInstalledElementRemoval(false);
+ av.setAllowInstalledElementChange(true);
+ av.setProvisioningContext(context);
+ IProfileChangeRequest realRequest = av.getChangeRequest(originalRequest, profile, new NullProgressMonitor());
+
+ //In this case we can update the base, so we will find sdk2
+ assertTrue(realRequest.getAdditions().contains(egit2));
+ assertTrue(realRequest.getAdditions().contains(sdk2));
+ }
+}