diff options
author | DJ Houghton | 2011-12-14 19:45:56 +0000 |
---|---|---|
committer | DJ Houghton | 2011-12-14 19:45:56 +0000 |
commit | c1602228f9af66f5d380dddd193273632a82a477 (patch) | |
tree | b2ad6000fc6849fd7198ffae19cfdbb59ea64521 | |
parent | 8acd32afbd56143feca777eab271051f4b0df937 (diff) | |
download | rt.equinox.p2-c1602228f9af66f5d380dddd193273632a82a477.tar.gz rt.equinox.p2-c1602228f9af66f5d380dddd193273632a82a477.tar.xz rt.equinox.p2-c1602228f9af66f5d380dddd193273632a82a477.zip |
Fixed up old test.
-rw-r--r-- | bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java | 85 |
1 files changed, 37 insertions, 48 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java index 50dbfc36f..76cacae2c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 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 @@ -10,12 +10,10 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.full; -import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; - import java.net.URI; -import java.net.URISyntaxException; -import java.util.*; -import org.eclipse.core.runtime.IStatus; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; import org.eclipse.equinox.p2.core.ProvisionException; import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.engine.ProvisioningContext; @@ -26,55 +24,46 @@ import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; -import org.osgi.framework.ServiceReference; +import org.osgi.framework.BundleContext; +/* + * Grabs some IUs (SDK, Platform) from the current repository and creates a plan to see if + * they can be installed. + */ public class RepoValidator extends AbstractProvisioningTest { - public void testValidate() throws ProvisionException, URISyntaxException { - URI repoLoc = new URI("http://fullmoon.ottawa.ibm.com/eclipse/updates/3.5-I-builds/"); - ServiceReference sr = TestActivator.context.getServiceReference(IPlanner.SERVICE_NAME); - if (sr == null) { - throw new RuntimeException("Planner service not available"); - } - IPlanner planner = (IPlanner) TestActivator.context.getService(sr); - if (planner == null) { - throw new RuntimeException("Planner could not be loaded"); - } + public void testValidate() throws ProvisionException { + BundleContext context = TestActivator.getContext(); + String repositoryString = context.getProperty("org.eclipse.equinox.p2.tests.current.build.repo"); + assertNotNull("Need set the \'org.eclipse.equinox.p2.tests.current.build.repo\' property.", repositoryString); + URI repositoryLocation = URI.create(repositoryString); - IMetadataRepositoryManager mgr = (IMetadataRepositoryManager) getAgent().getService(IMetadataRepositoryManager.SERVICE_NAME); - if (mgr == null) { - throw new RuntimeException("Repository manager could not be loaded"); - } - IMetadataRepository validatedRepo = mgr.loadRepository(repoLoc, null); - - Map properties = new HashMap(); - properties.put("osgi.os", "win32"); - properties.put("osgi.ws", "win32"); - properties.put("osgi.arch", "x86"); - IProfile p = createProfile("repoValidator", properties); + IPlanner planner = getPlanner(getAgent()); + assertNotNull("Unable to aquire IPlanner service.", planner); - IQuery q; + IMetadataRepositoryManager manager = getMetadataRepositoryManager(); + assertNotNull("Unable to aquire IMetadataManager service.", manager); + IMetadataRepository repository = manager.loadRepository(repositoryLocation, null); - q = QueryUtil.createIUQuery("org.eclipse.rcp.feature.group"); + Map properties = new HashMap(); + properties.put("osgi.os", context.getProperty("osgi.os")); + properties.put("osgi.ws", context.getProperty("osgi.ws")); + properties.put("osgi.arch", context.getProperty("osgi.arch")); + IProfile profile = createProfile("repoValidator", properties); - // q = InstallableUnitQuery.ANY; - IQueryResult iusToTest = validatedRepo.query(q, null); + // get the latest versions of the SDK and platform + String[] ius = new String[] {"org.eclipse.sdk.ide", "org.eclipse.platform.ide"}; + for (String id : ius) { + IQuery query = QueryUtil.createLatestQuery(QueryUtil.createIUQuery(id)); + IQueryResult result = repository.query(query, getMonitor()); + assertFalse("SDK IU not found in repository: " + repositoryString, result.isEmpty()); + IInstallableUnit iu = (IInstallableUnit) result.iterator().next(); - ProvisioningContext pc = new ProvisioningContext(getAgent()); - pc.setMetadataRepositories(new URI[] {repoLoc}); - for (Iterator iterator = iusToTest.iterator(); iterator.hasNext();) { - try { - IInstallableUnit isInstallable = (IInstallableUnit) iterator.next(); - ProfileChangeRequest req = new ProfileChangeRequest(p); - req.setProfileProperty("eclipse.p2.install.features", "true"); - req.addInstallableUnits(new IInstallableUnit[] {isInstallable}); - // System.out.println("Working on: " + isInstallable); - IStatus s = planner.getProvisioningPlan(req, pc, null).getStatus(); - if (!s.isOK()) { - System.err.println("Can't resolve: " + isInstallable); - } - } catch (ArrayIndexOutOfBoundsException e) { - //ignore - } + ProvisioningContext provisioningContext = new ProvisioningContext(getAgent()); + provisioningContext.setMetadataRepositories(new URI[] {repositoryLocation}); + ProfileChangeRequest req = new ProfileChangeRequest(profile); + req.setProfileProperty("eclipse.p2.install.features", "true"); + req.addInstallableUnits(new IInstallableUnit[] {iu}); + assertOK("Cannot resolve: " + iu, planner.getProvisioningPlan(req, provisioningContext, null).getStatus()); } } } |