Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 163355 Details for
Bug 222157
[planner] Projector should get fragments dependencies
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed patch for fragments & unit tests
patch-222157.txt (text/plain), 7.69 KB, created by
Alin Dreghiciu
on 2010-03-29 23:15:38 EDT
(
hide
)
Description:
Proposed patch for fragments & unit tests
Filename:
MIME Type:
Creator:
Alin Dreghiciu
Created:
2010-03-29 23:15:38 EDT
Size:
7.69 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.director >Index: src/org/eclipse/equinox/internal/p2/director/Projector.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java,v >retrieving revision 1.60 >diff -u -r1.60 Projector.java >--- src/org/eclipse/equinox/internal/p2/director/Projector.java 18 Mar 2010 02:32:12 -0000 1.60 >+++ src/org/eclipse/equinox/internal/p2/director/Projector.java 30 Mar 2010 03:04:17 -0000 >@@ -378,9 +378,6 @@ > if (!isApplicable(req)) > return; > List<IInstallableUnit> matches = getApplicableMatches(req); >- if (isHostRequirement(iu, req)) { >- rememberHostMatches((IInstallableUnitFragment) iu, matches); >- } > if (req.getMin() > 0) { > if (matches.isEmpty()) { > missingRequirement(iu, req); >@@ -439,6 +436,26 @@ > //Patches are applicable to the IU > expandRequirementsWithPatches(iu, applicablePatches, isRootIU); > } >+ determinePotentialHostsForFragment(iu); >+ } >+ >+ /** >+ * Determines all potential hosts for a fragment. >+ * A potential host is an IU that satisfies requirements specified for fragment. >+ * >+ * @param iu an eventual fragment. It does nothing if IU is not a fragment or is null >+ */ >+ private void determinePotentialHostsForFragment(IInstallableUnit iu) { >+ // determine matching hosts only for fragments >+ if (!(iu instanceof IInstallableUnitFragment)) >+ return; >+ >+ IInstallableUnitFragment fragment = (IInstallableUnitFragment) iu; >+ // for each host requirement, find matches and remember them >+ for (IRequirement req : fragment.getHost()) { >+ List<IInstallableUnit> matches = getApplicableMatches(req); >+ rememberHostMatches((IInstallableUnitFragment) iu, matches); >+ } > } > > private Collection<IRequirement> getRequiredCapabilities(IInstallableUnit iu) { >@@ -499,9 +516,6 @@ > if (isApplicable(reqs[i][1])) { > IRequirement req = reqs[i][1]; > List<IInstallableUnit> matches = getApplicableMatches(req); >- if (isHostRequirement(iu, req)) { >- rememberHostMatches((IInstallableUnitFragment) iu, matches); >- } > if (req.getMin() > 0) { > if (matches.isEmpty()) { > missingRequirement(patch, req); >#P org.eclipse.equinox.p2.metadata >Index: src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitFragment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitFragment.java,v >retrieving revision 1.12 >diff -u -r1.12 InstallableUnitFragment.java >--- src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitFragment.java 2 Mar 2010 23:05:03 -0000 1.12 >+++ src/org/eclipse/equinox/internal/p2/metadata/InstallableUnitFragment.java 30 Mar 2010 03:04:18 -0000 >@@ -11,7 +11,6 @@ > package org.eclipse.equinox.internal.p2.metadata; > > import java.util.Collection; >-import java.util.List; > import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment; > import org.eclipse.equinox.p2.metadata.IRequirement; > >@@ -27,19 +26,6 @@ > if (hostRequirements == null) > return; > this.hostRequirements = hostRequirements; >- addRequiredCapability(hostRequirements); >- } >- >- private void addRequiredCapability(Collection<IRequirement> toAdd) { >- List<IRequirement> current = super.getRequirements(); >- int currSize = current.size(); >- IRequirement[] result = new IRequirement[currSize + toAdd.size()]; >- int i = 0; >- for (; i < currSize; ++i) >- result[i] = current.get(i); >- for (IRequirement requirement : toAdd) >- result[i++] = requirement; >- setRequiredCapabilities(result); > } > > public Collection<IRequirement> getHost() { >#P org.eclipse.equinox.p2.tests >Index: src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java,v >retrieving revision 1.21 >diff -u -r1.21 FragmentTest.java >--- src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java 8 Mar 2010 18:40:06 -0000 1.21 >+++ src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java 30 Mar 2010 03:04:19 -0000 >@@ -13,6 +13,7 @@ > import java.util.*; > import junit.framework.AssertionFailedError; > import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; >+import org.eclipse.equinox.p2.engine.IProvisioningPlan; > import org.eclipse.equinox.p2.metadata.*; > import org.eclipse.equinox.p2.query.QueryUtil; > import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; >@@ -96,6 +97,65 @@ > throw new AssertionFailedError("No capability for the iu id"); > } > >+ /** >+ * Test that fragments does not affect the solution when the fragments do not have requirements. >+ * This mean that having a fragment that has a host requirement that cannot be satisfied it will not determine solver to fail to find a solution. >+ * This case is valid only in the context that bug #222157 is solved, meaning that host requirements are not supposed to be expressed also >+ * as requirements (which was the case described also in #222158) >+ * >+ * This test does not include the host IU in request or metadata repository. >+ */ >+ public void testFragmentsOptionality1() { >+ testFragmentsOptionality(false); >+ } >+ >+ /** >+ * Test that fragments does not affect the solution when the fragments do not have requirements. >+ * This mean that having a fragment that has a host requirement that cannot be satisfied it will not determine solver to fail to find a solution. >+ * This case is valid only in the context that bug #222157 is solved, meaning that host requirements are not supposed to be expressed also >+ * as requirements (which was the case described also in #222158) >+ * >+ * This test does not include the host IU in request but it includes it in metadata repository. >+ */ >+ public void testFragmentsOptionality2() { >+ testFragmentsOptionality(true); >+ } >+ >+ private void testFragmentsOptionality(boolean includeHostIUInRepository) { >+ String ID1 = "iu.test1"; >+ String ID2 = "iu.test2"; >+ String ID3 = "iuFragment.test3"; >+ IInstallableUnit iu1 = createEclipseIU(ID1); >+ IInstallableUnit iu2 = createEclipseIU(ID2); >+ IInstallableUnit iu3 = createIUFragment(iu1, ID3, DEFAULT_VERSION); >+ >+ ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName())); >+ req.addAll(Arrays.asList(iu2, iu3)); >+ >+ if (includeHostIUInRepository) { >+ createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2, iu3}); >+ } else { >+ createTestMetdataRepository(new IInstallableUnit[] {iu2, iu3}); >+ } >+ >+ IProvisioningPlan provisioningPlan = createPlanner().getProvisioningPlan(req, null, null); >+ >+ { >+ Iterator<IInstallableUnit> iterator = provisioningPlan.getAdditions().query(QueryUtil.createIUQuery(ID1), null).iterator(); >+ assertTrue("IU " + ID1 + " not expected as part of solution", !iterator.hasNext()); >+ } >+ { >+ Iterator<IInstallableUnit> iterator = provisioningPlan.getAdditions().query(QueryUtil.createIUQuery(ID2), null).iterator(); >+ assertTrue("IU " + ID2 + " expected as part of solution", iterator.hasNext()); >+ assertEquals("Number of fragments", 0, iterator.next().getFragments().size()); >+ } >+ { >+ Iterator<IInstallableUnit> iterator = provisioningPlan.getAdditions().query(QueryUtil.createIUQuery(ID3), null).iterator(); >+ assertTrue("IU " + ID3 + " expected as part of solution", iterator.hasNext()); >+ assertEquals("Number of fragments", 0, iterator.next().getFragments().size()); >+ } >+ } >+ > public static void assertContains(Object[] objects, Object searched) { > for (int i = 0; i < objects.length; i++) { > if (objects[i] == searched)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 222157
:
163355
|
167574