Skip to main content
summaryrefslogtreecommitdiffstats
blob: e917893f345fa6a186a800c539f4304678831f76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*******************************************************************************
 *  Copyright (c) 2007, 2009 IBM Corporation 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;

import org.eclipse.equinox.p2.metadata.VersionRange;

import java.util.Collection;
import java.util.Iterator;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;

public class MultipleIUAndFragmentTest extends AbstractProvisioningTest {

	IInstallableUnit iu1;
	IInstallableUnit iu2;
	IInstallableUnit iu3;
	Collection result;

	protected void tearDown() throws Exception {
		super.tearDown();
		iu1 = null;
		iu2 = null;
		iu3 = null;
	}

	public void testAttachment() {
		iu1 = createEclipseIU("one");
		iu2 = createIUWithDependencyOn("two", "one");
		iu3 = createBundleFragment("fragment");
		ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName()));
		createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2, iu3});
		Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, null).iterator();
		for (; iterator.hasNext();) {
			IInstallableUnit iu = (IInstallableUnit) iterator.next();
			if (iu.getId().equals(iu1.getId())) {
				assertEquals(1, iu.getFragments().size());
				assertEquals(iu.getFragments().get(0).getId(), iu3.getId());
			}
			if (iu.getId().equals(iu2.getId())) {
				assertEquals(1, iu.getFragments().size());
				assertEquals(iu.getFragments().get(0).getId(), iu3.getId());
			}
			if (iu.getId().equals(iu3.getId())) {
				//fragments don't have fragments
				assertNull(iu.getFragments());
			}
		}

	}

	private static IInstallableUnit createIUWithDependencyOn(String iuName, String dependencyOn) {
		IRequiredCapability[] requires = new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, dependencyOn, VersionRange.emptyRange, null, false, true)};
		return createEclipseIU(iuName, DEFAULT_VERSION, requires, NO_TP_DATA);
	}
}

Back to the top