Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
add IT to verify results
Browse files Browse the repository at this point in the history
NEXUS-5094
  • Loading branch information
kellyrob99 committed May 1, 2013
1 parent ffab40c commit 1418fc8
Show file tree
Hide file tree
Showing 34 changed files with 697 additions and 0 deletions.
Expand Up @@ -21,6 +21,8 @@
import org.sonatype.nexus.AbstractMavenRepoContentTests;
import org.sonatype.nexus.proxy.ItemNotFoundException;
import org.sonatype.nexus.proxy.ResourceStoreRequest;
import org.sonatype.nexus.proxy.access.OpenAccessManager;
import org.sonatype.nexus.proxy.item.StorageItem;
import org.sonatype.nexus.proxy.maven.MavenRepository;
import org.sonatype.nexus.proxy.maven.metadata.operations.MetadataBuilder;
import org.sonatype.nexus.proxy.maven.metadata.operations.MetadataException;
Expand All @@ -30,6 +32,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -741,6 +744,36 @@ public void testEndWithSNAPSHOT()
validateResults( snapshots, expecting );
}

/**
* This test case uses 3 alpha snapshots and 2 beta snapshots, and after running the task only one of each
* artifacts should still be present.
* @see <a href='https://issues.sonatype.org/browse/NEXUS-3148'>NEXUS-5094</a>
*/
@Test
public void testSnapshotsWithClassifiers()
throws Exception
{
fillInRepo();

SnapshotRemovalRequest request = new SnapshotRemovalRequest( snapshots.getId(), 1, -1, false );
SnapshotRemovalResult snapshotRemovalResult = defaultNexus.removeSnapshots( request );
assertThat( snapshotRemovalResult.isSuccessful(), is( true ) );

HashMap<String, Boolean> expecting = new HashMap<String, Boolean>();
expecting.put( "/org/sonatype/test/1.0-SNAPSHOT/test-1.0-20130501.154949-1-alpha.jar", false );
expecting.put( "/org/sonatype/test/1.0-SNAPSHOT/test-1.0-20130501.154949-1.pom", false );
expecting.put( "/org/sonatype/test/1.0-SNAPSHOT/test-1.0-20130501.154953-2-alpha.jar", false );
expecting.put( "/org/sonatype/test/1.0-SNAPSHOT/test-1.0-20130501.154953-2.pom", false );
expecting.put( "/org/sonatype/test/1.0-SNAPSHOT/test-1.0-20130501.154956-3-alpha.jar", true );
expecting.put( "/org/sonatype/test/1.0-SNAPSHOT/test-1.0-20130501.154956-3.pom", true );
expecting.put( "/org/sonatype/test/1.0-SNAPSHOT/test-1.0-20130501.155001-4-beta.jar", false );
expecting.put( "/org/sonatype/test/1.0-SNAPSHOT/test-1.0-20130501.155001-4.pom", false );
expecting.put( "/org/sonatype/test/1.0-SNAPSHOT/test-1.0-20130501.155005-5-beta.jar", true );
expecting.put( "/org/sonatype/test/1.0-SNAPSHOT/test-1.0-20130501.155005-5.pom", true );

validateResults( snapshots, expecting );
}

