]> source.dussan.org Git - archiva.git/commitdiff
add unit for deletion of timestamped snapshot
authorOlivier Lamy <olamy@apache.org>
Tue, 26 Jun 2012 17:24:37 +0000 (17:24 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 26 Jun 2012 17:24:37 +0000 (17:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1354118 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java

index 2fc5c977ea286b644cc65cfd0bfcee2625f34f15..2d3c9fe996c482034597b08d1784af46b1783b83 100644 (file)
@@ -33,7 +33,6 @@ import org.apache.archiva.metadata.model.ProjectMetadata;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.model.Scm;
 import org.fest.assertions.Assertions;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
@@ -1141,6 +1140,49 @@ public abstract class AbstractMetadataRepositoryTest
             repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ).isEmpty() );
     }
 
+    @Test
+    public void deleteSnapshotVersion()
+        throws Exception
+    {
+        ArtifactMetadata artifactOne = createArtifact();
+        artifactOne.setVersion( "2.0-20120618.214127-1" );
+        artifactOne.setProjectVersion( "2.0-SNAPSHOT" );
+        artifactOne.addFacet( new TestMetadataFacet( "value" ) );
+        artifactOne.setId( TEST_PROJECT + "-" + "2.0-20120618.214127-1" + "." + "jar" );
+
+        repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT", artifactOne );
+
+        ArtifactMetadata artifactTwo = createArtifact();
+        artifactTwo.setVersion( "2.0-20120618.214135-2" );
+        artifactTwo.setProjectVersion( "2.0-SNAPSHOT" );
+        artifactTwo.addFacet( new TestMetadataFacet( "value" ) );
+        artifactTwo.setId( TEST_PROJECT + "-" + "2.0-20120618.214135-2" + "." + "jar" );
+
+        repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT", artifactTwo );
+
+        Collection<ArtifactMetadata> artifactMetadatas =
+            repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT" );
+
+        Assertions.assertThat( artifactMetadatas ).isNotNull().isNotEmpty().hasSize( 2 );
+
+        log.info( "artifactMetadatas: {}", artifactMetadatas );
+
+        //assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>(
+        //    repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT" ) ) );
+
+        repository.removeArtifact( artifactOne, "2.0-SNAPSHOT" );
+
+        artifactMetadatas = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT" );
+
+        Assertions.assertThat( artifactMetadatas ).isNotNull().isNotEmpty().hasSize( 1 );
+
+        repository.removeArtifact( artifactTwo, "2.0-SNAPSHOT" );
+
+        artifactMetadatas = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT" );
+
+        Assertions.assertThat( artifactMetadatas ).isNotNull().isEmpty();
+    }
+
     private static ProjectMetadata createProject()
     {
         return createProject( TEST_NAMESPACE );