diff options
author | Brett Porter <brett@apache.org> | 2010-12-30 01:41:07 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2010-12-30 01:41:07 +0000 |
commit | de23f7ef3fab748ae66ebcf95b48904397a52a55 (patch) | |
tree | dd6f692321b6fbc45a20b41faa320d901ca78e36 /archiva-modules/metadata/metadata-repository-api | |
parent | e28ae522d1ce049848d2a30fa4e2371b0b4be706 (diff) | |
download | archiva-de23f7ef3fab748ae66ebcf95b48904397a52a55.tar.gz archiva-de23f7ef3fab748ae66ebcf95b48904397a52a55.zip |
[MRM-1327] make sure getArtifactsByDateRange and getArtifactsByChecksum query is restricted to the right repository
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1053783 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/metadata/metadata-repository-api')
-rw-r--r-- | archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java | 51 |
1 files changed, 49 insertions, 2 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 204c6cbe4..466f92613 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 @@ -457,7 +457,10 @@ public abstract class AbstractMetadataRepositoryTest artifacts = repository.getArtifacts( TEST_REPO_ID ); assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<ArtifactMetadata>( artifacts ) ); - artifacts = repository.getArtifactsByChecksum( TEST_REPO_ID, artifactMetadata.getSha1() ); + artifacts = repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_SHA1 ); + assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<ArtifactMetadata>( artifacts ) ); + + artifacts = repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_MD5 ); assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<ArtifactMetadata>( artifacts ) ); artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ); @@ -827,6 +830,44 @@ public abstract class AbstractMetadataRepositoryTest assertEquals( Collections.singletonList( secondArtifact ), repository.getArtifacts( OTHER_REPO_ID ) ); } + public void testGetArtifactsByDateRangeMultipleCopies() + throws Exception + { + ArtifactMetadata artifact = createArtifact(); + repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact ); + + ArtifactMetadata secondArtifact = createArtifact(); + secondArtifact.setRepositoryId( OTHER_REPO_ID ); + repository.updateArtifact( OTHER_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, secondArtifact ); + + // test it restricts to the appropriate repository + assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByDateRange( TEST_REPO_ID, null, + null ) ); + assertEquals( Collections.singletonList( secondArtifact ), repository.getArtifactsByDateRange( OTHER_REPO_ID, + null, null ) ); + } + + public void testGetArtifactsByChecksumMultipleCopies() + throws Exception + { + ArtifactMetadata artifact = createArtifact(); + repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact ); + + ArtifactMetadata secondArtifact = createArtifact(); + secondArtifact.setRepositoryId( OTHER_REPO_ID ); + repository.updateArtifact( OTHER_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, secondArtifact ); + + // test it restricts to the appropriate repository + assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByChecksum( TEST_REPO_ID, + TEST_SHA1 ) ); + assertEquals( Collections.singletonList( secondArtifact ), repository.getArtifactsByChecksum( OTHER_REPO_ID, + TEST_SHA1 ) ); + assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByChecksum( TEST_REPO_ID, + TEST_MD5 ) ); + assertEquals( Collections.singletonList( secondArtifact ), repository.getArtifactsByChecksum( OTHER_REPO_ID, + TEST_MD5 ) ); + } + public void testGetNamespacesWithSparseDepth() throws Exception { @@ -868,6 +909,8 @@ public abstract class AbstractMetadataRepositoryTest assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_SHA1 ) ); + assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByChecksum( TEST_REPO_ID, + TEST_MD5 ) ); } public void testGetArtifactsByChecksumMultipleResult() @@ -885,6 +928,10 @@ public abstract class AbstractMetadataRepositoryTest TEST_REPO_ID, TEST_SHA1 ) ); Collections.sort( artifacts, new ArtifactMetadataComparator() ); assertEquals( Arrays.asList( artifact2, artifact1 ), artifacts ); + + artifacts = new ArrayList<ArtifactMetadata>( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_MD5 ) ); + Collections.sort( artifacts, new ArtifactMetadataComparator() ); + assertEquals( Arrays.asList( artifact2, artifact1 ), artifacts ); } public void testGetArtifactsByChecksumNoResult() @@ -894,7 +941,7 @@ public abstract class AbstractMetadataRepositoryTest repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact ); assertEquals( Collections.<ArtifactMetadata>emptyList(), repository.getArtifactsByChecksum( TEST_REPO_ID, - "not a checksum" ) ); + "not checksum" ) ); } public void testDeleteArtifact() |