Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2009-04-09 17:27:15 +0000
committerPascal Rapicault2009-04-09 17:27:15 +0000
commitff14e77bec38fbd0d4e8d5636f97f4665873c2da (patch)
treec28466922a99be2abe0b8ff831440fd308e97495 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact
parentb954df11db3ae7575fd018878cdc9f65e5110a29 (diff)
downloadrt.equinox.p2-ff14e77bec38fbd0d4e8d5636f97f4665873c2da.tar.gz
rt.equinox.p2-ff14e77bec38fbd0d4e8d5636f97f4665873c2da.tar.xz
rt.equinox.p2-ff14e77bec38fbd0d4e8d5636f97f4665873c2da.zip
additional test for processing steps
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java78
1 files changed, 73 insertions, 5 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
index 3b9c44874..d711d7eb6 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
@@ -11,20 +11,22 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
-
-import java.io.File;
+import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
+import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.SimpleArtifactRepositoryFactory;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
@@ -167,4 +169,70 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
fail("2.0", e);
}
}
+
+ public void testErrorStatus() {
+ class TestStep extends ProcessingStep {
+ IStatus myStatus;
+
+ public TestStep(IStatus status) {
+ this.myStatus = status;
+ }
+
+ public void close() throws IOException {
+ setStatus(myStatus);
+ super.close();
+ }
+ }
+ repositoryURI = getTestData("Loading test data", "testData/artifactRepo/simple").toURI();
+ repositoryFile = new File(getTempFolder(), getUniqueString());
+
+ IArtifactRepository repo = null;
+ try {
+ repo = getArtifactRepositoryManager().loadRepository(repositoryURI, new NullProgressMonitor());
+ } catch (ProvisionException e) {
+ fail("Failed to create repository", e);
+ }
+ IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", new Version("1.0.0")));
+
+ OutputStream out = null;
+ try {
+ TestStep errStep = new TestStep(new Status(IStatus.ERROR, "plugin", "Error Step Message"));
+ TestStep warnStep = new TestStep(new Status(IStatus.WARNING, "plugin", "Warning Step Message"));
+ TestStep okStep = new TestStep(Status.OK_STATUS);
+ out = new FileOutputStream(repositoryFile);
+ (new ProcessingStepHandler()).link(new ProcessingStep[] {okStep, errStep, warnStep}, out, new NullProgressMonitor());
+ IStatus status = repo.getRawArtifact(descriptor, okStep, new NullProgressMonitor());
+ out.close();
+
+ // Only the error step should be collected
+ assertFalse(status.isOK());
+ assertTrue("Unexpected Severity", status.matches(IStatus.ERROR));
+ assertEquals(1, status.getChildren().length);
+
+ errStep = new TestStep(new Status(IStatus.ERROR, "plugin", "Error Step Message"));
+ warnStep = new TestStep(new Status(IStatus.WARNING, "plugin", "Warning Step Message"));
+ TestStep warnStep2 = new TestStep(new Status(IStatus.WARNING, "plugin", "2 - Warning Step Message"));
+ okStep = new TestStep(Status.OK_STATUS);
+ out = new FileOutputStream(repositoryFile);
+ (new ProcessingStepHandler()).link(new ProcessingStep[] {okStep, warnStep, errStep, warnStep2}, out, new NullProgressMonitor());
+ status = repo.getRawArtifact(descriptor, okStep, new NullProgressMonitor());
+ out.close();
+
+ // The first warning step and the error step should be collected
+ assertFalse(status.isOK());
+ assertTrue("Unexpected Severity", status.matches(IStatus.ERROR));
+ assertEquals(2, status.getChildren().length);
+
+ } catch (IOException e) {
+ fail("Failed to create ouptut stream", e);
+ } finally {
+ if (out != null)
+ try {
+ out.close();
+ } catch (IOException e) {
+ // don't care
+ }
+ }
+
+ }
}

Back to the top