Example #1
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());
  }
Example #2
0
  public void testTransferError() throws Exception {
    File simpleRepo = getTestData("simple repository", "testData/artifactRepo/transferTestRepo");
    IArtifactRepository source = null;
    IArtifactRepository target = null;
    try {
      source =
          getArtifactRepositoryManager()
              .loadRepository(simpleRepo.toURI(), new NullProgressMonitor());
      target = createArtifactRepository(new File(getTempFolder(), getName()).toURI(), null);
    } catch (ProvisionException e) {
      fail("failing setting up the tests", e);
    }

    IArtifactDescriptor sourceDescriptor =
        getArtifactKeyFor(
            source, "osgi.bundle", "missingFromFileSystem", Version.createOSGi(1, 0, 0))[0];
    SimpleArtifactDescriptor targetDescriptor = new SimpleArtifactDescriptor(sourceDescriptor);
    targetDescriptor.setRepositoryProperty("artifact.folder", "true");
    class TestRequest extends MirrorRequest {
      public TestRequest(
          IArtifactKey key,
          IArtifactRepository targetRepository,
          Map<String, String> targetDescriptorProperties,
          Map<String, String> targetRepositoryProperties) {
        super(
            key,
            targetRepository,
            targetDescriptorProperties,
            targetRepositoryProperties,
            getTransport());
      }

      public void setSource(IArtifactRepository source) {
        super.setSourceRepository(source);
      }
    }
    TestRequest request =
        new TestRequest(
            new ArtifactKey("osgi.bundle", "missingFromFileSystem", Version.createOSGi(1, 0, 0)),
            target,
            null,
            null);
    request.setSource(source);
    IStatus s =
        transferSingle(request, targetDescriptor, sourceDescriptor, new NullProgressMonitor());
    assertTrue(s.toString(), s.getException().getClass() == FileNotFoundException.class);
  }