]> source.dussan.org Git - archiva.git/commitdiff
cleanup created test repos after test
authorOlivier Lamy <olamy@apache.org>
Thu, 22 Sep 2011 22:21:24 +0000 (22:21 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 22 Sep 2011 22:21:24 +0000 (22:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1174425 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java

index 27118fbcd194f1815b23e3d0ad159419b1dd44f5..92203f182f28ed5d3f0848401a523fa50944696b 100644 (file)
@@ -42,6 +42,7 @@ public class CopyArtifactTest
     @Inject
     private RepositoryContentFactory repositoryFactory;
 
+
     private void initSourceTargetRepo()
         throws Exception
     {
@@ -53,6 +54,11 @@ public class CopyArtifactTest
         assertFalse( targetRepo.exists() );
         targetRepo.mkdirs();
 
+        if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) != null )
+        {
+            getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( TARGET_REPO_ID, true );
+            assertNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) );
+        }
         ManagedRepository managedRepository = getTestManagedRepository();
         managedRepository.setId( TARGET_REPO_ID );
         managedRepository.setLocation( targetRepo.getCanonicalPath() );
@@ -60,7 +66,6 @@ public class CopyArtifactTest
         getManagedRepositoriesService( authorizationHeader ).addManagedRepository( managedRepository );
         assertNotNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) );
 
-
         File originRepo = new File( "target/test-origin-repo" );
         if ( originRepo.exists() )
         {
@@ -69,6 +74,12 @@ public class CopyArtifactTest
         assertFalse( originRepo.exists() );
         FileUtils.copyDirectory( new File( "src/test/repo-with-osgi" ), originRepo );
 
+        if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) != null )
+        {
+            getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( SOURCE_REPO_ID, true );
+            assertNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) );
+        }
+
         managedRepository = getTestManagedRepository();
         managedRepository.setId( SOURCE_REPO_ID );
         managedRepository.setLocation( originRepo.getCanonicalPath() );
@@ -81,6 +92,22 @@ public class CopyArtifactTest
 
     }
 
+    public void clean()  throws Exception
+    {
+
+        if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) != null )
+        {
+            getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( TARGET_REPO_ID, true );
+            assertNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) );
+        }
+        if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) != null )
+        {
+            getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( SOURCE_REPO_ID, true );
+            assertNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) );
+        }
+
+    }
+
     @Test
     public void copyToAnEmptyRepo()
         throws Exception
@@ -116,7 +143,7 @@ public class CopyArtifactTest
                              "/org/apache/karaf/features/org.apache.karaf.features.core/2.2.2/org.apache.karaf.features.core-2.2.2.pom" );
 
         assertTrue( "not exists " + pom.getPath(), pom.exists() );
-
+        clean();
     }
 
     //@Test
@@ -124,5 +151,6 @@ public class CopyArtifactTest
         throws Exception
     {
         initSourceTargetRepo();
+        clean();
     }
 }