Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2009-04-29 19:25:16 +0000
committerPascal Rapicault2009-04-29 19:25:16 +0000
commit6c0796ef4acc9cf42114bb30093045230a03151f (patch)
tree60d68195d0ce7400e638e07c7f4f977215f1476e /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact
parentba712139afe03ba316cdd1aff7ca2c637006a999 (diff)
downloadrt.equinox.p2-6c0796ef4acc9cf42114bb30093045230a03151f.tar.gz
rt.equinox.p2-6c0796ef4acc9cf42114bb30093045230a03151f.tar.xz
rt.equinox.p2-6c0796ef4acc9cf42114bb30093045230a03151f.zip
Bug 272719 - [repository] root cause of failure is hidden when merging 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/MirrorRequestTest.java66
1 files changed, 61 insertions, 5 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java
index 6ce85ed92..555a9c9b3 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java
@@ -30,12 +30,14 @@ import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.AbstractArtifactRepository;
import org.eclipse.equinox.internal.provisional.spi.p2.repository.AbstractRepository;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.tests.AbstractWrappedArtifactRepository;
import org.w3c.dom.*;
public class MirrorRequestTest extends AbstractProvisioningTest {
private static final String testDataLocation = "testData/artifactRepo/emptyJarRepo";
File targetLocation;
IArtifactRepository targetRepository, sourceRepository;
+ URI destination, failedOptimized;
public void setUp() throws Exception {
super.setUp();
@@ -46,16 +48,21 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
IArtifactRepositoryManager mgr = getArtifactRepositoryManager();
sourceRepository = mgr.loadRepository((getTestData("EmptyJar repo", testDataLocation).toURI()), null);
-
+ failedOptimized = URIUtil.toJarURI(getTestData("Error loading test data", "testData/mirror/invalidPackedMissingCanonical.zip").toURI(), null);
+ destination = getTempFolder().toURI();
}
protected void tearDown() throws Exception {
+ getArtifactRepositoryManager().removeRepository(destination);
+ getArtifactRepositoryManager().removeRepository(failedOptimized);
+ getArtifactRepositoryManager().removeRepository(targetLocation.toURI());
AbstractProvisioningTest.delete(targetLocation);
+ delete(new File(destination));
super.tearDown();
}
public void testInvalidZipFileInTheSource() {
- IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "HelloWorldFeature", new Version(1, 0, 0));
+ IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "HelloWorldFeature", Version.createOSGi(1, 0, 0));
Properties targetProperties = new Properties();
targetProperties.put("artifact.folder", "true");
MirrorRequest request = new MirrorRequest(key, targetRepository, null, targetProperties);
@@ -68,7 +75,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
}
public void testMissingArtifact() {
- IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "Missing", new Version(1, 0, 0));
+ IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "Missing", Version.createOSGi(1, 0, 0));
Properties targetProperties = new Properties();
targetProperties.put("artifact.folder", "true");
MirrorRequest request = new MirrorRequest(key, targetRepository, null, targetProperties);
@@ -83,7 +90,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
public void testFailToCanonical() {
RemoteRepo src = new RemoteRepo((SimpleArtifactRepository) sourceRepository);
- IArtifactKey key = new ArtifactKey("test.txt", "fail_to_canonical", new Version("1.0.0"));
+ IArtifactKey key = new ArtifactKey("test.txt", "fail_to_canonical", Version.parseVersion("1.0.0"));
MirrorRequest request = new MirrorRequest(key, targetRepository, null, null);
request.setSourceRepository(src);
request.perform(new NullProgressMonitor());
@@ -98,7 +105,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
OrderedMirrorSelector selector = new OrderedMirrorSelector(sourceRepository);
// call test
- IArtifactKey key = new ArtifactKey("test.txt", "HelloWorldText", new Version("1.0.0"));
+ IArtifactKey key = new ArtifactKey("test.txt", "HelloWorldText", Version.parseVersion("1.0.0"));
MirrorRequest request = new MirrorRequest(key, targetRepository, null, null);
request.setSourceRepository(sourceRepository);
request.perform(new NullProgressMonitor());
@@ -109,6 +116,55 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
assertTrue("All mirrors utilized", selector.index == selector.mirrors.length);
}
+ public void testFailedOptimizedMissingCanonical() {
+
+ try {
+ IArtifactRepository source = new AbstractWrappedArtifactRepository(getArtifactRepositoryManager().loadRepository(failedOptimized, new NullProgressMonitor())) {
+ public URI getLocation() {
+ try {
+ return new URI("http://nowhere");
+ } catch (URISyntaxException e) {
+ fail("Failed to create URI", e);
+ return null;
+ }
+ }
+ };
+ IArtifactRepository target = getArtifactRepositoryManager().createRepository(destination, "Destination", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, null);
+
+ IArtifactKey key = new ArtifactKey("osgi.bundle", "org.eclipse.ve.jfc", Version.parseVersion("1.4.0.HEAD"));
+ MirrorRequest req = new MirrorRequest(key, target, null, null);
+ req.setSourceRepository(source);
+
+ req.perform(new NullProgressMonitor());
+ IStatus result = req.getResult();
+ assertTrue("MirrorRequest should have failed", result.matches(IStatus.ERROR));
+ assertEquals("Result should contain two failures", 2, result.getChildren().length);
+ assertStatusContains("Return status does not contain Signature Verification failure", result, "Invalid content:");
+ assertStatusContains("Return status does not contain Missing Artifact status", result, "Artifact not found:");
+ } catch (ProvisionException e) {
+ fail("Failed to load repositories", e);
+ }
+ }
+
+ protected static void assertStatusContains(String message, IStatus status, String statusString) {
+ if (!statusContains(status, statusString))
+ fail(message);
+ }
+
+ private static boolean statusContains(IStatus status, String statusString) {
+ if (status.getMessage().indexOf(statusString) != -1)
+ return true;
+ if (!status.isMultiStatus())
+ return false;
+
+ IStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++)
+ if (statusContains(children[i], statusString))
+ return true;
+
+ return false;
+ }
+
// Repository which misleads about its location
protected class RemoteRepo extends AbstractArtifactRepository {
SimpleArtifactRepository delegate;

Back to the top