Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2010-03-30 23:40:03 -0400
committerPascal Rapicault2010-03-30 23:40:03 -0400
commitfa0501c918f4b187cfcc768b22c4c13f111a5127 (patch)
treedb01dd4d9fca79391ec9eb27919a8423f2a4f11c
parente05d8372d02e32a74142458137872079dfba78fc (diff)
downloadrt.equinox.p2-fa0501c918f4b187cfcc768b22c4c13f111a5127.tar.gz
rt.equinox.p2-fa0501c918f4b187cfcc768b22c4c13f111a5127.tar.xz
rt.equinox.p2-fa0501c918f4b187cfcc768b22c4c13f111a5127.zip
Bug 307471 - None of fragment related tests are actually running
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java130
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java49
3 files changed, 117 insertions, 63 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
index 8bb1bea82..c5bcdfb80 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
@@ -211,6 +211,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
fragment.setTouchpointType(TOUCHPOINT_OSGI);
fragment.addTouchpointData(NO_TP_DATA);
fragment.setHost(BUNDLE_REQUIREMENT);
+ fragment.setCapabilities(new IProvidedCapability[] {getSelfCapability(name, fragment.getVersion())});
return MetadataFactory.createInstallableUnitFragment(fragment);
// return createIUFragment(null, name, DEFAULT_VERSION, BUNDLE_REQUIREMENT, TOUCHPOINT_OSGI, NO_TP_DATA);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java
index 2359f19a0..b54d6e18d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java
@@ -14,82 +14,124 @@ import java.util.*;
import junit.framework.AssertionFailedError;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class FragmentTest extends AbstractProvisioningTest {
+ /**
+ * Tests that a fragment gets attached to host.
+ */
public void testAssociation() {
- String ID = "ui.test1";
- IInstallableUnit iu1 = createEclipseIU(ID);
- IInstallableUnit iu2 = createBundleFragment("iuFragment.test1");
+ String ID1 = "iu.1";
+ String IDF1 = "iu.fragment.1";
+ IInstallableUnit iu1 = createEclipseIU(ID1);
+ IInstallableUnit iuf1 = createBundleFragment(IDF1);
ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName()));
- createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2});
- Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(QueryUtil.createIUAnyQuery(), null).iterator();
+ req.addInstallableUnits(iu1, iuf1);
+ createTestMetdataRepository(new IInstallableUnit[] {iu1, iuf1});
+ IQueryable<IInstallableUnit> additions = createPlanner().getProvisioningPlan(req, null, null).getAdditions();
+ {
+ Iterator<IInstallableUnit> iterator = additions.query(QueryUtil.createIUQuery(ID1), null).iterator();
+ assertTrue("Solution contains IU " + ID1, iterator.hasNext());
+ IInstallableUnit iu = iterator.next();
+ assertEquals("Number of attached fragments to IU " + ID1, 1, iu.getFragments().size());
+ assertEquals("Attached fragment to IU " + ID1, IDF1, iu.getFragments().iterator().next().getId());
+ }
+ {
+ Iterator<IInstallableUnit> iterator = additions.query(QueryUtil.createIUQuery(IDF1), null).iterator();
+ assertTrue("Solution contains IU " + IDF1, iterator.hasNext());
+ IInstallableUnit iu = iterator.next();
+ assertEquals("Number of attached fragments to IU " + IDF1, 0, iu.getFragments().size());
+ }
// ResolutionHelper rh = new ResolutionHelper(new Hashtable(), null);
// HashSet set = new HashSet();
// set.add(iu1);
// set.add(iu2);
// Collection result = rh.attachCUs(set);
- for (; iterator.hasNext();) {
- IInstallableUnit iu = (IInstallableUnit) iterator.next();
- if (iu.getId().equals(ID)) {
- assertEquals(iu.getFragments().size(), 1);
- assertEquals(iu.getFragments().iterator().next().getId(), "iuFragment.test1");
- }
- }
}
+ /**
+ * Tests that a fragment gets attached to multiple hosts that matches the host requirements.
+ */
public void testAssociation2() {
- String ID1 = "ui.test1";
- String ID3 = "ui.test3";
+ String ID1 = "iu.1";
+ String ID2 = "iu.2";
+ String IDF1 = "iu.fragment.1";
IInstallableUnit iu1 = createEclipseIU(ID1);
- IInstallableUnit iu3 = createEclipseIU(ID3);
- IInstallableUnit iu2 = createBundleFragment("iuFragment.test1");
+ IInstallableUnit iu2 = createEclipseIU(ID2);
+ IInstallableUnit iuf1 = createBundleFragment(IDF1);
ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName()));
- createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2, iu3});
- Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(QueryUtil.createIUAnyQuery(), null).iterator();
- for (; iterator.hasNext();) {
- IInstallableUnit iu = (IInstallableUnit) iterator.next();
- if (iu.getId().equals(ID1)) {
- assertEquals(iu.getFragments().size(), 1);
- assertEquals(iu.getFragments().iterator().next().getId(), "iuFragment.test1");
- }
- if (iu.getId().equals(ID3)) {
- assertEquals(iu.getFragments().size(), 1);
- assertEquals(iu.getFragments().iterator().next().getId(), "iuFragment.test1");
- }
+ req.addInstallableUnits(iu1, iuf1, iu2);
+ createTestMetdataRepository(new IInstallableUnit[] {iu1, iuf1, iu2});
+ IQueryable<IInstallableUnit> additions = createPlanner().getProvisioningPlan(req, null, null).getAdditions();
+ {
+ Iterator<IInstallableUnit> iterator = additions.query(QueryUtil.createIUQuery(ID1), null).iterator();
+ assertTrue("Solution contains IU " + ID1, iterator.hasNext());
+ IInstallableUnit iu = iterator.next();
+ assertEquals("Number of attached fragments to IU " + ID1, 1, iu.getFragments().size());
+ assertEquals("Attached fragment to IU " + ID1, IDF1, iu.getFragments().iterator().next().getId());
+ }
+ {
+ Iterator<IInstallableUnit> iterator = additions.query(QueryUtil.createIUQuery(ID2), null).iterator();
+ assertTrue("Solution contains IU " + ID2, iterator.hasNext());
+ IInstallableUnit iu = iterator.next();
+ assertEquals("Number of attached fragments to IU " + ID2, 1, iu.getFragments().size());
+ assertEquals("Attached fragment to IU " + ID2, IDF1, iu.getFragments().iterator().next().getId());
+ }
+ {
+ Iterator<IInstallableUnit> iterator = additions.query(QueryUtil.createIUQuery(IDF1), null).iterator();
+ assertTrue("Solution contains IU " + IDF1, iterator.hasNext());
+ IInstallableUnit iu = iterator.next();
+ assertEquals("Number of attached fragments to IU " + IDF1, 0, iu.getFragments().size());
}
}
+ /**
+ * Tests that when a fragment is attached the touchpoint data from host IU gets merged with touchpoint data from fragment.
+ */
public void testTouchpointData() {
- assertEquals(createIUWithTouchpointData().getTouchpointData().size(), 1);
- assertEquals(createBundleFragment("iuFragment.test1").getTouchpointData().size(), 1);
+ String IDF1 = "iu.fragment.1";
IInstallableUnit iu1 = createIUWithTouchpointData();
- IInstallableUnit iu2 = createBundleFragment("iuFragment.test1");
- ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName()));
- createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2});
- Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(QueryUtil.createIUAnyQuery(), null).iterator();
- for (; iterator.hasNext();) {
- IInstallableUnit iu = (IInstallableUnit) iterator.next();
- if (iu.getId().equals(iu1.getId()))
- assertEquals(2, iu.getTouchpointData().size());
+ IInstallableUnit iuf1 = createBundleFragment(IDF1);
+ String ID1 = iu1.getId();
+ assertEquals("Number of touchpoint instructions of IU " + ID1, 1, iu1.getTouchpointData().size());
+ assertEquals("Number of touchpoint instructions of IU " + IDF1, 1, iuf1.getTouchpointData().size());
+
+ ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName()));
+ req.addInstallableUnits(iu1, iuf1);
+ createTestMetdataRepository(new IInstallableUnit[] {iu1, iuf1});
+ IQueryable<IInstallableUnit> additions = createPlanner().getProvisioningPlan(req, null, null).getAdditions();
+ {
+ Iterator<IInstallableUnit> iterator = additions.query(QueryUtil.createIUQuery(ID1), null).iterator();
+ assertTrue("Solution contains IU " + ID1, iterator.hasNext());
+ IInstallableUnit iu = iterator.next();
+ assertEquals("Number of attached fragments to IU " + ID1, 1, iu.getFragments().size());
+ assertEquals("Attached fragment to IU " + ID1, IDF1, iu.getFragments().iterator().next().getId());
+ assertEquals("Number of touchpoint instructions of IU " + ID1, 2, iu.getTouchpointData().size());
+ }
+ {
+ Iterator<IInstallableUnit> iterator = additions.query(QueryUtil.createIUQuery(IDF1), null).iterator();
+ assertTrue("Solution contains IU " + IDF1, iterator.hasNext());
+ IInstallableUnit iu = iterator.next();
+ assertEquals("Number of attached fragments to IU " + IDF1, 0, iu.getFragments().size());
}
}
public void testFragmentCapability() {
- IInstallableUnit iu = createBundleFragment("iuFragment.test1");
- assertTrue(QueryUtil.isFragment(iu));
+ IInstallableUnit iuf1 = createBundleFragment("iu.fragment.1");
+ assertTrue(QueryUtil.isFragment(iuf1));
}
public void testDefaultIUCapability() {
- IInstallableUnit iu = createEclipseIU("ui.test1");
- Collection<IProvidedCapability> capabilities = iu.getProvidedCapabilities();
+ IInstallableUnit iu1 = createEclipseIU("iu.1");
+ Collection<IProvidedCapability> capabilities = iu1.getProvidedCapabilities();
for (IProvidedCapability c : capabilities) {
if (c.getNamespace().equals(IInstallableUnit.NAMESPACE_IU_ID)) {
assertEquals(c.getNamespace(), IInstallableUnit.NAMESPACE_IU_ID);
- assertEquals(c.getName(), iu.getId());
+ assertEquals(c.getName(), iu1.getId());
return;
}
}
@@ -113,7 +155,7 @@ public class FragmentTest extends AbstractProvisioningTest {
private IInstallableUnit createIUWithTouchpointData() {
ITouchpointData data = MetadataFactory.createTouchpointData(new HashMap());
- return createEclipseIU("ui.test1", DEFAULT_VERSION, NO_REQUIRES, data);
+ return createEclipseIU("iu.1", DEFAULT_VERSION, NO_REQUIRES, data);
}
// private IInstallableUnit createIUFragmentWithTouchpointData() {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java
index d976172fa..2337b8c7d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java
@@ -14,14 +14,20 @@ import java.util.Collection;
import java.util.Iterator;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class MultipleIUAndFragmentTest extends AbstractProvisioningTest {
+ private static final String ID1 = "iu.1";
+ private static final String ID2 = "iu.2";
+ private static final String IDF1 = "iu.fragment.1";
+
IInstallableUnit iu1;
IInstallableUnit iu2;
IInstallableUnit iu3;
+
Collection result;
protected void tearDown() throws Exception {
@@ -32,28 +38,33 @@ public class MultipleIUAndFragmentTest extends AbstractProvisioningTest {
}
public void testAttachment() {
- iu1 = createEclipseIU("one");
- iu2 = createIUWithDependencyOn("two", "one");
- iu3 = createBundleFragment("fragment");
+ iu1 = createEclipseIU(ID1);
+ iu2 = createIUWithDependencyOn(ID2, ID1);
+ iu3 = createBundleFragment(IDF1);
ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName()));
+ req.addInstallableUnits(iu1, iu2, iu3);
createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2, iu3});
- Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(QueryUtil.createIUAnyQuery(), null).iterator();
- for (; iterator.hasNext();) {
- IInstallableUnit iu = (IInstallableUnit) iterator.next();
- if (iu.getId().equals(iu1.getId())) {
- assertEquals(1, iu.getFragments().size());
- assertEquals(iu.getFragments().iterator().next().getId(), iu3.getId());
- }
- if (iu.getId().equals(iu2.getId())) {
- assertEquals(1, iu.getFragments().size());
- assertEquals(iu.getFragments().iterator().next().getId(), iu3.getId());
- }
- if (iu.getId().equals(iu3.getId())) {
- //fragments don't have fragments
- assertNull(iu.getFragments());
- }
+ IQueryable<IInstallableUnit> additions = createPlanner().getProvisioningPlan(req, null, null).getAdditions();
+ {
+ Iterator<IInstallableUnit> iterator = additions.query(QueryUtil.createIUQuery(ID1), null).iterator();
+ assertTrue("Solution contains IU " + ID1, iterator.hasNext());
+ IInstallableUnit iu = iterator.next();
+ assertEquals("Number of attached fragments to IU " + ID1, 1, iu.getFragments().size());
+ assertEquals("Attached fragment to IU " + ID1, IDF1, iu.getFragments().iterator().next().getId());
+ }
+ {
+ Iterator<IInstallableUnit> iterator = additions.query(QueryUtil.createIUQuery(ID2), null).iterator();
+ assertTrue("Solution contains IU " + ID2, iterator.hasNext());
+ IInstallableUnit iu = iterator.next();
+ assertEquals("Number of attached fragments to IU " + ID2, 1, iu.getFragments().size());
+ assertEquals("Attached fragment to IU " + ID2, IDF1, iu.getFragments().iterator().next().getId());
+ }
+ {
+ Iterator<IInstallableUnit> iterator = additions.query(QueryUtil.createIUQuery(IDF1), null).iterator();
+ assertTrue("Solution contains IU " + IDF1, iterator.hasNext());
+ IInstallableUnit iu = iterator.next();
+ assertEquals("Number of attached fragments to IU " + IDF1, 0, iu.getFragments().size());
}
-
}
private static IInstallableUnit createIUWithDependencyOn(String iuName, String dependencyOn) {

Back to the top