archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1128404 [1/2] - in /archiva/trunk: ./ archiva-modules/archiva-base/archiva-proxy/ archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/ archiva-modules/archiva-base/archiva-proxy/src/main/resources/META-I...
Date Fri, 27 May 2011 17:26:27 GMT
Author: olamy
Date: Fri May 27 17:26:26 2011
New Revision: 1128404

URL: http://svn.apache.org/viewvc?rev=1128404&view=rev
Log:
[MRM-1473] remove plexus-spring use
replace plexus-quartz with spring-quartz


Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/pom.xml
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/WagonFactory.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/resources/META-INF/spring-context.xml
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/HttpProxyTransferTest.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedLegacyTransferTest.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MockConfiguration.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/WagonDelegate.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/WagonFactoryTest.java
    archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/resources/META-INF/spring-context.xml
    archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/ArchivaTaskScheduler.java
    archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml
    archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java
    archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java
    archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryTaskJob.java
    archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/resources/META-INF/spring-context.xml
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/pom.xml
    archiva/trunk/pom.xml

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/pom.xml?rev=1128404&r1=1128403&r2=1128404&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/pom.xml (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/pom.xml Fri May 27 17:26:26 2011
@@ -49,6 +49,22 @@
       <artifactId>commons-io</artifactId>
     </dependency>
     <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.sonatype.sisu</groupId>
+      <artifactId>sisu-inject-plexus</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.sonatype.sisu</groupId>
+      <artifactId>sisu-guice</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-plexus-bridge</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.maven.wagon</groupId>
       <artifactId>wagon-file</artifactId>
       <scope>test</scope>
@@ -95,22 +111,4 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <excludes>
-            <exclude>**/Abstract*</exclude>
-            <exclude>**/*TestCase.java</exclude>
-            <exclude>**/*Tests.java</exclude>
-            <exclude>**/*TestSuite.java</exclude>
-            <exclude>**/RelocateTransfer*</exclude>
-          </excludes>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
 </project>

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java?rev=1128404&r1=1128403&r2=1128404&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java Fri May 27 17:26:26 2011
@@ -19,17 +19,6 @@ package org.apache.maven.archiva.proxy;
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-
 import org.apache.archiva.scheduler.ArchivaTaskScheduler;
 import org.apache.archiva.scheduler.repository.RepositoryTask;
 import org.apache.commons.collections.CollectionUtils;
@@ -65,43 +54,65 @@ import org.apache.maven.wagon.authentica
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
 import org.apache.maven.wagon.proxy.ProxyInfo;
 import org.apache.maven.wagon.repository.Repository;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 import org.codehaus.plexus.registry.Registry;
 import org.codehaus.plexus.registry.RegistryListener;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
 import org.codehaus.plexus.util.SelectorUtils;
+import org.codehaus.redback.components.springutils.ComponentContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
 
 /**
  * DefaultRepositoryProxyConnectors
- * 
+ *
  * @version $Id$
  * @todo exception handling needs work - "not modified" is not really an exceptional case, and it has more layers than
- *       your average brown onion
- * @plexus.component role-hint="default"
+ * your average brown onion
+ * plexus.component role-hint="default"
  */
+@Service( "repositoryProxyConnectors#default" )
 public class DefaultRepositoryProxyConnectors
-    implements RepositoryProxyConnectors, RegistryListener, Initializable
+    implements RepositoryProxyConnectors, RegistryListener
 {
     private Logger log = LoggerFactory.getLogger( DefaultRepositoryProxyConnectors.class );
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
+    @Named( value = "archivaConfiguration#default" )
     private ArchivaConfiguration archivaConfiguration;
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private RepositoryContentFactory repositoryFactory;
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private MetadataTools metadataTools;
 
+    @Inject
+    private ComponentContainer componentContainer;
+
     /**
      * @plexus.requirement role="org.apache.maven.archiva.policies.PreDownloadPolicy"
      */
@@ -118,8 +129,9 @@ public class DefaultRepositoryProxyConne
     private Map<String, DownloadErrorPolicy> downloadErrorPolicies;
 
     /**
-     * @plexus.requirement role-hint="default"
+     * plexus.requirement role-hint="default"
      */
+    @Inject
     private UrlFailureCache urlFailureCache;
 
     private Map<String, List<ProxyConnector>> proxyConnectorMap = new HashMap<String, List<ProxyConnector>>();
@@ -127,15 +139,125 @@ public class DefaultRepositoryProxyConne
     private Map<String, ProxyInfo> networkProxyMap = new HashMap<String, ProxyInfo>();
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private WagonFactory wagonFactory;
-    
+
     /**
-     * @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository"
+     * plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository"
      */
+    @Inject
+    @Named( value = "archivaTaskScheduler#repository" )
     private ArchivaTaskScheduler scheduler;
 
+    @PostConstruct
+    public void initialize()
+    {
+        initConnectorsAndNetworkProxies();
+        archivaConfiguration.addChangeListener( this );
+        this.postDownloadPolicies = componentContainer.buildMapWithRole( PostDownloadPolicy.class );
+        this.preDownloadPolicies = componentContainer.buildMapWithRole( PreDownloadPolicy.class );
+        this.downloadErrorPolicies = componentContainer.buildMapWithRole( DownloadErrorPolicy.class );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    private void initConnectorsAndNetworkProxies()
+    {
+        synchronized ( this.proxyConnectorMap )
+        {
+            ProxyConnectorOrderComparator proxyOrderSorter = new ProxyConnectorOrderComparator();
+            this.proxyConnectorMap.clear();
+
+            List<ProxyConnectorConfiguration> proxyConfigs =
+                archivaConfiguration.getConfiguration().getProxyConnectors();
+            for ( ProxyConnectorConfiguration proxyConfig : proxyConfigs )
+            {
+                String key = proxyConfig.getSourceRepoId();
+
+                try
+                {
+                    // Create connector object.
+                    ProxyConnector connector = new ProxyConnector();
+
+                    connector.setSourceRepository(
+                        repositoryFactory.getManagedRepositoryContent( proxyConfig.getSourceRepoId() ) );
+                    connector.setTargetRepository(
+                        repositoryFactory.getRemoteRepositoryContent( proxyConfig.getTargetRepoId() ) );
+
+                    connector.setProxyId( proxyConfig.getProxyId() );
+                    connector.setPolicies( proxyConfig.getPolicies() );
+                    connector.setOrder( proxyConfig.getOrder() );
+                    connector.setDisabled( proxyConfig.isDisabled() );
+
+                    // Copy any blacklist patterns.
+                    List<String> blacklist = new ArrayList<String>();
+                    if ( CollectionUtils.isNotEmpty( proxyConfig.getBlackListPatterns() ) )
+                    {
+                        blacklist.addAll( proxyConfig.getBlackListPatterns() );
+                    }
+                    connector.setBlacklist( blacklist );
+
+                    // Copy any whitelist patterns.
+                    List<String> whitelist = new ArrayList<String>();
+                    if ( CollectionUtils.isNotEmpty( proxyConfig.getWhiteListPatterns() ) )
+                    {
+                        whitelist.addAll( proxyConfig.getWhiteListPatterns() );
+                    }
+                    connector.setWhitelist( whitelist );
+
+                    // Get other connectors
+                    List<ProxyConnector> connectors = this.proxyConnectorMap.get( key );
+                    if ( connectors == null )
+                    {
+                        // Create if we are the first.
+                        connectors = new ArrayList<ProxyConnector>();
+                    }
+
+                    // Add the connector.
+                    connectors.add( connector );
+
+                    // Ensure the list is sorted.
+                    Collections.sort( connectors, proxyOrderSorter );
+
+                    // Set the key to the list of connectors.
+                    this.proxyConnectorMap.put( key, connectors );
+                }
+                catch ( RepositoryNotFoundException e )
+                {
+                    log.warn( "Unable to use proxy connector: " + e.getMessage(), e );
+                }
+                catch ( RepositoryException e )
+                {
+                    log.warn( "Unable to use proxy connector: " + e.getMessage(), e );
+                }
+            }
+
+        }
+
+        synchronized ( this.networkProxyMap )
+        {
+            this.networkProxyMap.clear();
+
+            List<NetworkProxyConfiguration> networkProxies =
+                archivaConfiguration.getConfiguration().getNetworkProxies();
+            for ( NetworkProxyConfiguration networkProxyConfig : networkProxies )
+            {
+                String key = networkProxyConfig.getId();
+
+                ProxyInfo proxy = new ProxyInfo();
+
+                proxy.setType( networkProxyConfig.getProtocol() );
+                proxy.setHost( networkProxyConfig.getHost() );
+                proxy.setPort( networkProxyConfig.getPort() );
+                proxy.setUserName( networkProxyConfig.getUsername() );
+                proxy.setPassword( networkProxyConfig.getPassword() );
+
+                this.networkProxyMap.put( key, proxy );
+            }
+        }
+    }
+
     public File fetchFromProxies( ManagedRepositoryContent repository, ArtifactReference artifact )
         throws ProxyDownloadException
     {
@@ -175,12 +297,12 @@ public class DefaultRepositoryProxyConne
             catch ( NotFoundException e )
             {
                 log.debug( "Artifact " + Keys.toKey( artifact ) + " not found on repository \""
-                    + targetRepository.getRepository().getId() + "\"." );
+                               + targetRepository.getRepository().getId() + "\"." );
             }
             catch ( NotModifiedException e )
             {
                 log.debug( "Artifact " + Keys.toKey( artifact ) + " not updated on repository \""
-                    + targetRepository.getRepository().getId() + "\"." );
+                               + targetRepository.getRepository().getId() + "\"." );
             }
             catch ( ProxyException e )
             {
@@ -241,18 +363,20 @@ public class DefaultRepositoryProxyConne
             }
             catch ( NotFoundException e )
             {
-                log.debug( "Resource " + path + " not found on repository \""
-                    + targetRepository.getRepository().getId() + "\"." );
+                log.debug( "Resource " + path + " not found on repository \"" + targetRepository.getRepository().getId()
+                               + "\"." );
             }
             catch ( NotModifiedException e )
             {
-                log.debug( "Resource " + path + " not updated on repository \""
-                    + targetRepository.getRepository().getId() + "\"." );
+                log.debug(
+                    "Resource " + path + " not updated on repository \"" + targetRepository.getRepository().getId()
+                        + "\"." );
             }
             catch ( ProxyException e )
             {
-                log.warn( "Transfer error from repository \"" + targetRepository.getRepository().getId()
-                    + "\" for resource " + path + ", continuing to next repository. Error message: " + e.getMessage() );
+                log.warn(
+                    "Transfer error from repository \"" + targetRepository.getRepository().getId() + "\" for resource "
+                        + path + ", continuing to next repository. Error message: " + e.getMessage() );
                 log.debug( "Full stack trace", e );
             }
         }
@@ -297,18 +421,18 @@ public class DefaultRepositoryProxyConne
             catch ( NotFoundException e )
             {
                 log.debug( "Metadata " + logicalPath + " not found on remote repository \""
-                    + targetRepository.getRepository().getId() + "\".", e );
+                               + targetRepository.getRepository().getId() + "\".", e );
             }
             catch ( NotModifiedException e )
             {
                 log.debug( "Metadata " + logicalPath + " not updated on remote repository \""
-                    + targetRepository.getRepository().getId() + "\".", e );
+                               + targetRepository.getRepository().getId() + "\".", e );
             }
             catch ( ProxyException e )
             {
                 log.warn( "Transfer error from repository \"" + targetRepository.getRepository().getId()
-                    + "\" for versioned Metadata " + logicalPath + ", continuing to next repository. Error message: "
-                    + e.getMessage() );
+                              + "\" for versioned Metadata " + logicalPath
+                              + ", continuing to next repository. Error message: " + e.getMessage() );
                 log.debug( "Full stack trace", e );
             }
         }
