aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-configuration/src
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2007-03-07 23:08:09 +0000
committerBrett Porter <brett@apache.org>2007-03-07 23:08:09 +0000
commit21f5499a2945462cdebf7dbb972cbbea89fa0aa2 (patch)
tree76a148303ee3584330e7c80956b8c5916b7de59c /archiva-configuration/src
parent053b62e3c52e5e95abca533adba3fbd905b2f8e2 (diff)
downloadarchiva-21f5499a2945462cdebf7dbb972cbbea89fa0aa2.tar.gz
archiva-21f5499a2945462cdebf7dbb972cbbea89fa0aa2.zip
[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
Diffstat (limited to 'archiva-configuration/src')
-rw-r--r--archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java4
-rw-r--r--archiva-configuration/src/test/conf/with-proxied-repos.xml44
-rw-r--r--archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java31
-rw-r--r--archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml45
4 files changed, 123 insertions, 1 deletions
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 @@
+<?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.
+ -->
+
+<configuration>
+ <repositories>
+ <repository>
+ <directory>managed-repository</directory>
+ <id>local</id>
+ <name>local</name>
+ </repository>
+ </repositories>
+ <proxiedRepositories>
+ <proxiedRepository>
+ <url>http://www.ibiblio.org/maven2/</url>
+ <managedRepository>local</managedRepository>
+ <useNetworkProxy>true</useNetworkProxy>
+ <id>ibiblio</id>
+ <name>Ibiblio</name>
+ </proxiedRepository>
+ <proxiedRepository>
+ <url>http://repository.codehaus.org/</url>
+ <managedRepository>local</managedRepository>
+ <id>codehaus</id>
+ <name>Codehaus</name>
+ </proxiedRepository>
+ </proxiedRepositories>
+</configuration>
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 @@
</properties>
</configuration>
</component>
+
+ <component>
+ <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+ <role-hint>test-remove-proxied-repo</role-hint>
+ <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>read-remove-proxied-repo</role-hint>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>read-remove-proxied-repo</role-hint>
+ <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
+ <configuration>
+ <properties>
+ <xml fileName="${basedir}/target/test/with-proxied-repos.xml"
+ config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
+ </properties>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+ <role-hint>test-read-back-remove-proxied-repo</role-hint>
+ <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>read-back-remove-proxied-repo</role-hint>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>read-back-remove-proxied-repo</role-hint>
+ <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
+ <configuration>
+ <properties>
+ <xml fileName="${basedir}/target/test/with-proxied-repos.xml"
+ config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
+ </properties>
+ </configuration>
+ </component>
</components>
</component-set>