From 24de9b28fb2843b80a35143f76d57373eab592e6 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 26 Mar 2014 06:29:55 +0000 Subject: [PATCH] add a test to ensure dependant are cleanup up git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1581705 13f79535-47bb-0310-9956-ffa450edef68 --- .../AbstractMetadataRepositoryTest.java | 6 +-- .../CassandraMetadataRepository.java | 5 ++- .../CassandraMetadataRepositoryTest.java | 37 +++++++++++++++++++ 3 files changed, 44 insertions(+), 4 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 f419e1fb0..14bf3b7cc 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 @@ -67,11 +67,11 @@ public abstract class AbstractMetadataRepositoryTest protected static final String TEST_REPO_ID = "test"; - private static final String TEST_PROJECT = "projectId"; + protected static final String TEST_PROJECT = "projectId"; - private static final String TEST_NAMESPACE = "namespace"; + protected static final String TEST_NAMESPACE = "namespace"; - private static final String TEST_PROJECT_VERSION = "1.0"; + protected static final String TEST_PROJECT_VERSION = "1.0"; private static final String TEST_PROJECT_VERSION_2_0 = "2.0"; diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java index 143f49d85..e46675472 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java @@ -1941,6 +1941,9 @@ public class CassandraMetadataRepository for ( Row row : result.get().getList() ) { this.projectVersionMetadataTemplate.deleteRow( row.getKey() ); + removeMailingList( row.getKey() ); + removeLicenses( row.getKey() ); + removeDependencies( row.getKey() ); } RangeSlicesQuery query = HFactory // @@ -1958,8 +1961,8 @@ public class CassandraMetadataRepository for ( Row row : result.get() ) { this.artifactMetadataTemplate.deleteRow( row.getKey() ); - } + } } @Override diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java b/archiva-modules/plugins/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java index 89ac59886..30d2049fd 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java @@ -19,19 +19,25 @@ package org.apache.archiva.metadata.repository.cassandra; * under the License. */ +import org.apache.archiva.metadata.model.MailingList; import org.apache.archiva.metadata.model.MetadataFacetFactory; import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest; +import org.apache.archiva.metadata.repository.cassandra.model.ProjectVersionMetadataModel; import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Before; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.inject.Inject; import javax.inject.Named; import java.io.File; +import java.util.List; import java.util.Map; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Olivier Lamy */ @@ -66,6 +72,37 @@ public class CassandraMetadataRepositoryTest clearReposAndNamespace(); } + /** + * ensure all dependant tables are cleaned up (mailinglist, license, dependencies) + * + * @throws Exception + */ + @Test + public void clean_dependant_tables() + throws Exception + { + + super.testUpdateProjectVersionMetadataWithAllElements(); + + String key = new ProjectVersionMetadataModel.KeyBuilder().withRepository( TEST_REPO_ID ) // + .withNamespace( TEST_NAMESPACE ) // + .withProjectId( TEST_PROJECT ) // + .withProjectVersion( TEST_PROJECT_VERSION ) // + .withId( TEST_PROJECT_VERSION ) // + .build(); + + this.cmr.removeProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ); + + assertThat( + repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ).isNull(); + + assertThat( cmr.getMailingLists( key ) ).isNotNull().isEmpty(); + + assertThat( cmr.getLicenses( key ) ).isNotNull().isEmpty(); + + assertThat( cmr.getDependencies( key ) ).isNotNull().isEmpty(); + } + @After public void shutdown() -- 2.39.5