Esempio n. 1
0
  public void testInitCompleteOperand() {
    TestPhase phase =
        new TestPhase() {
          protected IStatus completeOperand(
              IProfile profile, Operand operand, Map parameters, IProgressMonitor monitor) {
            assertTrue(parameters.containsKey("TestPhase.initializeOperand"));
            assertFalse(completeOperand);
            super.completeOperand(profile, operand, parameters, monitor);
            assertTrue(parameters.containsKey("TestPhase.initializeOperand"));
            assertTrue(completeOperand);
            return null;
          }

          protected IStatus initializeOperand(
              IProfile profile, Operand operand, Map parameters, IProgressMonitor monitor) {
            assertFalse(parameters.containsKey("TestPhase.initializeOperand"));
            assertFalse(completeOperand);
            super.initializeOperand(profile, operand, parameters, monitor);
            assertTrue(parameters.containsKey("TestPhase.initializeOperand"));
            assertFalse(completeOperand);
            return null;
          }
        };
    PhaseSet phaseSet = new TestPhaseSet(phase);
    IProfile profile = createProfile("PhaseTest");
    IInstallableUnit unit = createIU("testInitCompleteOperand");

    IProvisioningPlan plan = engine.createPlan(profile, null);
    plan.addInstallableUnit(unit);
    engine.perform(plan, phaseSet, new NullProgressMonitor());
    assertTrue(phase.initializeOperand);
    assertTrue(phase.completeOperand);
  }
  public void testChangeIUProperty() {
    // Add into the profile the version a1;
    ProfileChangeRequest req = new ProfileChangeRequest(profile);
    req.addInstallableUnits(new IInstallableUnit[] {a1});
    req.setInstallableUnitProfileProperty(
        a1, IProfile.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString());
    IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null);
    assertEquals(IStatus.OK, plan.getStatus().getSeverity());
    engine.perform(plan, null);
    assertProfileContainsAll("A1 is missing", profile, new IInstallableUnit[] {a1});

    IProfileRegistry profileRegistry = getProfileRegistry();
    profile = profileRegistry.getProfile(profile.getProfileId());
    IQueryResult c = profile.query(new UserVisibleRootQuery(), null);
    assertEquals(queryResultSize(c), 1);

    System.gc();
    ProfileChangeRequest req2 =
        ProfileChangeRequest.createByProfileId(getAgent(), profile.getProfileId());
    req2.removeInstallableUnits(new IInstallableUnit[] {a1});
    req2.addInstallableUnits(new IInstallableUnit[] {a2});
    //		req2.setInstallableUnitProfileProperty(a2, IProfile.PROP_PROFILE_ROOT_IU,
    // Boolean.TRUE.toString());
    IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null);
    assertEquals(IStatus.OK, plan2.getStatus().getSeverity());
    assertInstallOperand(plan2, a2);
    engine.perform(plan2, null);
    profile = getProfile(profile.getProfileId());
    assertProfileContains("A2 is missing", profile, new IInstallableUnit[] {a2});
  }
Esempio n. 3
0
  public void testOneIUWithMultiplePatchesApplyingOnIt() {
    //				//Confirm that f1 can't be installed
    //				ProfileChangeRequest req1 = new ProfileChangeRequest(profile1);
    //				req1.addInstallableUnits(new IInstallableUnit[] {f1});
    //				ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null);
    //				assertEquals(IStatus.ERROR, plan1.getStatus().getSeverity());
    //
    //				//Verify that the installation of f1 and p1 succeed
    //				ProfileChangeRequest req2 = new ProfileChangeRequest(profile1);
    //				req2.addInstallableUnits(new IInstallableUnit[] {f1, p1});
    //				ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null);
    //				assertEquals(IStatus.WARNING, plan2.getStatus().getSeverity());
    //				assertInstallOperand(plan2, f1);
    //				assertInstallOperand(plan2, a1);
    //				assertInstallOperand(plan2, b1);
    //				assertInstallOperand(plan2, c1);
    //				assertInstallOperand(plan2, x1);
    //				assertInstallOperand(plan2, y1);
    //				assertInstallOperand(plan2, p1);

    // Verify that the installation of f1 and p1 succeed
    ProfileChangeRequest req3 = new ProfileChangeRequest(profile1);
    req3.addInstallableUnits(new IInstallableUnit[] {f1, p1, r1});
    IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null);
    assertEquals(IStatus.OK, plan3.getStatus().getSeverity());
  }