@@ -384,7 +508,7 @@ public class DefaultRepositoryProxyConne
 
     /**
      * Simple method to test if the file exists on the local disk.
-     * 
+     *
      * @param file the file to test. (may be null)
      * @return true if file exists. false if the file param is null, doesn't exist, or is not of type File.
      */
@@ -410,19 +534,19 @@ public class DefaultRepositoryProxyConne
 
     /**
      * Perform the transfer of the file.
-     * 
-     * @param connector the connector configuration to use.
-     * @param remoteRepository the remote repository get the resource from.
-     * @param remotePath the path in the remote repository to the resource to get.
-     * @param repository the managed repository that will hold the file
-     * @param resource the local file to place the downloaded resource into
+     *
+     * @param connector         the connector configuration to use.
+     * @param remoteRepository  the remote repository get the resource from.
+     * @param remotePath        the path in the remote repository to the resource to get.
+     * @param repository        the managed repository that will hold the file
+     * @param resource          the local file to place the downloaded resource into
      * @param requestProperties the request properties to utilize for policy handling.
-     * @param executeConsumers whether to execute the consumers after proxying
+     * @param executeConsumers  whether to execute the consumers after proxying
      * @return the local file that was downloaded, or null if not downloaded.
-     * @throws NotFoundException if the file was not found on the remote repository.
+     * @throws NotFoundException    if the file was not found on the remote repository.
      * @throws NotModifiedException if the localFile was present, and the resource was present on remote repository, but
-     *             the remote resource is not newer than the local File.
-     * @throws ProxyException if transfer was unsuccessful.
+     *                              the remote resource is not newer than the local File.
+     * @throws ProxyException       if transfer was unsuccessful.
      */
     private File transferFile( ProxyConnector connector, RemoteRepositoryContent remoteRepository, String remotePath,
                                ManagedRepositoryContent repository, File resource, Properties requestProperties,
@@ -443,9 +567,8 @@ public class DefaultRepositoryProxyConne
             // Path must belong to whitelist.
             if ( !matchesPattern( remotePath, connector.getWhitelist() ) )
             {
-                log.debug( "Path [" + remotePath
-                    + "] is not part of defined whitelist (skipping transfer from repository ["
-                    + remoteRepository.getRepository().getName() + "])." );
+                log.debug( "Path [{}] is not part of defined whitelist (skipping transfer from repository [{}]).",
+                           remotePath, remoteRepository.getRepository().getName() );
                 return null;
             }
         }
@@ -453,8 +576,8 @@ public class DefaultRepositoryProxyConne
         // Is target path part of blacklist?
         if ( matchesPattern( remotePath, connector.getBlacklist() ) )
         {
-            log.debug( "Path [" + remotePath + "] is part of blacklist (skipping transfer from repository ["
-                + remoteRepository.getRepository().getName() + "])." );
+            log.debug( "Path [{}] is part of blacklist (skipping transfer from repository [{}]).", remotePath,
+                       remoteRepository.getRepository().getName() );
             return null;
         }
 
@@ -468,7 +591,7 @@ public class DefaultRepositoryProxyConne
             String emsg = "Transfer not attempted on " + url + " : " + e.getMessage();
             if ( fileExists( resource ) )
             {
-                log.debug( emsg + ": using already present local file." );
+                log.debug( "{} : using already present local file.", emsg );
                 return resource;
             }
 
@@ -488,7 +611,7 @@ public class DefaultRepositoryProxyConne
             {
                 RepositoryURL repoUrl = remoteRepository.getURL();
                 String protocol = repoUrl.getProtocol();
-                wagon = (Wagon) wagonFactory.getWagon( "wagon#" + protocol );
+                wagon = wagonFactory.getWagon( "wagon#" + protocol );
                 if ( wagon == null )
                 {
                     throw new ProxyException( "Unsupported target repository protocol: " + protocol );
@@ -526,6 +649,10 @@ public class DefaultRepositoryProxyConne
                 urlFailureCache.cacheFailure( url );
                 throw e;
             }
+            catch ( WagonFactoryException e )
+            {
+                throw new ProxyException( e.getMessage(), e );
+            }
             finally
             {
                 if ( wagon != null )
@@ -548,7 +675,7 @@ public class DefaultRepositoryProxyConne
             }
             catch ( PolicyViolationException e )
             {
-                log.warn( "Transfer invalidated from " + url + " : " + e.getMessage() );
+                log.warn( "Transfer invalidated from {} : {}", url, e.getMessage() );
                 executeConsumers = false;
                 if ( !fileExists( tmpResource ) )
                 {
@@ -596,16 +723,16 @@ public class DefaultRepositoryProxyConne
         }
         catch ( TaskQueueException e )
         {
-            log.error( "Unable to queue repository task to execute consumers on resource file ['" +
-                localFile.getName() + "']." );
+            log.error( "Unable to queue repository task to execute consumers on resource file ['" + localFile.getName()
+                           + "']." );
         }
     }
 
     /**
      * Moves the file into repository location if it exists
-     * 
+     *
      * @param fileToMove this could be either the main artifact, sha1 or md5 checksum file.
-     * @param directory directory to write files to
+     * @param directory  directory to write files to
      */
     private void moveFileIfExists( File fileToMove, File directory )
         throws ProxyException
@@ -621,14 +748,14 @@ public class DefaultRepositoryProxyConne
      * <p>
      * Quietly transfer the checksum file from the remote repository to the local file.
      * </p>
-     * 
-     * @param wagon the wagon instance (should already be connected) to use.
+     *
+     * @param wagon            the wagon instance (should already be connected) to use.
      * @param remoteRepository the remote repository to transfer from.
-     * @param remotePath the remote path to the resource to get.
-     * @param repository the managed repository that will hold the file
-     * @param resource the local file that should contain the downloaded contents
-     * @param tmpDirectory the temporary directory to download to
-     * @param ext the type of checksum to transfer (example: ".md5" or ".sha1")
+     * @param remotePath       the remote path to the resource to get.
+     * @param repository       the managed repository that will hold the file
+     * @param resource         the local file that should contain the downloaded contents
+     * @param tmpDirectory     the temporary directory to download to
+     * @param ext              the type of checksum to transfer (example: ".md5" or ".sha1")
      * @throws ProxyException if copying the downloaded file into place did not succeed.
      */
     private File transferChecksum( Wagon wagon, RemoteRepositoryContent remoteRepository, String remotePath,
@@ -653,12 +780,12 @@ public class DefaultRepositoryProxyConne
         catch ( NotFoundException e )
         {
             urlFailureCache.cacheFailure( url );
-            log.debug( "Transfer failed, checksum not found: " + url );
+            log.debug( "Transfer failed, checksum not found: {}", url );
             // Consume it, do not pass this on.
         }
         catch ( NotModifiedException e )
         {
-            log.debug( "Transfer skipped, checksum not modified: " + url );
+            log.debug( "Transfer skipped, checksum not modified: {}", url );
             // Consume it, do not pass this on.
         }
         catch ( ProxyException e )
@@ -673,12 +800,12 @@ public class DefaultRepositoryProxyConne
 
     /**
      * Perform the transfer of the remote file to the local file specified.
-     * 
-     * @param wagon the wagon instance to use.
+     *
+     * @param wagon            the wagon instance to use.
      * @param remoteRepository the remote repository to use
-     * @param remotePath the remote path to attempt to get
-     * @param repository the managed repository that will hold the file
-     * @param origFile the local file to save to
+     * @param remotePath       the remote path to attempt to get
+     * @param repository       the managed repository that will hold the file
+     * @param origFile         the local file to save to
      * @return The local file that was transfered.
      * @throws ProxyException if there was a problem moving the downloaded file into place.
      * @throws WagonException if there was a problem tranfering the file.
@@ -696,7 +823,7 @@ public class DefaultRepositoryProxyConne
 
             if ( !origFile.exists() )
             {
-                log.debug( "Retrieving " + remotePath + " from " + remoteRepository.getRepository().getName() );
+                log.debug( "Retrieving {} from {}", remotePath, remoteRepository.getRepository().getName() );
                 wagon.get( remotePath, destFile );
                 success = true;
 
@@ -705,13 +832,12 @@ public class DefaultRepositoryProxyConne
             }
             else
             {
-                log.debug( "Retrieving " + remotePath + " from " + remoteRepository.getRepository().getName()
-                    + " if updated" );
+                log.debug( "Retrieving {} from {} if updated", remotePath, remoteRepository.getRepository().getName() );
                 success = wagon.getIfNewer( remotePath, destFile, origFile.lastModified() );
                 if ( !success )
                 {
-                    throw new NotModifiedException( "Not downloaded, as local file is newer than remote side: "
-                        + origFile.getAbsolutePath() );
+                    throw new NotModifiedException(
+                        "Not downloaded, as local file is newer than remote side: " + origFile.getAbsolutePath() );
                 }
 
                 if ( destFile.exists() )
@@ -722,8 +848,9 @@ public class DefaultRepositoryProxyConne
         }
         catch ( ResourceDoesNotExistException e )
         {
-            throw new NotFoundException( "Resource [" + remoteRepository.getURL() + "/" + remotePath
-                + "] does not exist: " + e.getMessage(), e );
+            throw new NotFoundException(
+                "Resource [" + remoteRepository.getURL() + "/" + remotePath + "] does not exist: " + e.getMessage(),
+                e );
         }
         catch ( WagonException e )
         {
@@ -741,13 +868,13 @@ public class DefaultRepositoryProxyConne
 
     /**
      * Apply the policies.
-     * 
-     * @param policies the map of policies to execute. (Map of String policy keys, to {@link DownloadPolicy} objects)
-     * @param settings the map of settings for the policies to execute. (Map of String policy keys, to String policy
-     *            setting)
-     * @param request the request properties (utilized by the {@link DownloadPolicy#applyPolicy(String,Properties,File)}
-     *            )
-     * @param localFile the local file (utilized by the {@link DownloadPolicy#applyPolicy(String,Properties,File)})
+     *
+     * @param policies  the map of policies to execute. (Map of String policy keys, to {@link DownloadPolicy} objects)
+     * @param settings  the map of settings for the policies to execute. (Map of String policy keys, to String policy
+     *                  setting)
+     * @param request   the request properties (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, File)}
+     *                  )
+     * @param localFile the local file (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, File)})
      */
     private void validatePolicies( Map<String, ? extends DownloadPolicy> policies, Map<String, String> settings,
                                    Properties request, File localFile )
@@ -807,8 +934,8 @@ public class DefaultRepositoryProxyConne
             if ( !previousExceptions.containsKey( content.getId() ) )
             {
                 throw new ProxyDownloadException(
-                                                  "An error occurred in downloading from the remote repository, and the policy is to fail immediately",
-                                                  content.getId(), exception );
+                    "An error occurred in downloading from the remote repository, and the policy is to fail immediately",
+                    content.getId(), exception );
             }
         }
         else
@@ -818,13 +945,14 @@ public class DefaultRepositoryProxyConne
         }
 
         log.warn( "Transfer error from repository \"" + content.getRepository().getId() + "\" for artifact "
-            + Keys.toKey( artifact ) + ", continuing to next repository. Error message: " + exception.getMessage() );
+                      + Keys.toKey( artifact ) + ", continuing to next repository. Error message: "
+                      + exception.getMessage() );
         log.debug( "Full stack trace", exception );
     }
 
     /**
      * Creates a working directory in the repository root for this request
-     * 
+     *
      * @param repository
      * @return file location of working directory
      * @throws IOException
@@ -848,8 +976,8 @@ public class DefaultRepositoryProxyConne
     /**
      * Used to move the temporary file to its real destination. This is patterned from the way WagonManager handles its
      * downloaded files.
-     * 
-     * @param temp The completed download file
+     *
+     * @param temp   The completed download file
      * @param target The final location of the downloaded file
      * @throws ProxyException when the temp file cannot replace the target file
      */
@@ -875,12 +1003,12 @@ public class DefaultRepositoryProxyConne
                 if ( target.exists() )
                 {
                     log.debug( "Tried to copy file " + temp.getName() + " to " + target.getAbsolutePath()
-                        + " but file with this name already exists." );
+                                   + " but file with this name already exists." );
                 }
                 else
                 {
-                    throw new ProxyException( "Cannot copy tmp file " + temp.getAbsolutePath()
-                        + " to its final location", e );
+                    throw new ProxyException(
+                        "Cannot copy tmp file " + temp.getAbsolutePath() + " to its final location", e );
                 }
             }
             finally
@@ -892,13 +1020,14 @@ public class DefaultRepositoryProxyConne
 
     /**
      * Using wagon, connect to the remote repository.
-     * 
-     * @param connector the connector configuration to utilize (for obtaining network proxy configuration from)
-     * @param wagon the wagon instance to establish the connection on.
+     *
+     * @param connector        the connector configuration to utilize (for obtaining network proxy configuration from)
+     * @param wagon            the wagon instance to establish the connection on.
      * @param remoteRepository the remote repository to connect to.
      * @return true if the connection was successful. false if not connected.
      */
