Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 306424
Collapse All | Expand All

(-)src/org/eclipse/equinox/p2/tests/planner/Bug306424.java (+84 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.p2.tests.planner;
12
13
import java.io.File;
14
import java.lang.reflect.Field;
15
import org.eclipse.core.runtime.NullProgressMonitor;
16
import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
17
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
18
import org.eclipse.equinox.p2.engine.*;
19
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
20
import org.eclipse.equinox.p2.metadata.Version;
21
import org.eclipse.equinox.p2.planner.IPlanner;
22
import org.eclipse.equinox.p2.planner.IProfileChangeRequest;
23
import org.eclipse.equinox.p2.query.*;
24
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
25
26
public class Bug306424 extends AbstractProvisioningTest {
27
28
	private File previousStoreValue = null;
29
	private IProfile profile;
30
31
	protected String getTestDataPath() {
32
		return "testData/bug306424";
33
	}
34
35
	protected void tearDown() throws Exception {
36
		SimpleProfileRegistry realProfileRegistry = (SimpleProfileRegistry) getProfileRegistry();
37
38
		Field profilesMapField = SimpleProfileRegistry.class.getDeclaredField("profiles"); //$NON-NLS-1$
39
		profilesMapField.setAccessible(true);
40
		profilesMapField.set(realProfileRegistry, null);
41
42
		Field profileStore = SimpleProfileRegistry.class.getDeclaredField("store");
43
		profileStore.setAccessible(true);
44
		profileStore.set(realProfileRegistry, previousStoreValue);
45
		super.tearDown();
46
	}
47
48
	/*
49
	 * 	/* (non-Javadoc)
50
	 * @see org.eclipse.equinox.p2.tests.AbstractProvisioningTest#setUp()
51
	 */
52
	protected void setUp() throws Exception {
53
		super.setUp();
54
		File reporegistry1 = getTestData("loading planner test data", getTestDataPath());
55
		File tempFolder = getTempFolder();
56
		copy("0.2", reporegistry1, tempFolder);
57
		IProfileRegistry realProfileRegistry = getProfileRegistry();
58
		//Tweak the running profile registry
59
		Field profileStore = SimpleProfileRegistry.class.getDeclaredField("store");
60
		profileStore.setAccessible(true);
61
		previousStoreValue = (File) profileStore.get(realProfileRegistry);
62
		profileStore.set(realProfileRegistry, new File(tempFolder, "p2/org.eclipse.equinox.p2.engine/profileRegistry"));
63
64
		Field profilesMapField = SimpleProfileRegistry.class.getDeclaredField("profiles"); //$NON-NLS-1$
65
		profilesMapField.setAccessible(true);
66
		profilesMapField.set(realProfileRegistry, null);
67
		//End of tweaking the profile registry
68
69
		profile = realProfileRegistry.getProfile("PlatformProfile");
70
		assertNotNull(profile);
71
	}
72
73
	public void testInstall() {
74
		IPlanner planner = createPlanner();
75
76
		IInstallableUnit b = createIU("b", Version.create("1.0"));
77
		IProfileChangeRequest changeRequest = new ProfileChangeRequest(profile);
78
		changeRequest.remove(b);
79
		IProvisioningPlan plan = planner.getProvisioningPlan(changeRequest, null, new NullProgressMonitor());
80
		IQueryable result = plan.getRemovals();
81
		IQueryResult<IInstallableUnit> r = result.query(QueryUtil.ALL_UNITS, getMonitor());
82
		assertFalse("1.0", r.isEmpty());
83
	}
84
}
(-)testData/bug306424/p2/org.eclipse.equinox.p2.engine/profileRegistry/PlatformProfile.profile/123.profile (+83 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<?profile version='1.0.0'?>
3
<profile id='PlatformProfile' timestamp='1266347403310'>
4
  <properties size='8'>
5
    <property name='org.eclipse.equinox.p2.installFolder' value='C:\temp\zzz.plat\eclipse'/>
6
    <property name='org.eclipse.equinox.p2.cache' value='C:\temp\zzz.plat\eclipse'/>
7
    <property name='org.eclipse.update.install.features' value='true'/>
8
    <property name='org.eclipse.equinox.p2.roaming' value='true'/>
9
    <property name='org.eclipse.equinox.p2.flavor' value='tooling'/>
10
    <property name='org.eclipse.equinox.p2.environments' value='osgi.ws=win32,osgi.os=win32,osgi.arch=x86'/>
11
    <property name='eclipse.touchpoint.launcherName' value='eclipse'/>
12
    <property name='org.eclipse.equinox.p2.cache.extensions' value='file:/C:/temp/zzz.plat/eclipse/.eclipseextension|file:/C:/temp/zzz.plat/eclipse/configuration/org.eclipse.osgi/bundles/81/data/listener_1925729951/'/>
13
  </properties>
14
  <units size='2'>
15
    <unit id='a' version='1.0.0' singleton='false'>
16
      <update id='a' range='[0.0.0,1.0.0)' severity='0'/>
17
      <properties size='3'>
18
        <property name='org.eclipse.equinox.p2.name' value='A'/>
19
        <property name='file.name' value='C:\temp\zzz.plat\eclipse\dropins\a_1.0.0.jar'/>
20
        <property name='file.lastModified' value='1268923175284'/>
21
      </properties>
22
      <provides size='3'>
23
        <provided namespace='org.eclipse.equinox.p2.iu' name='a' version='1.0.0'/>
24
        <provided namespace='osgi.bundle' name='a' version='1.0.0'/>
25
        <provided namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' version='1.0.0'/>
26
      </provides>
27
      <requires size='1'>
28
        <required namespace='osgi.bundle' name='b' range='0.0.0'/>
29
      </requires>
30
      <artifacts size='1'>
31
        <artifact classifier='osgi.bundle' id='a' version='1.0.0'/>
32
      </artifacts>
33
      <touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
34
      <touchpointData size='1'>
35
        <instructions size='1'>
36
          <instruction key='manifest'>
37
            Bundle-ManifestVersion: 2&#xA;Bundle-SymbolicName: a&#xA;Require-Bundle: b&#xA;Bundle-Name: A&#xA;Manifest-Version: 1.0&#xA;Bundle-Version: 1.0.0&#xA;
38
          </instruction>
39
        </instructions>
40
      </touchpointData>
41
    </unit>
42
    <unit id='b' version='1.0.0' singleton='false'>
43
      <update id='b' range='[0.0.0,1.0.0)' severity='0'/>
44
      <properties size='3'>
45
        <property name='org.eclipse.equinox.p2.name' value='B'/>
46
        <property name='file.name' value='C:\temp\zzz.plat\eclipse\dropins\b_1.0.0.jar'/>
47
        <property name='file.lastModified' value='1268923175314'/>
48
      </properties>
49
      <provides size='3'>
50
        <provided namespace='org.eclipse.equinox.p2.iu' name='b' version='1.0.0'/>
51
        <provided namespace='osgi.bundle' name='b' version='1.0.0'/>
52
        <provided namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' version='1.0.0'/>
53
      </provides>
54
      <artifacts size='1'>
55
        <artifact classifier='osgi.bundle' id='b' version='1.0.0'/>
56
      </artifacts>
57
      <touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
58
      <touchpointData size='1'>
59
        <instructions size='1'>
60
          <instruction key='manifest'>
61
            Bundle-SymbolicName: b&#xA;Bundle-ManifestVersion: 2&#xA;Bundle-Version: 1.0.0&#xA;Bundle-Name: B&#xA;Manifest-Version: 1.0&#xA;
62
          </instruction>
63
        </instructions>
64
      </touchpointData>
65
    </unit>
66
  </units>
67
  <iusProperties size='2'>
68
    <iuProperties id='a' version='1.0.0'>
69
      <properties size='3'>
70
        <property name='org.eclipse.equinox.p2.type.lock' value='1'/>
71
        <property name='org.eclipse.equinox.p2.internal.inclusion.rules' value='OPTIONAL'/>
72
        <property name='org.eclipse.equinox.p2.reconciler.dropins' value='true'/>
73
      </properties>
74
    </iuProperties>
75
    <iuProperties id='b' version='1.0.0'>
76
      <properties size='3'>
77
        <property name='org.eclipse.equinox.p2.type.lock' value='1'/>
78
        <property name='org.eclipse.equinox.p2.internal.inclusion.rules' value='OPTIONAL'/>
79
        <property name='org.eclipse.equinox.p2.reconciler.dropins' value='true'/>
80
      </properties>
81
    </iuProperties>
82
  </iusProperties>
83
</profile>

Return to bug 306424