aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2018-10-25 22:04:55 +0200
committerMartin Stockhammer <martin_s@apache.org>2018-10-25 22:04:55 +0200
commitc069d160f92e67669150a376fec6661025b2d4b8 (patch)
treea89d12e2a07605eec6c32a681bf77df99e7be98f /archiva-modules/archiva-base
parente45634e2c9bedbf924cbd23a1e60b0ae9b8f3d56 (diff)
downloadarchiva-c069d160f92e67669150a376fec6661025b2d4b8.tar.gz
archiva-c069d160f92e67669150a376fec6661025b2d4b8.zip
Adding environment variable for user config file
Diffstat (limited to 'archiva-modules/archiva-base')
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java19
1 files changed, 18 insertions, 1 deletions
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 a8dddadc5..cd1635d6b 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
@@ -22,6 +22,7 @@ package org.apache.archiva.configuration;
import org.apache.archiva.redback.components.registry.RegistryException;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
@@ -326,10 +327,20 @@ public class ArchivaConfigurationTest
{
DefaultArchivaConfiguration archivaConfiguration =
(DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class, "default" );
+ String expectedFile = System.getProperty( "user.home" ) + "/.m2/archiva.xml";
+ String systemFile = System.getProperty(ArchivaConfiguration.USER_CONFIG_PROPERTY);
+ if (StringUtils.isNotEmpty( systemFile )) {
+ expectedFile = systemFile;
+ } else
+ {
+ String envFile = System.getenv( ArchivaConfiguration.USER_CONFIG_ENVVAR );
+ if ( StringUtils.isNotEmpty( envFile ) )
+ expectedFile = envFile;
+ }
archivaConfiguration.reload();
- assertEquals( System.getProperty( "user.home" ) + "/.m2/archiva.xml",
+ assertEquals( expectedFile,
archivaConfiguration.getUserConfigFilename() );
assertEquals( System.getProperty( "appserver.base", "${appserver.base}" ) + "/conf/archiva.xml",
archivaConfiguration.getAltConfigFilename() );
@@ -496,6 +507,8 @@ public class ArchivaConfigurationTest
public void testLoadConfigurationFromInvalidBothLocationsOnDisk()
throws Exception
{
+ String propFile = System.getProperty( ArchivaConfiguration.USER_CONFIG_PROPERTY );
+ System.setProperty( ArchivaConfiguration.USER_CONFIG_PROPERTY, "${basedir}/target/*intentionally:invalid*/.m2/archiva-user.xml" );
ArchivaConfiguration archivaConfiguration =
lookup( ArchivaConfiguration.class, "test-not-allowed-to-write-to-both" );
Configuration config = archivaConfiguration.getConfiguration();
@@ -509,6 +522,10 @@ public class ArchivaConfigurationTest
{
/* expected exception */
}
+ if (propFile!=null)
+ {
+ System.setProperty( ArchivaConfiguration.USER_CONFIG_PROPERTY, propFile );
+ }
}
@Test