Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2012-05-30 07:57:23 -0400
committerIgor Fedorenko2012-05-31 06:42:03 -0400
commitdeb2d1f14ffebeca74125ee1cc5cd88bc6df6ecb (patch)
tree2998a5ad775d4e846a3ae5eb2597cdc699c4bc7e
parent08a5d6d2242f5ebba6d66cc40353c3ebfc7bb56a (diff)
downloadorg.eclipse.tycho-tycho-0.15.x.tar.gz
org.eclipse.tycho-tycho-0.15.x.tar.xz
org.eclipse.tycho-tycho-0.15.x.zip
380904 380903 380898: normalize canonical artifact descriptortycho-0.15.0tycho-0.15.x
Change-Id: Iba7dd92318cb5afe1cf8a7cf90b969b13558e36c Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/p2/maven/repository/tests/MavenMirrorRequestTest.java65
-rw-r--r--tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/p2/maven/repository/MavenMirrorRequest.java4
2 files changed, 60 insertions, 9 deletions
diff --git a/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/p2/maven/repository/tests/MavenMirrorRequestTest.java b/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/p2/maven/repository/tests/MavenMirrorRequestTest.java
index cd8b4ae6e..3fc77bed6 100644
--- a/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/p2/maven/repository/tests/MavenMirrorRequestTest.java
+++ b/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/p2/maven/repository/tests/MavenMirrorRequestTest.java
@@ -24,6 +24,7 @@ import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest;
+import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.tycho.p2.maven.repository.Activator;
import org.eclipse.tycho.p2.maven.repository.LocalArtifactRepository;
import org.eclipse.tycho.p2.maven.repository.MavenMirrorRequest;
@@ -54,7 +55,11 @@ public class MavenMirrorRequestTest extends BaseMavenRepositoryTest {
repository.getArtifacts(new IArtifactRequest[] { request }, monitor);
- Assert.assertEquals(1, localRepository.getArtifactDescriptors(key).length);
+ IArtifactDescriptor[] descriptors = localRepository.getArtifactDescriptors(key);
+ Assert.assertEquals(1, descriptors.length);
+ Assert.assertNotNull(descriptors[0]);
+ Assert.assertTrue(descriptors[0].getProperties().isEmpty());
+ Assert.assertEquals(0, descriptors[0].getProcessingSteps().length);
}
@Test
@@ -79,12 +84,19 @@ public class MavenMirrorRequestTest extends BaseMavenRepositoryTest {
IArtifactDescriptor[] descriptors = localRepository.getArtifactDescriptors(key);
Assert.assertEquals(2, descriptors.length);
- Assert.assertNotNull(getDescriptor(descriptors, null)); // canonical
- Assert.assertNotNull(getDescriptor(descriptors, IArtifactDescriptor.FORMAT_PACKED));
-
- File file = localRepository.getArtifactFile(getDescriptor(descriptors, null));
+ IArtifactDescriptor packed = getDescriptor(descriptors, IArtifactDescriptor.FORMAT_PACKED);
+ Assert.assertNotNull(packed);
+ Assert.assertEquals(IArtifactDescriptor.FORMAT_PACKED, packed.getProperty(IArtifactDescriptor.FORMAT));
+ Assert.assertEquals(1, packed.getProcessingSteps().length);
+ Assert.assertEquals("org.eclipse.equinox.p2.processing.Pack200Unpacker",
+ packed.getProcessingSteps()[0].getProcessorId());
+
+ IArtifactDescriptor canonical = getDescriptor(descriptors, null);
+ Assert.assertNotNull(canonical);
+ Assert.assertTrue(canonical.getProperties().isEmpty());
+ Assert.assertEquals(0, canonical.getProcessingSteps().length);
+ File file = localRepository.getArtifactFile(canonical);
Assert.assertTrue(file.isFile() && file.canRead());
-
// make sure this is actually a jar
JarFile jar = new JarFile(file);
try {
@@ -92,6 +104,7 @@ public class MavenMirrorRequestTest extends BaseMavenRepositoryTest {
} finally {
jar.close();
}
+
}
@Test
@@ -129,7 +142,47 @@ public class MavenMirrorRequestTest extends BaseMavenRepositoryTest {
} finally {
jar.close();
}
+ }
+
+ @Test
+ public void testArtifactImplementationClass() throws Exception {
+ // The point of this test is to ensure that the same IArtifact implementation used by MavenMirrorRequest
+ // and by (maven) LocalArtifactRepository. If MavenMirrorRequest and LocalArtifactRepository use different
+ // IArtifact implementation, this results in duplicate copies of the artifact descriptor.
+
+ IProvisioningAgent agent = Activator.getProvisioningAgent();
+ Transport transport = (Transport) agent.getService(Transport.SERVICE_NAME);
+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent
+ .getService(IArtifactRepositoryManager.SERVICE_NAME);
+
+ IArtifactRepository repository = manager.loadRepository(new File("resources/repositories/e342").toURI(),
+ monitor);
+
+ IArtifactKey key = new ArtifactKey("osgi.bundle", "org.eclipse.osgi",
+ Version.parseVersion("3.4.3.R34x_v20081215-1030"));
+
+ LocalArtifactRepository localRepository;
+ MavenMirrorRequest request;
+ IArtifactDescriptor[] descriptors;
+
+ localRepository = new LocalArtifactRepository(localRepoIndices);
+
+ // mirror
+ request = new MavenMirrorRequest(key, localRepository, transport, false);
+ repository.getArtifacts(new IArtifactRequest[] { request }, monitor);
+ descriptors = localRepository.getArtifactDescriptors(key);
+ Assert.assertEquals(1, descriptors.length);
+ Assert.assertTrue(descriptors[0].getClass() == ArtifactDescriptor.class);
+
+ // force reload
+ localRepository.save();
+
+ // make sure the same artifact implementation is loaded from metadata
+ localRepository = new LocalArtifactRepository(localRepoIndices);
+ descriptors = localRepository.getArtifactDescriptors(key);
+ Assert.assertEquals(1, descriptors.length);
+ Assert.assertTrue(descriptors[0].getClass() == ArtifactDescriptor.class);
}
private IArtifactDescriptor getDescriptor(IArtifactDescriptor[] descriptors, String format) {
diff --git a/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/p2/maven/repository/MavenMirrorRequest.java b/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/p2/maven/repository/MavenMirrorRequest.java
index f09727a90..dffea5aa0 100644
--- a/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/p2/maven/repository/MavenMirrorRequest.java
+++ b/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/p2/maven/repository/MavenMirrorRequest.java
@@ -22,7 +22,6 @@ import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
-import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
@SuppressWarnings("restriction")
public class MavenMirrorRequest extends MirrorRequest {
@@ -94,8 +93,7 @@ public class MavenMirrorRequest extends MirrorRequest {
}
// copy jar
- ArtifactDescriptor targetDescriptor = new ArtifactDescriptor(canonical);
- targetDescriptor.setProperty(IArtifactDescriptor.FORMAT, null);
+ IArtifactDescriptor targetDescriptor = target.createArtifactDescriptor(canonical.getArtifactKey());
IStatus status = Status.OK_STATUS;
if (!target.contains(targetDescriptor)) {
monitor.subTask("Downloading " + getArtifactKey().getId());

Back to the top