コード例 #1
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    sdk =
        createIU(
            "SDK",
            PublisherHelper.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")),
            createRequiredCapabilities(
                IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]")));
    IInstallableUnit sdkPart =
        createIU(
            "SDKPart",
            PublisherHelper.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")),
            true);
    IInstallableUnit sdkPart2 =
        createIU(
            "SDKPart",
            PublisherHelper.fromOSGiVersion(new org.osgi.framework.Version("2.0.0")),
            true);

    createTestMetdataRepository(new IInstallableUnit[] {sdk, sdkPart, sdkPart2});

    profile = createProfile("TestProfile." + getName());
    planner = createPlanner();
    engine = createEngine();

    ProfileChangeRequest pcr = new ProfileChangeRequest(profile);
    pcr.addInstallableUnits(new IInstallableUnit[] {sdk});
    engine.perform(planner.getProvisioningPlan(pcr, null, null), null);
  }
コード例 #2
0
  public void testNoProblemWithMissingOptionalDependency() {
    // CDT will be missing a requirement but it is optional so everything should be good
    // EMF will be not be good because it is missing a requirement
    IRequirement missingOptionalDependency =
        MetadataFactory.createRequirement(
            IInstallableUnit.NAMESPACE_IU_ID,
            "MissingSomething",
            new VersionRange("[1.0.0, 1.0.0]"),
            null,
            true,
            false);
    IInstallableUnit cdt =
        createIU(
            "CDT",
            PublisherHelper.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")),
            new IRequirement[] {missingOptionalDependency});

    IRequirement emfMissing =
        MetadataFactory.createRequirement(
            IInstallableUnit.NAMESPACE_IU_ID,
            "EMFPart",
            new VersionRange("[1.0.0, 1.0.0]"),
            null,
            false,
            false);
    IInstallableUnit emf =
        createIU(
            "EMF",
            PublisherHelper.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")),
            new IRequirement[] {emfMissing},
            NO_PROPERTIES,
            true);

    createTestMetdataRepository(new IInstallableUnit[] {cdt, emf});
    ProfileChangeRequest pcr = new ProfileChangeRequest(profile);
    pcr.addInstallableUnits(new IInstallableUnit[] {cdt, emf});
    ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(pcr, null, null);
    RequestStatus requestStatus = ((PlannerStatus) plan.getStatus()).getRequestStatus();
    assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(emf));
    assertFalse(requestStatus.getConflictsWithInstalledRoots().contains(cdt));
    assertFalse(requestStatus.getConflictsWithInstalledRoots().contains(sdk));

    //		assertTrue(plan.getRequestStatus(cdt).getSeverity() != IStatus.ERROR);
    //
    //		assertTrue(plan.getRequestStatus(emf).getSeverity() == IStatus.ERROR);
    //		assertEquals(0, plan.getRequestStatus(emf).getConflictsWithInstalledRoots());
  }
コード例 #3
0
  public void testExecuteUndo() throws Exception {
    Properties profileProperties = new Properties();
    File installFolder = getTempFolder();
    profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString());
    profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString());
    IProfile profile = createProfile("test", profileProperties);

    IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile);
    File osgiSource =
        getTestData(
            "1.0",
            "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi.source_3.4.2.R34x_v20080826-1230.jar");
    File targetPlugins = new File(installFolder, "plugins");
    assertTrue(targetPlugins.mkdir());
    File osgiTarget =
        new File(targetPlugins, "org.eclipse.osgi.source_3.4.2.R34x_v20080826-1230.jar");
    copy("2.0", osgiSource, osgiTarget);

    BundleDescription bundleDescription = BundlesAction.createBundleDescription(osgiTarget);
    IArtifactKey key =
        BundlesAction.createBundleArtifactKey(
            bundleDescription.getSymbolicName(), bundleDescription.getVersion().toString());
    IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, osgiTarget);
    IInstallableUnit iu = createBundleIU(bundleDescription, osgiTarget.isDirectory(), key);
    bundlePool.addDescriptor(descriptor);

    Map parameters = new HashMap();
    parameters.put(ActionConstants.PARM_AGENT, getAgent());
    parameters.put(ActionConstants.PARM_PROFILE, profile);
    EclipseTouchpoint touchpoint = new EclipseTouchpoint();
    touchpoint.initializePhase(null, profile, "test", parameters);
    InstallableUnitOperand operand = new InstallableUnitOperand(null, iu);
    parameters.put("iu", operand.second());
    touchpoint.initializeOperand(profile, parameters);

    parameters.put(ActionConstants.PARM_BUNDLE, key.toString());
    parameters = Collections.unmodifiableMap(parameters);

    SourceManipulator manipulator =
        (SourceManipulator) parameters.get(EclipseTouchpoint.PARM_SOURCE_BUNDLES);
    assertNotNull(manipulator);

    assertFalse(inBundles(manipulator, osgiTarget));
    AddSourceBundleAction action = new AddSourceBundleAction();
    action.execute(parameters);
    assertTrue(inBundles(manipulator, osgiTarget));
    action.undo(parameters);
    assertFalse(inBundles(manipulator, osgiTarget));
  }