]> source.dussan.org Git - archiva.git/commitdiff
use getBasedir() in FileUtil in archiva-common
authorMaria Odea B. Ching <oching@apache.org>
Wed, 15 Jun 2011 11:03:10 +0000 (11:03 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Wed, 15 Jun 2011 11:03:10 +0000 (11:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1135993 13f79535-47bb-0310-9956-ffa450edef68

15 files changed:
archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java
archiva-modules/archiva-base/archiva-checksum/pom.xml
archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java
archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java
archiva-modules/archiva-base/archiva-converter/pom.xml
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/maven/archiva/policies/ChecksumPolicyTest.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AbstractRepositoryLayerTestCase.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
archiva-modules/archiva-base/archiva-transaction/pom.xml
archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java
archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CopyFileEventTest.java
archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CreateFileEventTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java

index b81612d1ef8d1a817f1854b424cc187868a01008..0d0b37b21d76030e05294c813774414e27af5377 100644 (file)
@@ -22,6 +22,7 @@ package org.apache.maven.archiva.converter.artifact;
 import junit.framework.TestCase;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.common.utils.FileUtil;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
@@ -108,18 +109,7 @@ public class LegacyToDefaultConverterTest
 
     public static File getTestFile( String path )
     {
-        return new File( getBasedir(), path );
-    }
-
-    public static String getBasedir()
-    {
-        String basedir = System.getProperty( "basedir" );
-        if ( basedir == null )
-        {
-            basedir = new File( "" ).getAbsolutePath();
-        }
-
-        return basedir;
+        return new File( FileUtil.getBasedir(), path );
     }
 
     private void copyDirectoryStructure( File sourceDirectory, File destinationDirectory )
@@ -440,7 +430,7 @@ public class LegacyToDefaultConverterTest
         Artifact artifact =
             createArtifact( "org.apache.maven.plugins", "maven-foo-plugin", "1.0", "1.0", "maven-plugin" );
         artifact.setFile(
-            new File( getBasedir(), "src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar" ) );
+            new File( FileUtil.getBasedir(), "src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar" ) );
         artifactConverter.convert( artifact, targetRepository );
         // There is a warning but I can't figure out how to look at it. Eyeballing the results it appears
         // the plugin is being coverted correctly.
index 5d7053fea8987f6600588e5ace4507bf3b30773f..3faf4fa5ffaea3ccda83ef7db2d9184d38abf64d 100644 (file)
   </build>
 
   <dependencies>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-common</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
index 6f75f69448a3143901770df28c9e0956b7b00090..6f8d285a05eae8adabba57b7ab644f866722521f 100644 (file)
@@ -22,6 +22,7 @@ package org.apache.archiva.checksum;
 import java.io.File;
 
 import junit.framework.TestCase;
+import org.apache.maven.archiva.common.utils.FileUtil;
 
 /**
  * AbstractChecksumTestCase
@@ -31,28 +32,9 @@ import junit.framework.TestCase;
 public abstract class AbstractChecksumTestCase
     extends TestCase
 {
-    private File basedir;
-
-    public File getBasedir()
-    {
-        if ( basedir == null )
-        {
-            String sysprop = System.getProperty( "basedir" );
-            if ( sysprop != null )
-            {
-                basedir = new File( sysprop );
-            }
-            else
-            {
-                basedir = new File( System.getProperty( "user.dir" ) );
-            }
-        }
-        return basedir;
-    }
-
     public File getTestOutputDir()
     {
-        File dir = new File( getBasedir(), "target/test-output/" + getName() );
+        File dir = new File( FileUtil.getBasedir(), "target/test-output/" + getName() );
         if ( dir.exists() == false )
         {
             if ( dir.mkdirs() == false )
@@ -65,7 +47,7 @@ public abstract class AbstractChecksumTestCase
 
     public File getTestResource( String filename )
     {
-        File dir = new File( getBasedir(), "src/test/resources" );
+        File dir = new File( FileUtil.getBasedir(), "src/test/resources" );
         File file = new File( dir, filename );
         if ( file.exists() == false )
         {
index a167c973deae6d57c742fd5f335148326b2d4782..048544ece626c5156b3c3235bf4f89d98d3b198e 100644 (file)
@@ -22,6 +22,7 @@ package org.apache.maven.archiva.configuration;
 import junit.framework.TestCase;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.common.utils.FileUtil;
 import org.codehaus.plexus.registry.RegistryException;
 import org.codehaus.redback.components.springutils.ComponentContainer;
 import org.custommonkey.xmlunit.XMLAssert;
@@ -48,20 +49,9 @@ public class ArchivaConfigurationTest
     @Inject
     private ComponentContainer componentContainer;
 
-    public static String getBasedir()
-    {
-        String basedir = System.getProperty( "basedir" );
-        if ( basedir == null )
-        {
-            basedir = new File( "" ).getAbsolutePath();
-        }
-
-        return basedir;
-    }
-
     public static File getTestFile( String path )
     {
-        return new File( getBasedir(), path );
+        return new File( FileUtil.getBasedir(), path );
     }
 
     /**
@@ -131,19 +121,19 @@ public class ArchivaConfigurationTest
     public void testGetConfigurationFromDefaultsWithDefaultRepoLocationAlreadyExisting()
         throws Exception
     {
-        File repo = new File( getBasedir(), "/target/test-classes/existing_snapshots" );
+        File repo = new File( FileUtil.getBasedir(), "/target/test-classes/existing_snapshots" );
         repo.mkdirs();
 
-        repo = new File( getBasedir(), "/target/test-classes/existing_internal" );
+        repo = new File( FileUtil.getBasedir(), "/target/test-classes/existing_internal" );
         repo.mkdirs();
 
         String existingTestDefaultArchivaConfigFile = FileUtils.readFileToString(
             getTestFile( "target/test-classes/org/apache/maven/archiva/configuration/test-default-archiva.xml" ) );
         existingTestDefaultArchivaConfigFile =
-            StringUtils.replace( existingTestDefaultArchivaConfigFile, "${appserver.base}", getBasedir() );
+            StringUtils.replace( existingTestDefaultArchivaConfigFile, "${appserver.base}", FileUtil.getBasedir() );
 
         File generatedTestDefaultArchivaConfigFile =
-            new File( getBasedir(), "target/test-classes/org/apache/maven/archiva/configuration/default-archiva.xml" );
+            new File( FileUtil.getBasedir(), "target/test-classes/org/apache/maven/archiva/configuration/default-archiva.xml" );
 
         FileUtils.writeStringToFile( generatedTestDefaultArchivaConfigFile, existingTestDefaultArchivaConfigFile,
                                      null );
index 25b1888e02f4e29a33d1d7d422e83cd2b04faa74..8f7dc1e6fc4a84b0780efc411220f42432566531 100644 (file)
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-plexus-bridge</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-common</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-i18n</artifactId>
index 687a5fb207dc91fd81e9b2ef755b1a0e440688a5..3b1a83da37b076abda696ed4075cb05d4a901ac2 100644 (file)
@@ -23,6 +23,7 @@ import junit.framework.TestCase;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil;
+import org.apache.maven.archiva.common.utils.FileUtil;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
@@ -100,26 +101,15 @@ public class NexusRepositorySearchTest
         config.addManagedRepository( createRepositoryConfig( TEST_REPO_2 ) );
     }
 
-    public static String getBasedir()
-    {
-        String basedir = System.getProperty( "basedir" );
-        if ( basedir == null )
-        {
-            basedir = new File( "" ).getAbsolutePath();
-        }
-
-        return basedir;
-    }
-
     private void createSimpleIndex()
         throws IOException, UnsupportedExistingLuceneIndexException, IllegalArtifactCoordinateException
     {
         List<File> files = new ArrayList<File>();
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) );
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) );
 
         createIndex( TEST_REPO_1, files );
@@ -129,19 +119,19 @@ public class NexusRepositorySearchTest
         throws IOException, UnsupportedExistingLuceneIndexException, IllegalArtifactCoordinateException
     {
         List<File> files = new ArrayList<File>();
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) );
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) );
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war" ) );
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) );
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) );
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/com/classname-search/1.0/classname-search-1.0.jar" ) );
 
         createIndex( TEST_REPO_1, files );
@@ -151,7 +141,7 @@ public class NexusRepositorySearchTest
     {
         ManagedRepositoryConfiguration repositoryConfig = new ManagedRepositoryConfiguration();
         repositoryConfig.setId( repository );
-        repositoryConfig.setLocation( getBasedir() + "/target/test-classes/" + repository );
+        repositoryConfig.setLocation( FileUtil.getBasedir() + "/target/test-classes/" + repository );
         repositoryConfig.setLayout( "default" );
         repositoryConfig.setName( repository );
         repositoryConfig.setScanned( true );
@@ -165,11 +155,11 @@ public class NexusRepositorySearchTest
     public void tearDown()
         throws Exception
     {
-        FileUtils.deleteDirectory( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + "/.indexer" ) );
-        assertFalse( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + "/.indexer" ).exists() );
+        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1 + "/.indexer" ) );
+        assertFalse( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1 + "/.indexer" ).exists() );
 
-        FileUtils.deleteDirectory( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_2 + "/.indexer" ) );
-        assertFalse( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_2 + "/.indexer" ).exists() );
+        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_2 + "/.indexer" ) );
+        assertFalse( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_2 + "/.indexer" ).exists() );
 
         super.tearDown();
     }
@@ -178,8 +168,8 @@ public class NexusRepositorySearchTest
         throws IOException, UnsupportedExistingLuceneIndexException, IllegalArtifactCoordinateException
     {
         context = new DefaultIndexingContext( repository, repository,
-                                              new File( getBasedir(), "/target/test-classes/" + repository ),
-                                              new File( getBasedir(),
+                                              new File( FileUtil.getBasedir(), "/target/test-classes/" + repository ),
+                                              new File( FileUtil.getBasedir(),
                                                         "/target/test-classes/" + repository + "/.indexer" ), null,
                                               null, ArchivaNexusIndexerUtil.FULL_INDEX, false );
         //indexer.addIndexingContext( repository, repository, new File( getBasedir(), "/target/test-classes/" +
@@ -199,7 +189,7 @@ public class NexusRepositorySearchTest
         //indexerEngine.endIndexing( context );
         //indexer.removeIndexingContext( context, false );
 
-        assertTrue( new File( getBasedir(), "/target/test-classes/" + repository + "/.indexer" ).exists() );
+        assertTrue( new File( FileUtil.getBasedir(), "/target/test-classes/" + repository + "/.indexer" ).exists() );
     }
 
     @Test
@@ -319,9 +309,9 @@ public class NexusRepositorySearchTest
         createSimpleIndex();
 
         List<File> files = new ArrayList<File>();
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_2
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_2
             + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_2
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_2
             + "/org/apache/archiva/archiva-search/1.1/archiva-search-1.1.jar" ) );
         createIndex( TEST_REPO_2, files );
 
@@ -447,9 +437,9 @@ public class NexusRepositorySearchTest
         throws Exception
     {
         List<File> files = new ArrayList<File>();
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_2
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_2
             + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) );
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_2
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_2
             + "/org/apache/archiva/archiva-search/1.1/archiva-search-1.1.jar" ) );
         createIndex( TEST_REPO_2, files );
 
@@ -533,9 +523,9 @@ public class NexusRepositorySearchTest
         throws Exception
     {
         List<File> files = new ArrayList<File>();
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) );
-        files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1
+        files.add( new File( FileUtil.getBasedir(), "/target/test-classes/" + TEST_REPO_1
             + "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) );
         createIndex( TEST_REPO_1, files );
 
index 7d744886202e24e9ccace089a7e12c7ebff9c16c..e2a3aa92e7cb6322c5ba0c6c2ac12e7953522385 100644 (file)
@@ -21,6 +21,7 @@ package org.apache.maven.archiva.policies;
 
 import junit.framework.TestCase;
 import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.common.utils.FileUtil;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.test.context.ContextConfiguration;
@@ -357,22 +358,9 @@ public class ChecksumPolicyTest
         return localFile;
     }
 
-
-
-    public static String getBasedir()
-    {
-        String basedir = System.getProperty( "basedir" );
-        if ( basedir == null )
-        {
-            basedir = new File( "" ).getAbsolutePath();
-        }
-
-        return basedir;
-    }
-
     public static File getTestFile( String path )
     {
-        return new File( getBasedir(), path );
+        return new File( FileUtil.getBasedir(), path );
     }
 
 }
index 9ed7d5e7cda05f67d16bdfcf9214b0543720fad0..7697905b7be32da76e35bcef88e8efb892cc246b 100644 (file)
@@ -41,17 +41,6 @@ public abstract class AbstractRepositoryLayerTestCase
     extends TestCase
 {
 
-    public static String getBasedir()
-    {
-       String basedir = System.getProperty( "basedir" );
-        if ( basedir == null )
-        {
-            basedir = new File( "" ).getAbsolutePath();
-        }
-
-        return basedir;
-    }
-
     @Inject
     protected ApplicationContext applicationContext;
 
index 894ec85d49e116e4bf196d2130ec17a641121802..5ac2583ea7cb79eff24d97b5e78fa2c090ca71ba 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.maven.archiva.repository.content;
  */
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.common.utils.FileUtil;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.repository.AbstractRepositoryLayerTestCase;
@@ -369,7 +370,7 @@ public class RepositoryRequestTest
     private ManagedRepositoryContent createManagedRepo( String layout )
         throws Exception
     {
-        File repoRoot = new File( getBasedir() + "/target/test-repo" );
+        File repoRoot = new File( FileUtil.getBasedir() + "/target/test-repo" );
         return createManagedRepositoryContent( "test-internal", "Internal Test Repo", repoRoot, layout );
     }
 
index 2de639c52d5bf980c8e452d50742cf4d55160f4c..193b4c19fd4a438bda6dc3000bd0982cbd8efe77 100644 (file)
   <name>Archiva Transactions</name>
   <description>API for managing transaction.</description>
   <dependencies>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-common</artifactId>
+    </dependency>
     <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
index f25f0488e55ca3dfcfec6fa7380d71166d033a1b..c860a68525620595b599a65b9e389a30b5973fe3 100644 (file)
@@ -38,18 +38,6 @@ public abstract class AbstractFileEventTest
 {
     protected List<Digester> digesters;
 
-    public static String getBasedir()
-    {
-
-        String basedir = System.getProperty( "basedir" );
-        if (basedir == null)
-        {
-            basedir = new File( "" ).getAbsolutePath();
-        }
-        return basedir;
-
-    }
-
     @SuppressWarnings( "unchecked" )
     public void setUp()
         throws Exception
index 00121332069968690b428188d6123d12ffa469e4..4d9c86c6053c4f50f636094bdaaf1b2cb0aec0f3 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.maven.archiva.transaction;
  */
 
 import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.common.utils.FileUtil;
 
 import java.io.File;
 import java.io.IOException;
@@ -29,11 +30,11 @@ import java.io.IOException;
 public class CopyFileEventTest
     extends AbstractFileEventTest
 {
-    private File testDir = new File( getBasedir(), "target/transaction-tests/copy-file" );
+    private File testDir = new File( FileUtil.getBasedir(), "target/transaction-tests/copy-file" );
 
     private File testDest = new File( testDir, "test-file.txt" );
 
-    private File testSource = new File( getBasedir(), "target/transaction-tests/test-file.txt" );
+    private File testSource = new File( FileUtil.getBasedir(), "target/transaction-tests/test-file.txt" );
 
     private File testDestChecksum;
 
@@ -152,7 +153,7 @@ public class CopyFileEventTest
     {
         super.tearDown();
 
-        FileUtils.deleteDirectory( new File( getBasedir(), "target/transaction-tests" ) );
+        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "target/transaction-tests" ) );
     }
 
     protected void assertChecksumCommit( File file )
index 467ffc9e3f1b65fcb2b8585bbfa177fbe389861a..263ff9fe4fb11150ceef4f83ed9a00f6cba29523 100644 (file)
@@ -22,13 +22,14 @@ package org.apache.maven.archiva.transaction;
 import java.io.File;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.common.utils.FileUtil;
 
 /**
  */
 public class CreateFileEventTest
     extends AbstractFileEventTest
 {
-    private File testDir = new File( getBasedir(), "target/transaction-tests/create-file" );
+    private File testDir = new File( FileUtil.getBasedir(), "target/transaction-tests/create-file" );
 
     public void testCreateCommitRollback()
         throws Exception
@@ -52,7 +53,7 @@ public class CreateFileEventTest
         assertChecksumRollback( testFile );
 
         assertFalse( "Test file parent directories has been rolledback too", testDir.exists() );
-        assertTrue( "target directory still exists", new File( getBasedir(), "target" ).exists() );
+        assertTrue( "target directory still exists", new File( FileUtil.getBasedir(), "target" ).exists() );
     }
 
     public void testCreateCommitRollbackWithBackup()
@@ -114,6 +115,6 @@ public class CreateFileEventTest
     {
         super.tearDown();
 
-        FileUtils.deleteDirectory( new File( getBasedir(), "target/transaction-tests" ) );
+        FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "target/transaction-tests" ) );
     }
 }
