* Fixing test of propertyName values in ConfigurationNames class.

* Updating ProxyTestCase to use trigger with appropriate values.

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@541383 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joakim Erdfelt 2007-05-24 18:47:50 +00:00
parent d32992e00d
commit c8610ec35d
4 changed files with 53 additions and 92 deletions

View File

@ -19,9 +19,6 @@ package org.apache.maven.archiva.configuration;
* under the License.
*/
import java.util.HashSet;
import java.util.Set;
/**
* Utility methods for testing the configuration property name.
*
@ -30,107 +27,38 @@ import java.util.Set;
*/
public class ConfigurationNames
{
private static final Set networkProxies = new HashSet();
private static final Set repositoryScanning = new HashSet();
private static final Set repositories = new HashSet();
private static final Set proxyConnectors = new HashSet();
static
{
repositories.add( "repositories" );
repositories.add( "repository" );
repositories.add( "id" );
repositories.add( "name" );
repositories.add( "url" );
repositories.add( "layout" );
repositories.add( "releases" );
repositories.add( "snapshots" );
repositories.add( "indexed" );
repositories.add( "refreshCronExpression" );
networkProxies.add( "networkProxies" );
networkProxies.add( "networkProxy" );
networkProxies.add( "id" );
networkProxies.add( "protocol" );
networkProxies.add( "host" );
networkProxies.add( "port" );
networkProxies.add( "username" );
networkProxies.add( "password" );
repositoryScanning.add( "repositoryScanning" );
repositoryScanning.add( "fileTypes" );
repositoryScanning.add( "fileType" );
repositoryScanning.add( "patterns" );
repositoryScanning.add( "pattern" );
repositoryScanning.add( "goodConsumers" );
repositoryScanning.add( "goodConsumer" );
repositoryScanning.add( "badConsumers" );
repositoryScanning.add( "badConsumer" );
proxyConnectors.add( "proxyConnectors" );
proxyConnectors.add( "proxyConnector" );
proxyConnectors.add( "sourceRepoId" );
proxyConnectors.add( "targetRepoId" );
proxyConnectors.add( "proxyId" );
proxyConnectors.add( "snapshotsPolicy" );
proxyConnectors.add( "releasePolicy" );
proxyConnectors.add( "checksumPolicy" );
proxyConnectors.add( "whiteListPatterns" );
proxyConnectors.add( "whiteListPattern" );
proxyConnectors.add( "blackListPatterns" );
proxyConnectors.add( "blackListPattern" );
}
public static boolean isNetworkProxy( String propertyName )
{
if ( empty( propertyName ) )
{
return false;
}
return networkProxies.contains( propertyName );
return startsWith( "networkProxies.", propertyName );
}
public static boolean isRepositoryScanning( String propertyName )
{
if ( empty( propertyName ) )
{
return false;
}
return repositoryScanning.contains( propertyName );
return startsWith( "repositoryScanning.", propertyName );
}
public static boolean isRepositories( String propertyName )
{
if ( empty( propertyName ) )
{
return false;
}
return repositories.contains( propertyName );
return startsWith( "repositories.", propertyName );
}
public static boolean isProxyConnector( String propertyName )
{
if ( empty( propertyName ) )
{
return false;
}
return proxyConnectors.contains( propertyName );
return startsWith( "proxyConnectors.", propertyName );
}
private static boolean empty( String name )
private static boolean startsWith( String prefix, String name )
{
if ( name == null )
{
return false;
}
return ( name.trim().length() <= 0 );
if ( name.length() <= 0 )
{
return false;
}
return name.startsWith( prefix );
}
}

View File

@ -744,7 +744,7 @@ public class DefaultRepositoryProxyConnectors
public void initialize()
throws InitializationException
{
archivaConfiguration.addChangeListener( this );
initConnectorsAndNetworkProxies();
archivaConfiguration.addChangeListener( this );
}
}

View File