-    private boolean connectToRepository( ProxyConnector connector, Wagon wagon, RemoteRepositoryContent remoteRepository )
+    private boolean connectToRepository( ProxyConnector connector, Wagon wagon,
+                                         RemoteRepositoryContent remoteRepository )
     {
         boolean connected = false;
 
@@ -913,9 +1042,8 @@ public class DefaultRepositoryProxyConne
             if ( networkProxy != null )
             {
                 // TODO: move to proxyInfo.toString()
-                String msg =
-                    "Using network proxy " + networkProxy.getHost() + ":" + networkProxy.getPort()
-                        + " to connect to remote repository " + remoteRepository.getURL();
+                String msg = "Using network proxy " + networkProxy.getHost() + ":" + networkProxy.getPort()
+                    + " to connect to remote repository " + remoteRepository.getURL();
                 if ( networkProxy.getNonProxyHosts() != null )
                 {
                     msg += "; excluding hosts: " + networkProxy.getNonProxyHosts();
@@ -969,8 +1097,8 @@ public class DefaultRepositoryProxyConne
 
     /**
      * Tests whitelist and blacklist patterns against path.
-     * 
-     * @param path the path to test.
+     *
+     * @param path     the path to test.
      * @param patterns the list of patterns to check.
      * @return true if the path matches at least 1 pattern in the provided patterns list.
      */
@@ -985,14 +1113,14 @@ public class DefaultRepositoryProxyConne
         {
             path = "/" + path;
         }
-        
+
         for ( String pattern : patterns )
         {
             if ( !pattern.startsWith( "/" ) )
             {
                 pattern = "/" + pattern;
             }
-            
+
             if ( SelectorUtils.matchPath( pattern, path, false ) )
             {
                 return true;
@@ -1024,8 +1152,8 @@ public class DefaultRepositoryProxyConne
     {
         if ( ConfigurationNames.isNetworkProxy( propertyName )
             || ConfigurationNames.isManagedRepositories( propertyName )
-            || ConfigurationNames.isRemoteRepositories( propertyName )
-            || ConfigurationNames.isProxyConnector( propertyName ) )
+            || ConfigurationNames.isRemoteRepositories( propertyName ) || ConfigurationNames.isProxyConnector(
+            propertyName ) )
         {
             initConnectorsAndNetworkProxies();
         }
@@ -1036,105 +1164,4 @@ public class DefaultRepositoryProxyConne
         /* do nothing */
     }
 
-    @SuppressWarnings( "unchecked" )
-    private void initConnectorsAndNetworkProxies()
-    {
-        synchronized ( this.proxyConnectorMap )
-        {
-            ProxyConnectorOrderComparator proxyOrderSorter = new ProxyConnectorOrderComparator();
-            this.proxyConnectorMap.clear();
-
-            List<ProxyConnectorConfiguration> proxyConfigs =
-                archivaConfiguration.getConfiguration().getProxyConnectors();
-            for ( ProxyConnectorConfiguration proxyConfig : proxyConfigs )
-            {
-                String key = proxyConfig.getSourceRepoId();
-
-                try
-                {
-                    // Create connector object.
-                    ProxyConnector connector = new ProxyConnector();
-
-                    connector.setSourceRepository( repositoryFactory.getManagedRepositoryContent( proxyConfig.getSourceRepoId() ) );
-                    connector.setTargetRepository( repositoryFactory.getRemoteRepositoryContent( proxyConfig.getTargetRepoId() ) );
-
-                    connector.setProxyId( proxyConfig.getProxyId() );
-                    connector.setPolicies( proxyConfig.getPolicies() );
-                    connector.setOrder( proxyConfig.getOrder() );
-                    connector.setDisabled( proxyConfig.isDisabled() );
-
-                    // Copy any blacklist patterns.
-                    List<String> blacklist = new ArrayList<String>();
-                    if ( CollectionUtils.isNotEmpty( proxyConfig.getBlackListPatterns() ) )
-                    {
-                        blacklist.addAll( proxyConfig.getBlackListPatterns() );
-                    }
-                    connector.setBlacklist( blacklist );
-
-                    // Copy any whitelist patterns.
-                    List<String> whitelist = new ArrayList<String>();
-                    if ( CollectionUtils.isNotEmpty( proxyConfig.getWhiteListPatterns() ) )
-                    {
-                        whitelist.addAll( proxyConfig.getWhiteListPatterns() );
-                    }
-                    connector.setWhitelist( whitelist );
-
-                    // Get other connectors
-                    List<ProxyConnector> connectors = this.proxyConnectorMap.get( key );
-                    if ( connectors == null )
-                    {
-                        // Create if we are the first.
-                        connectors = new ArrayList<ProxyConnector>();
-                    }
-
-                    // Add the connector.
-                    connectors.add( connector );
-
-                    // Ensure the list is sorted.
-                    Collections.sort( connectors, proxyOrderSorter );
-
-                    // Set the key to the list of connectors.
-                    this.proxyConnectorMap.put( key, connectors );
-                }
-                catch ( RepositoryNotFoundException e )
-                {
-                    log.warn( "Unable to use proxy connector: " + e.getMessage(), e );
-                }
-                catch ( RepositoryException e )
-                {
-                    log.warn( "Unable to use proxy connector: " + e.getMessage(), e );
-                }
-            }
-
-        }
-
-        synchronized ( this.networkProxyMap )
-        {
-            this.networkProxyMap.clear();
-
-            List<NetworkProxyConfiguration> networkProxies =
-                archivaConfiguration.getConfiguration().getNetworkProxies();
-            for ( NetworkProxyConfiguration networkProxyConfig : networkProxies )
-            {
-                String key = networkProxyConfig.getId();
-
-                ProxyInfo proxy = new ProxyInfo();
-
-                proxy.setType( networkProxyConfig.getProtocol() );
-                proxy.setHost( networkProxyConfig.getHost() );
-                proxy.setPort( networkProxyConfig.getPort() );
-                proxy.setUserName( networkProxyConfig.getUsername() );
-                proxy.setPassword( networkProxyConfig.getPassword() );
-
-                this.networkProxyMap.put( key, proxy );
-            }
-        }
-    }
-
-    public void initialize()
-        throws InitializationException
-    {
-        initConnectorsAndNetworkProxies();
-        archivaConfiguration.addChangeListener( this );
-    }
 }

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/WagonFactory.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/WagonFactory.java?rev=1128404&r1=1128403&r2=1128404&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/WagonFactory.java (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/WagonFactory.java Fri May 27 17:26:26 2011
@@ -22,17 +22,17 @@ package org.apache.maven.archiva.proxy;
 import org.apache.maven.wagon.Wagon;
 
 /**
- * Create a Wagon instance for the given protocol. Implementation will be provided by a Spring service locator.
- * 
+ * Create a Wagon instance for the given protocol.
  */
 public interface WagonFactory
 {
     /**
      * Create a new Wagon instance for the given protocol.
-     * 
-     * @param   protocol the protocol to find the Wagon for, which must be prefixed with <code>wagon#</code>, for example 
-     *          <code>wagon#http</code>.
-     * @return  the Wagon instance
+     *
+     * @param protocol the protocol to find the Wagon for, which must be prefixed with <code>wagon#</code>, for example
+     *                 <code>wagon#http</code>.
+     * @return the Wagon instance
      */
-    Wagon getWagon( String protocol );
+    Wagon getWagon( String protocol )
+        throws WagonFactoryException;
 }

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/resources/META-INF/spring-context.xml?rev=1128404&r1=1128403&r2=1128404&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/resources/META-INF/spring-context.xml (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/main/resources/META-INF/spring-context.xml Fri May 27 17:26:26 2011
@@ -16,15 +16,19 @@
   ~ KIND, either express or implied.  See the License for the
   ~ specific language governing permissions and limitations
   ~ under the License.
--->
+  -->
+
 <beans xmlns="http://www.springframework.org/schema/beans"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://www.springframework.org/schema/beans
-           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+           http://www.springframework.org/schema/context
+           http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+       default-lazy-init="true">
+
+  <context:annotation-config/>
+  <context:component-scan base-package="org.apache.maven.archiva.proxy"/>
+
 
-  <bean id="wagonFactory"
-    class="org.springframework.beans.factory.config.ServiceLocatorFactoryBean">
-    <property name="serviceLocatorInterface"
-      value="org.apache.maven.archiva.proxy.WagonFactory" />
-  </bean>
 </beans>
\ No newline at end of file

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java?rev=1128404&r1=1128403&r2=1128404&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java Fri May 27 17:26:26 2011
@@ -1,24 +1,26 @@
 package org.apache.archiva.metadata.repository;
 
-/*
- * 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.
- */
+import org.springframework.stereotype.Service;
 
+/*
+* 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.
+*/
+@Service("repositorySessionFactory")
 public class TestRepositorySessionFactory
     implements RepositorySessionFactory
 {

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java?rev=1128404&r1=1128403&r2=1128404&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java Fri May 27 17:26:26 2011
@@ -19,6 +19,7 @@ package org.apache.maven.archiva.proxy;
  * under the License.
  */
 
+import junit.framework.TestCase;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
@@ -33,10 +34,16 @@ import org.apache.maven.archiva.policies
 import org.apache.maven.archiva.policies.SnapshotsPolicy;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.wagon.Wagon;
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.easymock.ArgumentsMatcher;
 import org.easymock.MockControl;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
+import javax.inject.Inject;
+import javax.inject.Named;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
@@ -53,9 +60,15 @@ import java.util.Locale;
  *
  * @version $Id$
  */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
 public abstract class AbstractProxyTestCase
-    extends PlexusInSpringTestCase
+    extends TestCase
 {
+
+    @Inject
+    protected ApplicationContext applicationContext;
+
     protected static final String ID_LEGACY_PROXIED = "legacy-proxied";
 
     protected static final String ID_PROXIED1 = "proxied1";
@@ -88,6 +101,90 @@ public abstract class AbstractProxyTestC
 
     protected static final String REPOPATH_LEGACY_MANAGED_TARGET = "target/test-repository/legacy-managed";
 
+    protected MockControl wagonMockControl;
+
+    protected Wagon wagonMock;
+
+
+    protected RepositoryProxyConnectors proxyHandler;
+
+    protected ManagedRepositoryContent managedDefaultRepository;
+
+    protected File managedDefaultDir;
+
+    protected ManagedRepositoryContent managedLegacyRepository;
+
+    protected File managedLegacyDir;
+
+    protected MockConfiguration config;
+
+    @Inject
+    @Named( value = "wagon#test" )
+    WagonDelegate delegate;
+
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        proxyHandler = applicationContext.getBean( RepositoryProxyConnectors.class );
+
+        config =
+            (MockConfiguration) applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class );
+
+        // Setup source repository (using default layout)
+        String repoPath = "target/test-repository/managed/" + getName();
+        File repoLocation = new File( repoPath );
+
+        managedDefaultRepository =
+            createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath, "default" );
+
+        managedDefaultDir = new File( managedDefaultRepository.getRepoRoot() );
+
+        ManagedRepositoryConfiguration repoConfig = managedDefaultRepository.getRepository();
+
+        config.getConfiguration().addManagedRepository( repoConfig );
+
+        // Setup source repository (using legacy layout)
+        repoLocation = new File( REPOPATH_LEGACY_MANAGED_TARGET );
+        FileUtils.deleteDirectory( repoLocation );
+        copyDirectoryStructure( new File( REPOPATH_LEGACY_MANAGED ), repoLocation );
+
+        managedLegacyRepository =
+            createRepository( ID_LEGACY_MANAGED, "Legacy Managed Repository", REPOPATH_LEGACY_MANAGED_TARGET,
+                              "legacy" );
+
+        managedLegacyDir = new File( managedLegacyRepository.getRepoRoot() );
+
+        repoConfig = managedLegacyRepository.getRepository();
+
+        config.getConfiguration().addManagedRepository( repoConfig );
+
+        // Setup target (proxied to) repository.
+        saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1",
+                                    new File( REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" );
+
+        // Setup target (proxied to) repository.
+        saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2",
+                                    new File( REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" );
+
+        // Setup target (proxied to) repository using legacy layout.
+        saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository",
+                                    new File( REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" );
+
+        // Setup the proxy handler.
+        //proxyHandler = applicationContext.getBean (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
+
+        // Setup the wagon mock.
+        wagonMockControl = MockControl.createNiceControl( Wagon.class );
+        wagonMock = (Wagon) wagonMockControl.getMock();
+
+        delegate.setDelegate( wagonMock );
+
+        System.out.println( "\n.\\ " + getName() + "() \\._________________________________________\n" );
+    }
+
     protected static final ArgumentsMatcher customWagonGetIfNewerMatcher = new ArgumentsMatcher()
     {
 
@@ -97,8 +194,8 @@ public abstract class AbstractProxyTestC
             {
                 return false;
             }
-            return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ), ArrayUtils.remove( actual,
-                                                                                                           1 ) );
+            return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ),
+                                                      ArrayUtils.remove( actual, 1 ) );
         }
 
         public String toString( Object[] arguments )
@@ -140,21 +237,6 @@ public abstract class AbstractProxyTestC
         }
     };
 
-    protected MockControl wagonMockControl;
-
-    protected Wagon wagonMock;
-
-    protected RepositoryProxyConnectors proxyHandler;
-
-    protected ManagedRepositoryContent managedDefaultRepository;
-
-    protected File managedDefaultDir;
-
-    protected ManagedRepositoryContent managedLegacyRepository;
-
-    protected File managedLegacyDir;
-
-    protected MockConfiguration config;
 
     protected void assertChecksums( File expectedFile, String expectedSha1Contents, String expectedMd5Contents )
         throws Exception
@@ -215,7 +297,7 @@ public abstract class AbstractProxyTestC
             return;
         }
 
