diff options
author | Olivier Lamy <olamy@apache.org> | 2012-10-11 22:43:15 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-10-11 22:43:15 +0000 |
commit | e7bc35db81e879f19a7846098d1f6eed31e1b142 (patch) | |
tree | ae48aa808bf1ada4698ea33a22009a47a8ab9503 | |
parent | 092a635e39f0329c59d23745cdd93fdd000516e4 (diff) | |
download | archiva-e7bc35db81e879f19a7846098d1f6eed31e1b142.tar.gz archiva-e7bc35db81e879f19a7846098d1f6eed31e1b142.zip |
add unit test for new method in MetadataRepository and fix compilation for some impls/mocks
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1397345 13f79535-47bb-0310-9956-ffa450edef68
11 files changed, 94 insertions, 2 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index b3effd9c9..36ab43c3d 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -201,4 +201,10 @@ public class TestMetadataRepository { } + + public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) + throws MetadataRepositoryException + { + + } } diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java index cdaee822e..2f1d8aa85 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java @@ -260,6 +260,13 @@ public class MockRepositorySessionFactory { } + + public void removeProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataRepositoryException + { + + } }; } }; diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index cfc5a9732..8e7013db3 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -206,4 +206,10 @@ public class TestMetadataRepository { } + + public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) + throws MetadataRepositoryException + { + + } } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositorySessionFactory.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositorySessionFactory.java index 9be74fa74..ad8928c23 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositorySessionFactory.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositorySessionFactory.java @@ -260,6 +260,13 @@ public class MockRepositorySessionFactory { } + + public void removeProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataRepositoryException + { + + } }; } }; diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/mock/MockRepositorySessionFactory.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/mock/MockRepositorySessionFactory.java index 217338775..09297f1ec 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/mock/MockRepositorySessionFactory.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/mock/MockRepositorySessionFactory.java @@ -260,6 +260,13 @@ public class MockRepositorySessionFactory { } + + public void removeProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataRepositoryException + { + + } }; } }; diff --git a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java index d53314266..5978c7c98 100644 --- a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java +++ b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java @@ -337,5 +337,11 @@ public class NewArtifactsRssFeedProcessorTest { } + + public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) + throws MetadataRepositoryException + { + + } } } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataRepository.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataRepository.java index 8702ee366..d5a4da2ed 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataRepository.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataRepository.java @@ -241,4 +241,10 @@ public class TestMetadataRepository { } + + public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) + throws MetadataRepositoryException + { + + } }
\ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index f15ac0e63..089bcc025 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -202,4 +202,10 @@ public class TestMetadataRepository { } + + public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) + throws MetadataRepositoryException + { + + } } 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 ca400cc9e..55aed9ce7 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 @@ -1132,7 +1132,7 @@ public abstract class AbstractMetadataRepositoryTest } @Test - public void deleteVersion() + public void deleteArtifact() throws Exception { ArtifactMetadata artifact = createArtifact(); @@ -1152,6 +1152,24 @@ public abstract class AbstractMetadataRepositoryTest } @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( 1, repository.getProjectVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ).size() ); + + repository.removeProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ); + + assertEquals( 0, repository.getProjectVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ).size() ); + } + + @Test public void deleteSnapshotVersion() throws Exception { diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index 3f615c09b..214e6a81e 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -217,4 +217,10 @@ public class TestMetadataRepository { } + + public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) + throws MetadataRepositoryException + { + + } }
\ No newline at end of file diff --git a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java index 3294ab895..87c3b6711 100644 --- a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java @@ -703,7 +703,6 @@ public class FileMetadataRepository * @param namespace * @param project * @param projectVersion - * @param projectId * @param metadataFacet will remove artifacts which have this {@link MetadataFacet} using equals * @throws MetadataRepositoryException */ @@ -1163,6 +1162,24 @@ public class FileMetadataRepository return projectVersions; } + + public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) + throws MetadataRepositoryException + { + File directory = new File( getDirectory( repoId ), namespace + "/" + projectId + "/" + projectVersion ); + if ( directory.exists() ) + { + try + { + FileUtils.deleteDirectory( directory ); + } + catch ( IOException e ) + { + throw new MetadataRepositoryException( e.getMessage(), e ); + } + } + } + private void writeProperties( Properties properties, File directory, String propertiesKey ) throws IOException { |