@ -59,11 +59,11 @@ public class AbstractProxyTestCase
protected static final String ID_LEGACY_PROXIED = "legacy-proxied";
protected static final String ID_PROXIED1 = "proxied1";
protected static final String ID_PROXIED1_TARGET = "proxied1-target";
protected static final String ID_PROXIED2 = "proxied2";
protected static final String ID_PROXIED2_TARGET = "proxied2-target";
protected static final String ID_DEFAULT_MANAGED = "default-managed-repository";
@ -73,11 +73,11 @@ public class AbstractProxyTestCase
protected static final String REPOPATH_PROXIED_LEGACY = "src/test/repositories/legacy-proxied";
protected static final String REPOPATH_PROXIED1 = "src/test/repositories/proxied1";
protected static final String REPOPATH_PROXIED1_TARGET = "target/test-repository/proxied1";
protected static final String REPOPATH_PROXIED2 = "src/test/repositories/proxied2";
protected static final String REPOPATH_PROXIED2_TARGET = "target/test-repository/proxied2";
protected static final String REPOPATH_DEFAULT_MANAGED = "src/test/repositories/managed";
@ -134,7 +134,7 @@ public class AbstractProxyTestCase
assertEquals( "MD5 File contents: " + md5File.getPath(), expectedMd5Contents, actualMd5Contents );
}
}
protected void assertFileEquals( File expectedFile, File actualFile, File sourceFile )
throws Exception
{
@ -343,8 +343,18 @@ public class AbstractProxyTestCase
connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, snapshotPolicy );
connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, cacheFailuresPolicy );
int count = config.getConfiguration().getProxyConnectors().size();
config.getConfiguration().addProxyConnector( connectorConfig );
config.triggerChange( "proxyConnector", "" );
// Proper Triggering ...
String prefix = "proxyConnectors.proxyConnector(" + count + ")";
config.triggerChange( prefix + ".sourceRepoId", connectorConfig.getSourceRepoId() );
config.triggerChange( prefix + ".targetRepoId", connectorConfig.getTargetRepoId() );
config.triggerChange( prefix + ".proxyId", connectorConfig.getProxyId() );
config.triggerChange( prefix + ".policies.releases", connectorConfig.getPolicy( "releases", "" ) );
config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) );
config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) );
config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
}
protected void saveRepositoryConfig( String id, String name, String path, String layout )
@ -368,14 +378,15 @@ public class AbstractProxyTestCase
config.triggerChange( "repository", "" );
}
protected File saveTargetedRepositoryConfig( String id, String originalPath, String targetPath, String layout ) throws IOException
protected File saveTargetedRepositoryConfig( String id, String originalPath, String targetPath, String layout )
throws IOException
{
File repoLocation = getTestFile( targetPath );
FileUtils.deleteDirectory( repoLocation );
copyDirectoryStructure( getTestFile( originalPath ), repoLocation );
saveRepositoryConfig( id, "Target Repo-" + id, targetPath, layout );
return repoLocation;
}

View File

@ -63,6 +63,28 @@
</requirement>
</requirements>
</component>
<component>
<role>org.codehaus.plexus.cache.Cache</role>
<role-hint>url-failures-cache</role-hint>
<implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation>
<description>URL Failure Cache</description>
<configuration>
<disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds>
<disk-persistent>false</disk-persistent> <!--disabling disk persistence for unit testing. -->
<disk-store-path>${java.io.tmpdir}/archiva/urlcache</disk-store-path>
<eternal>false</eternal>
<max-elements-in-memory>1000</max-elements-in-memory>
<memory-eviction-policy>LRU</memory-eviction-policy>
<name>cache</name>
<overflow-to-disk>false</overflow-to-disk>
<!-- 45 minutes = 2700 seconds -->
<time-to-idle-seconds>2700</time-to-idle-seconds>
<!-- 30 minutes = 1800 seconds -->
<time-to-live-seconds>1800</time-to-live-seconds>
</configuration>
</component>
<component>
<role>org.codehaus.plexus.logging.LoggerManager</role>
<implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation>