From c3af85436f0c8188d9995dd9c953cb0921094dfa Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sun, 19 Jun 2011 15:07:34 +0000 Subject: [PATCH] ensure starting unit tests with clean configuration to prevent sporadic failure git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1137376 13f79535-47bb-0310-9956-ffa450edef68 --- .../AbstractRepositoryServletTestCase.java | 24 +++++++++---------- .../webdav/RepositoryServletBrowseTest.java | 8 +++---- 2 files changed, 15 insertions(+), 17 deletions(-) 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 b3318286f..2c42b67e2 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 @@ -100,25 +100,24 @@ public abstract class AbstractRepositoryServletTestCase } FileUtils.copyFile( testConf, testConfDest ); - archivaConfiguration = applicationContext.getBean( ArchivaConfiguration.class ); - //archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class ); repoRootInternal = new File( appserverBase, "data/repositories/internal" ); repoRootLegacy = new File( appserverBase, "data/repositories/legacy" ); Configuration config = archivaConfiguration.getConfiguration(); - if ( !config.getManagedRepositoriesAsMap().containsKey( REPOID_INTERNAL ) ) - { - config.addManagedRepository( - createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) ); - } - if ( !config.getManagedRepositoriesAsMap().containsKey( REPOID_LEGACY ) ) - { - config.addManagedRepository( - createManagedRepository( REPOID_LEGACY, "Legacy Format Test Repo", repoRootLegacy, "legacy", true ) ); - } + config.getManagedRepositories().clear(); + + config.addManagedRepository( + createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) ); + + config.addManagedRepository( + createManagedRepository( REPOID_LEGACY, "Legacy Format Test Repo", repoRootLegacy, "legacy", true ) ); + + config.getProxyConnectors().clear(); + + config.getRemoteRepositories().clear(); saveConfiguration( archivaConfiguration ); @@ -161,7 +160,6 @@ public abstract class AbstractRepositoryServletTestCase } - protected void assertFileContents( String expectedContents, File repoRoot, String path ) throws IOException { diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java index 9d2344d34..f8fb52504 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java @@ -86,19 +86,19 @@ public class RepositoryServletBrowseTest WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId" ); WebResponse response = sc.getResponse( request ); - assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() ); + assertEquals( "1st Response", HttpServletResponse.SC_OK, response.getResponseCode() ); request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/" ); response = sc.getResponse( request ); - assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() ); + assertEquals( "2nd Response", HttpServletResponse.SC_OK, response.getResponseCode() ); request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar" ); response = sc.getResponse( request ); - assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() ); + assertEquals( "3rd Response", HttpServletResponse.SC_OK, response.getResponseCode() ); request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar/" ); response = sc.getResponse( request ); - assertEquals( "Response", HttpServletResponse.SC_NOT_FOUND, response.getResponseCode() ); + assertEquals( "4th Response", HttpServletResponse.SC_NOT_FOUND, response.getResponseCode() ); }