]> source.dussan.org Git - archiva.git/commitdiff
avoid writing tmp files to sources tree
authorOlivier Lamy <olamy@apache.org>
Wed, 25 Jan 2012 00:21:45 +0000 (00:21 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 25 Jan 2012 00:21:45 +0000 (00:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1235569 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/pom.xml
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java

index d4e368c139e09c3bd1c0c12da70664beb9bf3de5..184c84648314a949df95bdad7884d11887e7252a 100644 (file)
             <redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
             <redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
             <basedir>${basedir}</basedir>
+            <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
           </systemPropertyVariables>
         </configuration>
       </plugin>
index 2210ef8e7353f33493576a427b8af292aa085bad..19d562cd004d3f91e5381aef859ed44b5e69acf1 100644 (file)
@@ -29,14 +29,17 @@ import org.apache.archiva.rest.api.services.ProxyConnectorService;
 import org.apache.archiva.rest.api.services.RepositoriesService;
 import org.apache.archiva.rest.api.services.RepositoryGroupService;
 import org.apache.archiva.rest.api.services.SearchService;
+import org.apache.commons.io.FileUtils;
 import org.codehaus.redback.integration.security.role.RedbackRoleConstants;
 import org.codehaus.redback.rest.services.FakeCreateAdminService;
+import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
+import java.io.File;
 import java.util.Arrays;
 import java.util.List;
 
@@ -66,16 +69,34 @@ public class DownloadMergedIndexTest
         return "classpath*:META-INF/spring-context.xml classpath*:spring-context-merge-index-download.xml";
     }
 
+    @After
+    public void cleanup()
+        throws Exception
+    {
+        super.tearDown();
+        File tmpIndexDir = new File( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex" );
+        if ( tmpIndexDir.exists() )
+        {
+            FileUtils.deleteDirectory( tmpIndexDir );
+        }
+    }
+
+
     @Test
     public void downloadMergedIndex()
         throws Exception
     {
+        File tmpIndexDir = new File( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex" );
+        if ( tmpIndexDir.exists() )
+        {
+            FileUtils.deleteDirectory( tmpIndexDir );
+        }
         String id = Long.toString( System.currentTimeMillis() );
         ManagedRepository managedRepository = new ManagedRepository();
         managedRepository.setId( id );
         managedRepository.setName( "name of " + id );
         managedRepository.setLocation( "src/test/repositories/test-repo" );
-        managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/target/tmpIndex/" + id );
+        managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex/" + id );
 
         ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService();
 
@@ -112,7 +133,7 @@ public class DownloadMergedIndexTest
         managedRepository.setId( id );
         managedRepository.setName( "name of " + id );
         managedRepository.setLocation( "src/test/repositories/test-repo" );
-        managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/target/tmpIndex/" + id );
+        managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex/" + id );
 
         if ( managedRepositoriesService.getManagedRepository( id ) != null )
         {