public void testExtractRootCauseErrorStatusWithException() throws Exception {
   IStatus status =
       extractRootCause(new Status(IStatus.ERROR, "id1", "Test", new IOException("IO")));
   assertNotNull(status);
   assertEquals("id1", status.getPlugin());
   assertEquals("Test", status.getMessage());
   assertEquals("IO", status.getException().getMessage());
 }
  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);
  }
Exemple #3
0
 /**
  * Returns the cause of this exception, or <code>null</code> if none.
  *
  * @return the cause for this exception
  */
 public Throwable getCause() {
   return status.getException();
 }