From 21f5499a2945462cdebf7dbb972cbbea89fa0aa2 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 7 Mar 2007 23:08:09 +0000 Subject: [PATCH] [MRM-300] add test and update to latest modello to fix the saving of proxied repositories git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@515833 13f79535-47bb-0310-9956-ffa450edef68 --- archiva-configuration/pom.xml | 6 +-- .../DefaultArchivaConfiguration.java | 4 +- .../src/test/conf/with-proxied-repos.xml | 44 ++++++++++++++++++ .../ArchivaConfigurationTest.java | 31 +++++++++++++ .../ArchivaConfigurationTest.xml | 45 +++++++++++++++++++ 5 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 archiva-configuration/src/test/conf/with-proxied-repos.xml diff --git a/archiva-configuration/pom.xml b/archiva-configuration/pom.xml index 3a90d995e..4a502130b 100644 --- a/archiva-configuration/pom.xml +++ b/archiva-configuration/pom.xml @@ -48,12 +48,12 @@ org.codehaus.plexus.registry plexus-registry-api - 1.0-alpha-1 + 1.0-alpha-2-SNAPSHOT org.codehaus.plexus.registry plexus-registry-commons - 1.0-alpha-1 + 1.0-alpha-2-SNAPSHOT test @@ -74,7 +74,7 @@ org.codehaus.modello modello-maven-plugin - 1.0-alpha-14 + 1.0-alpha-15-SNAPSHOT diff --git a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java index adfd01d31..4a4f7fa50 100644 --- a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java @@ -27,6 +27,8 @@ import org.codehaus.plexus.registry.Registry; import org.codehaus.plexus.registry.RegistryException; import org.codehaus.plexus.registry.RegistryListener; +import java.util.Iterator; + /** * Implementation of configuration holder that retrieves it from the registry. * @@ -60,7 +62,7 @@ public class DefaultArchivaConfiguration configuration.setIndexPath( removeExpressions( configuration.getIndexPath() ) ); configuration.setMinimalIndexPath( removeExpressions( configuration.getMinimalIndexPath() ) ); configuration.setLocalRepository( removeExpressions( configuration.getLocalRepository() ) ); - for ( java.util.Iterator i = configuration.getRepositories().iterator(); i.hasNext(); ) + for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); ) { RepositoryConfiguration c = (RepositoryConfiguration) i.next(); c.setDirectory( removeExpressions( c.getDirectory() ) ); diff --git a/archiva-configuration/src/test/conf/with-proxied-repos.xml b/archiva-configuration/src/test/conf/with-proxied-repos.xml new file mode 100644 index 000000000..c8032436a --- /dev/null +++ b/archiva-configuration/src/test/conf/with-proxied-repos.xml @@ -0,0 +1,44 @@ + + + + + + + managed-repository + local + local + + + + + http://www.ibiblio.org/maven2/ + local + true + ibiblio + Ibiblio + + + http://repository.codehaus.org/ + local + codehaus + Codehaus + + + diff --git a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java b/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java index 5164c561d..5c17abd6d 100644 --- a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java +++ b/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java @@ -19,6 +19,7 @@ package org.apache.maven.archiva.configuration; * under the License. */ +import org.apache.commons.io.FileUtils; import org.codehaus.plexus.PlexusTestCase; import java.io.File; @@ -140,4 +141,34 @@ public class ArchivaConfigurationTest configuration = archivaConfiguration.getConfiguration(); assertEquals( "check value", "index-path", configuration.getIndexPath() ); } + + public void testRemoveProxiedRepositoryAndStoreConfiguration() + throws Exception + { + // MRM-300 + + File src = getTestFile( "src/test/conf/with-proxied-repos.xml" ); + File dest = getTestFile( "target/test/with-proxied-repos.xml" ); + FileUtils.copyFile( src, dest ); + + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-remove-proxied-repo" ); + + Configuration configuration = archivaConfiguration.getConfiguration(); + configuration.getProxiedRepositories().remove( 0 ); + + archivaConfiguration.save( configuration ); + + // check it + configuration = archivaConfiguration.getConfiguration(); + assertEquals( 1, configuration.getProxiedRepositories().size() ); + + release( archivaConfiguration ); + + // read it back + archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-back-remove-proxied-repo" ); + configuration = archivaConfiguration.getConfiguration(); + assertEquals( 1, configuration.getProxiedRepositories().size() ); + } } diff --git a/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml b/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml index 55daf43f2..44319293d 100644 --- a/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml +++ b/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml @@ -108,5 +108,50 @@ + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-remove-proxied-repo + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + read-remove-proxied-repo + + + + + org.codehaus.plexus.registry.Registry + read-remove-proxied-repo + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-read-back-remove-proxied-repo + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + read-back-remove-proxied-repo + + + + + org.codehaus.plexus.registry.Registry + read-back-remove-proxied-repo + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + -- 2.39.5