Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2010-02-10 18:34:21 +0000
committerDJ Houghton2010-02-10 18:34:21 +0000
commit8cbf52abd477d04546c962fde4878d211d1e5d1e (patch)
tree22b674550bcfd4d52186996bd1accd326706a52e
parent02d87bfd7e9eaaf01f4eccf8febbade5224b94c2 (diff)
downloadrt.equinox.p2-8cbf52abd477d04546c962fde4878d211d1e5d1e.tar.gz
rt.equinox.p2-8cbf52abd477d04546c962fde4878d211d1e5d1e.tar.xz
rt.equinox.p2-8cbf52abd477d04546c962fde4878d211d1e5d1e.zip
Bug 301446 - [planner] Planner does not find the solution with the default time out settings
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300104bis.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300104bis.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300104bis.java
index c18199261..29f7ea55c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300104bis.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300104bis.java
@@ -1 +1 @@
-/******************************************************************************* * Copyright (c) 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.planner; import java.io.File; import java.lang.reflect.Field; import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.director.*; import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; import org.eclipse.equinox.internal.provisional.p2.query.Collector; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.Version; public class Bug300104bis extends AbstractProvisioningTest { private IProfile profile; private File previousStoreValue = null; String profileLoadedId = "bootProfile"; String directory = "testData/bug300104bis/case1"; IMetadataRepository repo = null; protected void setUp() throws Exception { super.setUp(); File reporegistry1 = getTestData("test data bug 300104bis", directory); File tempFolder = getTempFolder(); copy("0.2", reporegistry1, tempFolder); SimpleProfileRegistry realProfileRegistry = getProfileRegistry(); //Tweak the running profile registry Field profileStore = SimpleProfileRegistry.class.getDeclaredField("store"); profileStore.setAccessible(true); previousStoreValue = (File) profileStore.get(realProfileRegistry); profileStore.set(realProfileRegistry, new File(tempFolder, "p2/org.eclipse.equinox.p2.engine/profileRegistry")); Field profilesMapField = SimpleProfileRegistry.class.getDeclaredField("profiles"); //$NON-NLS-1$ profilesMapField.setAccessible(true); profilesMapField.set(realProfileRegistry, null); //End of tweaking the profile registry profile = realProfileRegistry.getProfile(profileLoadedId); assertNotNull(profile); repo = loadMetadataRepository(getTestData("Repository for 300104bis", directory + "/repo").toURL()); } private SimpleProfileRegistry getProfileRegistry() { return (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); } protected IMetadataRepository loadMetadataRepository(URL location) throws ProvisionException { IMetadataRepositoryManager metadataRepositoryManager = getMetadataRepositoryManager(); return metadataRepositoryManager.loadRepository(location, null); } protected void tearDown() throws Exception { SimpleProfileRegistry realProfileRegistry = (SimpleProfileRegistry) getProfileRegistry(); Field profilesMapField = SimpleProfileRegistry.class.getDeclaredField("profiles"); //$NON-NLS-1$ profilesMapField.setAccessible(true); profilesMapField.set(realProfileRegistry, null); Field profileStore = SimpleProfileRegistry.class.getDeclaredField("store"); profileStore.setAccessible(true); profileStore.set(realProfileRegistry, previousStoreValue); super.tearDown(); } public void testInstall() { IMetadataRepositoryManager mgr = getMetadataRepositoryManager(); try { repo = loadMetadataRepository(getTestData("test data bug 300104bis repo", directory + "/repo").toURL()); } catch (ProvisionException e) { assertNull(e); //This guarantees that the error does not go unnoticed } catch (MalformedURLException e) { assertNull(e); } Collector ius = repo.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()); IPlanner planner = createPlanner(); ProvisioningPlan plan, expectedPlan = null; plan = planner.getProvisioningPlan(createRequest(ius), null, new NullProgressMonitor()); expectedPlan = planner.getProvisioningPlan(createFilteredRequest(ius), null, new NullProgressMonitor()); Operand[] expectedOperands = expectedPlan.getOperands(); for (int i = 0; i < expectedOperands.length; i++) { if (!(expectedOperands[i] instanceof InstallableUnitOperand)) continue; IInstallableUnit iu = ((InstallableUnitOperand) expectedOperands[i]).second(); assertInstallOperand(plan, iu); } } private ProfileChangeRequest createRequest(Collector ius) { ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits((IInstallableUnit[]) ius.toArray(IInstallableUnit.class)); Iterator it = ius.iterator(); while (it.hasNext()) { IInstallableUnit iu = (IInstallableUnit) it.next(); pcr.setInstallableUnitInclusionRules(iu, PlannerHelper.createOptionalInclusionRule(iu)); } return pcr; } private ProfileChangeRequest createFilteredRequest(Collector ius) { ProfileChangeRequest pcr = new ProfileChangeRequest(profile); Iterator it = ius.iterator(); while (it.hasNext()) { IInstallableUnit iu = (IInstallableUnit) it.next(); if ((iu.getId().equals("com.dcns.rsm.rda") && iu.getVersion().equals(new Version("5.1.0.v20100112"))) || (iu.getId().equals("com.dcns.rsm.profile.equipment") && iu.getVersion().equals(new Version("1.2.2.v20100108"))) || (iu.getId().equals("com.dcns.rsm.profile.gemo") && iu.getVersion().equals(new Version("3.7.2.v20100108"))) || (iu.getId().equals("com.dcns.rsm.profile.system") && iu.getVersion().equals(new Version("4.2.2.v20100112")))) { pcr.addInstallableUnits(new IInstallableUnit[] {iu}); } } return pcr; } } \ No newline at end of file
+/******************************************************************************* * Copyright (c) 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.planner; import java.io.File; import java.lang.reflect.Field; import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.director.*; import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; import org.eclipse.equinox.internal.provisional.p2.query.Collector; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.Version; public class Bug300104bis extends AbstractProvisioningTest { private IProfile profile; private File previousStoreValue = null; String profileLoadedId = "bootProfile"; String directory = "testData/bug300104bis/case1"; IMetadataRepository repo = null; protected void setUp() throws Exception { super.setUp(); File reporegistry1 = getTestData("test data bug 300104bis", directory); File tempFolder = getTempFolder(); copy("0.2", reporegistry1, tempFolder); SimpleProfileRegistry realProfileRegistry = getProfileRegistry(); //Tweak the running profile registry Field profileStore = SimpleProfileRegistry.class.getDeclaredField("store"); profileStore.setAccessible(true); previousStoreValue = (File) profileStore.get(realProfileRegistry); profileStore.set(realProfileRegistry, new File(tempFolder, "p2/org.eclipse.equinox.p2.engine/profileRegistry")); Field profilesMapField = SimpleProfileRegistry.class.getDeclaredField("profiles"); //$NON-NLS-1$ profilesMapField.setAccessible(true); profilesMapField.set(realProfileRegistry, null); //End of tweaking the profile registry profile = realProfileRegistry.getProfile(profileLoadedId); assertNotNull(profile); repo = loadMetadataRepository(getTestData("Repository for 300104bis", directory + "/repo").toURL()); } private SimpleProfileRegistry getProfileRegistry() { return (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); } protected IMetadataRepository loadMetadataRepository(URL location) throws ProvisionException { IMetadataRepositoryManager metadataRepositoryManager = getMetadataRepositoryManager(); return metadataRepositoryManager.loadRepository(location, null); } protected void tearDown() throws Exception { SimpleProfileRegistry realProfileRegistry = getProfileRegistry(); Field profilesMapField = SimpleProfileRegistry.class.getDeclaredField("profiles"); //$NON-NLS-1$ profilesMapField.setAccessible(true); profilesMapField.set(realProfileRegistry, null); Field profileStore = SimpleProfileRegistry.class.getDeclaredField("store"); profileStore.setAccessible(true); profileStore.set(realProfileRegistry, previousStoreValue); super.tearDown(); } public void testInstall() { try { repo = loadMetadataRepository(getTestData("test data bug 300104bis repo", directory + "/repo").toURL()); } catch (ProvisionException e) { assertNull(e); //This guarantees that the error does not go unnoticed } catch (MalformedURLException e) { assertNull(e); } Collector ius = repo.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()); IPlanner planner = createPlanner(); ProvisioningPlan plan, expectedPlan = null; plan = planner.getProvisioningPlan(createRequest(ius), null, new NullProgressMonitor()); expectedPlan = planner.getProvisioningPlan(createFilteredRequest(ius), null, new NullProgressMonitor()); Operand[] expectedOperands = expectedPlan.getOperands(); Operand[] actualOperands = plan.getOperands(); for (int outer = 0; outer < expectedOperands.length; outer++) { if (!(expectedOperands[outer] instanceof InstallableUnitOperand)) continue; IInstallableUnit first = ((InstallableUnitOperand) expectedOperands[outer]).first(); IInstallableUnit second = ((InstallableUnitOperand) expectedOperands[outer]).second(); assertNull("0.1", first); assertNotNull("0.2", second); // see if there is an operand in the actual plan which involved this IU. boolean found = false; for (int inner = 0; inner < actualOperands.length; inner++) { if (!(actualOperands[inner] instanceof InstallableUnitOperand)) continue; InstallableUnitOperand actual = (InstallableUnitOperand) actualOperands[inner]; assertNull("1.1", actual.first()); assertNotNull("1.2", actual.second()); if (!actual.second().getId().equals(second.getId())) continue; // we have IUs with the same id... do they have the same version too? assertEquals("2.0", second, actual.second()); found = true; } if (!found) fail("Plan is missing install operand for: " + second); } } private ProfileChangeRequest createRequest(Collector ius) { ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits((IInstallableUnit[]) ius.toArray(IInstallableUnit.class)); Iterator it = ius.iterator(); while (it.hasNext()) { IInstallableUnit iu = (IInstallableUnit) it.next(); pcr.setInstallableUnitInclusionRules(iu, PlannerHelper.createOptionalInclusionRule(iu)); } return pcr; } private ProfileChangeRequest createFilteredRequest(Collector ius) { ProfileChangeRequest pcr = new ProfileChangeRequest(profile); Iterator it = ius.iterator(); while (it.hasNext()) { IInstallableUnit iu = (IInstallableUnit) it.next(); if ((iu.getId().equals("com.dcns.rsm.rda") && iu.getVersion().equals(new Version("5.1.0.v20100112"))) || (iu.getId().equals("com.dcns.rsm.profile.equipment") && iu.getVersion().equals(new Version("1.2.2.v20100108"))) || (iu.getId().equals("com.dcns.rsm.profile.gemo") && iu.getVersion().equals(new Version("3.7.2.v20100108"))) || (iu.getId().equals("com.dcns.rsm.profile.system") && iu.getVersion().equals(new Version("4.2.2.v20100112")))) { pcr.addInstallableUnits(new IInstallableUnit[] {iu}); } } return pcr; } } \ No newline at end of file

Back to the top