Skip to content

Commit

Permalink
Adapt to removed support for loading pack.gz packaged artifacts in P2
Browse files Browse the repository at this point in the history
Eclipse P2 got its support for loading pack.gz packed artifacts from
repositories finally removed in
eclipse-equinox/p2#310.

In order to fix the tests, remove packed duplicates from and replace
only packed ecf artifact with unpacked eclipse.core.runtime artifact in
test repository at '\resources\repositories\packgz'
  • Loading branch information
HannesWell authored and akurtakov committed Dec 7, 2023
1 parent 82e571d commit bdfe7a5
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@ public void testGetArtifactDescriptorsDoesNotReturnDuplicates() {
List<IArtifactDescriptor> result = Arrays.asList(subject.getArtifactDescriptors(BUNDLE_A_KEY));

assertThat(result, hasItem(inCanonicalFormat()));
assertEquals(2, result.size()); // no duplicates
assertEquals(1, result.size()); // no duplicates
}

@Test
public void testContainsArtifactDescriptor() {
assertTrue(subject.contains(canonicalDescriptorFor(BUNDLE_A_KEY)));
assertFalse(subject.contains(canonicalDescriptorFor(BUNDLE_B_KEY)));
assertTrue(subject.contains(canonicalDescriptorFor(BUNDLE_B_KEY)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.eclipse.tycho.test.util.ProbeArtifactSink.newArtifactSinkFor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;

import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
Expand All @@ -36,7 +37,7 @@

public class MirroringArtifactProviderErrorTest extends TychoPlexusTestCase {

private static final IArtifactKey CORRUPT_ARTIFACT = TestRepositoryContent.BUNDLE_B_KEY;
private static final IArtifactKey CORRUPT_ARTIFACT = TestRepositoryContent.BUNDLE_A_KEY;

@Rule
public LogVerifier logVerifier = new LogVerifier();
Expand All @@ -58,19 +59,15 @@ public void before() throws Exception {
new MockMavenContext(null, logVerifier.getLogger()));
}

@Test(expected = MirroringFailedException.class)
@Test
public void testMirrorCorruptArtifact() throws Exception {
logVerifier.expectError(CORRUPT_ARTIFACT.toString());

testSink = newArtifactSinkFor(CORRUPT_ARTIFACT);
try {
// here we expect an exception, an not (!) an error status, to be consistent with other methods that mirror but don't return a status
subject.getArtifact(testSink, null);

} finally {
assertNotMirrored(CORRUPT_ARTIFACT);
assertFalse(testSink.writeIsStarted());
}
// here we expect an exception, an not (!) an error status, to be consistent with other methods that mirror but don't return a status
assertThrows(MirroringFailedException.class, () -> subject.getArtifact(testSink, null));
assertNotMirrored(CORRUPT_ARTIFACT);
assertFalse(testSink.writeIsStarted());
}

private void assertNotMirrored(IArtifactKey key) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public final class TestRepositoryContent {

public static final IArtifactKey BUNDLE_A_KEY = new ArtifactKey("osgi.bundle", "org.eclipse.osgi",
Version.parseVersion("3.4.3.R34x_v20081215-1030"));
public static final IArtifactKey BUNDLE_B_KEY = new ArtifactKey("osgi.bundle", "org.eclipse.ecf",
Version.parseVersion("3.1.300.v20120319-0616"));
public static final IArtifactKey BUNDLE_B_KEY = new ArtifactKey("osgi.bundle", "org.eclipse.core.runtime",
Version.parseVersion("3.4.0.v20080512"));

public static final Set<String> BUNDLE_A_FILES = new HashSet<>(Arrays.asList("about_files/", "META-INF/",
"META-INF/MANIFEST.MF", "org/", "org/eclipse/", "org/eclipse/core/", "org/eclipse/core/runtime/",
Expand Down Expand Up @@ -73,13 +73,10 @@ public final class TestRepositoryContent {
// repositories (of regular p2 type) containing the test data

/** Repository with bundle A */
public static final URI REPO_BUNDLE_A = P2Repositories.ECLIPSE_342.toURI();
public static final URI REPO_BUNDLE_A = ResourceUtil.resourceFile("repositories/e342").toURI();
public static final URI REPO2_BUNDLE_A = ResourceUtil.resourceFile("repositories2/e342").toURI();
/**
* Repository with bundles A and B. Bundle A is available both in packed and canonical format,
* bundle B only in packed format.
*/
public static final URI REPO_BUNDLE_AB = P2Repositories.PACK_GZ.toURI();
/** Repository with bundles A and B. Both bundles are available in canonical format. */
public static final URI REPO_BUNDLE_AB = ResourceUtil.resourceFile("repositories/e342_3").toURI();

/** Repository that claims to contain bundle A, but accesses to the artifact file will fail */
public static final URI REPO_BUNDLE_A_CORRUPT = ResourceUtil.resourceFile("repositories/e342_missing_file").toURI();
Expand All @@ -88,7 +85,7 @@ public final class TestRepositoryContent {
* format, but the artifact is broken. Bundle A is contained in packed format (artifact missing)
* and in canonical format (working).
*/
public static final URI REPO_BUNLDE_AB_PACK_CORRUPT = ResourceUtil.resourceFile("repositories/packgz_corrupt")
public static final URI REPO_BUNLDE_AB_PACK_CORRUPT = ResourceUtil.resourceFile("repositories/e342_corrupt")
.toURI();

}
30 changes: 30 additions & 0 deletions tycho-core/src/test/resources/repositories/e342_3/artifacts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version='1.0' encoding='UTF-8'?>
<?artifactRepository version='1.1.0'?>
<repository name='e342_3' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1'>
<properties size='2'>
<property name='p2.compressed' value='false'/>
<property name='p2.timestamp' value='1338060413228'/>
</properties>
<mappings size='3'>
<rule filter='(&amp; (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
<rule filter='(&amp; (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
<rule filter='(&amp; (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
</mappings>
<artifacts size='2'>
<artifact classifier='osgi.bundle' id='org.eclipse.core.runtime' version='3.4.0.v20080512'>
<properties size='3'>
<property name='artifact.size' value='69026'/>
<property name='download.size' value='69026'/>
<property name='download.md5' value='c1c7af4eaca62fcc24f82c2c02ac77dd'/>
</properties>
</artifact>
<artifact classifier='osgi.bundle' id='org.eclipse.osgi' version='3.4.3.R34x_v20081215-1030'>
<properties size='4'>
<property name='artifact.size' value='11034'/>
<property name='download.size' value='11034'/>
<property name='download.md5' value='58057045158895009b845b9a93f3eb6e'/>
<property name='download.contentType' value='application/zip'/>
</properties>
</artifact>
</artifacts>
</repository>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<?metadataRepository version='1.1.0'?>
<repository name='packgz' type='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1'>
<repository name='e342_3' type='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1'>
<properties size='2'>
<property name='p2.compressed' value='false'/>
<property name='p2.timestamp' value='1338060413234'/>
Expand Down Expand Up @@ -267,45 +267,43 @@
</provides>
<touchpoint id='org.eclipse.equinox.p2.native' version='1.0.0'/>
</unit>
<unit id='org.eclipse.ecf' version='3.1.300.v20120319-0616'>
<update id='org.eclipse.ecf' range='[0.0.0,3.1.300.v20120319-0616)' severity='0'/>
<properties size='2'>
<property name='org.eclipse.equinox.p2.name' value='%plugin.name'/>
<property name='org.eclipse.equinox.p2.provider' value='%plugin.provider'/>
<unit id='org.eclipse.core.runtime' version='3.4.0.v20080512'>
<update id='org.eclipse.core.runtime' range='[0.0.0,3.4.0.v20080512)' severity='0'/>
<properties size='5'>
<property name='df_LT.providerName' value='Eclipse.org'/>
<property name='df_LT.pluginName' value='Core Runtime'/>
<property name='org.eclipse.equinox.p2.name' value='%pluginName'/>
<property name='org.eclipse.equinox.p2.provider' value='%providerName'/>
<property name='org.eclipse.equinox.p2.bundle.localization' value='plugin'/>
</properties>
<provides size='13'>
<provided namespace='org.eclipse.equinox.p2.iu' name='org.eclipse.ecf' version='3.1.300.v20120319-0616'/>
<provided namespace='osgi.bundle' name='org.eclipse.ecf' version='3.1.300.v20120319-0616'/>
<provided namespace='java.package' name='org.eclipse.ecf.core' version='3.0.0'/>
<provided namespace='java.package' name='org.eclipse.ecf.core.events' version='0.0.0'/>
<provided namespace='java.package' name='org.eclipse.ecf.core.jobs' version='1.0.0'/>
<provided namespace='java.package' name='org.eclipse.ecf.core.provider' version='0.0.0'/>
<provided namespace='java.package' name='org.eclipse.ecf.core.security' version='0.0.0'/>
<provided namespace='java.package' name='org.eclipse.ecf.core.start' version='0.0.0'/>
<provided namespace='java.package' name='org.eclipse.ecf.core.status' version='1.0.0'/>
<provided namespace='java.package' name='org.eclipse.ecf.core.user' version='0.0.0'/>
<provided namespace='java.package' name='org.eclipse.ecf.core.util' version='0.0.0'/>
<provided namespace='java.package' name='org.eclipse.ecf.internal.core' version='0.0.0'/>
<provides size='7'>
<provided namespace='org.eclipse.equinox.p2.iu' name='org.eclipse.core.runtime' version='3.4.0.v20080512'/>
<provided namespace='osgi.bundle' name='org.eclipse.core.runtime' version='3.4.0.v20080512'/>
<provided namespace='java.package' name='org.eclipse.core.internal.preferences.legacy' version='0.0.0'/>
<provided namespace='java.package' name='org.eclipse.core.internal.runtime' version='0.0.0'/>
<provided namespace='java.package' name='org.eclipse.core.runtime' version='3.4.0'/>
<provided namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' version='1.0.0'/>
<provided namespace='org.eclipse.equinox.p2.localization' name='df_LT' version='1.0.0'/>
</provides>
<requires size='8'>
<required namespace='osgi.bundle' name='org.eclipse.equinox.common' range='0.0.0'/>
<required namespace='osgi.bundle' name='org.eclipse.equinox.registry' range='0.0.0'/>
<required namespace='osgi.bundle' name='org.eclipse.ecf.identity' range='0.0.0'/>
<required namespace='java.package' name='org.eclipse.core.runtime.jobs' range='0.0.0'/>
<required namespace='java.package' name='org.eclipse.equinox.concurrent.future' range='1.0.0' optional='true'/>
<required namespace='java.package' name='org.osgi.framework' range='1.3.0'/>
<required namespace='java.package' name='org.osgi.service.log' range='1.3.0'/>
<required namespace='java.package' name='org.osgi.util.tracker' range='1.3.2'/>
<requires size='9'>
<required namespace='osgi.bundle' name='org.eclipse.osgi' range='[3.2.0,4.0.0)'/>
<required namespace='osgi.bundle' name='org.eclipse.equinox.common' range='[3.2.0,4.0.0)'/>
<required namespace='osgi.bundle' name='org.eclipse.core.jobs' range='[3.2.0,4.0.0)'/>
<required namespace='osgi.bundle' name='org.eclipse.equinox.registry' range='[3.4.0,4.0.0)'/>
<required namespace='osgi.bundle' name='org.eclipse.equinox.preferences' range='[3.2.0,4.0.0)'/>
<required namespace='osgi.bundle' name='org.eclipse.core.contenttype' range='[3.3.0,4.0.0)'/>
<required namespace='osgi.bundle' name='org.eclipse.core.runtime.compatibility.auth' range='[3.2.0,4.0.0)' optional='true'/>
<required namespace='osgi.bundle' name='org.eclipse.equinox.app' range='[1.0.0,2.0.0)'/>
<required namespace='java.package' name='org.eclipse.core.internal.runtime.auth' range='0.0.0' optional='true'/>
</requires>
<artifacts size='1'>
<artifact classifier='osgi.bundle' id='org.eclipse.ecf' version='3.1.300.v20120319-0616'/>
<artifact classifier='osgi.bundle' id='org.eclipse.core.runtime' version='3.4.0.v20080512'/>
</artifacts>
<touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
<touchpointData size='1'>
<instructions size='1'>
<instruction key='manifest'>
Import-Package: org.eclipse.core.runtime.jobs,org.eclipse.equinox.concurrent.future;version=&quot;1.0.0&quot;;resolution:=optional,org.osgi.framework;version=&quot;1.3.0&quot;,org.osgi.service.log;version=&quot;1.3.0&quot;,org.osgi.util.tracker;version=&quot;1.3.2&quot;&#xA;Bundle-ManifestVersion: 2&#xA;Created-By: 1.5.0_22-b03 (Sun Microsystems Inc.)&#xA;Manifest-Version: 1.0&#xA;Bundle-Name: %plugin.name&#xA;Bundle-Vendor: %plugin.provider&#xA;Bundle-ActivationPolicy: lazy&#xA;Ant-Version: Apache Ant 1.7.1&#xA;Bundle-Version: 3.1.300.v20120319-0616&#xA;Export-Package: org.eclipse.ecf.core;version=&quot;3.0.0&quot;,org.eclipse.ecf.core.events,org.eclipse.ecf.core.jobs;version=&quot;1.0&quot;;x-internal:=true,org.eclipse.ecf.core.provider,org.eclipse.ecf.core.security,org.eclipse.ecf.core.start,org.eclipse.ecf.core.status;version=&quot;1.0&quot;;x-internal:=true,org.eclipse.ecf.core.user,org.eclipse.ecf.core.util,org.eclipse.ecf.internal.core;x-internal:=true&#xA;Require-Bundle: org.eclipse.equinox.common,org.eclipse.equinox.registry,org.eclipse.ecf.identity;visibility:=reexport&#xA;Bundle-Activator: org.eclipse.ecf.internal.core.ECFPlugin&#xA;Bundle-SymbolicName: org.eclipse.ecf;singleton:=true&#xA;Eclipse-LazyStart: true&#xA;Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,J2SE-1.4&#xA;Bundle-Localization: plugin&#xA;
Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0,J2SE-1.3&#xA;Bundle-Name: %pluginName&#xA;Bundle-Activator: org.eclipse.core.internal.runtime.PlatformActivator&#xA;Manifest-Version: 1.0&#xA;Bundle-Vendor: %providerName&#xA;Bundle-ActivationPolicy: lazy&#xA;Bundle-SymbolicName: org.eclipse.core.runtime; singleton:=true&#xA;Bundle-ManifestVersion: 2&#xA;DynamicImport-Package: org.eclipse.core.internal.runtime.auth&#xA;Bundle-Version: 3.4.0.v20080512&#xA;Bundle-Localization: plugin&#xA;Export-Package: org.eclipse.core.internal.preferences.legacy;x-internal:=true,org.eclipse.core.internal.runtime;x-friends:=&quot;org.eclipse.core.runtime.compatibility&quot;,org.eclipse.core.runtime;version=&quot;3.4.0&quot;&#xA;Require-Bundle: org.eclipse.osgi;bundle-version=&quot;[3.2.0,4.0.0)&quot;;visibility:=reexport,org.eclipse.equinox.common;bundle-version=&quot;[3.2.0,4.0.0)&quot;;visibility:=reexport,org.eclipse.core.jobs;bundle-version=&quot;[3.2.0,4.0.0)&quot;;visibility:=reexport,org.eclipse.equinox.registry;bundle-version=&quot;[3.4.0,4.0.0)&quot;;visibility:=reexport,org.eclipse.equinox.preferences;bundle-version=&quot;[3.2.0,4.0.0)&quot;;visibility:=reexport,org.eclipse.core.contenttype;bundle-version=&quot;[3.3.0,4.0.0)&quot;;visibility:=reexport,org.eclipse.core.runtime.compatibility.auth;bundle-version=&quot;[3.2.0,4.0.0)&quot;;resolution:=optional,org.eclipse.equinox.app;bundle-version=&quot;[1.0.0,2.0.0)&quot;;visibility:=reexport&#xA;
</instruction>
</instructions>
</touchpointData>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,49 +1,31 @@
<?xml version='1.0' encoding='UTF-8'?>
<?artifactRepository version='1.1.0'?>
<repository name='packgz' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1'>
<properties size='3'>
<property name='publishPackFilesAsSiblings' value='true'/>
<repository name='e342_corrupt' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1'>
<properties size='2'>
<property name='p2.compressed' value='false'/>
<property name='p2.timestamp' value='1338060413228'/>
</properties>
<mappings size='5'>
<rule filter='(&amp; (classifier=osgi.bundle) (format=packed))' output='${repoUrl}/plugins/${id}_${version}.jar.pack.gz'/>
<mappings size='3'>
<rule filter='(&amp; (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
<rule filter='(&amp; (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
<rule filter='(&amp; (classifier=org.eclipse.update.feature) (format=packed))' output='${repoUrl}/features/${id}_${version}.jar.pack.gz'/>
<rule filter='(&amp; (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
</mappings>
<artifacts size='3'>
<!-- broken entry because artifact is "corrupt" (actually the artifact is a different pack200-compressed archive, containing a wrong_content.txt file) -->
<artifacts size='2'>
<!-- broken entry because artifact is missing -->
<artifact classifier='osgi.bundle' id='org.eclipse.ecf' version='3.1.300.v20120319-0616'>
<processing size='1'>
<step id='org.eclipse.equinox.p2.processing.Pack200Unpacker' required='true'/>
</processing>
<properties size='3'>
<property name='artifact.size' value='971'/>
<property name='download.size' value='703'/>
<property name='download.md5' value='00000000000000000000000000000000'/><!-- non-matching md5 -->
<property name='format' value='packed'/>
</properties>
</artifact>
<!-- broken entry because artifact is "corrupt" (actually the artifact is a different pack200-compressed archive, containing a wrong_content.txt file) -->
<artifact classifier='osgi.bundle' id='org.eclipse.osgi' version='3.4.3.R34x_v20081215-1030'>
<properties size='4'>
<property name='artifact.size' value='11034'/>
<property name='download.size' value='11034'/>
<property name='download.md5' value='58057045158895009b845b9a93f3eb6e'/>
<property name='download.md5' value='00000000000000000000000000000000'/><!-- non-matching md5 -->
<property name='download.contentType' value='application/zip'/>
</properties>
</artifact>
<!-- broken entry because artifact is missing -->
<artifact classifier='osgi.bundle' id='org.eclipse.osgi' version='3.4.3.R34x_v20081215-1030'>
<processing size='1'>
<step id='org.eclipse.equinox.p2.processing.Pack200Unpacker' required='true'/>
</processing>
<properties size='3'>
<property name='artifact.size' value='10855'/>
<property name='download.size' value='1723'/>
<property name='format' value='packed'/>
</properties>
</artifact>
</artifacts>
</repository>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<?artifactRepository version='1.1.0'?>
<artifacts size='1'>
<artifact classifier='osgi.bundle' id='org.eclipse.core.runtime' version='3.4.0.v20080512'>
<properties size='2'>
<property name='artifact.size' value='69026'/>
<property name='download.size' value='69026'/>
</properties>
</artifact>
</artifacts>
Binary file not shown.

This file was deleted.

Binary file not shown.
Loading

0 comments on commit bdfe7a5

Please sign in to comment.