index 9a95ce5469313e1000cb8ae0267ec555b9aec6df..cd3562ae6741a188ca9c1032ed821017c7be5078 100644 (file)
@@ -221,15 +221,4 @@ public abstract class AbstractActionTestCase
         stack.getContext().put( ActionContext.CONTAINER, container );
         ActionContext.setContext( new ActionContext( stack.getContext() ) );
     }
-
-    public static String getBasedir()
-    {
-        String basedir = System.getProperty( "basedir" );
-        if ( basedir == null )
-        {
-            basedir = new File( "" ).getAbsolutePath();
-        }
-
-        return basedir;
-    }
 }
index c8930ab66fd011c1d66d9dfc1427825a2c1a90b5..e9e80111f356915287e927aaf99c87a234a54487 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.archiva.checksum.ChecksummedFile;
 import org.apache.archiva.scheduler.ArchivaTaskScheduler;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.common.utils.FileUtil;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
@@ -91,7 +92,7 @@ public class UploadActionTest
         uploadAction.setConfiguration( archivaConfig );
         uploadAction.setRepositoryFactory( repoFactory );
 
-        File testRepo = new File( getBasedir(), "target/test-classes/test-repo" );
+        File testRepo = new File( FileUtil.getBasedir(), "target/test-classes/test-repo" );
         testRepo.mkdirs();
 
         assertTrue( testRepo.exists() );
