summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaria Odea B. Ching <oching@apache.org>2011-06-15 11:03:10 +0000
committerMaria Odea B. Ching <oching@apache.org>2011-06-15 11:03:10 +0000
commit1af82ff7d8db47ff0dee286869d80189cabf78e4 (patch)
treee20a661bf889dca04af820b71e9908e7e2a86f02
parentdab1e929905186a20423260d0f1ce275eef4add2 (diff)
downloadarchiva-1af82ff7d8db47ff0dee286869d80189cabf78e4.tar.gz
archiva-1af82ff7d8db47ff0dee286869d80189cabf78e4.zip
use getBasedir() in FileUtil in archiva-common
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1135993 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java16
-rw-r--r--archiva-modules/archiva-base/archiva-checksum/pom.xml4
-rw-r--r--archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java24
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java22
-rw-r--r--archiva-modules/archiva-base/archiva-converter/pom.xml4
-rw-r--r--archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java60
-rw-r--r--archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/maven/archiva/policies/ChecksumPolicyTest.java16
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AbstractRepositoryLayerTestCase.java11
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java3
-rw-r--r--archiva-modules/archiva-base/archiva-transaction/pom.xml4
-rw-r--r--archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java12
-rw-r--r--archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CopyFileEventTest.java7
-rw-r--r--archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CreateFileEventTest.java7
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java11
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java33
15 files changed, 78 insertions, 156 deletions
diff --git a/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java b/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java
index b81612d1e..0d0b37b21 100644
--- a/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java
+++ b/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java
@@ -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.
diff --git a/archiva-modules/archiva-base/archiva-checksum/pom.xml b/archiva-modules/archiva-base/archiva-checksum/pom.xml
index 5d7053fea..3faf4fa5f 100644
--- a/archiva-modules/archiva-base/archiva-checksum/pom.xml
+++ b/archiva-modules/archiva-base/archiva-checksum/pom.xml
@@ -41,6 +41,10 @@
<dependencies>
<dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-common</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
diff --git a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java
index 6f75f6944..6f8d285a0 100644
--- a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java
+++ b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java
@@ -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 )
{
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java
index a167c973d..048544ece 100644
--- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java
+++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java
@@ -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 );
diff --git a/archiva-modules/archiva-base/archiva-converter/pom.xml b/archiva-modules/archiva-base/archiva-converter/pom.xml
index 25b1888e0..8f7dc1e6f 100644
--- a/archiva-modules/archiva-base/archiva-converter/pom.xml
+++ b/archiva-modules/archiva-base/archiva-converter/pom.xml
@@ -49,6 +49,10 @@
<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>
</dependency>
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
index 687a5fb20..3b1a83da3 100644
--- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
+++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
@@ -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 );
diff --git a/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/maven/archiva/policies/ChecksumPolicyTest.java b/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/maven/archiva/policies/ChecksumPolicyTest.java
index 7d7448862..e2a3aa92e 100644
--- a/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/maven/archiva/policies/ChecksumPolicyTest.java
+++ b/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/maven/archiva/policies/ChecksumPolicyTest.java
@@ -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 );
}
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AbstractRepositoryLayerTestCase.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AbstractRepositoryLayerTestCase.java
index 9ed7d5e7c..7697905b7 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AbstractRepositoryLayerTestCase.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AbstractRepositoryLayerTestCase.java
@@ -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;
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
index 894ec85d4..5ac2583ea 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
@@ -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 );
}
diff --git a/archiva-modules/archiva-base/archiva-transaction/pom.xml b/archiva-modules/archiva-base/archiva-transaction/pom.xml
index 2de639c52..193b4c19f 100644
--- a/archiva-modules/archiva-base/archiva-transaction/pom.xml
+++ b/archiva-modules/archiva-base/archiva-transaction/pom.xml
@@ -29,6 +29,10 @@
<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>
</dependency>
diff --git a/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java b/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java
index f25f0488e..c860a6852 100644
--- a/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java
+++ b/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java
@@ -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
diff --git a/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CopyFileEventTest.java b/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CopyFileEventTest.java
index 001213320..4d9c86c60 100644
--- a/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CopyFileEventTest.java
+++ b/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CopyFileEventTest.java
@@ -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 )
diff --git a/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CreateFileEventTest.java b/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CreateFileEventTest.java
index 467ffc9e3..263ff9fe4 100644
--- a/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CreateFileEventTest.java
+++ b/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/CreateFileEventTest.java
@@ -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" ) );
}
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java
index 9a95ce546..cd3562ae6 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java
@@ -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;
- }
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java
index c8930ab66..e9e80111f 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java
@@ -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 );