|
Lines 13-18
Link Here
|
| 13 |
import java.util.*; |
13 |
import java.util.*; |
| 14 |
import junit.framework.AssertionFailedError; |
14 |
import junit.framework.AssertionFailedError; |
| 15 |
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; |
15 |
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; |
|
|
16 |
import org.eclipse.equinox.p2.engine.IProvisioningPlan; |
| 16 |
import org.eclipse.equinox.p2.metadata.*; |
17 |
import org.eclipse.equinox.p2.metadata.*; |
| 17 |
import org.eclipse.equinox.p2.query.QueryUtil; |
18 |
import org.eclipse.equinox.p2.query.QueryUtil; |
| 18 |
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; |
19 |
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; |
|
Lines 96-101
Link Here
|
| 96 |
throw new AssertionFailedError("No capability for the iu id"); |
97 |
throw new AssertionFailedError("No capability for the iu id"); |
| 97 |
} |
98 |
} |
| 98 |
|
99 |
|
|
|
100 |
/** |
| 101 |
* Test that fragments does not affect the solution when the fragments do not have requirements. |
| 102 |
* 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. |
| 103 |
* This case is valid only in the context that bug #222157 is solved, meaning that host requirements are not supposed to be expressed also |
| 104 |
* as requirements (which was the case described also in #222158) |
| 105 |
* |
| 106 |
* This test does not include the host IU in request or metadata repository. |
| 107 |
*/ |
| 108 |
public void testFragmentsOptionality1() { |
| 109 |
testFragmentsOptionality(false); |
| 110 |
} |
| 111 |
|
| 112 |
/** |
| 113 |
* Test that fragments does not affect the solution when the fragments do not have requirements. |
| 114 |
* 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. |
| 115 |
* This case is valid only in the context that bug #222157 is solved, meaning that host requirements are not supposed to be expressed also |
| 116 |
* as requirements (which was the case described also in #222158) |
| 117 |
* |
| 118 |
* This test does not include the host IU in request but it includes it in metadata repository. |
| 119 |
*/ |
| 120 |
public void testFragmentsOptionality2() { |
| 121 |
testFragmentsOptionality(true); |
| 122 |
} |
| 123 |
|
| 124 |
private void testFragmentsOptionality(boolean includeHostIUInRepository) { |
| 125 |
String ID1 = "iu.test1"; |
| 126 |
String ID2 = "iu.test2"; |
| 127 |
String ID3 = "iuFragment.test3"; |
| 128 |
IInstallableUnit iu1 = createEclipseIU(ID1); |
| 129 |
IInstallableUnit iu2 = createEclipseIU(ID2); |
| 130 |
IInstallableUnit iu3 = createIUFragment(iu1, ID3, DEFAULT_VERSION); |
| 131 |
|
| 132 |
ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName())); |
| 133 |
req.addAll(Arrays.asList(iu2, iu3)); |
| 134 |
|
| 135 |
if (includeHostIUInRepository) { |
| 136 |
createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2, iu3}); |
| 137 |
} else { |
| 138 |
createTestMetdataRepository(new IInstallableUnit[] {iu2, iu3}); |
| 139 |
} |
| 140 |
|
| 141 |
IProvisioningPlan provisioningPlan = createPlanner().getProvisioningPlan(req, null, null); |
| 142 |
|
| 143 |
{ |
| 144 |
Iterator<IInstallableUnit> iterator = provisioningPlan.getAdditions().query(QueryUtil.createIUQuery(ID1), null).iterator(); |
| 145 |
assertTrue("IU " + ID1 + " not expected as part of solution", !iterator.hasNext()); |
| 146 |
} |
| 147 |
{ |
| 148 |
Iterator<IInstallableUnit> iterator = provisioningPlan.getAdditions().query(QueryUtil.createIUQuery(ID2), null).iterator(); |
| 149 |
assertTrue("IU " + ID2 + " expected as part of solution", iterator.hasNext()); |
| 150 |
assertEquals("Number of fragments", 0, iterator.next().getFragments().size()); |
| 151 |
} |
| 152 |
{ |
| 153 |
Iterator<IInstallableUnit> iterator = provisioningPlan.getAdditions().query(QueryUtil.createIUQuery(ID3), null).iterator(); |
| 154 |
assertTrue("IU " + ID3 + " expected as part of solution", iterator.hasNext()); |
| 155 |
assertEquals("Number of fragments", 0, iterator.next().getFragments().size()); |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 99 |
public static void assertContains(Object[] objects, Object searched) { |
159 |
public static void assertContains(Object[] objects, Object searched) { |
| 100 |
for (int i = 0; i < objects.length; i++) { |
160 |
for (int i = 0; i < objects.length; i++) { |
| 101 |
if (objects[i] == searched) |
161 |
if (objects[i] == searched) |