diff options
3 files changed, 37 insertions, 63 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/pom.xml b/archiva-modules/archiva-web/archiva-webdav/pom.xml index b6ef0aca4..50901f454 100644 --- a/archiva-modules/archiva-web/archiva-webdav/pom.xml +++ b/archiva-modules/archiva-web/archiva-webdav/pom.xml @@ -157,7 +157,7 @@ <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> - <appserver.base>${project.build.outputDirectory}</appserver.base> + <appserver.base>${basedir}/target/appserver-base</appserver.base> </systemPropertyVariables> </configuration> </plugin> diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java index f6188e644..63e9b11bc 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java @@ -43,7 +43,7 @@ import java.io.File; import java.io.IOException; /** - * AbstractRepositoryServletTestCase + * AbstractRepositoryServletTestCase * * @version $Id$ */ @@ -80,7 +80,7 @@ public abstract class AbstractRepositoryServletTestCase assertTrue( "File <" + actualFile.getAbsolutePath() + "> should exist.", actualFile.exists() ); assertTrue( "File <" + actualFile.getAbsolutePath() + "> should be a file (not a dir/link/device/etc).", actualFile.isFile() ); - + String actualContents = FileUtils.readFileToString( actualFile, null ); assertEquals( "File Contents of <" + actualFile.getAbsolutePath() + ">", expectedContents, actualContents ); } @@ -90,9 +90,8 @@ public abstract class AbstractRepositoryServletTestCase ManagedRepositoryConfiguration repository = servlet.getRepository( repoId ); assertNotNull( "Archiva Managed Repository id:<" + repoId + "> should exist.", repository ); File repoRoot = new File( repository.getLocation() ); - assertTrue( "Archiva Managed Repository id:<" + repoId + "> should have a valid location on disk.", repoRoot - .exists() - && repoRoot.isDirectory() ); + assertTrue( "Archiva Managed Repository id:<" + repoId + "> should have a valid location on disk.", + repoRoot.exists() && repoRoot.isDirectory() ); } protected void assertResponseOK( WebResponse response ) @@ -108,21 +107,21 @@ public abstract class AbstractRepositoryServletTestCase Assert.assertEquals( "Should have been an OK response code for path: " + path, HttpServletResponse.SC_OK, response.getResponseCode() ); } - + protected void assertResponseNotFound( WebResponse response ) { assertNotNull( "Should have recieved a response", response ); - Assert.assertEquals( "Should have been an 404/Not Found response code.", HttpServletResponse.SC_NOT_FOUND, response - .getResponseCode() ); + Assert.assertEquals( "Should have been an 404/Not Found response code.", HttpServletResponse.SC_NOT_FOUND, + response.getResponseCode() ); } protected void assertResponseInternalServerError( WebResponse response ) { assertNotNull( "Should have recieved a response", response ); - Assert.assertEquals( "Should have been an 500/Internal Server Error response code.", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, response - .getResponseCode() ); + Assert.assertEquals( "Should have been an 500/Internal Server Error response code.", + HttpServletResponse.SC_INTERNAL_SERVER_ERROR, response.getResponseCode() ); } - + protected void assertResponseConflictError( WebResponse response ) { assertNotNull( "Should have received a response", response ); @@ -130,14 +129,15 @@ public abstract class AbstractRepositoryServletTestCase response.getResponseCode() ); } - protected ManagedRepositoryConfiguration createManagedRepository( String id, String name, File location, boolean blockRedeployments ) + protected ManagedRepositoryConfiguration createManagedRepository( String id, String name, File location, + boolean blockRedeployments ) { ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration(); repo.setId( id ); repo.setName( name ); repo.setLocation( location.getAbsolutePath() ); repo.setBlockRedeployments( blockRedeployments ); - + return repo; } @@ -175,6 +175,10 @@ public abstract class AbstractRepositoryServletTestCase File testConf = new File( "src/test/resources/repository-archiva.xml" ); File testConfDest = new File( appserverBase, "conf/archiva.xml" ); + if ( testConfDest.exists() ) + { + FileUtils.deleteQuietly( testConfDest ); + } FileUtils.copyFile( testConf, testConfDest ); //archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class ); @@ -182,15 +186,27 @@ public abstract class AbstractRepositoryServletTestCase repoRootLegacy = new File( appserverBase, "data/repositories/legacy" ); Configuration config = archivaConfiguration.getConfiguration(); - config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) ); - config.addManagedRepository( createManagedRepository( REPOID_LEGACY, "Legacy Format Test Repo", repoRootLegacy, "legacy", true ) ); - saveConfiguration( archivaConfiguration ); + if ( !config.getManagedRepositoriesAsMap().containsKey( REPOID_INTERNAL ) ) + { + config.addManagedRepository( + createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) ); + saveConfiguration( archivaConfiguration ); + } + if ( !config.getManagedRepositoriesAsMap().containsKey( REPOID_LEGACY ) ) + { + config.addManagedRepository( + createManagedRepository( REPOID_LEGACY, "Legacy Format Test Repo", repoRootLegacy, "legacy", true ) ); + saveConfiguration( archivaConfiguration ); + } + - CacheManager.getInstance().removeCache( "url-failures-cache" ); + //CacheManager.getInstance().removeCache( "url-failures-cache" ); + CacheManager.getInstance().clearAll(); - HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); + HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); sr = new ServletRunner( new File( "src/test/resources/WEB-INF/web.xml" ) ); + sr.registerServlet( "/repository/*", UnauthenticatedRepositoryServlet.class.getName() ); sc = sr.newClient(); } @@ -236,8 +252,8 @@ public abstract class AbstractRepositoryServletTestCase protected void assertManagedFileNotExists( File repoRootInternal, String resourcePath ) { File repoFile = new File( repoRootInternal, resourcePath ); - assertFalse( "Managed Repository File <" + repoFile.getAbsolutePath() + "> should not exist.", repoFile - .exists() ); + assertFalse( "Managed Repository File <" + repoFile.getAbsolutePath() + "> should not exist.", + repoFile.exists() ); } protected void setupCleanInternalRepo() diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/META-INF/plexus/components.xml b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/META-INF/plexus/components.xml deleted file mode 100644 index 74ecdc0b9..000000000 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/META-INF/plexus/components.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. - --> - -<component-set> - <components> - <!-- Components that are common for all test cases --> - <component> - <role>org.apache.maven.archiva.webdav.util.MimeTypes</role> - <implementation>org.apache.maven.archiva.webdav.util.MimeTypes</implementation> - <description>MimeTypes</description> - <configuration> - <resource>archiva-mime-types.txt</resource> - </configuration> - </component> - - <component> - <role>org.apache.archiva.metadata.repository.MetadataRepository</role> - <implementation>org.apache.archiva.metadata.repository.TestMetadataRepository</implementation> - </component> - <component> - <role>org.apache.archiva.metadata.repository.RepositorySessionFactory</role> - <implementation>org.apache.archiva.metadata.repository.TestRepositorySessionFactory</implementation> - </component> - </components> -</component-set>
\ No newline at end of file |