@@ -289,9 +290,9 @@ public class UploadActionTest
     public void testArtifactUploadWithPomSuccessful()
         throws Exception
     {
-        setUploadParameters( "1.0", null, new File( getBasedir(),
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             new File( getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ), false );
+                             new File( FileUtil.getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ), false );
 
         ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
         content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) );
@@ -324,9 +325,9 @@ public class UploadActionTest
     public void testArtifactUploadWithClassifier()
         throws Exception
     {
-        setUploadParameters( "1.0", "tests", new File( getBasedir(),
+        setUploadParameters( "1.0", "tests", new File( FileUtil.getBasedir(),
                                                        "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
-                             new File( getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ), false );
+                             new File( FileUtil.getBasedir(), "target/test-classes/upload-artifact-test/pom.xml" ), false );
 
         ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
         content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) );
@@ -371,7 +372,7 @@ public class UploadActionTest
     public void testArtifactUploadGeneratePomSuccessful()
         throws Exception
     {
-        setUploadParameters( "1.0", null, new File( getBasedir(),
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
                              null, true );
 
@@ -406,7 +407,7 @@ public class UploadActionTest
     public void testArtifactUploadNoPomSuccessful()
         throws Exception
     {
-        setUploadParameters( "1.0", null, new File( getBasedir(),
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
                              null, false );
 
@@ -483,7 +484,7 @@ public class UploadActionTest
     public void testArtifactUploadFailedRepositoryNotFound()
         throws Exception
     {
-        setUploadParameters( "1.0", null, new File( getBasedir(),
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
                              null, false );
 
@@ -511,7 +512,7 @@ public class UploadActionTest
     public void testArtifactUploadSnapshots()
         throws Exception
     {
-        setUploadParameters( "1.0-SNAPSHOT", null, new File( getBasedir(),
+        setUploadParameters( "1.0-SNAPSHOT", null, new File( FileUtil.getBasedir(),
                                                              "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
                              null, true );
 
@@ -583,7 +584,7 @@ public class UploadActionTest
         // MRM-1353
         // upload snapshot artifact again and check if build number was incremented
         setUploadParameters( "1.0-SNAPSHOT", null,
-                             new File( getBasedir(),
+                             new File( FileUtil.getBasedir(),
                                        "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null,
                              true );
 
@@ -640,7 +641,7 @@ public class UploadActionTest
     public void testChecksumIsCorrectWhenArtifactIsReUploaded()
         throws Exception
     {
-        setUploadParameters( "1.0", null, new File( getBasedir(),
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
                              null, true );
 
@@ -672,7 +673,7 @@ public class UploadActionTest
         verifyProjectMetadataChecksums( repoLocation );
 
         // RE-upload artifact
-        setUploadParameters( "1.0", null, new File( getBasedir(),
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-reuploaded.jar" ),
                              null, true );
 
@@ -706,7 +707,7 @@ public class UploadActionTest
     public void testUploadArtifactAlreadyExistingRedeploymentsBlocked()
         throws Exception
     {
-        setUploadParameters( "1.0", null, new File( getBasedir(),
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
                              null, true );
 
@@ -722,7 +723,7 @@ public class UploadActionTest
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
-        setUploadParameters( "1.0", null, new File( getBasedir(),
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
                              null, true );
 
@@ -746,7 +747,7 @@ public class UploadActionTest
     public void testUploadArtifactAlreadyExistingRedeploymentsAllowed()
         throws Exception
     {
-        setUploadParameters( "1.0", null, new File( getBasedir(),
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
                              null, true );
 
@@ -764,7 +765,7 @@ public class UploadActionTest
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
-        setUploadParameters( "1.0", null, new File( getBasedir(),
+        setUploadParameters( "1.0", null, new File( FileUtil.getBasedir(),
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
                              null, true );