Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Sievers2013-09-04 10:34:47 -0400
committerJan Sievers2013-09-04 10:36:38 -0400
commit55edac37a1ae781fcfba3704abee6045bc92329b (patch)
tree339ebdddc2c9b811dd7b6afe53b26e7f9567f60d
parent0e812461b1412c0c53818774b18256e06fc65122 (diff)
downloadorg.eclipse.tycho.nexus-55edac37a1ae781fcfba3704abee6045bc92329b.tar.gz
org.eclipse.tycho.nexus-55edac37a1ae781fcfba3704abee6045bc92329b.tar.xz
org.eclipse.tycho.nexus-55edac37a1ae781fcfba3704abee6045bc92329b.zip
405154 add IT for virtual "SNAPSHOT" version
Bug: 405154 Change-Id: I3a1169554499cb114450e3f7df0adaac9424ca6a Signed-off-by: Jan Sievers <jan.sievers@sap.com>
-rw-r--r--unzip-repository-plugin-its/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--unzip-repository-plugin-its/src/test/it-resources/artifacts/releases/org/example/artifact/1.0.1/artifact-1.0.1.jar (renamed from unzip-repository-plugin-its/src/test/it-resources/artifacts/org/example/artifact/1.0.1/artifact-1.0.1.jar)bin2140 -> 2140 bytes
-rw-r--r--unzip-repository-plugin-its/src/test/it-resources/artifacts/releases/org/example/artifact/1.0.1/artifact-1.0.1.pom (renamed from unzip-repository-plugin-its/src/test/it-resources/artifacts/org/example/artifact/1.0.1/artifact-1.0.1.pom)0
-rw-r--r--unzip-repository-plugin-its/src/test/it-resources/artifacts/releases/org/example/artifact/maven-metadata.xml (renamed from unzip-repository-plugin-its/src/test/it-resources/artifacts/org/example/artifact/maven-metadata.xml)0
-rw-r--r--unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/artifact-2.0.0-20130904.072115-1.jarbin0 -> 2109 bytes
-rw-r--r--unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/artifact-2.0.0-20130904.072115-1.pom10
-rw-r--r--unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/maven-metadata.xml25
-rw-r--r--unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/maven-metadata.xml13
-rw-r--r--unzip-repository-plugin-its/src/test/it-resources/preset-nexus/nexus.xml47
-rw-r--r--unzip-repository-plugin-its/src/test/java/org/eclipse/tycho/nexus/internal/plugin/AbstractUnzipRepositoryPluginITCase.java7
-rw-r--r--unzip-repository-plugin-its/src/test/java/org/eclipse/tycho/nexus/internal/plugin/UnzipRepositoryPluginITCase.java87
11 files changed, 163 insertions, 29 deletions
diff --git a/unzip-repository-plugin-its/.settings/org.eclipse.core.resources.prefs b/unzip-repository-plugin-its/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 8dd9b1d..0000000
--- a/unzip-repository-plugin-its/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-eclipse.preferences.version=1
-encoding//src/test/java=UTF-8
-encoding/<project>=UTF-8
diff --git a/unzip-repository-plugin-its/src/test/it-resources/artifacts/org/example/artifact/1.0.1/artifact-1.0.1.jar b/unzip-repository-plugin-its/src/test/it-resources/artifacts/releases/org/example/artifact/1.0.1/artifact-1.0.1.jar
index ff7a559..ff7a559 100644
--- a/unzip-repository-plugin-its/src/test/it-resources/artifacts/org/example/artifact/1.0.1/artifact-1.0.1.jar
+++ b/unzip-repository-plugin-its/src/test/it-resources/artifacts/releases/org/example/artifact/1.0.1/artifact-1.0.1.jar
Binary files differ
diff --git a/unzip-repository-plugin-its/src/test/it-resources/artifacts/org/example/artifact/1.0.1/artifact-1.0.1.pom b/unzip-repository-plugin-its/src/test/it-resources/artifacts/releases/org/example/artifact/1.0.1/artifact-1.0.1.pom
index ea15212..ea15212 100644
--- a/unzip-repository-plugin-its/src/test/it-resources/artifacts/org/example/artifact/1.0.1/artifact-1.0.1.pom
+++ b/unzip-repository-plugin-its/src/test/it-resources/artifacts/releases/org/example/artifact/1.0.1/artifact-1.0.1.pom
diff --git a/unzip-repository-plugin-its/src/test/it-resources/artifacts/org/example/artifact/maven-metadata.xml b/unzip-repository-plugin-its/src/test/it-resources/artifacts/releases/org/example/artifact/maven-metadata.xml
index 064638c..064638c 100644
--- a/unzip-repository-plugin-its/src/test/it-resources/artifacts/org/example/artifact/maven-metadata.xml
+++ b/unzip-repository-plugin-its/src/test/it-resources/artifacts/releases/org/example/artifact/maven-metadata.xml
diff --git a/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/artifact-2.0.0-20130904.072115-1.jar b/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/artifact-2.0.0-20130904.072115-1.jar
new file mode 100644
index 0000000..e3fd6ed
--- /dev/null
+++ b/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/artifact-2.0.0-20130904.072115-1.jar
Binary files differ
diff --git a/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/artifact-2.0.0-20130904.072115-1.pom b/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/artifact-2.0.0-20130904.072115-1.pom
new file mode 100644
index 0000000..4578d62
--- /dev/null
+++ b/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/artifact-2.0.0-20130904.072115-1.pom
@@ -0,0 +1,10 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.example</groupId>
+ <artifactId>artifact</artifactId>
+ <packaging>jar</packaging>
+ <version>2.0.0-SNAPSHOT</version>
+
+</project>
diff --git a/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/maven-metadata.xml b/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/maven-metadata.xml
new file mode 100644
index 0000000..aac4eee
--- /dev/null
+++ b/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/2.0.0-SNAPSHOT/maven-metadata.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata modelVersion="1.1.0">
+ <groupId>org.example</groupId>
+ <artifactId>artifact</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <versioning>
+ <snapshot>
+ <timestamp>20130904.072115</timestamp>
+ <buildNumber>1</buildNumber>
+ </snapshot>
+ <lastUpdated>20130904072115</lastUpdated>
+ <snapshotVersions>
+ <snapshotVersion>
+ <extension>jar</extension>
+ <value>2.0.0-20130904.072115-1</value>
+ <updated>20130904072115</updated>
+ </snapshotVersion>
+ <snapshotVersion>
+ <extension>pom</extension>
+ <value>2.0.0-20130904.072115-1</value>
+ <updated>20130904072115</updated>
+ </snapshotVersion>
+ </snapshotVersions>
+ </versioning>
+</metadata>
diff --git a/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/maven-metadata.xml b/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/maven-metadata.xml
new file mode 100644
index 0000000..ebdbdbe
--- /dev/null
+++ b/unzip-repository-plugin-its/src/test/it-resources/artifacts/snapshots/org/example/artifact/maven-metadata.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+ <groupId>org.example</groupId>
+ <artifactId>artifact</artifactId>
+ <versioning>
+ <latest>2.0.0-SNAPSHOT</latest>
+ <release/>
+ <versions>
+ <version>2.0.0-SNAPSHOT</version>
+ </versions>
+ <lastUpdated>20130904072115</lastUpdated>
+ </versioning>
+</metadata>
diff --git a/unzip-repository-plugin-its/src/test/it-resources/preset-nexus/nexus.xml b/unzip-repository-plugin-its/src/test/it-resources/preset-nexus/nexus.xml
index 20d386f..5323b44 100644
--- a/unzip-repository-plugin-its/src/test/it-resources/preset-nexus/nexus.xml
+++ b/unzip-repository-plugin-its/src/test/it-resources/preset-nexus/nexus.xml
@@ -46,6 +46,32 @@
</externalConfiguration>
</repository>
<repository>
+ <id>snapshots</id>
+ <name>snapshots</name>
+ <providerRole>org.sonatype.nexus.proxy.repository.Repository</providerRole>
+ <providerHint>maven2</providerHint>
+ <localStatus>IN_SERVICE</localStatus>
+ <notFoundCacheTTL>1440</notFoundCacheTTL>
+ <userManaged>true</userManaged>
+ <exposed>true</exposed>
+ <browseable>true</browseable>
+ <writePolicy>ALLOW_WRITE</writePolicy>
+ <indexable>true</indexable>
+ <searchable>true</searchable>
+ <localStorage>
+ <provider>file</provider>
+ </localStorage>
+ <externalConfiguration>
+ <proxyMode>ALLOW</proxyMode>
+ <artifactMaxAge>-1</artifactMaxAge>
+ <itemMaxAge>1440</itemMaxAge>
+ <cleanseRepositoryMetadata>false</cleanseRepositoryMetadata>
+ <downloadRemoteIndex>false</downloadRemoteIndex>
+ <checksumPolicy>WARN</checksumPolicy>
+ <repositoryPolicy>SNAPSHOT</repositoryPolicy>
+ </externalConfiguration>
+ </repository>
+ <repository>
<id>releases.unzip</id>
<name>releases.unzip</name>
<providerRole>org.eclipse.tycho.nexus.internal.plugin.UnzipRepository</providerRole>
@@ -67,6 +93,27 @@
</externalConfiguration>
</repository>
<repository>
+ <id>snapshots.unzip</id>
+ <name>snapshots.unzip</name>
+ <providerRole>org.eclipse.tycho.nexus.internal.plugin.UnzipRepository</providerRole>
+ <providerHint>org.eclipse.tycho.nexus.plugin.DefaultUnzipRepository</providerHint>
+ <localStatus>IN_SERVICE</localStatus>
+ <notFoundCacheTTL>15</notFoundCacheTTL>
+ <userManaged>true</userManaged>
+ <exposed>true</exposed>
+ <browseable>true</browseable>
+ <writePolicy>READ_ONLY</writePolicy>
+ <searchable>true</searchable>
+ <localStorage>
+ <provider>file</provider>
+ </localStorage>
+ <externalConfiguration>
+ <masterRepositoryId>snapshots</masterRepositoryId>
+ <synchronizeAtStartup>false</synchronizeAtStartup>
+ <useVirtualVersion>true</useVirtualVersion>
+ </externalConfiguration>
+ </repository>
+ <repository>
<id>releases.group</id>
<name>releases.group</name>
<providerRole>org.sonatype.nexus.proxy.repository.GroupRepository</providerRole>
diff --git a/unzip-repository-plugin-its/src/test/java/org/eclipse/tycho/nexus/internal/plugin/AbstractUnzipRepositoryPluginITCase.java b/unzip-repository-plugin-its/src/test/java/org/eclipse/tycho/nexus/internal/plugin/AbstractUnzipRepositoryPluginITCase.java
index f65b834..0f4af5d 100644
--- a/unzip-repository-plugin-its/src/test/java/org/eclipse/tycho/nexus/internal/plugin/AbstractUnzipRepositoryPluginITCase.java
+++ b/unzip-repository-plugin-its/src/test/java/org/eclipse/tycho/nexus/internal/plugin/AbstractUnzipRepositoryPluginITCase.java
@@ -61,9 +61,10 @@ public abstract class AbstractUnzipRepositoryPluginITCase extends NexusRunningPa
return configuration;
}
- protected void uploadToReleasesRepository(final String artifactPath) throws IOException {
- final File resolveFile = testData().resolveFile("artifacts/" + artifactPath);
- getNexusContentService().upload(repositoryLocation("releases", artifactPath), resolveFile);
+ protected void uploadToRepository(String testDataPathPrefix, final String artifactPath, String repositoryId)
+ throws IOException {
+ final File resolveFile = testData().resolveFile(testDataPathPrefix + artifactPath);
+ getNexusContentService().upload(repositoryLocation(repositoryId, artifactPath), resolveFile);
}
protected Content getNexusContentService() {
diff --git a/unzip-repository-plugin-its/src/test/java/org/eclipse/tycho/nexus/internal/plugin/UnzipRepositoryPluginITCase.java b/unzip-repository-plugin-its/src/test/java/org/eclipse/tycho/nexus/internal/plugin/UnzipRepositoryPluginITCase.java
index 0839d8f..3c64da5 100644
--- a/unzip-repository-plugin-its/src/test/java/org/eclipse/tycho/nexus/internal/plugin/UnzipRepositoryPluginITCase.java
+++ b/unzip-repository-plugin-its/src/test/java/org/eclipse/tycho/nexus/internal/plugin/UnzipRepositoryPluginITCase.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.tycho.nexus.internal.plugin;
+import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.sonatype.nexus.client.core.subsystem.content.Location.repositoryLocation;
@@ -18,7 +19,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
import java.util.zip.ZipEntry;
@@ -41,7 +41,7 @@ public class UnzipRepositoryPluginITCase extends AbstractUnzipRepositoryPluginIT
@Parameters
public static Collection<Object[]> data() {
// nexus versions to be tested against
- return Arrays.asList(//
+ return asList(//
new Object[] { getTestProperty("nexus.min.coords") }, //
new Object[] { getTestProperty("nexus.max.coords") });
}
@@ -63,36 +63,77 @@ public class UnzipRepositoryPluginITCase extends AbstractUnzipRepositoryPluginIT
super(nexusBundleCoordinates);
}
- private static final String EXAMPLE_POM = "org/example/artifact/1.0.1/artifact-1.0.1.pom";
- private static final String EXAMPLE_JAR = "org/example/artifact/1.0.1/artifact-1.0.1.jar";
- private static final String EXAMPLE_MAVEN_METADATA = "org/example/artifact/maven-metadata.xml";
+ private static final String EXAMPLE_GROUPID = "org.example";
+ private static final String EXAMPLE_ARTIFACTID = "artifact";
+ private static final String EXAMPLE_RELEASED_VERSION = "1.0.1";
+ private static final String EXAMPLE_SNAPSHOT_VERSION = "2.0.0-SNAPSHOT";
+ private static final String EXAMPLE_SNAPSHOT_TIMESTAMP = "2.0.0-20130904.072115-1";
+ private static final String EXAMPLE_PATH_PREFIX = EXAMPLE_GROUPID.replace('.', '/') + "/" + EXAMPLE_ARTIFACTID
+ + "/";
+ private static final String EXAMPLE_RELEASEPATH_SUFFIX = EXAMPLE_RELEASED_VERSION + "/" + EXAMPLE_ARTIFACTID + "-"
+ + EXAMPLE_RELEASED_VERSION;
+ private static final String EXAMPLE_SNAPSHOTPATH_SUFFIX = EXAMPLE_SNAPSHOT_VERSION + "/" + EXAMPLE_ARTIFACTID + "-"
+ + EXAMPLE_SNAPSHOT_TIMESTAMP;
+
+ private static final String EXAMPLE_RELEASED_POM = EXAMPLE_PATH_PREFIX + EXAMPLE_RELEASEPATH_SUFFIX + ".pom";
+ private static final String EXAMPLE_SNAPSHOT_POM = EXAMPLE_PATH_PREFIX + EXAMPLE_SNAPSHOTPATH_SUFFIX + ".pom";
+ private static final String EXAMPLE_RELEASED_JAR = EXAMPLE_PATH_PREFIX + EXAMPLE_RELEASEPATH_SUFFIX + ".jar";
+ private static final String EXAMPLE_SNAPSHOT_JAR = EXAMPLE_PATH_PREFIX + EXAMPLE_SNAPSHOTPATH_SUFFIX + ".jar";
+ private static final String EXAMPLE_SNAPSHOT_METADATA = EXAMPLE_PATH_PREFIX + EXAMPLE_SNAPSHOT_VERSION
+ + "/maven-metadata.xml";
+ private static final String EXAMPLE_MAVEN_METADATA = EXAMPLE_PATH_PREFIX + "maven-metadata.xml";
@Before
public void uploadExampleArtifacts() throws IOException {
- if (!canResolveExampleArtifact()) {
- uploadToReleasesRepository(EXAMPLE_POM);
- uploadToReleasesRepository(EXAMPLE_JAR);
- uploadToReleasesRepository(EXAMPLE_MAVEN_METADATA);
- assertTrue(canResolveExampleArtifact());
+ String repositoryId = "releases";
+ if (!canResolveExampleArtifact(repositoryId, EXAMPLE_RELEASED_VERSION)) {
+ String pathPrefix = "artifacts/releases/";
+ uploadToRepository(pathPrefix, EXAMPLE_RELEASED_POM, repositoryId);
+ uploadToRepository(pathPrefix, EXAMPLE_RELEASED_JAR, repositoryId);
+ uploadToRepository(pathPrefix, EXAMPLE_MAVEN_METADATA, repositoryId);
+ assertTrue(canResolveExampleArtifact(repositoryId, EXAMPLE_RELEASED_VERSION));
+ }
+ repositoryId = "snapshots";
+ if (!canResolveExampleArtifact(repositoryId, EXAMPLE_SNAPSHOT_VERSION)) {
+ String pathPrefix = "artifacts/snapshots/";
+ uploadToRepository(pathPrefix, EXAMPLE_SNAPSHOT_POM, repositoryId);
+ uploadToRepository(pathPrefix, EXAMPLE_SNAPSHOT_JAR, repositoryId);
+ uploadToRepository(pathPrefix, EXAMPLE_MAVEN_METADATA, repositoryId);
+ uploadToRepository(pathPrefix, EXAMPLE_SNAPSHOT_METADATA, repositoryId);
+ assertTrue(canResolveExampleArtifact(repositoryId, EXAMPLE_SNAPSHOT_VERSION));
}
}
@Test
public void testUnzipRepoWithHostedRepoAsMaster() throws Exception {
- assertDownloadExampleZipEntryFromUnzipRepository("releases.unzip");
+ assertDownloadExampleZipEntryFromUnzipRepository("releases.unzip", EXAMPLE_RELEASED_JAR, "artifacts/releases/");
}
@Test
public void testUnzipRepoWithGroupRepoAsMaster() throws Exception {
- assertDownloadExampleZipEntryFromUnzipRepository("releases.group.unzip");
+ assertDownloadExampleZipEntryFromUnzipRepository("releases.group.unzip", EXAMPLE_RELEASED_JAR,
+ "artifacts/releases/");
+ }
+
+ @Test
+ public void testUnzipRepoWithVirtualSnapshotVersion() throws Exception {
+ // use virtual version "SNAPSHOT" which should translate to latest available snapshot
+ assertDownloadExampleZipEntryFromUnzipRepository("snapshots.unzip", EXAMPLE_SNAPSHOT_JAR, EXAMPLE_PATH_PREFIX
+ + "SNAPSHOT/" + EXAMPLE_ARTIFACTID + "-SNAPSHOT.jar", "artifacts/snapshots/");
+ }
+
+ private void assertDownloadExampleZipEntryFromUnzipRepository(final String unzipRepositoryId, String artifactPath,
+ String testDataPrefix) throws IOException {
+ assertDownloadExampleZipEntryFromUnzipRepository(unzipRepositoryId, artifactPath, artifactPath, testDataPrefix);
}
- private void assertDownloadExampleZipEntryFromUnzipRepository(final String unzipRepositoryId) throws IOException {
+ private void assertDownloadExampleZipEntryFromUnzipRepository(final String unzipRepositoryId,
+ String localArtifactPath, String remoteArtifactPath, String testDataPrefix) throws IOException {
final String pathInZip = "META-INF/maven/org.example/artifact/pom.properties";
String downloadedContent;
final File tempFile = File.createTempFile("test", "unzip");
try {
- final Location loc = repositoryLocation(unzipRepositoryId, EXAMPLE_JAR + "-unzip/" + pathInZip);
+ final Location loc = repositoryLocation(unzipRepositoryId, remoteArtifactPath + "-unzip/" + pathInZip);
getNexusContentService().download(loc, tempFile);
FileInputStream stream = new FileInputStream(tempFile);
try {
@@ -103,7 +144,7 @@ public class UnzipRepositoryPluginITCase extends AbstractUnzipRepositoryPluginIT
} finally {
tempFile.delete();
}
- ZipFile zipFile = new ZipFile(testData().resolveFile("artifacts/" + EXAMPLE_JAR));
+ ZipFile zipFile = new ZipFile(testData().resolveFile(testDataPrefix + localArtifactPath));
String expectedContent;
try {
ZipEntry entry = zipFile.getEntry(pathInZip);
@@ -114,18 +155,18 @@ public class UnzipRepositoryPluginITCase extends AbstractUnzipRepositoryPluginIT
assertEquals(expectedContent, downloadedContent);
}
- private boolean canResolveExampleArtifact() {
+ private boolean canResolveExampleArtifact(String repositoryId, String version) {
ResolveResponse resolveResponse = null;
try {
resolveResponse = getNexusArtifactMavenService().resolve(
- new ResolveRequest("releases", "org.example", "artifact", ResolveRequest.VERSION_RELEASE));
+ new ResolveRequest(repositoryId, EXAMPLE_GROUPID, EXAMPLE_ARTIFACTID, version));
} catch (final NexusClientNotFoundException e) {
- // if it's not there yet... that's o.k.
+ return false;
}
- return resolveResponse != null //
- && "org.example".equals(resolveResponse.getGroupId()) //
- && "artifact".equals(resolveResponse.getArtifactId()) //
- && "jar".equals(resolveResponse.getExtension()) //
- && !resolveResponse.isSnapshot();
+ assertEquals(EXAMPLE_GROUPID, resolveResponse.getGroupId());
+ assertEquals(EXAMPLE_ARTIFACTID, resolveResponse.getArtifactId());
+ assertEquals("jar", resolveResponse.getExtension());
+ assertEquals(version.endsWith("-SNAPSHOT"), resolveResponse.isSnapshot());
+ return true;
}
}

Back to the top