Skip to main content
summaryrefslogtreecommitdiffstats
blob: fb84ec0945c23dd02376363635351cd6100cb0de (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
/*******************************************************************************
 *  Copyright (c) 2010 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.planner;

import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;

import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.planner.IPlanner;
import org.eclipse.equinox.p2.planner.ProfileInclusionRules;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;

public class SimpleOptionalTest5 extends AbstractProvisioningTest {
	IInstallableUnit a1;
	IInstallableUnit a2;

	IPlanner planner;
	IProfile profile;
	private IEngine engine;

	protected void setUp() throws Exception {
		super.setUp();
		a1 = createIU("A", Version.create("1.0.0"), false);

		a2 = createIU("A", Version.create("2.0.0"), false);

		createTestMetdataRepository(new IInstallableUnit[] {a1, a2});

		profile = createProfile("TestProfile." + getName());
		planner = createPlanner();
		engine = createEngine();
	}

	public void test2() {
		ProfileChangeRequest req = new ProfileChangeRequest(profile);
		req.addInstallableUnits(new IInstallableUnit[] {a1, a2});
		req.setInstallableUnitInclusionRules(a1, ProfileInclusionRules.createOptionalInclusionRule(a1));
		req.setInstallableUnitInclusionRules(a2, ProfileInclusionRules.createOptionalInclusionRule(a2));
		IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null);
		engine.perform(plan, new NullProgressMonitor());
		assertProfileContains("foo", profile, new IInstallableUnit[] {a1, a2});

		ProfileChangeRequest req4 = new ProfileChangeRequest(profile);
		req4.addInstallableUnits(new IInstallableUnit[] {a2});
		req4.setInstallableUnitInclusionRules(a2, ProfileInclusionRules.createOptionalInclusionRule(a2));
		IProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null);
		engine.perform(plan4, new NullProgressMonitor());
		assertProfileContains("foo", profile, new IInstallableUnit[] {a1, a2});

	}
}

Back to the top