Author: olamy
Date: Thu Sep 22 22:21:24 2011
New Revision: 1174425

URL: http://svn.apache.org/viewvc?rev=1174425&view=rev
Log:
cleanup created test repos after test

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

Modified: 
archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java?rev=1174425&r1=1174424&r2=1174425&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java
 Thu Sep 22 22:21:24 2011
@@ -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();
     }
 }


Reply via email to