1 /******************************************************************************* 2 * Copyright (c) 2008, 2017 IBM Corporation 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 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.equinox.p2.tests.planner; 15 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; 18 import org.eclipse.equinox.p2.engine.*; 19 import org.eclipse.equinox.p2.metadata.*; 20 import org.eclipse.equinox.p2.planner.IPlanner; 21 import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; 22 23 public class PatchTest7 extends AbstractProvisioningTest { 24 // IInstallableUnit a1; 25 // IInstallableUnit b1; 26 IInstallableUnit c1; 27 // IInstallableUnit x1; 28 IInstallableUnit y1; 29 IInstallableUnit y2; 30 IInstallableUnit f1; 31 32 // IInstallableUnitPatch p1; 33 IInstallableUnitPatch pp1; 34 35 IProfile profile1; 36 IPlanner planner; 37 IEngine engine; 38 39 @Override setUp()40 protected void setUp() throws Exception { 41 super.setUp(); 42 // x1 = createIU("X", Version.createOSGi(1, 2, 0), true); 43 y1 = createIU("Y", Version.createOSGi(1, 0, 0), true); 44 y2 = createIU("Y", Version.createOSGi(1, 2, 0), true); 45 // a1 = createIU("A", Version.create("1.0.0"), new Requirement[] {MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); 46 // b1 = createIU("B", Version.create("1.0.0"), new Requirement[] {MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); 47 c1 = createIU("C", Version.create("1.0.0"), new IRequirement[] {MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "Y", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); 48 49 IRequirement[] req = new IRequirement[1]; 50 // req[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0)"), null, false, true); 51 // req[1] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true); 52 req[0] = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 1.1.0)"), null, false, true); 53 f1 = createIU("F", Version.createOSGi(1, 0, 0), req); 54 55 // RequirementChange changeX = new RequirementChange(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "X", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); 56 // Requirement[][] scope = new Requirement[0][0]; //new Requirement[][] {{MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, false)}}; 57 // p1 = createIUPatch("P", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, TouchpointType.NONE, NO_TP_DATA, false, null, new RequirementChange[] {changeX}, scope, null); 58 59 IRequirementChange changeY = MetadataFactory.createRequirementChange(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "Y", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "Y", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); 60 IRequirement[][] scopePP = new IRequirement[0][0]; //new Requirement[][] {{MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, false)}}; 61 pp1 = createIUPatch("PP", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeY}, scopePP, null, new IRequirement[0]); 62 63 // createTestMetdataRepository(new IInstallableUnit[] {a1, b1, c1, x1, y1, y2, f1, p1, pp1}); 64 createTestMetdataRepository(new IInstallableUnit[] {c1, y1, y2, f1, pp1}); 65 66 profile1 = createProfile("TestProfile." + getName()); 67 planner = createPlanner(); 68 engine = createEngine(); 69 } 70 testGeneralScope()71 public void testGeneralScope() { 72 // //Confirm that f1 can't be installed 73 // ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); 74 // req1.addInstallableUnits(new IInstallableUnit[] {f1}); 75 // ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); 76 // assertEquals(IStatus.ERROR, plan1.getStatus().getSeverity()); 77 // 78 // //Verify that the installation of f1 and p1 succeed 79 // ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); 80 // req2.addInstallableUnits(new IInstallableUnit[] {f1, p1}); 81 // ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); 82 // assertEquals(IStatus.WARNING, plan2.getStatus().getSeverity()); 83 // assertInstallOperand(plan2, f1); 84 // assertInstallOperand(plan2, a1); 85 // assertInstallOperand(plan2, b1); 86 // assertInstallOperand(plan2, c1); 87 // assertInstallOperand(plan2, x1); 88 // assertInstallOperand(plan2, y1); 89 // assertInstallOperand(plan2, p1); 90 91 //Verify that the installation of f1 and p1 succeed 92 ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); 93 req3.addInstallableUnits(new IInstallableUnit[] {f1, pp1}); 94 IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); 95 assertEquals(IStatus.OK, plan3.getStatus().getSeverity()); 96 assertInstallOperand(plan3, f1); 97 // assertInstallOperand(plan3, a1); 98 // assertInstallOperand(plan3, b1); 99 assertInstallOperand(plan3, c1); 100 // assertInstallOperand(plan3, x1); 101 assertInstallOperand(plan3, y2); 102 // assertInstallOperand(plan3, p1); 103 assertInstallOperand(plan3, pp1); 104 } 105 } 106