]> source.dussan.org Git - archiva.git/commitdiff
add unit test for new method in MetadataRepository and fix compilation for some impls...
authorOlivier Lamy <olamy@apache.org>
Thu, 11 Oct 2012 22:43:15 +0000 (22:43 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 11 Oct 2012 22:43:15 +0000 (22:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1397345 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositorySessionFactory.java
archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/mock/MockRepositorySessionFactory.java
archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java
archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataRepository.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java
archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java
archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java

index b3effd9c93a8782b1247f81f99d1ca8f23aa2013..36ab43c3dde2fe63bb151d7879dec909d133abb8 100644 (file)
@@ -201,4 +201,10 @@ public class TestMetadataRepository
     {
 
     }
+
+    public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
+        throws MetadataRepositoryException
+    {
+
+    }
 }
index cdaee822ebac57eafb5f6f5c1334d38374bf33c2..2f1d8aa8529c59c4d738587b9c0386de5a0a6933 100644 (file)
@@ -260,6 +260,13 @@ public class MockRepositorySessionFactory
                     {
 
                     }
+
+                    public void removeProjectVersion( String repoId, String namespace, String projectId,
+                                                      String projectVersion )
+                        throws MetadataRepositoryException
+                    {
+
+                    }
                 };
             }
         };
index cfc5a9732905b3d7715abe609826d1f1bf116c07..8e7013db3e55fd5925f4ae226cc77b6ef2403691 100644 (file)
@@ -206,4 +206,10 @@ public class TestMetadataRepository
     {
 
     }
+
+    public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
+        throws MetadataRepositoryException
+    {
+
+    }
 }
index 9be74fa747e232529618aa3628c7da4e86af4538..ad8928c23aba650fd3ec61281c2b0f79d2464d95 100644 (file)
@@ -260,6 +260,13 @@ public class MockRepositorySessionFactory
                     {
 
                     }
+
+                    public void removeProjectVersion( String repoId, String namespace, String projectId,
+                                                      String projectVersion )
+                        throws MetadataRepositoryException
+                    {
+
+                    }
                 };
             }
         };
index 21733877596b29b7632237d5a9669e0c8b2c2d87..09297f1ec3c8acb46fae87023e6b09c7f177473d 100644 (file)
@@ -260,6 +260,13 @@ public class MockRepositorySessionFactory
                     {
 
                     }
+
+                    public void removeProjectVersion( String repoId, String namespace, String projectId,
+                                                      String projectVersion )
+                        throws MetadataRepositoryException
+                    {
+
+                    }
                 };
             }
         };
index d533142663b647408029c04ce2278da9e6d8c5a1..5978c7c988dec975f697b040f33e0446914b7764 100644 (file)
@@ -337,5 +337,11 @@ public class NewArtifactsRssFeedProcessorTest
         {
 
         }
+
+        public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
+            throws MetadataRepositoryException
+        {
+
+        }
     }
 }
index 8702ee36615e77799d3c61155e68d6573162bfbc..d5a4da2ed7723fe7937a85a232d13be8899a6630 100644 (file)
@@ -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
index f15ac0e63271a74b362d464b882f6a004627b086..089bcc0256309dcbfcdeb143ee107bfe35e39e14 100644 (file)
@@ -202,4 +202,10 @@ public class TestMetadataRepository
     {
 
     }
+
+    public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
+        throws MetadataRepositoryException
+    {
+
+    }
 }
index ca400cc9e714dc7c92c9c52691c9e0edda6cad87..55aed9ce7ab4a274f9d19749eb0f61a7b823f533 100644 (file)
@@ -1132,7 +1132,7 @@ public abstract class AbstractMetadataRepositoryTest
     }
 
     @Test
-    public void deleteVersion()
+    public void deleteArtifact()
         throws Exception
     {
         ArtifactMetadata artifact = createArtifact();
@@ -1151,6 +1151,24 @@ public abstract class AbstractMetadataRepositoryTest
             repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ).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( 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
index 3f615c09b7f894e2baf5541b86ac44a5d0351a07..214e6a81e821cb2203e1d085429c348fb40de39c 100644 (file)
@@ -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
index 3294ab895adc51ecad36a0d3430e45ca44ef8b2b..87c3b6711c3da18a3728575be6d6ea765dee55da 100644 (file)
@@ -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
     {