From c97525b3b60229b88aafeff0707d46280879ccf0 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 13 Jun 2011 14:22:15 +0000 Subject: [PATCH] fix archiva configuration duplicate remote repos during unit tests for RepositoryServletProxiedPluginSnapshotPolicyTest git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1135113 13f79535-47bb-0310-9956-ffa450edef68 --- ...AbstractRepositoryServletProxiedTestCase.java | 16 +++++++++++++++- .../AbstractRepositoryServletTestCase.java | 4 ++++ .../repository-servlet-security-test/web.xml | 4 ++++ .../src/test/resources/WEB-INF/web.xml | 4 ++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java index 5017f3dd1..98d7f10d9 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java @@ -138,7 +138,7 @@ public abstract class AbstractRepositoryServletProxiedTestCase int port = repo.server.getConnectors()[0].getLocalPort(); repo.url = "http://localhost:" + port + repo.context; - System.out.println( "Remote HTTP Server started on " + repo.url ); + log.info( "Remote HTTP Server started on " + repo.url ); repo.config = createRemoteRepository( repo.id, "Testable [" + repo.id + "] Remote Repo", repo.url ); @@ -206,6 +206,14 @@ public abstract class AbstractRepositoryServletProxiedTestCase remoteCentral = createServer( "central" ); assertServerSetupCorrectly( remoteCentral ); + + RemoteRepositoryConfiguration remoteRepositoryConfiguration = + archivaConfiguration.getConfiguration().getRemoteRepositoriesAsMap().get( remoteCentral.id ); + if ( remoteRepositoryConfiguration != null ) + { + archivaConfiguration.getConfiguration().removeRemoteRepository( remoteRepositoryConfiguration ); + } + archivaConfiguration.getConfiguration().addRemoteRepository( remoteCentral.config ); setupCleanRepo( remoteCentral.root ); } @@ -231,6 +239,12 @@ public abstract class AbstractRepositoryServletProxiedTestCase remoteSnapshots = createServer( "snapshots" ); assertServerSetupCorrectly( remoteSnapshots ); + RemoteRepositoryConfiguration remoteRepositoryConfiguration = + archivaConfiguration.getConfiguration().getRemoteRepositoriesAsMap().get( remoteSnapshots.id ); + if ( remoteRepositoryConfiguration != null ) + { + archivaConfiguration.getConfiguration().removeRemoteRepository( remoteRepositoryConfiguration ); + } archivaConfiguration.getConfiguration().addRemoteRepository( remoteSnapshots.config ); setupCleanRepo( remoteSnapshots.root ); } 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 e508e4aad..67c5e8fa4 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 @@ -34,6 +34,8 @@ import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; import org.junit.After; import org.junit.Before; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -70,6 +72,8 @@ public abstract class AbstractRepositoryServletTestCase @Inject protected ApplicationContext applicationContext; + protected Logger log = LoggerFactory.getLogger( getClass() ); + protected void saveConfiguration() throws Exception diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/WEB-INF/repository-servlet-security-test/web.xml b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/WEB-INF/repository-servlet-security-test/web.xml index f1defb60f..69ef84322 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/WEB-INF/repository-servlet-security-test/web.xml +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/WEB-INF/repository-servlet-security-test/web.xml @@ -27,6 +27,10 @@ org.springframework.web.context.ContextLoaderListener + + contextClass + org.codehaus.redback.components.springutils.CachingWebApplicationContext + contextConfigLocation diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/WEB-INF/web.xml b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/WEB-INF/web.xml index 1175e70c7..ad0d1d1a0 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/WEB-INF/web.xml +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/WEB-INF/web.xml @@ -27,6 +27,10 @@ org.springframework.web.context.ContextLoaderListener + + contextClass + org.codehaus.redback.components.springutils.CachingWebApplicationContext + contextConfigLocation