Esempio n. 4
0
 private IStatus performOperation(
     IProfile profile, IProfileChangeRequest request, IProgressMonitor monitor) {
   ProvisioningContext context = new ProvisioningContext(agent);
   IProvisioningPlan plan = planner.getProvisioningPlan(request, context, monitor);
   if (!plan.getStatus().isOK()) return plan.getStatus();
   // add the id IU if its not already installed.
   plan = installIdIU(plan);
   return engine.perform(plan, monitor);
 }
Esempio n. 5
0
 /**
  * Add in an IU that sets the toast.id system property to identify the client running this profile
  */
 private IProvisioningPlan installIdIU(IProvisioningPlan plan) {
   IQuery query = QueryUtil.createIUQuery("toast.id");
   IQueryResult toastIU = plan.getProfile().query(query, null);
   // If we find the id IU then it is already installed.
   //		if (!toastIU.isEmpty())
   //			return plan;
   IInstallableUnit idIU = createIdIU(plan.getProfile().getProfileId());
   plan.addInstallableUnit(idIU);
   return plan;
 }
 public void testInstallation() {
   // Ensure that D's installation does not fail because of C's absence
   ProfileChangeRequest req = new ProfileChangeRequest(profile);
   req.addInstallableUnits(new IInstallableUnit[] {a1, b1});
   IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null);
   assertEquals(IStatus.OK, plan.getStatus().getSeverity());
   assertInstallOperand(plan, a1);
   assertInstallOperand(plan, b1);
   assertInstallOperand(plan, b2);
   assertInstallOperand(plan, b3);
   assertInstallOperand(plan, b4);
 }
Esempio n. 7
0
  public void testGetAction() {
    final ArrayList actionsList1 = new ArrayList();
    InstallableUnitPhase phase1 =
        new InstallableUnitPhase("test", 1) {
          protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) {
            List<ProvisioningAction> actions = getActions(operand.second(), "test1");
            actionsList1.addAll(actions);
            return actions;
          }
        };
    final ArrayList actionsList2 = new ArrayList();
    InstallableUnitPhase phase2 =
        new InstallableUnitPhase("test", 1) {
          protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) {
            List<ProvisioningAction> actions = getActions(operand.second(), "test2");
            actionsList2.addAll(actions);
            return actions;
          }
        };

    PhaseSet phaseSet = new TestPhaseSet(new Phase[] {phase1, phase2});
    IProfile profile = createProfile("PhaseTest");

    Map instructions = new HashMap();
    instructions.put("test1", MetadataFactory.createTouchpointInstruction("test1.test()", null));
    instructions.put("test2", MetadataFactory.createTouchpointInstruction("test2.test()", null));
    ITouchpointData touchpointData = MetadataFactory.createTouchpointData(instructions);
    IInstallableUnit unit =
        createIU(
            "test",
            Version.create("1.0.0"),
            null,
            NO_REQUIRES,
            new IProvidedCapability[0],
            NO_PROPERTIES,
            ITouchpointType.NONE,
            touchpointData,
            false);
    IProvisioningPlan plan = engine.createPlan(profile, null);
    plan.addInstallableUnit(unit);
    IStatus status = engine.perform(plan, phaseSet, new NullProgressMonitor());
    if (!status.isOK()) {
      fail(status.toString());
    }

    assertEquals(
        TestAction.class,
        ((ParameterizedProvisioningAction) actionsList1.get(0)).getAction().getClass());
    assertEquals(
        TestAction.class,
        ((ParameterizedProvisioningAction) actionsList2.get(0)).getAction().getClass());
  }
 public long getSize(
     IProvisioningPlan provisioningPlan,
     IProfile profile,
     IEngine engine,
     ProvisioningContext context,
     IProgressMonitor monitor) {
   // If there is nothing to size, return 0
   if (provisioningPlan == null) {
     return SIZE_NOTAPPLICABLE;
   }
   if (((ProvisioningPlan) provisioningPlan).getOperands().length == 0) {
     return 0;
   }
   long installPlanSize = 0;
   if (provisioningPlan.getInstallerPlan() != null) {
     SizingPhaseSet set = new SizingPhaseSet(new Sizing(100));
     IStatus status = engine.perform(provisioningPlan, set, null);
     if (status.isOK()) {
       installPlanSize = set.getSizing().getDiskSize();
     }
   }
   SizingPhaseSet set = new SizingPhaseSet(new Sizing(100));
   IStatus status = engine.perform(provisioningPlan, set, null);
   if (status.isOK()) {
     return installPlanSize + set.getSizing().getDiskSize();
   }
   return SIZE_UNAVAILABLE;
 }