-        Collection<File> tmpFiles = FileUtils.listFiles( workingDir, new String[]{"tmp"}, false );
+        Collection<File> tmpFiles = FileUtils.listFiles( workingDir, new String[]{ "tmp" }, false );
         if ( !tmpFiles.isEmpty() )
         {
             StringBuffer emsg = new StringBuffer();
@@ -309,8 +391,8 @@ public abstract class AbstractProxyTestC
         repo.setLocation( path );
         repo.setLayout( layout );
 
-        ManagedRepositoryContent repoContent = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class,
-                                                                                  layout );
+        ManagedRepositoryContent repoContent =
+            applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
         repoContent.setRepository( repo );
         return repoContent;
     }
@@ -392,10 +474,10 @@ public abstract class AbstractProxyTestC
         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", "" ) );
-        config.triggerChange( prefix + ".policies.propagate-errors", connectorConfig.getPolicy( "propagate-errors",
-                                                                                                "" ) );
-        config.triggerChange( prefix + ".policies.propagate-errors-on-update", connectorConfig.getPolicy(
-            "propagate-errors-on-update", "" ) );
+        config.triggerChange( prefix + ".policies.propagate-errors",
+                              connectorConfig.getPolicy( "propagate-errors", "" ) );
+        config.triggerChange( prefix + ".policies.propagate-errors-on-update",
+                              connectorConfig.getPolicy( "propagate-errors-on-update", "" ) );
     }
 
     protected void saveManagedRepositoryConfig( String id, String name, String path, String layout )
@@ -440,99 +522,21 @@ public abstract class AbstractProxyTestC
     protected File saveTargetedRepositoryConfig( String id, String originalPath, String targetPath, String layout )
         throws IOException
     {
-        File repoLocation = getTestFile( targetPath );
+        File repoLocation = new File( targetPath );
         FileUtils.deleteDirectory( repoLocation );
-        copyDirectoryStructure( getTestFile( originalPath ), repoLocation );
+        copyDirectoryStructure( new File( originalPath ), repoLocation );
 
         saveRemoteRepositoryConfig( id, "Target Repo-" + id, targetPath, layout );
 
         return repoLocation;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.codehaus.plexus.spring.PlexusInSpringTestCase#getConfigLocation()
-     */
-    @Override
-    protected String getSpringConfigLocation()
-    {
-        return "org/apache/maven/archiva/proxy/spring-context.xml";
-    }
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        config = (MockConfiguration) lookup( ArchivaConfiguration.class.getName(), "mock" );
-
-        // Setup source repository (using default layout)
-        String repoPath = "target/test-repository/managed/" + getName();
-        File repoLocation = getTestFile( repoPath );
-
-        managedDefaultRepository = createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath,
-                                                     "default" );
-
-        managedDefaultDir = new File( managedDefaultRepository.getRepoRoot() );
-
-        ManagedRepositoryConfiguration repoConfig = managedDefaultRepository.getRepository();
-
-        config.getConfiguration().addManagedRepository( repoConfig );
-
-        // Setup source repository (using legacy layout)
-        repoLocation = getTestFile( REPOPATH_LEGACY_MANAGED_TARGET );
-        FileUtils.deleteDirectory( repoLocation );
-        copyDirectoryStructure( getTestFile( REPOPATH_LEGACY_MANAGED ), repoLocation );
-
-        managedLegacyRepository = createRepository( ID_LEGACY_MANAGED, "Legacy Managed Repository",
-                                                    REPOPATH_LEGACY_MANAGED_TARGET, "legacy" );
-
-        managedLegacyDir = new File( managedLegacyRepository.getRepoRoot() );
-
-        repoConfig = managedLegacyRepository.getRepository();
-
-        config.getConfiguration().addManagedRepository( repoConfig );
-
-        // Setup target (proxied to) repository.
-        saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1", new File(
-            REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" );
-
-        // Setup target (proxied to) repository.
-        saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2", new File(
-            REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" );
-
-        // Setup target (proxied to) repository using legacy layout.
-        saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository", new File(
-            REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" );
-
-        // Setup the proxy handler.
-        try
-        {
-            proxyHandler = (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
-        }
-        catch ( Exception e )
-        {
-            // TODO: handle in plexus-spring instead
-            applicationContext.close();
-            throw e;
-        }
-
-        // Setup the wagon mock.
-        wagonMockControl = MockControl.createNiceControl( Wagon.class );
-        wagonMock = (Wagon) wagonMockControl.getMock();
-        WagonDelegate delegate = (WagonDelegate) lookup( Wagon.ROLE, "test" );
-        delegate.setDelegate( wagonMock );
-
-        System.out.println( "\n.\\ " + getName() + "() \\._________________________________________\n" );
-    }
 
     /**
      * Copy the specified resource directory from the src/test/repository/managed/ to
      * the testable directory under target/test-repository/managed/${testName}/
      *
-     * @param resourceDir
+     * @param resourcePath
      * @throws IOException
      */
     protected void setupTestableManagedRepository( String resourcePath )
