aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-webdav
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2018-11-01 14:02:41 +0100
committerMartin Stockhammer <martin_s@apache.org>2018-11-01 14:02:41 +0100
commit39b2449b7d545295227e576247ecd67afd1cd925 (patch)
treed482da01e98e62b5d738abf4b93cba3952c2efeb /archiva-modules/archiva-web/archiva-webdav
parent956818e3e6c6b8b9b6184633fefa946b7f45ec00 (diff)
downloadarchiva-39b2449b7d545295227e576247ecd67afd1cd925.tar.gz
archiva-39b2449b7d545295227e576247ecd67afd1cd925.zip
Switching to forked tests in webdav project
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webdav')
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/pom.xml32
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java10
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java12
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java57
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java33
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaTemporaryFolderRule.java23
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java7
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java8
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyMetadataTest.java8
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyTest.java8
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletRepositoryGroupTest.java10
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java28
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/resources/log4j2-test.xml54
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/resources/repository-servlet-simple.xml3
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/resources/spring-context-servlet-security-test.xml3
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/resources/spring-context.xml4
16 files changed, 266 insertions, 34 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/pom.xml b/archiva-modules/archiva-web/archiva-webdav/pom.xml
index b2d19b896..931b2f9f6 100644
--- a/archiva-modules/archiva-web/archiva-webdav/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webdav/pom.xml
@@ -178,8 +178,13 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -335,20 +340,31 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>${webdav.argLine} @{jacocoproperty}</argLine>
+ <forkCount>2</forkCount>
+ <reuseForks>false</reuseForks>
+ <!--
+ The property jdk.net.URLClassPath.disableClassPathURLCheck is a workaround for a regression
+ with surefire and OpenJDK 8 181b13 on Debian/Ubuntu,
+ @see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911925
+ -->
+ <argLine>${webdav.argLine} -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
+ <workingDirectory>${project.build.directory}/WDIR-${surefire.forkNumber}</workingDirectory>
+ <environmentVariables>
+ <ARCHIVA_USER_CONFIG_FILE>${java.io.tmpdir}/archiva-webdav-${surefire.forkNumber}.xml</ARCHIVA_USER_CONFIG_FILE>
+ </environmentVariables>
<systemPropertyVariables>
- <appserver.base>${project.build.directory}/appserver-base</appserver.base>
- <plexus.home>${project.build.directory}/appserver-base</plexus.home>
- <derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
+ <mvn.project.base.dir>${project.basedir}</mvn.project.base.dir>
+ <appserver.base>${project.build.directory}/appserver-base-${surefire.forkNumber}</appserver.base>
+ <plexus.home>${project.build.directory}/appserver-base-${surefire.forkNumber}</plexus.home>
+ <derby.system.home>${project.build.directory}/appserver-base-${surefire.forkNumber}</derby.system.home>
<test.resources.path>${project.build.testOutputDirectory}</test.resources.path>
- <archiva.user.configFileName>${project.build.testOutputDirectory}/repository-archiva.xml</archiva.user.configFileName>
+ <archiva.user.configFileName>${project.build.directory}/appserver-base-${surefire.forkNumber}/conf/archiva.xml</archiva.user.configFileName>
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
<archiva.repositorySessionFactory.id>mock</archiva.repositorySessionFactory.id>
<openjpa.Log>${openjpa.Log}</openjpa.Log>
<org.apache.jackrabbit.core.state.validatehierarchy>true</org.apache.jackrabbit.core.state.validatehierarchy>
</systemPropertyVariables>
- <forkMode>${webdav.forkMode}</forkMode>
</configuration>
</plugin>
</plugins>
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java
index eb7bd3637..224603ff8 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedMetadataTestCase.java
@@ -22,12 +22,15 @@ package org.apache.archiva.webdav;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.WebResponse;
+import org.apache.archiva.common.utils.FileUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.custommonkey.xmlunit.DetailedDiff;
import org.custommonkey.xmlunit.Diff;
import org.junit.Before;
+import java.nio.file.Paths;
+
/**
* Abstract TestCase for RepositoryServlet Tests, Proxied, Get of Metadata.
*
@@ -210,5 +213,12 @@ public abstract class AbstractRepositoryServletProxiedMetadataTestCase
shutdownServer( remotePrivateSnapshots );
super.tearDown();
+
+ String appserverBase = System.getProperty( "appserver.base" );
+ if ( StringUtils.isNotEmpty( appserverBase ) )
+ {
+ FileUtils.deleteDirectory( Paths.get( appserverBase ) );
+ }
+
}
}
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java
index 26afd9504..70df4ae02 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java
@@ -21,12 +21,14 @@ package org.apache.archiva.webdav;
import com.gargoylesoftware.htmlunit.WebClient;
+import org.apache.archiva.common.utils.FileUtils;
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.archiva.policies.CachedFailuresPolicy;
import org.apache.archiva.policies.ChecksumPolicy;
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
+import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
@@ -42,6 +44,7 @@ import javax.servlet.http.HttpServletResponse;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import static org.assertj.core.api.Assertions.assertThat;
@@ -116,6 +119,13 @@ public abstract class AbstractRepositoryServletProxiedTestCase
shutdownServer( remoteCentral );
shutdownServer( remoteSnapshots );
super.tearDown();
+ String baseDirProp = System.getProperty( "appserver.base" );
+ if ( StringUtils.isNotEmpty( baseDirProp )) {
+ Path baseDir = Paths.get(baseDirProp);
+ log.info("Deleting appserver base {}", baseDir);
+ FileUtils.deleteDirectory( baseDir );
+ log.info("exist {}", Files.exists(baseDir));
+ }
}
protected RemoteRepoInfo createServer( String id )
@@ -130,7 +140,7 @@ public abstract class AbstractRepositoryServletProxiedTestCase
// Remove exising root contents.
if ( Files.exists(repo.root) )
{
- org.apache.archiva.common.utils.FileUtils.deleteDirectory( repo.root );
+ FileUtils.deleteDirectory( repo.root );
}
// Establish root directory.
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
index b04a13db8..3b82377c2 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
@@ -78,6 +78,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Locale;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
/**
* AbstractRepositoryServletTestCase
@@ -108,6 +109,42 @@ public abstract class AbstractRepositoryServletTestCase
protected Logger log = LoggerFactory.getLogger( getClass() );
+ private AtomicReference<Path> projectBase = new AtomicReference<>( );
+ private AtomicReference<Path> appserverBase = new AtomicReference<>( );
+
+
+ public Path getProjectBase() {
+ if (this.projectBase.get()==null) {
+ String pathVal = System.getProperty("mvn.project.base.dir");
+ Path baseDir;
+ if (StringUtils.isEmpty(pathVal)) {
+ baseDir= Paths.get("").toAbsolutePath();
+ } else {
+ baseDir = Paths.get(pathVal).toAbsolutePath();
+ }
+ this.projectBase.compareAndSet(null, baseDir);
+ }
+ return this.projectBase.get();
+ }
+
+ public Path getAppserverBase() {
+ if (appserverBase.get()==null)
+ {
+ String pathVal = System.getProperty( "appserver.base" );
+ Path basePath;
+ if ( StringUtils.isNotEmpty( pathVal ) )
+ {
+ basePath = Paths.get( pathVal );
+ }
+ else
+ {
+ log.warn("Using relative path to working directory, appserver.base was not set!");
+ basePath = Paths.get( "target/appserver-base" );
+ }
+ appserverBase.set( basePath );
+ }
+ return appserverBase.get();
+ }
protected void saveConfiguration()
throws Exception
@@ -124,19 +161,21 @@ public abstract class AbstractRepositoryServletTestCase
super.setUp();
- String appserverBase = Paths.get( "target/appserver-base" ).toAbsolutePath().toString();
- System.setProperty( "appserver.base", appserverBase );
+ System.setProperty( "appserver.base", getAppserverBase().toAbsolutePath().toString());
+ log.info("setUp appserverBase={}, projectBase={}, workingDir={}", getAppserverBase(), getProjectBase(), Paths.get("").toString());
- Path testConf = Paths.get( "src/test/resources/repository-archiva.xml" );
- Path testConfDest = Paths.get(appserverBase, "conf/archiva.xml" );
+ org.apache.archiva.common.utils.FileUtils.deleteDirectory( getAppserverBase() );
+
+ Path testConf = getProjectBase().resolve( "src/test/resources/repository-archiva.xml" );
+ Path testConfDest = getAppserverBase().resolve("conf/archiva.xml" );
if ( Files.exists(testConfDest) )
{
org.apache.archiva.common.utils.FileUtils.deleteQuietly( testConfDest );
}
FileUtils.copyFile( testConf.toFile(), testConfDest.toFile() );
- repoRootInternal = Paths.get( appserverBase, "data/repositories/internal" );
- repoRootLegacy = Paths.get( appserverBase, "data/repositories/legacy" );
+ repoRootInternal = getAppserverBase().resolve("data/repositories/internal" );
+ repoRootLegacy = getAppserverBase().resolve( "data/repositories/legacy" );
Configuration config = archivaConfiguration.getConfiguration();
config.getManagedRepositories().clear();
@@ -687,6 +726,12 @@ public abstract class AbstractRepositoryServletTestCase
org.apache.archiva.common.utils.FileUtils.deleteDirectory( repoRootLegacy );
}
+ String appserverBase = System.getProperty( "appserver.base" );
+ if ( StringUtils.isNotEmpty( appserverBase ) )
+ {
+ org.apache.archiva.common.utils.FileUtils.deleteDirectory( Paths.get( appserverBase ) );
+ }
+
}
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java
index 1c56a04af..9b5bb7f18 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java
@@ -51,6 +51,7 @@ import org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryCont
import org.apache.archiva.repository.content.maven2.RepositoryRequest;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.DavResourceLocator;
import org.apache.jackrabbit.webdav.DavServletRequest;
@@ -75,6 +76,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
import static org.easymock.EasyMock.*;
@@ -86,6 +88,8 @@ import static org.easymock.EasyMock.*;
public class ArchivaDavResourceFactoryTest
extends TestCase
{
+ private AtomicReference<Path> projectBase = new AtomicReference<>();
+
private static final String RELEASES_REPO = "releases";
private static final String INTERNAL_REPO = "internal";
@@ -145,6 +149,19 @@ public class ArchivaDavResourceFactoryTest
@Inject
FileTypes fileTypes;
+ private Path getProjectBase() {
+ if (this.projectBase.get()==null) {
+ String pathVal = System.getProperty("mvn.project.base.dir");
+ Path baseDir;
+ if (StringUtils.isEmpty(pathVal)) {
+ baseDir= Paths.get("").toAbsolutePath();
+ } else {
+ baseDir = Paths.get(pathVal).toAbsolutePath();
+ }
+ this.projectBase.compareAndSet(null, baseDir);
+ }
+ return this.projectBase.get();
+ }
@Before
@Override
@@ -181,13 +198,13 @@ public class ArchivaDavResourceFactoryTest
if ( defaultManagedRepositoryAdmin.getManagedRepository( RELEASES_REPO ) == null )
{
defaultManagedRepositoryAdmin.addManagedRepository(
- createManagedRepository( RELEASES_REPO, Paths.get( "target/test-classes/" + RELEASES_REPO ).toString(),
+ createManagedRepository( RELEASES_REPO, getProjectBase().resolve( "target/test-classes/" + RELEASES_REPO ).toString(),
"default" ), false, null );
}
if ( defaultManagedRepositoryAdmin.getManagedRepository( INTERNAL_REPO ) == null )
{
defaultManagedRepositoryAdmin.addManagedRepository(
- createManagedRepository( INTERNAL_REPO, Paths.get( "target/test-classes/" + INTERNAL_REPO ).toString(),
+ createManagedRepository( INTERNAL_REPO, getProjectBase().resolve( "target/test-classes/" + INTERNAL_REPO ).toString(),
"default" ), false, null );
}
RepositoryGroup repoGroupConfig = new RepositoryGroup();
@@ -294,6 +311,11 @@ public class ArchivaDavResourceFactoryTest
throws Exception
{
super.tearDown();
+ String appserverBase = System.getProperty( "appserver.base" );
+ if ( StringUtils.isNotEmpty( appserverBase ) )
+ {
+ org.apache.archiva.common.utils.FileUtils.deleteDirectory( Paths.get( appserverBase ) );
+ }
}
// MRM-1232 - Unable to get artifacts from repositories which requires Repository Manager role using repository group
@@ -584,7 +606,8 @@ public class ArchivaDavResourceFactoryTest
}
catch ( DavException e )
{
- fail( "A DavException should not have been thrown!" );
+ e.printStackTrace();
+ fail( "A DavException should not have been thrown! "+e.getMessage() );
}
}
@@ -648,7 +671,7 @@ public class ArchivaDavResourceFactoryTest
RepositoryContentFactory repoContentFactory = applicationContext.getBean( "repositoryContentFactory#default", RepositoryContentFactory.class );
repoContentFactory.getRepositoryContentProviders().add(provider);
defaultManagedRepositoryAdmin.addManagedRepository(
- createManagedRepository( LEGACY_REPO, Paths.get( "target/test-classes/" + LEGACY_REPO ).toString(),
+ createManagedRepository( LEGACY_REPO, getProjectBase().resolve( "target/test-classes/" + LEGACY_REPO ).toString(),
"legacy" ), false, null );
DavResourceLocator locator =
new ArchivaDavResourceLocator( "", "/repository/" + LEGACY_REPO + "/eclipse/maven-metadata.xml",
@@ -735,7 +758,7 @@ public class ArchivaDavResourceFactoryTest
Path target = Paths.get(repository.getRepoRoot(), logicalPath );
try
{
- FileUtils.copyFile( Paths.get( "target/test-classes/maven-metadata.xml" ).toFile(), target.toFile() );
+ FileUtils.copyFile( getProjectBase().resolve( "target/test-classes/maven-metadata.xml" ).toFile(), target.toFile() );
}
catch ( IOException e )
{
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaTemporaryFolderRule.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaTemporaryFolderRule.java
index 1229c39a6..df5f62833 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaTemporaryFolderRule.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaTemporaryFolderRule.java
@@ -15,6 +15,7 @@
*/
package org.apache.archiva.webdav;
+import org.apache.commons.lang.StringUtils;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@@ -24,18 +25,38 @@ import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.concurrent.atomic.AtomicReference;
/**
* Rule to help creating folder for repository based on testmethod name
* @author Eric
*/
public class ArchivaTemporaryFolderRule implements TestRule {
+
+
+
private Path d;
private Description desc = Description.EMPTY;
+ private AtomicReference<Path> projectBase = new AtomicReference<>( );
+
+ private Path getProjectBase() {
+ if (this.projectBase.get()==null) {
+ String pathVal = System.getProperty("mvn.project.base.dir");
+ Path baseDir;
+ if ( StringUtils.isEmpty(pathVal)) {
+ baseDir= Paths.get("").toAbsolutePath();
+ } else {
+ baseDir = Paths.get(pathVal).toAbsolutePath();
+ }
+ this.projectBase.compareAndSet(null, baseDir);
+ }
+ return this.projectBase.get();
+ }
+
public void before() throws IOException {
// hard coded maven target file
- Path f1 = Paths.get("target", "archivarepo", ArchivaTemporaryFolderRule.resumepackage(desc.getClassName()), desc.getMethodName());
+ Path f1 = getProjectBase().resolve("target/archivarepo").resolve(ArchivaTemporaryFolderRule.resumepackage(desc.getClassName())).resolve(desc.getMethodName());
d = Files.createDirectories( f1 );
}
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java
index 394e82aec..a9bef0410 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java
@@ -21,10 +21,12 @@ package org.apache.archiva.webdav;
import junit.framework.TestCase;
import org.apache.archiva.common.filelock.FileLockManager;
+import org.apache.archiva.common.utils.FileUtils;
import org.apache.archiva.repository.events.AuditListener;
import org.apache.archiva.repository.maven2.MavenManagedRepository;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.archiva.webdav.util.MimeTypes;
+import org.apache.commons.lang.StringUtils;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.DavResource;
import org.apache.jackrabbit.webdav.DavResourceFactory;
@@ -107,6 +109,11 @@ public class DavResourceTest
{
super.tearDown();
org.apache.archiva.common.utils.FileUtils.deleteDirectory( baseDir );
+ String appserverBase = System.getProperty( "appserver.base" );
+ if ( StringUtils.isNotEmpty( appserverBase ) )
+ {
+ FileUtils.deleteDirectory( Paths.get( appserverBase ) );
+ }
}
private DavResource getDavResource( String logicalPath, Path file )
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java
index 2a93a4461..3b170401a 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java
@@ -23,6 +23,7 @@ import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.WebResponse;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.webdav.httpunit.MkColMethodWebRequest;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -50,6 +51,13 @@ public class RepositoryServletDeployTest
startRepository();
}
+ @Override
+ @After
+ public void tearDown( ) throws Exception
+ {
+ super.tearDown( );
+ }
+
@Test
public void testPutWithMissingParentCollection()
throws Exception
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyMetadataTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyMetadataTest.java
index bb91dd2f6..f320fd740 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyMetadataTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyMetadataTest.java
@@ -21,6 +21,7 @@ package org.apache.archiva.webdav;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.WebResponse;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -43,6 +44,13 @@ public class RepositoryServletNoProxyMetadataTest
startRepository();
}
+ @Override
+ @After
+ public void tearDown( ) throws Exception
+ {
+ super.tearDown( );
+ }
+
@Test
public void testGetVersionMetadataDefaultLayout()
throws Exception
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyTest.java
index 89a16d4e5..a532de1a6 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletNoProxyTest.java
@@ -23,6 +23,7 @@ package org.apache.archiva.webdav;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.WebResponse;
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
@@ -51,6 +52,13 @@ public class RepositoryServletNoProxyTest
startRepository();
}
+ @Override
+ @After
+ public void tearDown( ) throws Exception
+ {
+ super.tearDown( );
+ }
+
@Test
public void testLastModifiedHeaderExists()
throws Exception
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletRepositoryGroupTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletRepositoryGroupTest.java
index c07ce0d57..6daee289e 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletRepositoryGroupTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletRepositoryGroupTest.java
@@ -22,11 +22,13 @@ package org.apache.archiva.webdav;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.WebResponse;
+import org.apache.archiva.common.utils.FileUtils;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.archiva.maven2.metadata.MavenMetadataReader;
import org.apache.archiva.model.ArchivaRepositoryMetadata;
+import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -140,6 +142,12 @@ public class RepositoryServletRepositoryGroupTest
setupCleanRepo( repoRootLast );
super.tearDown();
+
+ String appserverBase = System.getProperty( "appserver.base" );
+ if ( StringUtils.isNotEmpty( appserverBase ) )
+ {
+ FileUtils.deleteDirectory( Paths.get( appserverBase ) );
+ }
}
/*
@@ -265,7 +273,7 @@ public class RepositoryServletRepositoryGroupTest
+ "dummy-merged-metadata-resource/maven-metadata.xml" );
WebResponse response = getServletUnitClient().getResource( request );
- Path returnedMetadata = Paths.get( "target/test-classes/retrievedMetadataFile.xml" );
+ Path returnedMetadata = getProjectBase().resolve( "target/test-classes/retrievedMetadataFile.xml" );
org.apache.archiva.common.utils.FileUtils.writeStringToFile( returnedMetadata, Charset.defaultCharset(), response.getContentAsString() );
ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( returnedMetadata );
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java
index 41683c07c..eaf24739c 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java
@@ -40,6 +40,7 @@ import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.jackrabbit.webdav.DavSessionProvider;
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
@@ -68,6 +69,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.eq;
@@ -107,7 +109,23 @@ public class RepositoryServletSecurityTest
@Rule
public ArchivaTemporaryFolderRule repoRootInternal = new ArchivaTemporaryFolderRule();
-
+
+ private AtomicReference<Path> projectBase = new AtomicReference<>( );
+
+ public Path getProjectBase() {
+ if (this.projectBase.get()==null) {
+ String pathVal = System.getProperty("mvn.project.base.dir");
+ Path baseDir;
+ if ( StringUtils.isEmpty(pathVal)) {
+ baseDir= Paths.get("").toAbsolutePath();
+ } else {
+ baseDir = Paths.get(pathVal).toAbsolutePath();
+ }
+ this.projectBase.compareAndSet(null, baseDir);
+ }
+ return this.projectBase.get();
+ }
+
@Before
@Override
public void setUp()
@@ -117,9 +135,9 @@ public class RepositoryServletSecurityTest
super.setUp();
String appserverBase =
- System.getProperty( "appserver.base", Paths.get( "target/appserver-base" ).toAbsolutePath().toString() );
+ System.getProperty( "appserver.base", getProjectBase().resolve( "target/appserver-base" ).toAbsolutePath().toString() );
- Path testConf = Paths.get( "src/test/resources/repository-archiva.xml" );
+ Path testConf = getProjectBase().resolve( "src/test/resources/repository-archiva.xml" );
Path testConfDest = Paths.get(appserverBase, "conf/archiva.xml" );
FileUtils.copyFile( testConf.toFile(), testConfDest.toFile() );
@@ -212,6 +230,10 @@ public class RepositoryServletSecurityTest
}*/
super.tearDown();
+ String appBaseProp = System.getProperty( "appserver.base" );
+ if (StringUtils.isNotEmpty( appBaseProp )) {
+ org.apache.archiva.common.utils.FileUtils.deleteDirectory( Paths.get(appBaseProp) );
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/log4j2-test.xml b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/log4j2-test.xml
new file mode 100644
index 000000000..0da8a7fe9
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/log4j2-test.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+
+<configuration> <!-- status="debug" -->
+ <appenders>
+ <Console name="console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%highlight{%d{HH:mm:ss.SSS} [%L] [%t] %-5level %logger{3} - %msg%n}" />
+ </Console>
+ <RollingRandomAccessFile name="rolling" fileName="/tmp/archiva.log"
+ filePattern="/tmp/archiva-%d{yyyyMMdd}.log"
+ immediateFlush="true" append="true">
+ <PatternLayout>
+ <pattern>%d [%t] %-5p %c %x - %m%n</pattern>
+ </PatternLayout>
+ <Policies>
+ <TimeBasedTriggeringPolicy />
+ </Policies>
+ </RollingRandomAccessFile>
+ </appenders>
+
+ <loggers>
+
+ <logger name="org.apache.archiva.redback.rest.services" level="error"/>
+ <logger name="JPOX" level="error"/>
+ <logger name="org.apache.archiva.rest.services" level="info"/>
+ <logger name="org.springframework" level="info"/>
+ <logger name="org.apache.commons.configuration" level="info"/>
+
+ <root level="info">
+ <appender-ref ref="console"/>
+ <appender-ref ref="rolling" />
+ </root>
+ </loggers>
+</configuration>
+
+
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/repository-servlet-simple.xml b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/repository-servlet-simple.xml
index ce9777fa8..10979d0f3 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/repository-servlet-simple.xml
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/repository-servlet-simple.xml
@@ -43,9 +43,6 @@
<![CDATA[
<configuration>
<system/>
- <xml fileName="${test.resources.path}/repository-archiva.xml" config-forceCreate="true"
- config-optional="true"
- config-name="org.apache.archiva.base" config-at="org.apache.archiva"/>
</configuration>
]]>
</value>
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/spring-context-servlet-security-test.xml b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/spring-context-servlet-security-test.xml
index 9f38b827d..ee6bcb7b8 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/spring-context-servlet-security-test.xml
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/spring-context-servlet-security-test.xml
@@ -59,9 +59,6 @@
<![CDATA[
<configuration>
<system/>
- <xml fileName="${test.resources.path}/repository-archiva.xml" config-forceCreate="true"
- config-optional="true"
- config-name="org.apache.archiva.base" config-at="org.apache.archiva"/>
</configuration>
]]>
</value>
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/spring-context.xml b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/spring-context.xml
index fba970705..b816f0ccb 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/spring-context.xml
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/spring-context.xml
@@ -58,9 +58,7 @@
<![CDATA[
<configuration>
<system/>
- <xml fileName="${test.resources.path}/repository-archiva.xml" config-forceCreate="true"
- config-optional="true"
- config-name="org.apache.archiva.base" config-at="org.apache.archiva"/>
+
</configuration>
]]>
</value>