From: Olivier Lamy Date: Tue, 26 Jun 2012 17:24:37 +0000 (+0000) Subject: add unit for deletion of timestamped snapshot X-Git-Tag: archiva-1.4-M3~596 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=035a4704d59ca76443b18865dc6ccb52e98b045f;p=archiva.git add unit for deletion of timestamped snapshot git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1354118 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java index 2fc5c977e..2d3c9fe99 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java +++ b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java @@ -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 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( + // 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 );