aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-09-28 09:06:32 +0000
committerOlivier Lamy <olamy@apache.org>2011-09-28 09:06:32 +0000
commit1e6934261ce6e7e559553e4bccd926b0fbab8706 (patch)
tree443ae5e15f0d62de12f40935e432fa383a4bbf17
parente3c75d50b375c4c41fc959d541ed0eca79ba8f71 (diff)
downloadarchiva-1e6934261ce6e7e559553e4bccd926b0fbab8706.tar.gz
archiva-1e6934261ce6e7e559553e4bccd926b0fbab8706.zip
[MRM-1393] Commons configuration bug causes build to fail on Windows 7
I have changed a unit which IMHO was wrong as didn't take care about managed repo coming from old configuration format: ArchivaConfigurationTest#testConfigurationUpgradeFrom09 git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1176791 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java25
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo13
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java61
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/pom.xml10
-rw-r--r--pom.xml2
5 files changed, 73 insertions, 38 deletions
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java
index 33f52d17a..a639782ee 100644
--- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java
+++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java
@@ -19,11 +19,6 @@ package org.apache.archiva.configuration;
* under the License.
*/
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-import org.apache.commons.configuration.BaseConfiguration;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
import org.apache.archiva.configuration.functors.ProxyConnectorConfigurationOrderComparator;
import org.apache.archiva.configuration.io.registry.ConfigurationRegistryReader;
import org.apache.archiva.configuration.io.registry.ConfigurationRegistryWriter;
@@ -33,6 +28,11 @@ import org.apache.archiva.policies.ChecksumPolicy;
import org.apache.archiva.policies.Policy;
import org.apache.archiva.policies.PostDownloadPolicy;
import org.apache.archiva.policies.PreDownloadPolicy;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
import org.codehaus.plexus.evaluator.DefaultExpressionEvaluator;
import org.codehaus.plexus.evaluator.EvaluatorException;
import org.codehaus.plexus.evaluator.ExpressionEvaluator;
@@ -197,16 +197,27 @@ public class DefaultArchivaConfiguration
V1RepositoryConfiguration r = i.next();
r.setScanned( r.isIndexed() );
- if ( r.getUrl().startsWith( "file://" ) )
+ if ( StringUtils.startsWith( r.getUrl(), "file://" ) )
{
r.setLocation( r.getUrl().substring( 7 ) );
config.addManagedRepository( r );
}
- else if ( r.getUrl().startsWith( "file:" ) )
+ else if ( StringUtils.startsWith( r.getUrl(), "file:" ) )
{
r.setLocation( r.getUrl().substring( 5 ) );
config.addManagedRepository( r );
}
+ else if ( StringUtils.isEmpty( r.getUrl() ) )
+ {
+ // in case of empty url we can consider it as a managed one
+ // check if location is null
+ //file://${appserver.base}/repositories/${id}
+ if ( StringUtils.isEmpty( r.getLocation() ) )
+ {
+ r.setLocation( "file://${appserver.base}/repositories/" + r.getId() );
+ }
+ config.addManagedRepository( r );
+ }
else
{
RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
index 9dd0dc679..763e5ee6f 100644
--- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
+++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
@@ -528,6 +528,19 @@
<defaultValue>300</defaultValue>
</field>
</fields>
+ <codeSegments>
+ <codeSegment>
+ <version>1.0.0+</version>
+ <code><![CDATA[
+ public String toString()
+ {
+ return "RemoteRepositoryConfiguration id:'" + getId() + "',name:'" + getName() +"'";
+ }
+
+
+ ]]></code>
+ </codeSegment>
+ </codeSegments>
</class>
<class>
<name>ManagedRepositoryConfiguration</name>
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
index 6866218da..7c027290d 100644
--- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
+++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
@@ -20,9 +20,9 @@ package org.apache.archiva.configuration;
*/
import junit.framework.TestCase;
+import org.apache.archiva.common.utils.FileUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.common.utils.FileUtil;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.redback.components.springutils.ComponentContainer;
import org.custommonkey.xmlunit.XMLAssert;
@@ -41,7 +41,7 @@ import java.util.Map;
* Test the configuration store.
*/
@RunWith( SpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath:/spring-context.xml"} )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
public class ArchivaConfigurationTest
extends TestCase
{
@@ -62,12 +62,12 @@ public class ArchivaConfigurationTest
return "org/apache/maven/archiva/configuration/spring-context.xml";
}
- protected <T> T lookup(Class<T> clazz, String hint)
+ protected <T> T lookup( Class<T> clazz, String hint )
{
return componentContainer.getComponent( clazz, hint );
}
- protected <T> T lookup(Class<T> clazz)
+ protected <T> T lookup( Class<T> clazz )
{
return componentContainer.getComponent( clazz );
}
@@ -132,14 +132,14 @@ public class ArchivaConfigurationTest
existingTestDefaultArchivaConfigFile =
StringUtils.replace( existingTestDefaultArchivaConfigFile, "${appserver.base}", FileUtil.getBasedir() );
- File generatedTestDefaultArchivaConfigFile =
- new File( FileUtil.getBasedir(), "target/test-classes/org/apache/archiva/configuration/default-archiva.xml" );
+ File generatedTestDefaultArchivaConfigFile = new File( FileUtil.getBasedir(),
+ "target/test-classes/org/apache/archiva/configuration/default-archiva.xml" );
FileUtils.writeStringToFile( generatedTestDefaultArchivaConfigFile, existingTestDefaultArchivaConfigFile,
null );
- ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class,
- "test-defaults-default-repo-location-exists" );
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-defaults-default-repo-location-exists" );
Configuration configuration = archivaConfiguration.getConfiguration();
assertConfiguration( configuration );
@@ -152,17 +152,26 @@ public class ArchivaConfigurationTest
assertFalse( generatedTestDefaultArchivaConfigFile.exists() );
}
+ private void assertConfiguration( Configuration configuration )
+ throws Exception
+ {
+ assertConfiguration( configuration, 2 );
+ }
+
/**
* Ensures that the provided configuration matches the details present in the archiva-default.xml file.
*/
- private void assertConfiguration( Configuration configuration )
+ private void assertConfiguration( Configuration configuration, int managedExpected )
throws Exception
{
- FileTypes filetypes = (FileTypes) lookup( FileTypes.class );
+ FileTypes filetypes = lookup( FileTypes.class );
- assertEquals( "check repositories", 2, configuration.getManagedRepositories().size() );
- assertEquals( "check repositories", 2, configuration.getRemoteRepositories().size() );
- assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() );
+ assertEquals( "check managed repositories: " + configuration.getManagedRepositories(), managedExpected,
+ configuration.getManagedRepositories().size() );
+ assertEquals( "check remote repositories: " + configuration.getRemoteRepositories(), 2,
+ configuration.getRemoteRepositories().size() );
+ assertEquals( "check proxy connectors:" + configuration.getProxyConnectors(), 2,
+ configuration.getProxyConnectors().size() );
RepositoryScanningConfiguration repoScanning = configuration.getRepositoryScanning();
assertNotNull( "check repository scanning", repoScanning );
@@ -277,8 +286,7 @@ public class ArchivaConfigurationTest
assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
// read it back
- archivaConfiguration =
- (DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-read-saved" );
+ archivaConfiguration = (DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-read-saved" );
archivaConfiguration.reload();
configuration = archivaConfiguration.getConfiguration();
@@ -413,7 +421,6 @@ public class ArchivaConfigurationTest
assertTrue( "Check file exists", baseFile.exists() );
assertFalse( "Check file not created", userFile.exists() );
-
// check it
configuration = archivaConfiguration.getConfiguration();
assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
@@ -582,16 +589,15 @@ public class ArchivaConfigurationTest
public void testConfigurationUpgradeFrom09()
throws Exception
{
- ArchivaConfiguration archivaConfiguration =
- (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-upgrade-09" );
+ ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-upgrade-09" );
// we just use the defaults when upgrading from 0.9 at this point.
Configuration configuration = archivaConfiguration.getConfiguration();
- assertConfiguration( configuration );
+ // test-upgrade-09 contains a managed with id: local so it's 3 managed
+ assertConfiguration( configuration, 3 );
assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() );
- ManagedRepositoryConfiguration repository =
- (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
+ ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get( 0 );
assertEquals( "check managed repositories", "${appserver.base}/data/repositories/internal",
repository.getLocation() );
@@ -614,8 +620,7 @@ public class ArchivaConfigurationTest
FileUtils.copyFile( getTestFile( "src/test/conf/autodetect-v1.xml" ), userFile );
// Load the original (unconverted) archiva.xml
- ArchivaConfiguration archivaConfiguration =
- (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-autodetect-v1" );
+ ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-autodetect-v1" );
archivaConfiguration.reload();
@@ -623,8 +628,7 @@ public class ArchivaConfigurationTest
assertConfiguration( configuration );
assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() );
- ManagedRepositoryConfiguration repository =
- (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
+ ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get( 0 );
assertEquals( "check managed repositories", "${appserver.base}/repositories/internal",
repository.getLocation() );
@@ -645,8 +649,7 @@ public class ArchivaConfigurationTest
//release( archivaConfiguration );
// Reload.
- archivaConfiguration =
- (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-autodetect-v1" );
+ archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-autodetect-v1" );
configuration = archivaConfiguration.getConfiguration();
// Test that only 1 set of repositories exist.
@@ -714,8 +717,7 @@ public class ArchivaConfigurationTest
userFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( userFile, "<configuration/>", null );
- final ArchivaConfiguration archivaConfiguration =
- lookup( ArchivaConfiguration.class, "test-cron-expressions" );
+ final ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-cron-expressions" );
archivaConfiguration.reload();
@@ -726,7 +728,6 @@ public class ArchivaConfigurationTest
assertEquals( "check cron expression", "0 0,30 * * * ?", repository.getRefreshCronExpression().trim() );
-
// add a test listener to confirm it doesn't see the escaped format. We don't need to test the number of calls,
// etc. as it's done in other tests
archivaConfiguration.addListener( new ConfigurationListener()
diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml
index 838d8cd05..bd0cd8aa9 100644
--- a/archiva-modules/archiva-web/archiva-webapp/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml
@@ -176,6 +176,16 @@
<artifactId>commons-compress</artifactId>
</dependency>
<dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<exclusions>
diff --git a/pom.xml b/pom.xml
index 11dea2034..15b1354fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -488,7 +488,7 @@
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
- <version>1.6</version>
+ <version>1.7</version>
<exclusions>
<exclusion>
<groupId>commons-beanutils</groupId>