aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/metadata/metadata-repository-api/src/test
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-06-01 23:48:01 +0000
committerOlivier Lamy <olamy@apache.org>2012-06-01 23:48:01 +0000
commiteeed20ed3604a898910b347cecd19a6d8793e210 (patch)
tree34b9685ec8cd9269359d9dde6fea881904812da7 /archiva-modules/metadata/metadata-repository-api/src/test
parent096a4c0ed1d0d4e82c8ebf276554b2663d54cdec (diff)
downloadarchiva-eeed20ed3604a898910b347cecd19a6d8793e210.tar.gz
archiva-eeed20ed3604a898910b347cecd19a6d8793e210.zip
fix an issue with not removing project version when removing an artifact from Metadatarepository
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1345397 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/metadata/metadata-repository-api/src/test')
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java46
1 files changed, 46 insertions, 0 deletions
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 afaf1f149..da9099aaa 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
@@ -32,8 +32,11 @@ import org.apache.archiva.metadata.model.Organization;
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.Test;
import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -64,6 +67,8 @@ public abstract class AbstractMetadataRepositoryTest
private static final String TEST_PROJECT_VERSION = "1.0";
+ private static final String TEST_PROJECT_VERSION_2_0 = "2.0";
+
private static final String TEST_FACET_ID = "test-facet-id";
private static final String TEST_NAME = "test/name";
@@ -78,6 +83,8 @@ public abstract class AbstractMetadataRepositoryTest
private static final String TEST_METADATA_VALUE = "test-metadata";
+ protected Logger log = LoggerFactory.getLogger( getClass() );
+
protected static Map<String, MetadataFacetFactory> createTestMetadataFacetFactories()
{
Map<String, MetadataFacetFactory> factories = new HashMap<String, MetadataFacetFactory>();
@@ -603,6 +610,7 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetMetadataFacetsWhenEmpty()
throws Exception
{
+
List<String> facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID );
assertTrue( facets.isEmpty() );
}
@@ -1049,10 +1057,27 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>(
repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ) );
+ repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION_2_0, artifact );
+
+ Collection<String> versions = repository.getProjectVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
+
+ log.info( "versions {}", versions );
+
+ Assertions.assertThat( versions ).isNotNull().isNotEmpty().hasSize( 2 ).contains( "1.0", "2.0" );
+
repository.removeArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId() );
+ versions = repository.getProjectVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
+
+ log.info( "versions {}", versions );
+
+ Assertions.assertThat( versions ).isNotNull().isNotEmpty().hasSize( 1 ).contains( "2.0" );
+
assertTrue(
repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ).isEmpty() );
+
+ Assertions.assertThat( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
+ TEST_PROJECT_VERSION_2_0 ) ).isNotEmpty().hasSize( 1 );
}
@Test
@@ -1093,6 +1118,27 @@ public abstract class AbstractMetadataRepositoryTest
assertTrue( repository.getRootNamespaces( TEST_REPO_ID ).isEmpty() );
}
+
+ @Test
+ public void deleteVersion()
+ throws Exception
+ {
+ ArtifactMetadata artifact = createArtifact();
+ artifact.addFacet( new TestMetadataFacet( "value" ) );
+
+ repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+
+ repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+
+ assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>(
+ repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ) );
+
+ repository.removeArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId() );
+
+ assertTrue(
+ repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ).isEmpty() );
+ }
+
private static ProjectMetadata createProject()
{
return createProject( TEST_NAMESPACE );