@@ -610,9 +614,9 @@ public abstract class AbstractProxyTestC
         String managedLegacyPath = managedLegacyDir.getCanonicalPath();
         String testFile = file.getCanonicalPath();
 
-        assertTrue( "Unit Test Failure: File <" + testFile +
-                        "> should be have been defined within the legacy managed path of <" + managedLegacyPath + ">",
-                    testFile.startsWith( managedLegacyPath ) );
+        assertTrue(
+            "Unit Test Failure: File <" + testFile + "> should be have been defined within the legacy managed path of <"
+                + managedLegacyPath + ">", testFile.startsWith( managedLegacyPath ) );
 
         assertFalse( "File < " + testFile + "> should not exist in managed legacy repository.", file.exists() );
     }
@@ -623,9 +627,9 @@ public abstract class AbstractProxyTestC
         String managedDefaultPath = managedDefaultDir.getCanonicalPath();
         String testFile = file.getCanonicalPath();
 
-        assertTrue( "Unit Test Failure: File <" + testFile +
-                        "> should be have been defined within the managed default path of <" + managedDefaultPath + ">",
-                    testFile.startsWith( managedDefaultPath ) );
+        assertTrue( "Unit Test Failure: File <" + testFile
+                        + "> should be have been defined within the managed default path of <" + managedDefaultPath
+                        + ">", testFile.startsWith( managedDefaultPath ) );
 
         assertFalse( "File < " + testFile + "> should not exist in managed default repository.", file.exists() );
     }

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java?rev=1128404&r1=1128403&r2=1128404&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java Fri May 27 17:26:26 2011
@@ -27,7 +27,9 @@ import org.apache.maven.archiva.policies
 import org.apache.maven.archiva.policies.SnapshotsPolicy;
 import org.apache.maven.archiva.policies.urlcache.UrlFailureCache;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.junit.Test;
 