private Metadata readMavenMetadata( File mdFle )
throws MetadataException, IOException
{
Expand Down
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
<groupId>org.sonatype</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<versioning>
<snapshot>
<timestamp>20130501.155005</timestamp>
<buildNumber>5</buildNumber>
</snapshot>
<lastUpdated>20130501155005</lastUpdated>
<snapshotVersions>
<snapshotVersion>
<extension>pom</extension>
<value>1.0-20130501.155005-5</value>
<updated>20130501155005</updated>
</snapshotVersion>
<snapshotVersion>
<classifier>alpha</classifier>
<extension>jar</extension>
<value>1.0-20130501.154956-3</value>
<updated>20130501154956</updated>
</snapshotVersion>
<snapshotVersion>
<classifier>beta</classifier>
<extension>jar</extension>
<value>1.0-20130501.155005-5</value>
<updated>20130501155005</updated>
</snapshotVersion>
</snapshotVersions>
</versioning>
</metadata>
@@ -0,0 +1 @@
99d9bb8d5e12b1bf824604066f439bc1
@@ -0,0 +1 @@
5bb5a4024fcd907d99da73c263a54ab02dd62d96
Binary file not shown.
@@ -0,0 +1 @@
f5c4ef7c78a8bd6c136ec3e6ab45cbfc
@@ -0,0 +1 @@
e68f95d461e6b9228bd73f8c7d5452f12e6dbe68
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<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.sonatype</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>


<packaging>jar</packaging>

<name>release-remover-test</name>

<properties>
<classifier>alpha</classifier>
</properties>

<distributionManagement>
<!-- use the following if you're not using a snapshot version. -->
<repository>
<id>staging-nexus</id>
<name>RepositoryProxyRel</name>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>staging-nexus</id>
<name>RepositoryProxyRel</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>

<dependencies>

<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5.6</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>

<!-- Have to set source level to at least Java5, we use annotations (Nexus requries 1.6) -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<!--<configuration>-->
<!--<skip>true</skip>-->
<!--</configuration>-->
</plugin>

<!-- NEXUS-5094 Purging snapshot task should take into account classifier -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classifier>${classifier}</classifier>
</configuration>
</plugin>

<!--<plugin>-->
<!--<groupId>org.sonatype.plugins</groupId>-->
<!--<artifactId>nexus-staging-maven-plugin</artifactId>-->
<!--<version>1.4.4</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<goals>-->
<!--<goal>deploy</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--<configuration>-->
<!--<serverId>staging-nexus</serverId>-->
<!--<nexusUrl>http://localhost:8081/nexus/</nexusUrl>-->

<!--&lt;!&ndash; explicit matching using the staging profile id &ndash;&gt;-->
<!--<stagingProfileId>12f36b985ec40644</stagingProfileId>-->

<!--</configuration>-->
<!--</plugin>-->
</plugins>
</build>

</project>
@@ -0,0 +1 @@
c84ba04ce87a11fb89f8aae1008ac478
@@ -0,0 +1 @@
49350cf225c3eed4381a797b33d30f5ca74b07d0
Binary file not shown.
@@ -0,0 +1 @@
f5c4ef7c78a8bd6c136ec3e6ab45cbfc
@@ -0,0 +1 @@
e68f95d461e6b9228bd73f8c7d5452f12e6dbe68
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<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.sonatype</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>


<packaging>jar</packaging>

<name>release-remover-test</name>

<properties>
<classifier>alpha</classifier>
</properties>

<distributionManagement>
<!-- use the following if you're not using a snapshot version. -->
<repository>
<id>staging-nexus</id>
<name>RepositoryProxyRel</name>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>staging-nexus</id>
<name>RepositoryProxyRel</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>

<dependencies>

<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5.6</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>

<!-- Have to set source level to at least Java5, we use annotations (Nexus requries 1.6) -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<!--<configuration>-->
<!--<skip>true</skip>-->
<!--</configuration>-->
</plugin>

<!-- NEXUS-5094 Purging snapshot task should take into account classifier -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classifier>${classifier}</classifier>
</configuration>
</plugin>

<!--<plugin>-->
<!--<groupId>org.sonatype.plugins</groupId>-->
<!--<artifactId>nexus-staging-maven-plugin</artifactId>-->
<!--<version>1.4.4</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<goals>-->
<!--<goal>deploy</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--<configuration>-->
<!--<serverId>staging-nexus</serverId>-->
<!--<nexusUrl>http://localhost:8081/nexus/</nexusUrl>-->

<!--&lt;!&ndash; explicit matching using the staging profile id &ndash;&gt;-->
<!--<stagingProfileId>12f36b985ec40644</stagingProfileId>-->

<!--</configuration>-->
<!--</plugin>-->
</plugins>
</build>

</project>
@@ -0,0 +1 @@
c84ba04ce87a11fb89f8aae1008ac478
@@ -0,0 +1 @@
49350cf225c3eed4381a797b33d30f5ca74b07d0
Binary file not shown.
@@ -0,0 +1 @@
f5c4ef7c78a8bd6c136ec3e6ab45cbfc
@@ -0,0 +1 @@
e68f95d461e6b9228bd73f8c7d5452f12e6dbe68

0 comments on commit 1418fc8

Please sign in to comment.