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
This commit is contained in:
Olivier Lamy 2011-06-19 15:07:34 +00:00
parent 701a06014a
commit c3af85436f
2 changed files with 15 additions and 17 deletions

View File

@ -100,25 +100,24 @@ public abstract class AbstractRepositoryServletTestCase
} }
FileUtils.copyFile( testConf, testConfDest ); FileUtils.copyFile( testConf, testConfDest );
archivaConfiguration = applicationContext.getBean( ArchivaConfiguration.class ); archivaConfiguration = applicationContext.getBean( ArchivaConfiguration.class );
//archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class ); //archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
repoRootInternal = new File( appserverBase, "data/repositories/internal" ); repoRootInternal = new File( appserverBase, "data/repositories/internal" );
repoRootLegacy = new File( appserverBase, "data/repositories/legacy" ); repoRootLegacy = new File( appserverBase, "data/repositories/legacy" );
Configuration config = archivaConfiguration.getConfiguration(); Configuration config = archivaConfiguration.getConfiguration();
if ( !config.getManagedRepositoriesAsMap().containsKey( REPOID_INTERNAL ) ) config.getManagedRepositories().clear();
{
config.addManagedRepository( config.addManagedRepository(
createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) ); createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) );
}
if ( !config.getManagedRepositoriesAsMap().containsKey( REPOID_LEGACY ) )
{
config.addManagedRepository( config.addManagedRepository(
createManagedRepository( REPOID_LEGACY, "Legacy Format Test Repo", repoRootLegacy, "legacy", true ) ); createManagedRepository( REPOID_LEGACY, "Legacy Format Test Repo", repoRootLegacy, "legacy", true ) );
}
config.getProxyConnectors().clear();
config.getRemoteRepositories().clear();
saveConfiguration( archivaConfiguration ); saveConfiguration( archivaConfiguration );
@ -161,7 +160,6 @@ public abstract class AbstractRepositoryServletTestCase
} }
protected void assertFileContents( String expectedContents, File repoRoot, String path ) protected void assertFileContents( String expectedContents, File repoRoot, String path )
throws IOException throws IOException
{ {

View File

@ -86,19 +86,19 @@ public class RepositoryServletBrowseTest
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId" ); WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId" );
WebResponse response = sc.getResponse( request ); 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/" ); request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/" );
response = sc.getResponse( request ); 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" ); request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar" );
response = sc.getResponse( request ); 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/" ); request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar/" );
response = sc.getResponse( request ); response = sc.getResponse( request );
assertEquals( "Response", HttpServletResponse.SC_NOT_FOUND, response.getResponseCode() ); assertEquals( "4th Response", HttpServletResponse.SC_NOT_FOUND, response.getResponseCode() );
} }