+import javax.inject.Inject;
 import java.io.File;
 
 /**
@@ -41,6 +43,7 @@ public class CacheFailuresTransferTest
     // TODO: test some hard failures (eg TransferFailedException)
     // TODO: test the various combinations of fetchFrom* (note: need only test when caching is enabled)
 
+    @Test
     public void testGetWithCacheFailuresOn()
         throws Exception
     {
@@ -64,7 +67,7 @@ public class CacheFailuresTransferTest
 
         wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) );
 
-        wagonMockControl.setMatcher(customWagonGetMatcher);
+        wagonMockControl.setMatcher( customWagonGetMatcher );
 
         wagonMockControl.setThrowable( new ResourceDoesNotExistException( "resource does not exist." ), 2 );
 
@@ -84,6 +87,7 @@ public class CacheFailuresTransferTest
         assertNoTempFiles( expectedFile );
     }
 
+    @Test
     public void testGetWithCacheFailuresOff()
         throws Exception
     {
@@ -101,13 +105,13 @@ public class CacheFailuresTransferTest
 
         // Configure Connector (usually done within archiva.xml configuration)
         saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
-                       SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false  );
+                       SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
         saveConnector( ID_DEFAULT_MANAGED, "badproxied2", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
-                       SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false  );
+                       SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
 
         wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) );
 
-        wagonMockControl.setMatcher(customWagonGetMatcher);
+        wagonMockControl.setMatcher( customWagonGetMatcher );
         wagonMockControl.setThrowable( new ResourceDoesNotExistException( "resource does not exist." ), 2 );
 
         wagonMockControl.replay();
@@ -120,7 +124,7 @@ public class CacheFailuresTransferTest
         wagonMockControl.reset();
         wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) );
 
-        wagonMockControl.setMatcher(customWagonGetMatcher);
+        wagonMockControl.setMatcher( customWagonGetMatcher );
         wagonMockControl.setThrowable( new ResourceDoesNotExistException( "resource does not exist." ), 2 );
         wagonMockControl.replay();
 
@@ -132,6 +136,7 @@ public class CacheFailuresTransferTest
         assertNoTempFiles( expectedFile );
     }
 
+    @Test
     public void testGetWhenInBothProxiedButFirstCacheFailure()
         throws Exception
     {
@@ -163,10 +168,13 @@ public class CacheFailuresTransferTest
         assertNoTempFiles( expectedFile );
     }
 
+    @Inject
+    UrlFailureCache urlFailureCache;
+
     protected UrlFailureCache lookupUrlFailureCache()
         throws Exception
     {
-        UrlFailureCache urlFailureCache = (UrlFailureCache) lookup( "urlFailureCache" );
+        //UrlFailureCache urlFailureCache = (UrlFailureCache) lookup( "urlFailureCache" );
         assertNotNull( "URL Failure Cache cannot be null.", urlFailureCache );
         return urlFailureCache;
     }

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java?rev=1128404&r1=1128403&r2=1128404&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java Fri May 27 17:26:26 2011
@@ -26,6 +26,7 @@ import org.apache.maven.archiva.policies
 import org.apache.maven.archiva.policies.ReleasesPolicy;
 import org.apache.maven.archiva.policies.SnapshotsPolicy;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.junit.Test;
 
 import java.io.File;
 
@@ -37,6 +38,7 @@ import java.io.File;
 public class ChecksumTransferTest
     extends AbstractProxyTestCase
 {
+    @Test
     public void testGetChecksumWhenConnectorIsDisabled()
         throws Exception
     {
@@ -57,7 +59,8 @@ public class ChecksumTransferTest
         
         assertNull(downloadedFile);
     }
-    
+
+    @Test
     public void testGetChecksumBothCorrect()
         throws Exception
     {
@@ -83,6 +86,7 @@ public class ChecksumTransferTest
                          "e58f30c6a150a2e843552438d18e15cb *get-checksum-both-right-1.0.jar" );
     }
 
+    @Test
     public void testGetChecksumCorrectSha1NoMd5()
         throws Exception
     {
@@ -108,6 +112,7 @@ public class ChecksumTransferTest
                          null );
     }
 
+    @Test
     public void testGetChecksumNoSha1CorrectMd5()
         throws Exception
     {
@@ -132,6 +137,7 @@ public class ChecksumTransferTest
         assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
     }
 
+    @Test
     public void testGetWithNoChecksumsUsingIgnoredSetting()
         throws Exception
     {
@@ -156,6 +162,7 @@ public class ChecksumTransferTest
         assertChecksums( expectedFile, null, null );
     }
 
+    @Test
     public void testGetChecksumBadSha1BadMd5IgnoredSetting()
         throws Exception
     {
@@ -180,6 +187,7 @@ public class ChecksumTransferTest
         assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
     }
 
+    @Test
     public void testGetChecksumBadSha1BadMd5FailSetting()
         throws Exception
     {
@@ -202,6 +210,7 @@ public class ChecksumTransferTest
         assertChecksums( expectedFile, null, null );
     }
 
+    @Test
     public void testGetChecksumBadSha1BadMd5FixSetting()
         throws Exception
     {
@@ -227,6 +236,7 @@ public class ChecksumTransferTest
                          "a292491a35925465e693a44809a078b5  get-checksum-both-bad-1.0.jar" );
     }
 
+    @Test
     public void testGetChecksumCorrectSha1BadMd5UsingFailSetting()
         throws Exception
     {
@@ -249,6 +259,7 @@ public class ChecksumTransferTest
         assertChecksums( expectedFile, null, null );
     }
 
+    @Test
     public void testGetChecksumNoSha1CorrectMd5UsingFailSetting()
         throws Exception
     {
@@ -274,6 +285,7 @@ public class ChecksumTransferTest
         assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
     }
 
+    @Test
     public void testGetWithNoChecksumsUsingFailSetting()
         throws Exception
     {
@@ -296,6 +308,7 @@ public class ChecksumTransferTest
         assertChecksums( expectedFile, null, null );
     }
 
+    @Test
     public void testGetChecksumCorrectSha1BadMd5UsingIgnoredSetting()
         throws Exception
     {
@@ -321,6 +334,7 @@ public class ChecksumTransferTest
                          "invalid checksum file" );
     }
 
+    @Test
     public void testGetChecksumCorrectSha1BadMd5UsingFixSetting()
         throws Exception
     {
@@ -346,6 +360,7 @@ public class ChecksumTransferTest
                          "c35f3b76268b73a4ba617f6f275c49ab  get-checksum-sha1-bad-md5-1.0.jar" );
     }
 
+    @Test
     public void testGetChecksumNoSha1CorrectMd5UsingFixSetting()
         throws Exception
     {
@@ -371,6 +386,7 @@ public class ChecksumTransferTest
                          "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
     }
 
+    @Test
     public void testGetWithNoChecksumsUsingFixSetting()
         throws Exception
     {
@@ -396,6 +412,7 @@ public class ChecksumTransferTest
                          "3f7341545f21226b6f49a3c2704cb9be  get-default-layout-1.0.jar" );
     }
 
+    @Test
     public void testGetChecksumNotFoundOnRemote()
         throws Exception
     {
@@ -444,6 +461,7 @@ public class ChecksumTransferTest
                          null );
     }
 
+    @Test
     public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting()
         throws Exception
     {
@@ -470,6 +488,7 @@ public class ChecksumTransferTest
         assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
     }
 
+    @Test
     public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFailSetting()
         throws Exception
     {
@@ -497,6 +516,7 @@ public class ChecksumTransferTest
         assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
     }
 
+    @Test
     public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFixSetting()
         throws Exception
     {

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java?rev=1128404&r1=1128403&r2=1128404&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java Fri May 27 17:26:26 2011
@@ -30,6 +30,7 @@ import org.apache.maven.archiva.reposito
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.junit.Test;
 
 import java.io.File;
 
@@ -55,6 +56,7 @@ public class ErrorHandlingTest
 
     private static final String NAME_MOCKED_PROXIED2 = "Bad Proxied 2";
 
+    @Test
     public void testPropagateErrorImmediatelyWithErrorThenSuccess()
         throws Exception
     {
@@ -69,6 +71,7 @@ public class ErrorHandlingTest
         confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
     }
 
+    @Test
     public void testPropagateErrorImmediatelyWithNotFoundThenError()
         throws Exception
     {
@@ -85,6 +88,7 @@ public class ErrorHandlingTest
         confirmSingleFailure( path, ID_MOCKED_PROXIED2 );
     }
 
+    @Test
     public void testPropagateErrorImmediatelyWithSuccessThenError()
         throws Exception
     {
@@ -98,6 +102,7 @@ public class ErrorHandlingTest
         confirmSuccess( path, expectedFile, REPOPATH_PROXIED1 );
     }
 
+    @Test
     public void testPropagateErrorImmediatelyWithNotFoundThenSuccess()
         throws Exception
     {
@@ -113,6 +118,7 @@ public class ErrorHandlingTest
         confirmSuccess( path, expectedFile, REPOPATH_PROXIED2 );
     }
 
+    @Test
     public void testPropagateErrorAtEndWithErrorThenSuccess()
         throws Exception
     {
@@ -128,6 +134,7 @@ public class ErrorHandlingTest
         confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
     }
 
+    @Test
     public void testPropagateErrorAtEndWithSuccessThenError()
         throws Exception
     {
@@ -141,6 +148,7 @@ public class ErrorHandlingTest
         confirmSuccess( path, expectedFile, REPOPATH_PROXIED1 );
     }
 
+    @Test
     public void testPropagateErrorAtEndWithNotFoundThenError()
         throws Exception
     {
@@ -158,6 +166,7 @@ public class ErrorHandlingTest
         confirmSingleFailure( path, ID_MOCKED_PROXIED2 );
     }
 
+    @Test
     public void testPropagateErrorAtEndWithErrorThenNotFound()
         throws Exception
     {
@@ -175,6 +184,7 @@ public class ErrorHandlingTest
         confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
     }
 
+    @Test
     public void testPropagateErrorAtEndWithErrorThenError()
         throws Exception
     {
@@ -192,6 +202,7 @@ public class ErrorHandlingTest
         confirmFailures( path, new String[]{ID_MOCKED_PROXIED1, ID_MOCKED_PROXIED2} );
     }
 
+    @Test
     public void testPropagateErrorAtEndWithNotFoundThenSuccess()
         throws Exception
     {
@@ -207,6 +218,7 @@ public class ErrorHandlingTest
         confirmSuccess( path, expectedFile, REPOPATH_PROXIED2 );
     }
 
+    @Test
     public void testIgnoreErrorWithErrorThenSuccess()
         throws Exception
     {
@@ -222,6 +234,7 @@ public class ErrorHandlingTest
         confirmSuccess( path, expectedFile, REPOPATH_PROXIED2 );
     }
 
+    @Test
     public void testIgnoreErrorWithSuccessThenError()
         throws Exception
     {
@@ -235,6 +248,7 @@ public class ErrorHandlingTest
         confirmSuccess( path, expectedFile, REPOPATH_PROXIED1 );
     }
 
+    @Test
     public void testIgnoreErrorWithNotFoundThenError()
         throws Exception
     {
@@ -252,6 +266,7 @@ public class ErrorHandlingTest
         confirmNotDownloadedNoError( path );
     }
 
+    @Test
     public void testIgnoreErrorWithErrorThenNotFound()
         throws Exception
     {
@@ -269,6 +284,7 @@ public class ErrorHandlingTest
         confirmNotDownloadedNoError( path );
     }
 
+    @Test
     public void testIgnoreErrorWithErrorThenError()
         throws Exception
     {
@@ -286,6 +302,7 @@ public class ErrorHandlingTest
         confirmNotDownloadedNoError( path );
     }
 
+    @Test
     public void testPropagateOnUpdateAlwaysArtifactNotPresent()
         throws Exception
     {
@@ -302,6 +319,7 @@ public class ErrorHandlingTest
         confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
     }
 
+    @Test
     public void testPropagateOnUpdateAlwaysArtifactPresent()
         throws Exception
     {
@@ -318,6 +336,7 @@ public class ErrorHandlingTest
         confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
     }
 
+    @Test
     public void testPropagateOnUpdateAlwaysQueueArtifactNotPresent()
         throws Exception
     {
@@ -335,6 +354,7 @@ public class ErrorHandlingTest
         confirmFailures( path, new String[] { ID_MOCKED_PROXIED1, ID_MOCKED_PROXIED2 } );
     }
 
+    @Test
     public void testPropagateOnUpdateAlwaysQueueArtifactPresent()
         throws Exception
     {
@@ -352,6 +372,7 @@ public class ErrorHandlingTest
         confirmFailures( path, new String[] { ID_MOCKED_PROXIED1, ID_MOCKED_PROXIED2 } );
     }
 
+    @Test
     public void testPropagateOnUpdateAlwaysIgnoreArtifactNotPresent()
         throws Exception
     {
@@ -369,6 +390,7 @@ public class ErrorHandlingTest
         confirmNotDownloadedNoError( path );
     }
 
+    @Test
     public void testPropagateOnUpdateAlwaysIgnoreArtifactPresent()
         throws Exception
     {
@@ -387,6 +409,7 @@ public class ErrorHandlingTest
         assertTrue( expectedFile.exists() );
     }
 
+    @Test
     public void testPropagateOnUpdateNotPresentArtifactNotPresent()
         throws Exception
     {
@@ -403,6 +426,7 @@ public class ErrorHandlingTest
         confirmSingleFailure( path, ID_MOCKED_PROXIED1 );
     }
 
+    @Test
     public void testPropagateOnUpdateNotPresentArtifactPresent()
         throws Exception
     {
@@ -420,6 +444,7 @@ public class ErrorHandlingTest
         assertTrue( expectedFile.exists() );
     }
 
+    @Test
     public void testPropagateOnUpdateNotPresentQueueArtifactNotPresent()
         throws Exception
     {
@@ -437,6 +462,7 @@ public class ErrorHandlingTest
         confirmFailures( path, new String[] { ID_MOCKED_PROXIED1, ID_MOCKED_PROXIED2 } );
     }
 
+    @Test
     public void testPropagateOnUpdateNotPresentQueueArtifactPresent()
         throws Exception
     {
@@ -455,6 +481,7 @@ public class ErrorHandlingTest
         assertTrue( expectedFile.exists() );
     }
 
+    @Test
     public void testPropagateOnUpdateNotPresentIgnoreArtifactNotPresent()
         throws Exception
     {
@@ -472,6 +499,7 @@ public class ErrorHandlingTest
         confirmNotDownloadedNoError( path );
     }
 
+    @Test
     public void testPropagateOnUpdateNotPresentIgnoreArtifactPresent()
         throws Exception
     {

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/HttpProxyTransferTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/HttpProxyTransferTest.java?rev=1128404&r1=1128403&r2=1128404&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/HttpProxyTransferTest.java (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/HttpProxyTransferTest.java Fri May 27 17:26:26 2011
@@ -19,6 +19,7 @@ package org.apache.maven.archiva.proxy;
  * under the License.
  */
 