Esempio n. 9
0
  public void testGetProfileDataArea() {
    TestPhase phase =
        new TestPhase() {
          protected IStatus initializePhase(
              IProgressMonitor monitor, IProfile profile, Map parameters) {
            File profileDataArea = (File) parameters.get("profileDataDirectory");
            assertTrue(profileDataArea.isDirectory());
            File test = new File(profileDataArea, "test");
            assertFalse(test.exists());
            try {
              test.createNewFile();
            } catch (IOException e) {
              fail(e.getMessage());
            }
            assertTrue(test.exists());
            return super.initializePhase(monitor, profile, parameters);
          }

          protected IStatus completePhase(
              IProgressMonitor monitor, IProfile profile, Map parameters) {
            File profileDataArea = (File) parameters.get("profileDataDirectory");
            assertTrue(profileDataArea.isDirectory());
            File test = new File(profileDataArea, "test");
            assertTrue(test.exists());
            test.delete();
            assertFalse(test.exists());
            return super.completePhase(monitor, profile, parameters);
          }
        };
    PhaseSet phaseSet = new TestPhaseSet(phase);
    IProfile profile = createProfile("PhaseTest");
    IInstallableUnit unit = createIU("testGetProfileDataArea");

    IProvisioningPlan plan = engine.createPlan(profile, null);
    plan.addInstallableUnit(unit);
    engine.perform(plan, phaseSet, new NullProgressMonitor());
    assertTrue(phase.initializePhase);
    assertTrue(phase.completePhase);
  }
Esempio n. 10
0
  public void testGreedy() throws ProvisionException, OperationCanceledException {
    URI heliosRepo = getTestData("helios", "testData/bug306279/repo/helios").toURI();
    URI rienaRepo2 =
        getTestData("rienatoolbox-a", "testData/bug306279/repo/rienatoolbox-a").toURI();
    IMetadataRepository repo1 = getMetadataRepositoryManager().loadRepository(heliosRepo, null);
    assertFalse(
        repo1
            .query(
                QueryUtil.createIUQuery("org.eclipse.rap.jface.databinding"),
                new NullProgressMonitor())
            .isEmpty());
    IMetadataRepository repo2 = getMetadataRepositoryManager().loadRepository(rienaRepo2, null);

    IPlanner planner = getPlanner(getAgent());
    IProfile profile = createProfile(getName());
    IProfileChangeRequest request = new ProfileChangeRequest(profile);
    Set<IInstallableUnit> ius =
        repo2
            .query(
                QueryUtil.createIUQuery("org.eclipse.riena.toolbox.feature.feature.group"),
                new NullProgressMonitor())
            .toUnmodifiableSet();
    request.addAll(ius);
    ProvisioningContext ctx = new ProvisioningContext(getAgent());
    ctx.setMetadataRepositories(new URI[] {heliosRepo, rienaRepo2});
    IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor());

    assertOK("resolution failed", plan.getStatus());
    assertEquals(
        0,
        plan.getAdditions()
            .query(
                QueryUtil.createIUQuery("org.eclipse.rap.jface.databinding"),
                new NullProgressMonitor())
            .toUnmodifiableSet()
            .size());
    System.out.println(plan);
  }