1 /******************************************************************************* 2 * Copyright (c) 2010 Sonatype, Inc and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * Sonatype, Inc. - initial API and implementation 13 * IBM Corporation - ongoing development 14 *******************************************************************************/ 15 package org.eclipse.equinox.p2.tests.planner; 16 17 import java.net.URI; 18 import java.net.URISyntaxException; 19 import org.eclipse.core.runtime.OperationCanceledException; 20 import org.eclipse.equinox.p2.core.IProvisioningAgent; 21 import org.eclipse.equinox.p2.core.ProvisionException; 22 import org.eclipse.equinox.p2.engine.IProfile; 23 import org.eclipse.equinox.p2.engine.IProfileRegistry; 24 import org.eclipse.equinox.p2.planner.IPlanner; 25 import org.eclipse.equinox.p2.planner.IProfileChangeRequest; 26 import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; 27 import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; 28 import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; 29 30 public class Bug309717 extends AbstractProvisioningTest { 31 testUpdate()32 public void testUpdate() throws ProvisionException, OperationCanceledException, URISyntaxException { 33 IProvisioningAgent agent = getAgentProvider().createAgent(getTestData("test data bug309717", "testData/bug309717/p2").toURI()); 34 35 IMetadataRepository repo1 = agent.getService(IMetadataRepositoryManager.class).loadRepository(new URI("http://download.eclipse.org/releases/helios"), null); 36 // assertFalse(repo1.query(QueryUtil.createIUQuery("org.eclipse.rap.jface.databinding"), new NullProgressMonitor()).isEmpty()); 37 assertNotNull(repo1); 38 39 URI jazz = getTestData("repo for bug309717", "testData/bug309717/repo/jazz").toURI(); 40 IMetadataRepository repo2 = agent.getService(IMetadataRepositoryManager.class).loadRepository(jazz, null); 41 assertNotNull(repo2); 42 URI jdojo = getTestData("repo for bug309717", "testData/bug309717/repo/jdojo").toURI(); 43 IMetadataRepository repo3 = agent.getService(IMetadataRepositoryManager.class).loadRepository(jdojo, null); 44 assertNotNull(repo3); 45 IMetadataRepository repo4 = agent.getService(IMetadataRepositoryManager.class).loadRepository(new URI("http://download.eclipse.org/eclipse/updates/3.6"), null); 46 // assertFalse(repo1.query(QueryUtil.createIUQuery("org.eclipse.rap.jface.databinding"), new NullProgressMonitor()).isEmpty()); 47 assertNotNull(repo4); 48 IPlanner planner = getPlanner(agent); 49 IProfile profile = agent.getService(IProfileRegistry.class).getProfile("PlatformProfile"); 50 IProfileChangeRequest request = planner.createChangeRequest(profile); 51 assertNotNull(request); 52 // Set<IInstallableUnit> ius = repo2.query(QueryUtil.createIUQuery("org.eclipse.riena.toolbox.feature.feature.group", Version.create("2.0.0.201003181312")), new NullProgressMonitor()).toUnmodifiableSet(); 53 // request.addAll(ius); 54 // ProvisioningContext ctx = new ProvisioningContext(getAgent()); 55 // ctx.setMetadataRepositories(new URI[] {new URI("http://download.eclipse.org/releases/helios"), rienaRepo}); 56 // IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); 57 // 58 // assertOK("resolution failed", plan.getStatus()); 59 // assertEquals(0, plan.getAdditions().query(QueryUtil.createIUQuery("org.eclipse.rap.jface.databinding"), new NullProgressMonitor()).toUnmodifiableSet().size()); 60 // System.out.println(plan); 61 } 62 } 63