]> source.dussan.org Git - archiva.git/commitdiff
* Fixing test of propertyName values in ConfigurationNames class.
authorJoakim Erdfelt <joakime@apache.org>
Thu, 24 May 2007 18:47:50 +0000 (18:47 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Thu, 24 May 2007 18:47:50 +0000 (18:47 +0000)
* 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

archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationNames.java
archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.xml

index 589a511f52b85cead57bb2e617c1b6f0737e5f36..880b1e6ce9e22ecdbc29219975eaf52537e34218 100644 (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 );
     }
 }
index dae8e55da52f6e2095518583b952e09be91f9785..c23f80233366fbb620986fcd951105916940b683 100644 (file)
@@ -744,7 +744,7 @@ public class DefaultRepositoryProxyConnectors
     public void initialize()
         throws InitializationException
     {
-        archivaConfiguration.addChangeListener( this );
         initConnectorsAndNetworkProxies();
+        archivaConfiguration.addChangeListener( this );
     }
 }
index 0886104248d075c7cc65da7b4a2e188da7ea6ee7..fba5b8c274147850b5fc816560001c5ca5475510 100644 (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;
     }
 
index 6daa370b841fab3f78ba90ff8ff1e96a1eec5488..61b78d1ed163a1f5c61057942f2dd1e16bcaed2e 100644 (file)
         </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>