+import junit.framework.TestCase;
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
@@ -33,25 +34,35 @@ import org.apache.maven.archiva.policies
 import org.apache.maven.archiva.policies.ReleasesPolicy;
 import org.apache.maven.archiva.policies.SnapshotsPolicy;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mortbay.jetty.Handler;
 import org.mortbay.jetty.Request;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.handler.AbstractHandler;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-import java.io.File;
-import java.io.IOException;
+import javax.inject.Inject;
+import javax.inject.Named;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
 
 /**
  * Integration test for connecting over a HTTP proxy.
  *
  * @version $Id: ManagedDefaultTransferTest.java 677852 2008-07-18 08:16:24Z brett $
  */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
 public class HttpProxyTransferTest
-    extends PlexusInSpringTestCase
+    extends TestCase
 {
     private static final String PROXY_ID = "proxy";
 
@@ -67,14 +78,22 @@ public class HttpProxyTransferTest
 
     private ManagedRepositoryContent managedDefaultRepository;
 
+    @Inject
+    private ApplicationContext applicationContext;
+
     private Server server;
 
-    @Override
-    protected void setUp()
+    @Before
+    public void setUp()
         throws Exception
     {
         super.setUp();
 
+        proxyHandler = applicationContext.getBean( RepositoryProxyConnectors.class );
+
+        config =
+            (MockConfiguration) applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class );
+
         // Setup source repository (using default layout)
         String repoPath = "target/test-repository/managed/" + getName();
 
@@ -95,12 +114,12 @@ public class HttpProxyTransferTest
         repo.setLocation( repoPath );
         repo.setLayout( "default" );
 
-        ManagedRepositoryContent repoContent = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class,
-                                                                                  "default" );
+        ManagedRepositoryContent repoContent =
+            applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );
+
         repoContent.setRepository( repo );
         managedDefaultRepository = repoContent;
 
-        config = (MockConfiguration) lookup( ArchivaConfiguration.class.getName(), "mock" );
         config.getConfiguration().addManagedRepository( repo );
 
         Handler handler = new AbstractHandler()
@@ -140,21 +159,11 @@ public class HttpProxyTransferTest
 
         config.getConfiguration().addRemoteRepository( repoConfig );
 
-        // Setup the proxy handler.
-        try
-        {
-            proxyHandler = (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
-        }
-        catch ( Exception e )
-        {
-            server.stop();
-            applicationContext.close();
-            throw e;
-        }
+
     }
 
-    @Override
-    protected void tearDown()
+    @After
+    public void tearDown()
         throws Exception
     {
         super.tearDown();
@@ -162,6 +171,7 @@ public class HttpProxyTransferTest
         server.stop();
     }
 
+    @Test
     public void testGetOverHttpProxy()
         throws Exception
     {

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java?rev=1128404&r1=1128403&r2=1128404&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java Fri May 27 17:26:26 2011
@@ -27,6 +27,7 @@ import org.apache.maven.archiva.policies
 import org.apache.maven.archiva.policies.ReleasesPolicy;
 import org.apache.maven.archiva.policies.SnapshotsPolicy;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.junit.Test;
 
 import java.io.File;
 
@@ -38,6 +39,7 @@ import java.io.File;
 public class ManagedDefaultTransferTest
     extends AbstractProxyTestCase
 {
+    @Test
     public void testGetDefaultLayoutNotPresentConnectorOffline()
         throws Exception
     {
@@ -58,7 +60,8 @@ public class ManagedDefaultTransferTest
         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
         assertNull("File should not have been downloaded", downloadedFile);
     }
-    
+
+    @Test
     public void testGetDefaultLayoutNotPresent()
         throws Exception
     {
@@ -83,6 +86,7 @@ public class ManagedDefaultTransferTest
         assertNoTempFiles( expectedFile );
     }
 
+    @Test
     public void testGetDefaultLayoutNotPresentPassthrough()
         throws Exception
     {
@@ -116,6 +120,7 @@ public class ManagedDefaultTransferTest
      *
      * @throws Exception
      */
+    @Test
     public void testGetDefaultLayoutAlreadyPresentPolicyOnce()
         throws Exception
     {
@@ -146,6 +151,7 @@ public class ManagedDefaultTransferTest
      *
      * @throws Exception
      */
+    @Test
     public void testGetDefaultLayoutAlreadyPresentPassthrough()
         throws Exception
     {
@@ -189,6 +195,7 @@ public class ManagedDefaultTransferTest
      *
      * @throws Exception
      */
+    @Test
     public void testGetDefaultLayoutAlreadyPresentNewerThanRemotePolicyIgnored()
         throws Exception
     {
@@ -234,6 +241,7 @@ public class ManagedDefaultTransferTest
      *
      * @throws Exception
      */
+    @Test
     public void testGetDefaultLayoutAlreadyPresentOlderThanRemotePolicyIgnored()
         throws Exception
     {
@@ -269,6 +277,7 @@ public class ManagedDefaultTransferTest
      *
      * @throws Exception
      */
+    @Test
     public void testGetDefaultLayoutRemoteUpdate()
         throws Exception
     {
@@ -293,6 +302,7 @@ public class ManagedDefaultTransferTest
         assertNoTempFiles( expectedFile );
     }
 
+    @Test
     public void testGetWhenInBothProxiedRepos()
         throws Exception
     {
@@ -323,6 +333,7 @@ public class ManagedDefaultTransferTest
                      StringUtils.equals( actualContents, badContents ) );
     }
 
+    @Test
     public void testGetInSecondProxiedRepo()
         throws Exception
     {
@@ -346,6 +357,7 @@ public class ManagedDefaultTransferTest
         assertNoTempFiles( expectedFile );
     }
 
+    @Test
     public void testNotFoundInAnyProxies()
         throws Exception
     {
@@ -370,6 +382,7 @@ public class ManagedDefaultTransferTest
         assertNoTempFiles( expectedFile );
     }
 
+    @Test
     public void testGetInSecondProxiedRepoFirstFails()
         throws Exception
     {
@@ -403,6 +416,7 @@ public class ManagedDefaultTransferTest
         assertNoTempFiles( expectedFile );
     }
 
+    @Test
     public void testGetAllRepositoriesFail()
         throws Exception
     {
@@ -446,6 +460,7 @@ public class ManagedDefaultTransferTest
         // TODO: How much information on each failure should we pass back to the user vs. logging in the proxy? 
     }
 
+    @Test
     public void testGetFromLegacyProxyAlreadyPresentInManaged_NewerThanRemote()
         throws Exception
     {
@@ -473,7 +488,8 @@ public class ManagedDefaultTransferTest
         assertNotModified( expectedFile, expectedTimestamp );
         assertNoTempFiles( expectedFile );
     }
-    
+
+    @Test
     public void testGetFromLegacyProxyAlreadyPresentInManaged_OlderThanRemote()
         throws Exception
     {
@@ -501,6 +517,7 @@ public class ManagedDefaultTransferTest
         assertNoTempFiles( expectedFile );
     }
 
+    @Test
     public void testGetFromLegacyProxyNotPresentInManaged()
         throws Exception
     {
@@ -523,6 +540,7 @@ public class ManagedDefaultTransferTest
         assertNoTempFiles( expectedFile );
     }
 
+    @Test
     public void testGetFromLegacyProxyPluginNotPresentInManaged()
         throws Exception
     {



Mime
View raw message