]> source.dussan.org Git - archiva.git/commitdiff
fix some spring bean name in archiva-policies
authorOlivier Lamy <olamy@apache.org>
Sat, 21 May 2011 17:57:38 +0000 (17:57 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 21 May 2011 17:57:38 +0000 (17:57 +0000)
move archiva-repository-scanner to full spring

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1125755 13f79535-47bb-0310-9956-ffa450edef68

16 files changed:
archiva-modules/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java
archiva-modules/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ChecksumPolicy.java
archiva-modules/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/PropagateErrorsDownloadPolicy.java
archiva-modules/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/PropagateErrorsOnUpdateDownloadPolicy.java
archiva-modules/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ReleasesPolicy.java
archiva-modules/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/SnapshotsPolicy.java
archiva-modules/archiva-base/archiva-repository-scanner/pom.xml
archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java
archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java
archiva-modules/archiva-base/archiva-repository-scanner/src/main/resources/META-INF/spring-context.xml
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/InvalidScanConsumer.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryScannerTest.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/SampleKnownConsumer.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/resources/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.xml [deleted file]
archiva-modules/archiva-base/archiva-repository-scanner/src/test/resources/spring-context.xml [new file with mode: 0644]

index ae8b735d636ca2a5250ac29e8bd93bba6a9b55f3..3eb2797fb342ed9ca817ccad1fd07e3edfff0e47 100644 (file)
@@ -36,7 +36,7 @@ import javax.inject.Inject;
  * {@link PreDownloadPolicy} to check if the requested url has failed before.
  *
  * @version $Id$
- * @plexus.component role="org.apache.maven.archiva.policies.PreDownloadPolicy"
+ * plexus.component role="org.apache.maven.archiva.policies.PreDownloadPolicy"
  * role-hint="cache-failures"
  */
 @Service("preDownloadPolicy#cache-failures")
@@ -58,7 +58,7 @@ public class CachedFailuresPolicy
     public static final String YES = "yes";
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
     @Inject
     private UrlFailureCache urlFailureCache;
index 5fcea244047f276dc99a8c71f82a45a548301eb0..dcbeb542901515f5f1c50f7dc04e8ac3f23ac288 100644 (file)
@@ -37,7 +37,7 @@ import org.springframework.stereotype.Service;
  *
  * @version $Id$
  * 
- * @plexus.component role="org.apache.maven.archiva.policies.PostDownloadPolicy"
+ * plexus.component role="org.apache.maven.archiva.policies.PostDownloadPolicy"
  *                   role-hint="checksum"
  */
 @Service("postDownloadPolicy#checksum")
index 47e18173b1c542ab11d1c184c32a8fdbcff03463..be090edc21848fccb44a443f69943360a54c5247 100644 (file)
@@ -33,7 +33,7 @@ import org.springframework.stereotype.Service;
 /**
  * PropagateErrorsPolicy - a policy applied on error to determine how to treat the error.
  *
- * @plexus.component role="org.apache.maven.archiva.policies.DownloadErrorPolicy"
+ * plexus.component role="org.apache.maven.archiva.policies.DownloadErrorPolicy"
  * role-hint="propagate-errors"
  */
 @Service("downloadErrorPolicy#propagate-errors")
index bbceee338f1594287c7d5cd7d8e6149668948573..0ea8983765715ae4cca87a1518d61203b34f7a3a 100644 (file)
@@ -31,7 +31,7 @@ import org.springframework.stereotype.Service;
 /**
  * PropagateErrorsPolicy - a policy applied on error to determine how to treat the error.
  *
- * @plexus.component role="org.apache.maven.archiva.policies.DownloadErrorPolicy"
+ * plexus.component role="org.apache.maven.archiva.policies.DownloadErrorPolicy"
  *                   role-hint="propagate-errors-on-update"
  */
 @Service("downloadErrorPolicy#propagate-errors-on-update")
index 75bb82e7231c3afb0bb94f8e77c88312fe65b9e1..35740751634631fec9cbfedbe6fc53af83be7351 100644 (file)
@@ -27,7 +27,7 @@ import org.springframework.stereotype.Service;
  *
  * @version $Id$
  * 
- * @plexus.component role="org.apache.maven.archiva.policies.PreDownloadPolicy"
+ * plexus.component role="org.apache.maven.archiva.policies.PreDownloadPolicy"
  *                   role-hint="releases"
  */
 @Service("preDownloadPolicy#releases")
index a8e3863f38855b631a3ae3f939a34fc5a8b613b1..16b9a8eac8e00b350f76cc64065494bc76d7dd1f 100644 (file)
@@ -27,7 +27,7 @@ import org.springframework.stereotype.Service;
  *
  * @version $Id$
  * 
- * @plexus.component role="org.apache.maven.archiva.policies.PreDownloadPolicy"
+ * plexus.component role="org.apache.maven.archiva.policies.PreDownloadPolicy"
  *                   role-hint="snapshots"
  */
 @Service("preDownloadPolicy#snapshots")
index d8c6fcb90512bea3464c543c7b58ce88274f0208..4a873d9f7e96b745c131f23b57eabea345112dfb 100644 (file)
       <groupId>org.springframework</groupId>
       <artifactId>spring-context</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.codehaus.redback.components</groupId>
-      <artifactId>plexus-spring</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
index d6b96fcadbb30fa53ae14f1f1bb62ba008246611..a6d39c0f406fde4081f27c3d63ec23879b01bc12 100644 (file)
@@ -32,26 +32,31 @@ import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
 import org.codehaus.plexus.util.DirectoryWalker;
+import org.springframework.stereotype.Service;
 
+import javax.inject.Inject;
 import javax.swing.*;
 
 /**
  * DefaultRepositoryScanner
  *
  * @version $Id$
- * @plexus.component role="org.apache.archiva.repository.scanner.RepositoryScanner"
+ * plexus.component role="org.apache.archiva.repository.scanner.RepositoryScanner"
  */
+@Service("repositoryScanner#default")
 public class DefaultRepositoryScanner
     implements RepositoryScanner
 {
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private FileTypes filetypes;
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private RepositoryContentConsumers consumerUtil;
 
     private Set<RepositoryScannerInstance> inProgressScans = new LinkedHashSet<RepositoryScannerInstance>();
index 5b1e30a5dceee0f10f8f96d56cfeb73f071768a3..666ff004540822168d99deb12cfbf4bccb252858 100644 (file)
@@ -19,13 +19,6 @@ package org.apache.archiva.repository.scanner;
  * under the License.
  */
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.archiva.repository.scanner.functors.ConsumerProcessFileClosure;
 import org.apache.archiva.repository.scanner.functors.TriggerBeginScanClosure;
 import org.apache.archiva.repository.scanner.functors.TriggerScanCompletedClosure;
@@ -43,27 +36,35 @@ import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
- * RepositoryContentConsumerUtil 
+ * RepositoryContentConsumerUtil
  *
  * @version $Id$
  */
-public class RepositoryContentConsumers implements ApplicationContextAware
+public class RepositoryContentConsumers
+    implements ApplicationContextAware
 {
     private ApplicationContext applicationContext;
-    
+
     private ArchivaConfiguration archivaConfiguration;
 
     private List<KnownRepositoryContentConsumer> selectedKnownConsumers;
 
     private List<InvalidRepositoryContentConsumer> selectedInvalidConsumers;
 
-    public RepositoryContentConsumers(ArchivaConfiguration archivaConfiguration)
+    public RepositoryContentConsumers( ArchivaConfiguration archivaConfiguration )
     {
         this.archivaConfiguration = archivaConfiguration;
     }
 
-    public void setApplicationContext(ApplicationContext applicationContext)
+    public void setApplicationContext( ApplicationContext applicationContext )
         throws BeansException
     {
         this.applicationContext = applicationContext;
@@ -74,12 +75,12 @@ public class RepositoryContentConsumers implements ApplicationContextAware
      * Get the list of Ids associated with those {@link KnownRepositoryContentConsumer} that have
      * been selected in the configuration to execute.
      * </p>
-     * 
+     * <p/>
      * <p>
      * NOTE: This list can be larger and contain entries that might not exist or be available
      * in the classpath, or as a component.
      * </p>
-     * 
+     *
      * @return the list of consumer ids that have been selected by the configuration.
      */
     public List<String> getSelectedKnownConsumerIds()
@@ -93,12 +94,12 @@ public class RepositoryContentConsumers implements ApplicationContextAware
      * Get the list of Ids associated with those {@link InvalidRepositoryContentConsumer} that have
      * been selected in the configuration to execute.
      * </p>
-     * 
+     * <p/>
      * <p>
      * NOTE: This list can be larger and contain entries that might not exist or be available
      * in the classpath, or as a component.
      * </p>
-     * 
+     *
      * @return the list of consumer ids that have been selected by the configuration.
      */
     public List<String> getSelectedInvalidConsumerIds()
@@ -109,8 +110,8 @@ public class RepositoryContentConsumers implements ApplicationContextAware
 
     /**
      * Get the map of {@link String} ids to {@link KnownRepositoryContentConsumer} implementations,
-     * for those consumers that have been selected according to the active configuration. 
-     * 
+     * for those consumers that have been selected according to the active configuration.
+     *
      * @return the map of String ids to {@link KnownRepositoryContentConsumer} objects.
      */
     public Map<String, KnownRepositoryContentConsumer> getSelectedKnownConsumersMap()
@@ -127,13 +128,14 @@ public class RepositoryContentConsumers implements ApplicationContextAware
 
     /**
      * Get the map of {@link String} ids to {@link InvalidRepositoryContentConsumer} implementations,
-     * for those consumers that have been selected according to the active configuration. 
-     * 
+     * for those consumers that have been selected according to the active configuration.
+     *
      * @return the map of String ids to {@link InvalidRepositoryContentConsumer} objects.
      */
     public Map<String, InvalidRepositoryContentConsumer> getSelectedInvalidConsumersMap()
     {
-        Map<String, InvalidRepositoryContentConsumer> consumerMap = new HashMap<String, InvalidRepositoryContentConsumer>();
+        Map<String, InvalidRepositoryContentConsumer> consumerMap =
+            new HashMap<String, InvalidRepositoryContentConsumer>();
 
         for ( InvalidRepositoryContentConsumer consumer : getSelectedInvalidConsumers() )
         {
@@ -146,7 +148,7 @@ public class RepositoryContentConsumers implements ApplicationContextAware
     /**
      * Get the list of {@link KnownRepositoryContentConsumer} objects that are
      * selected according to the active configuration.
-     * 
+     *
      * @return the list of {@link KnownRepositoryContentConsumer} that have been selected
      *         by the active configuration.
      */
@@ -173,7 +175,7 @@ public class RepositoryContentConsumers implements ApplicationContextAware
     /**
      * Get the list of {@link InvalidRepositoryContentConsumer} objects that are
      * selected according to the active configuration.
-     * 
+     *
      * @return the list of {@link InvalidRepositoryContentConsumer} that have been selected
      *         by the active configuration.
      */
@@ -200,58 +202,61 @@ public class RepositoryContentConsumers implements ApplicationContextAware
     /**
      * Get the list of {@link KnownRepositoryContentConsumer} objects that are
      * available and present in the classpath and as components in the IoC.
-     * 
-     * @return the list of all available {@link KnownRepositoryContentConsumer} present in the classpath 
+     *
+     * @return the list of all available {@link KnownRepositoryContentConsumer} present in the classpath
      *         and as a component in the IoC.
      */
     public List<KnownRepositoryContentConsumer> getAvailableKnownConsumers()
     {
-        return new ArrayList<KnownRepositoryContentConsumer>( applicationContext.getBeansOfType( KnownRepositoryContentConsumer.class ).values() );
+        return new ArrayList<KnownRepositoryContentConsumer>(
+            applicationContext.getBeansOfType( KnownRepositoryContentConsumer.class ).values() );
     }
 
     /**
      * Get the list of {@link InvalidRepositoryContentConsumer} objects that are
      * available and present in the classpath and as components in the IoC.
-     * 
-     * @return the list of all available {@link InvalidRepositoryContentConsumer} present in the classpath 
+     *
+     * @return the list of all available {@link InvalidRepositoryContentConsumer} present in the classpath
      *         and as a component in the IoC.
      */
     public List<InvalidRepositoryContentConsumer> getAvailableInvalidConsumers()
     {
-        return new ArrayList<InvalidRepositoryContentConsumer>( applicationContext.getBeansOfType( InvalidRepositoryContentConsumer.class ).values() );
+        return new ArrayList<InvalidRepositoryContentConsumer>(
+            applicationContext.getBeansOfType( InvalidRepositoryContentConsumer.class ).values() );
     }
 
     /**
-     * A convienence method to execute all of the active selected consumers for a 
+     * A convienence method to execute all of the active selected consumers for a
      * particular arbitrary file.
      * NOTE: Make sure that there is no repository scanning task executing before invoking this so as to prevent
      * the index writer/reader of the current index-content consumer executing from getting closed. For an example,
      * see ArchivaDavResource#executeConsumers( File ).
-     * 
-     * @param repository the repository configuration to use.
-     * @param localFile the local file to execute the consumers against.
+     *
+     * @param repository             the repository configuration to use.
+     * @param localFile              the local file to execute the consumers against.
      * @param updateRelatedArtifacts TODO
      */
-    public void executeConsumers( ManagedRepositoryConfiguration repository, File localFile, boolean updateRelatedArtifacts )
+    public void executeConsumers( ManagedRepositoryConfiguration repository, File localFile,
+                                  boolean updateRelatedArtifacts )
     {
         // Run the repository consumers
         try
-        {   
+        {
             Closure triggerBeginScan = new TriggerBeginScanClosure( repository, getStartTime(), false );
 
             List<KnownRepositoryContentConsumer> selectedKnownConsumers = getSelectedKnownConsumers();
 
             // MRM-1212/MRM-1197 
             // - do not create missing/fix invalid checksums and update metadata when deploying from webdav since these are uploaded by maven
-            if( updateRelatedArtifacts == false )
+            if ( updateRelatedArtifacts == false )
             {
                 List<KnownRepositoryContentConsumer> clone = new ArrayList<KnownRepositoryContentConsumer>();
                 clone.addAll( selectedKnownConsumers );
 
-                for( KnownRepositoryContentConsumer consumer : clone )
+                for ( KnownRepositoryContentConsumer consumer : clone )
                 {
-                    if( consumer.getId().equals( "create-missing-checksums" ) ||
-                                    consumer.getId().equals( "metadata-updater" ) )
+                    if ( consumer.getId().equals( "create-missing-checksums" ) || consumer.getId().equals(
+                        "metadata-updater" ) )
                     {
                         selectedKnownConsumers.remove( consumer );
                     }
@@ -272,7 +277,7 @@ public class RepositoryContentConsumers implements ApplicationContextAware
             ConsumerProcessFileClosure closure = new ConsumerProcessFileClosure();
             closure.setBasefile( baseFile );
             closure.setExecuteOnEntireRepo( false );
-            
+
             Closure processIfWanted = IfClosure.getInstance( predicate, closure );
 
             CollectionUtils.forAllDo( selectedKnownConsumers, processIfWanted );
@@ -305,12 +310,12 @@ public class RepositoryContentConsumers implements ApplicationContextAware
     {
         this.selectedInvalidConsumers = selectedInvalidConsumers;
     }
-    
+
     protected Date getStartTime()
-    {   
+    {
         return new Date( System.currentTimeMillis() );
     }
-    
+
     public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
     {
         this.archivaConfiguration = archivaConfiguration;
index f8bce47bc470cc8bf08497885ee941a92790bb00..867eb1a27a446022d88a0cecd0593a50dcbf4b6e 100644 (file)
@@ -1,11 +1,39 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0"?>
+
+<!--
+  ~ 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.
+  -->
 <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: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.archiva.repository.scanner"/>
+  <alias name="repositoryScanner#default" alias="repositoryScanner"/>
 
-    <bean id="repositoryContentConsumers" class="org.apache.archiva.repository.scanner.RepositoryContentConsumers" scope="prototype">
-      <constructor-arg>
-        <ref bean="archivaConfiguration"/>
-      </constructor-arg>
-    </bean>
+  <bean id="repositoryContentConsumers" class="org.apache.archiva.repository.scanner.RepositoryContentConsumers" scope="prototype">
+    <constructor-arg>
+      <ref bean="archivaConfiguration"/>
+    </constructor-arg>
+  </bean>
 </beans>
index ab5879ae6d0972d4bca30170b58b393e49529df0..aaeb03197af4985dac2d8483f5bd66ebea577d5e 100644 (file)
@@ -37,7 +37,7 @@ public class InvalidScanConsumer
     implements InvalidRepositoryContentConsumer
 {
     /**
-     * @plexus.configuration default-value="unset-id"
+     * plexus.configuration default-value="unset-id"
      */
     private String id = "unset-id";
     
@@ -111,4 +111,9 @@ public class InvalidScanConsumer
     {
         this.processCount = processCount;
     }
+
+    public void setId( String id )
+    {
+        this.id = id;
+    }
 }
index 4e25a18a18f1ff1638bf8559559d09f0f3e9b08d..d95d97b2fc54f26f882aabc1b5a73a1cce68ef6e 100644 (file)
@@ -19,25 +19,16 @@ package org.apache.archiva.repository.scanner;
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
+import junit.framework.TestCase;
 import org.apache.commons.lang.SystemUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
 import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.easymock.MockControl;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -47,24 +38,34 @@ import org.springframework.context.ApplicationEvent;
 import org.springframework.context.MessageSourceResolvable;
 import org.springframework.context.NoSuchMessageException;
 import org.springframework.core.io.Resource;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
 
 /**
  * RepositoryContentConsumersTest
  *
  * @version $Id$
  */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
 public class RepositoryContentConsumersTest
-    extends PlexusInSpringTestCase
+    extends TestCase
 {
-    /**
-     * {@inheritDoc}
-     * @see org.codehaus.plexus.spring.PlexusInSpringTestCase#getSpringConfigLocation()
-     */
-    @Override
-    protected String getSpringConfigLocation()
-    {
-        return "org/apache/maven/archiva/repository/spring-context.xml";
-    }
+
+    @Inject
+    ApplicationContext applicationContext;
 
     protected ManagedRepositoryConfiguration createRepository( String id, String name, File location )
     {
@@ -87,42 +88,43 @@ public class RepositoryContentConsumersTest
     private RepositoryContentConsumers lookupRepositoryConsumers()
         throws Exception
     {
-        ArchivaConfiguration configuration = (ArchivaConfiguration)lookup(ArchivaConfiguration.class);
 
-        RepositoryContentConsumers consumerUtilStub = new RepositoryContentConsumersStub(configuration);
-               
-        RepositoryContentConsumers consumerUtil = (RepositoryContentConsumers) lookup( RepositoryContentConsumers.class
-                                                                                           .getName() );
-        ApplicationContext context = new MockApplicationContext(consumerUtil.getAvailableKnownConsumers(), consumerUtil.getAvailableInvalidConsumers());
+        ArchivaConfiguration configuration =
+            applicationContext.getBean( "archivaConfiguration#test-conf", ArchivaConfiguration.class );
+
+        RepositoryContentConsumers consumerUtilStub = new RepositoryContentConsumersStub( configuration );
 
-        consumerUtilStub.setApplicationContext(context);
+        RepositoryContentConsumers consumerUtil =
+            (RepositoryContentConsumers) applicationContext.getBean( "repositoryContentConsumers#test",
+                                                                     RepositoryContentConsumers.class );
+        ApplicationContext context = new MockApplicationContext( consumerUtil.getAvailableKnownConsumers(),
+                                                                 consumerUtil.getAvailableInvalidConsumers() );
+
+        consumerUtilStub.setApplicationContext( context );
         consumerUtilStub.setSelectedInvalidConsumers( consumerUtil.getSelectedInvalidConsumers() );
-        consumerUtilStub.setSelectedKnownConsumers( consumerUtil.getSelectedKnownConsumers() );        
+        consumerUtilStub.setSelectedKnownConsumers( consumerUtil.getSelectedKnownConsumers() );
         consumerUtilStub.setArchivaConfiguration( configuration );
-        
+
         assertNotNull( "RepositoryContentConsumers should not be null.", consumerUtilStub );
-        
+
         return consumerUtilStub;
     }
 
+    @Test
     public void testGetSelectedKnownIds()
         throws Exception
     {
         RepositoryContentConsumers consumerutil = lookupRepositoryConsumers();
 
-        String expectedKnownIds[] = new String[] {
-            "update-db-artifact",
-            "create-missing-checksums",
-            "update-db-repository-metadata",
-            "validate-checksum",
-            "validate-signature",
-            "index-content",
-            "auto-remove",
-            "auto-rename" };
-
+        String expectedKnownIds[] =
+            new String[]{ "update-db-artifact", "create-missing-checksums", "update-db-repository-metadata",
+                "validate-checksum", "validate-signature", "index-content", "auto-remove", "auto-rename" };
+//update-db-artifact, create-missing-checksums, update-db-repository-metadata,
+//validate-checksum, validate-signature, index-content, auto-remove, auto-rename,
+//metadata-updater
         List<String> knownConsumers = consumerutil.getSelectedKnownConsumerIds();
         assertNotNull( "Known Consumer IDs should not be null", knownConsumers );
-        assertEquals( "Known Consumer IDs.size", expectedKnownIds.length, knownConsumers.size() );
+        assertEquals( "Known Consumer IDs.size " + knownConsumers, expectedKnownIds.length, knownConsumers.size() );
 
         for ( String expectedId : expectedKnownIds )
         {
@@ -130,12 +132,13 @@ public class RepositoryContentConsumersTest
         }
     }
 
+    @Test
     public void testGetSelectedInvalidIds()
         throws Exception
     {
         RepositoryContentConsumers consumerutil = lookupRepositoryConsumers();
 
-        String expectedInvalidIds[] = new String[] { "update-db-bad-content" };
+        String expectedInvalidIds[] = new String[]{ "update-db-bad-content" };
 
         List<String> invalidConsumers = consumerutil.getSelectedInvalidConsumerIds();
         assertNotNull( "Invalid Consumer IDs should not be null", invalidConsumers );
@@ -147,19 +150,15 @@ public class RepositoryContentConsumersTest
         }
     }
 
+    @Test
     public void testGetSelectedKnownConsumerMap()
         throws Exception
     {
         RepositoryContentConsumers consumerutil = lookupRepositoryConsumers();
 
-        String expectedSelectedKnownIds[] = new String[] {
-            "update-db-artifact",
-            "create-missing-checksums",
-            "update-db-repository-metadata",
-            "validate-checksum",
-            "index-content",
-            "auto-remove",
-            "auto-rename" };
+        String expectedSelectedKnownIds[] =
+            new String[]{ "update-db-artifact", "create-missing-checksums", "update-db-repository-metadata",
+                "validate-checksum", "index-content", "auto-remove", "auto-rename" };
 
         Map<String, KnownRepositoryContentConsumer> knownConsumerMap = consumerutil.getSelectedKnownConsumersMap();
         assertNotNull( "Known Consumer Map should not be null", knownConsumerMap );
@@ -173,15 +172,16 @@ public class RepositoryContentConsumersTest
         }
     }
 
+    @Test
     public void testGetSelectedInvalidConsumerMap()
         throws Exception
     {
         RepositoryContentConsumers consumerutil = lookupRepositoryConsumers();
 
-        String expectedSelectedInvalidIds[] = new String[] { "update-db-bad-content" };
+        String expectedSelectedInvalidIds[] = new String[]{ "update-db-bad-content" };
 
-        Map<String, InvalidRepositoryContentConsumer> invalidConsumerMap = consumerutil
-            .getSelectedInvalidConsumersMap();
+        Map<String, InvalidRepositoryContentConsumer> invalidConsumerMap =
+            consumerutil.getSelectedInvalidConsumersMap();
         assertNotNull( "Invalid Consumer Map should not be null", invalidConsumerMap );
         assertEquals( "Invalid Consumer Map.size", expectedSelectedInvalidIds.length, invalidConsumerMap.size() );
 
@@ -193,20 +193,15 @@ public class RepositoryContentConsumersTest
         }
     }
 
+    @Test
     public void testGetAvailableKnownList()
         throws Exception
     {
         RepositoryContentConsumers consumerutil = lookupRepositoryConsumers();
 
-        String expectedKnownIds[] = new String[] {
-            "update-db-artifact",
-            "create-missing-checksums",
-            "update-db-repository-metadata",
-            "validate-checksum",
-            "index-content",
-            "auto-remove",
-            "auto-rename",
-            "available-but-unselected" };
+        String expectedKnownIds[] =
+            new String[]{ "update-db-artifact", "create-missing-checksums", "update-db-repository-metadata",
+                "validate-checksum", "index-content", "auto-remove", "auto-rename", "available-but-unselected" };
 
         List<KnownRepositoryContentConsumer> knownConsumers = consumerutil.getAvailableKnownConsumers();
         assertNotNull( "known consumers should not be null.", knownConsumers );
@@ -220,12 +215,13 @@ public class RepositoryContentConsumersTest
         }
     }
 
+    @Test
     public void testGetAvailableInvalidList()
         throws Exception
     {
         RepositoryContentConsumers consumerutil = lookupRepositoryConsumers();
 
-        String expectedInvalidIds[] = new String[] { "update-db-bad-content", "move-to-trash-then-notify" };
+        String expectedInvalidIds[] = new String[]{ "update-db-bad-content", "move-to-trash-then-notify" };
 
         List<InvalidRepositoryContentConsumer> invalidConsumers = consumerutil.getAvailableInvalidConsumers();
         assertNotNull( "invalid consumers should not be null.", invalidConsumers );
@@ -234,12 +230,13 @@ public class RepositoryContentConsumersTest
         List<String> expectedIds = Arrays.asList( expectedInvalidIds );
         for ( InvalidRepositoryContentConsumer consumer : invalidConsumers )
         {
-            assertTrue( "Consumer [" + consumer.getId()
-                + "] returned by .getAvailableInvalidConsumers() is unexpected.", expectedIds.contains( consumer
-                .getId() ) );
+            assertTrue(
+                "Consumer [" + consumer.getId() + "] returned by .getAvailableInvalidConsumers() is unexpected.",
+                expectedIds.contains( consumer.getId() ) );
         }
     }
 
+    @Test
     public void testExecution()
         throws Exception
     {
@@ -250,7 +247,8 @@ public class RepositoryContentConsumersTest
             (KnownRepositoryContentConsumer) MockControl.createNiceControl(
                 KnownRepositoryContentConsumer.class ).getMock();
 
-        consumers.setApplicationContext(new MockApplicationContext(Arrays.asList( selectedKnownConsumer, unselectedKnownConsumer ), null));
+        consumers.setApplicationContext(
+            new MockApplicationContext( Arrays.asList( selectedKnownConsumer, unselectedKnownConsumer ), null ) );
 
         consumers.setSelectedKnownConsumers( Collections.singletonList( selectedKnownConsumer ) );
 
@@ -261,12 +259,13 @@ public class RepositoryContentConsumersTest
             (InvalidRepositoryContentConsumer) MockControl.createControl(
                 InvalidRepositoryContentConsumer.class ).getMock();
 
-        consumers.setApplicationContext( new MockApplicationContext(null, Arrays.asList( selectedInvalidConsumer, unselectedInvalidConsumer )));
+        consumers.setApplicationContext(
+            new MockApplicationContext( null, Arrays.asList( selectedInvalidConsumer, unselectedInvalidConsumer ) ) );
 
         consumers.setSelectedInvalidConsumers( Collections.singletonList( selectedInvalidConsumer ) );
 
-        ManagedRepositoryConfiguration repo = createRepository( "id", "name", getTestFile( "target/test-repo" ) );
-        File testFile = getTestFile( "target/test-repo/path/to/test-file.txt" );
+        ManagedRepositoryConfiguration repo = createRepository( "id", "name", new File( "target/test-repo" ) );
+        File testFile = new File( "target/test-repo/path/to/test-file.txt" );
 
         Date startTime = new Date( System.currentTimeMillis() );
         startTime.setTime( 12345678 );
@@ -292,7 +291,7 @@ public class RepositoryContentConsumersTest
         knownControl.reset();
         invalidControl.reset();
 
-        File notIncludedTestFile = getTestFile( "target/test-repo/path/to/test-file.xml" );
+        File notIncludedTestFile = new File( "./target/test-repo/path/to/test-file.xml" );
 
         selectedKnownConsumer.beginScan( repo, startTime, false );
         selectedKnownConsumer.getExcludes();
@@ -317,7 +316,7 @@ public class RepositoryContentConsumersTest
         knownControl.reset();
         invalidControl.reset();
 
-        File excludedTestFile = getTestFile( "target/test-repo/path/to/test-file.txt" );
+        File excludedTestFile = new File( "target/test-repo/path/to/test-file.txt" );
 
         selectedKnownConsumer.beginScan( repo, startTime, false );
         selectedKnownConsumer.getExcludes();
@@ -351,171 +350,216 @@ public class RepositoryContentConsumersTest
         return path;
     }
 
-    private static Map convertToMap(List objects)
+    private static Map convertToMap( List objects )
     {
         HashMap map = new HashMap();
-        for (Object o : objects)
+        for ( Object o : objects )
         {
-            map.put(o, o);
+            map.put( o, o );
         }
         return map;
     }
 
-    public class MockApplicationContext implements ApplicationContext
+    public class MockApplicationContext
+        implements ApplicationContext
     {
         private List<KnownRepositoryContentConsumer> knownRepositoryContentConsumer;
 
         private List<InvalidRepositoryContentConsumer> invalidRepositoryContentConsumers;
 
-        public MockApplicationContext(List<KnownRepositoryContentConsumer> knownRepositoryContentConsumer, List<InvalidRepositoryContentConsumer> invalidRepositoryContentConsumers)
+        public MockApplicationContext( List<KnownRepositoryContentConsumer> knownRepositoryContentConsumer,
+                                       List<InvalidRepositoryContentConsumer> invalidRepositoryContentConsumers )
         {
             this.knownRepositoryContentConsumer = knownRepositoryContentConsumer;
             this.invalidRepositoryContentConsumers = invalidRepositoryContentConsumers;
         }
 
-        public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public AutowireCapableBeanFactory getAutowireCapableBeanFactory()
+            throws IllegalStateException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public String getDisplayName() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public String getDisplayName()
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public String getId() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public String getId()
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public ApplicationContext getParent() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public ApplicationContext getParent()
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public long getStartupDate() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public long getStartupDate()
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public boolean containsBeanDefinition(String beanName) {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public boolean containsBeanDefinition( String beanName )
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public int getBeanDefinitionCount() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public int getBeanDefinitionCount()
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public String[] getBeanDefinitionNames() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public String[] getBeanDefinitionNames()
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public String[] getBeanNamesForType(Class type) {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public String[] getBeanNamesForType( Class type )
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public String[] getBeanNamesForType(Class type, boolean includeNonSingletons, boolean allowEagerInit) {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public String[] getBeanNamesForType( Class type, boolean includeNonSingletons, boolean allowEagerInit )
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public Map getBeansOfType(Class type) throws BeansException {
-            if (type == KnownRepositoryContentConsumer.class)
+        public Map getBeansOfType( Class type )
+            throws BeansException
+        {
+            if ( type == KnownRepositoryContentConsumer.class )
             {
-                return convertToMap(knownRepositoryContentConsumer);
+                return convertToMap( knownRepositoryContentConsumer );
             }
-            if (type == InvalidRepositoryContentConsumer.class)
+            if ( type == InvalidRepositoryContentConsumer.class )
             {
-                return convertToMap(invalidRepositoryContentConsumers);
+                return convertToMap( invalidRepositoryContentConsumers );
             }
-            throw new UnsupportedOperationException("Should not have been called");
+            throw new UnsupportedOperationException( "Should not have been called" );
         }
 
-        public Map getBeansOfType(Class type, boolean includeNonSingletons, boolean allowEagerInit) throws BeansException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public Map getBeansOfType( Class type, boolean includeNonSingletons, boolean allowEagerInit )
+            throws BeansException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public boolean containsBean(String name) {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public boolean containsBean( String name )
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public String[] getAliases(String name) {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public String[] getAliases( String name )
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public Object getBean(String name) throws BeansException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public Object getBean( String name )
+            throws BeansException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public Object getBean(String name, Class requiredType) throws BeansException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public Object getBean( String name, Class requiredType )
+            throws BeansException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public Object getBean(String name, Object[] args) throws BeansException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public Object getBean( String name, Object[] args )
+            throws BeansException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public Class getType(String name) throws NoSuchBeanDefinitionException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public Class getType( String name )
+            throws NoSuchBeanDefinitionException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public boolean isPrototype( String name )
+            throws NoSuchBeanDefinitionException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public boolean isSingleton( String name )
+            throws NoSuchBeanDefinitionException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public boolean isTypeMatch( String name, Class targetType )
+            throws NoSuchBeanDefinitionException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public boolean containsLocalBean(String name) {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public boolean containsLocalBean( String name )
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public BeanFactory getParentBeanFactory() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public BeanFactory getParentBeanFactory()
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public String getMessage( String code, Object[] args, String defaultMessage, Locale locale )
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public String getMessage( String code, Object[] args, Locale locale )
+            throws NoSuchMessageException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public String getMessage( MessageSourceResolvable resolvable, Locale locale )
+            throws NoSuchMessageException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public void publishEvent(ApplicationEvent event) {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public void publishEvent( ApplicationEvent event )
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public Resource[] getResources(String locationPattern) throws IOException {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public Resource[] getResources( String locationPattern )
+            throws IOException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public ClassLoader getClassLoader() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public ClassLoader getClassLoader()
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
-        public Resource getResource(String location) {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public Resource getResource( String location )
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
         public <T> T getBean( Class<T> tClass )
             throws BeansException
         {
-            throw new UnsupportedOperationException("Not supported yet.");
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
         public Map<String, Object> getBeansWithAnnotation( Class<? extends Annotation> aClass )
             throws BeansException
         {
-            throw new UnsupportedOperationException("Not supported yet.");
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
 
         public <A extends Annotation> A findAnnotationOnBean( String s, Class<A> aClass )
         {
-            throw new UnsupportedOperationException("Not supported yet.");
+            throw new UnsupportedOperationException( "Not supported yet." );
         }
     }
 }
index 2f8c6408e38283457b6d23bffdaf87f5167347ef..709128e604a92f9c8d6899211c5052383082f158 100644 (file)
@@ -19,6 +19,19 @@ package org.apache.archiva.repository.scanner;
  * under the License.
  */
 
+import junit.framework.TestCase;
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import org.junit.Test;
+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 java.io.File;
 import java.io.IOException;
 import java.text.ParseException;
@@ -29,30 +42,19 @@ import java.util.List;
 import java.util.Locale;
 import java.util.TimeZone;
 
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
-import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
-
 /**
  * RepositoryScannerTest
  *
  * @version $Id$
  */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml" } )
 public class RepositoryScannerTest
-    extends PlexusInSpringTestCase
+    extends TestCase
 {
-    /**
-     * {@inheritDoc}
-     * @see org.codehaus.plexus.spring.PlexusInSpringTestCase#getSpringConfigLocation()
-     */
-    @Override
-    protected String getSpringConfigLocation()
-    {
-        return "org/apache/maven/archiva/repository/spring-context.xml";
-    }
+
+    @Inject
+    ApplicationContext applicationContext;
 
     protected ManagedRepositoryConfiguration createRepository( String id, String name, File location )
     {
@@ -73,11 +75,11 @@ public class RepositoryScannerTest
     }
 
     private static final String[] ARTIFACT_PATTERNS =
-        new String[]{"**/*.jar", "**/*.pom", "**/*.rar", "**/*.zip", "**/*.war", "**/*.tar.gz"};
+        new String[]{ "**/*.jar", "**/*.pom", "**/*.rar", "**/*.zip", "**/*.war", "**/*.tar.gz" };
 
     private ManagedRepositoryConfiguration createDefaultRepository()
     {
-        File repoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
+        File repoDir = new File( "src/test/repositories/default-repository" );
 
         assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
 
@@ -87,9 +89,9 @@ public class RepositoryScannerTest
     private ManagedRepositoryConfiguration createSimpleRepository()
         throws IOException, ParseException
     {
-        File srcDir = new File( getBasedir(), "src/test/repositories/simple-repository" );
+        File srcDir = new File( "src/test/repositories/simple-repository" );
 
-        File repoDir = getTestFile( "target/test-repos/simple-repository" );
+        File repoDir = new File( "target/test-repos/simple-repository" );
 
         FileUtils.deleteDirectory( repoDir );
 
@@ -114,7 +116,7 @@ public class RepositoryScannerTest
 
     private ManagedRepositoryConfiguration createLegacyRepository()
     {
-        File repoDir = new File( getBasedir(), "src/test/repositories/legacy-repository" );
+        File repoDir = new File( "src/test/repositories/legacy-repository" );
 
         assertTrue( "Legacy Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
 
@@ -128,15 +130,15 @@ public class RepositoryScannerTest
     {
         if ( actualCount < minimumHitCount )
         {
-            fail( "Minimum hit count on " + msg + " not satisfied.  Expected more than <" + minimumHitCount +
-                ">, but actually got <" + actualCount + ">." );
+            fail( "Minimum hit count on " + msg + " not satisfied.  Expected more than <" + minimumHitCount
+                      + ">, but actually got <" + actualCount + ">." );
         }
     }
 
     private RepositoryScanner lookupRepositoryScanner()
         throws Exception
     {
-        return (RepositoryScanner) lookup( RepositoryScanner.class );
+        return applicationContext.getBean( RepositoryScanner.class );
     }
 
     private List<String> getIgnoreList()
@@ -146,6 +148,7 @@ public class RepositoryScannerTest
         return ignores;
     }
 
+    @Test
     public void testTimestampRepositoryScanner()
         throws Exception
     {
@@ -163,7 +166,7 @@ public class RepositoryScannerTest
         RepositoryScanner scanner = lookupRepositoryScanner();
 
         RepositoryScanStatistics stats = scanner.scan( repository, knownConsumers, invalidConsumers, getIgnoreList(),
-                                                          getTimestampAsMillis( "20061101.000000" ) );
+                                                       getTimestampAsMillis( "20061101.000000" ) );
 
         assertNotNull( "Stats should not be null.", stats );
         assertEquals( "Stats.totalFileCount", 4, stats.getTotalFileCount() );
@@ -172,6 +175,7 @@ public class RepositoryScannerTest
         assertEquals( "Processed Count (of invalid items)", 1, badconsumer.getProcessCount() );
     }
 
+    @Test
     public void testTimestampRepositoryScannerFreshScan()
         throws Exception
     {
@@ -197,6 +201,7 @@ public class RepositoryScannerTest
         assertEquals( "Processed Count (of invalid items)", 1, badconsumer.getProcessCount() );
     }
 
+    @Test
     public void testTimestampRepositoryScannerProcessUnmodified()
         throws Exception
     {
@@ -214,7 +219,7 @@ public class RepositoryScannerTest
 
         RepositoryScanner scanner = lookupRepositoryScanner();
         RepositoryScanStatistics stats = scanner.scan( repository, knownConsumers, invalidConsumers, getIgnoreList(),
-                                                          getTimestampAsMillis( "20061101.000000" ) );
+                                                       getTimestampAsMillis( "20061101.000000" ) );
 
         assertNotNull( "Stats should not be null.", stats );
         assertEquals( "Stats.totalFileCount", 4, stats.getTotalFileCount() );
@@ -223,6 +228,7 @@ public class RepositoryScannerTest
         assertEquals( "Processed Count (of invalid items)", 1, badconsumer.getProcessCount() );
     }
 
+    @Test
     public void testDefaultRepositoryScanner()
         throws Exception
     {
@@ -230,8 +236,9 @@ public class RepositoryScannerTest
 
         List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
         KnownScanConsumer consumer = new KnownScanConsumer();
-        consumer.setIncludes( new String[]{"**/*.jar", "**/*.war", "**/*.pom", "**/maven-metadata.xml", "**/*-site.xml",
-            "**/*.zip", "**/*.tar.gz", "**/*.sha1", "**/*.md5"} );
+        consumer.setIncludes(
+            new String[]{ "**/*.jar", "**/*.war", "**/*.pom", "**/maven-metadata.xml", "**/*-site.xml", "**/*.zip",
+                "**/*.tar.gz", "**/*.sha1", "**/*.md5" } );
         knownConsumers.add( consumer );
 
         List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
@@ -248,6 +255,7 @@ public class RepositoryScannerTest
         assertEquals( "Processed Count (of invalid items)", 6, badconsumer.getProcessCount() );
     }
 
+    @Test
     public void testDefaultRepositoryArtifactScanner()
         throws Exception
     {
@@ -305,6 +313,7 @@ public class RepositoryScannerTest
         assertMinimumHits( "Processed Count", actualArtifactPaths.size(), consumer.getProcessCount() );
     }
 
+    @Test
     public void testDefaultRepositoryMetadataScanner()
         throws Exception
     {
@@ -325,7 +334,7 @@ public class RepositoryScannerTest
 
         List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
         KnownScanConsumer knownConsumer = new KnownScanConsumer();
-        knownConsumer.setIncludes( new String[]{"**/maven-metadata*.xml"} );
+        knownConsumer.setIncludes( new String[]{ "**/maven-metadata*.xml" } );
         knownConsumers.add( knownConsumer );
 
         List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
@@ -341,6 +350,7 @@ public class RepositoryScannerTest
         assertMinimumHits( "Processed Count", actualMetadataPaths.size(), knownConsumer.getProcessCount() );
     }
 
+    @Test
     public void testDefaultRepositoryProjectScanner()
         throws Exception
     {
@@ -361,7 +371,7 @@ public class RepositoryScannerTest
 
         List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
         KnownScanConsumer consumer = new KnownScanConsumer();
-        consumer.setIncludes( new String[]{"**/*.pom"} );
+        consumer.setIncludes( new String[]{ "**/*.pom" } );
         knownConsumers.add( consumer );
 
         List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
@@ -377,6 +387,7 @@ public class RepositoryScannerTest
         assertMinimumHits( "Processed Count", actualProjectPaths.size(), consumer.getProcessCount() );
     }
 
+    @Test
     public void testLegacyRepositoryArtifactScanner()
         throws Exception
     {
index 086f0436fed84b67c1ff36ea7395b24fd9ce1917..874567d59c1865986c9bc3965052c9e4f5bcc814 100644 (file)
@@ -32,7 +32,7 @@ import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
  *
  * @version $Id$
  * 
- * @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
+ * plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
  *                   role-hint="sample-known"
  */
 public class SampleKnownConsumer
@@ -40,7 +40,7 @@ public class SampleKnownConsumer
     implements KnownRepositoryContentConsumer
 {
     /**
-     * @plexus.configuration default-value="unset-id"
+     * plexus.configuration default-value="unset-id"
      */
     private String id = "unset-id";
     
@@ -102,4 +102,9 @@ public class SampleKnownConsumer
     {
         return false;
     }
+
+    public void setId( String id )
+    {
+        this.id = id;
+    }
 }
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/resources/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.xml b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/resources/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.xml
deleted file mode 100644 (file)
index acf9795..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-  ~ 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.
-  -->
-
-<component-set>
-  <components>
-    <component>
-      <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
-      <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
-      <requirements>
-        <requirement>
-          <role>org.codehaus.plexus.registry.Registry</role>
-          <role-hint>configured</role-hint>
-        </requirement>
-        <requirement>
-          <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role>
-          <field-name>prePolicies</field-name>
-        </requirement>
-        <requirement>
-          <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role>
-          <field-name>postPolicies</field-name>
-        </requirement>
-      </requirements>
-    </component>
-    <component>
-      <role>org.codehaus.plexus.registry.Registry</role>
-      <role-hint>configured</role-hint>
-      <implementation>org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry</implementation>
-      <configuration>
-        <properties>
-        <![CDATA[
-      <configuration>
-          <system/>
-          <xml fileName="${basedir}/src/test/resources/scanner-archiva.xml"
-               config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
-      </configuration>
-        ]]>
-        </properties>
-      </configuration>
-    </component>
-
-    <!-- Known Content Consumers -->
-    <component>
-      <role>org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer</role>
-      <role-hint>update-db-artifact</role-hint>
-      <implementation>org.apache.archiva.repository.scanner.SampleKnownConsumer</implementation>
-      <configuration>
-        <id>update-db-artifact</id>
-      </configuration>
-    </component>
-    <component>
-      <role>org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer</role>
-      <role-hint>create-missing-checksums</role-hint>
-      <implementation>org.apache.archiva.repository.scanner.SampleKnownConsumer</implementation>
-      <configuration>
-        <id>create-missing-checksums</id>
-      </configuration>
-    </component>
-    <component>
-      <role>org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer</role>
-      <role-hint>update-db-repository-metadata</role-hint>
-      <implementation>org.apache.archiva.repository.scanner.SampleKnownConsumer</implementation>
-      <configuration>
-        <id>update-db-repository-metadata</id>
-      </configuration>
-    </component>
-    <component>
-      <role>org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer</role>
-      <role-hint>validate-checksum</role-hint>
-      <implementation>org.apache.archiva.repository.scanner.SampleKnownConsumer</implementation>
-      <configuration>
-        <id>validate-checksum</id>
-      </configuration>
-    </component>
-    <component>
-      <role>org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer</role>
-      <role-hint>index-content</role-hint>
-      <implementation>org.apache.archiva.repository.scanner.SampleKnownConsumer</implementation>
-      <configuration>
-        <id>index-content</id>
-      </configuration>
-    </component>
-    <component>
-      <role>org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer</role>
-      <role-hint>auto-remove</role-hint>
-      <implementation>org.apache.archiva.repository.scanner.SampleKnownConsumer</implementation>
-      <configuration>
-        <id>auto-remove</id>
-      </configuration>
-    </component>
-    <component>
-      <role>org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer</role>
-      <role-hint>auto-rename</role-hint>
-      <implementation>org.apache.archiva.repository.scanner.SampleKnownConsumer</implementation>
-      <configuration>
-        <id>auto-rename</id>
-      </configuration>
-    </component>
-    <component>
-      <role>org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer</role>
-      <role-hint>available-but-unselected</role-hint>
-      <implementation>org.apache.archiva.repository.scanner.SampleKnownConsumer</implementation>
-      <configuration>
-        <id>available-but-unselected</id>
-      </configuration>
-    </component>
-    
-    <!-- Invalid Content Consumers -->
-    <component>
-      <role>org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer</role>
-      <role-hint>update-db-bad-content</role-hint>
-      <implementation>org.apache.archiva.repository.scanner.InvalidScanConsumer</implementation>
-      <configuration>
-        <id>update-db-bad-content</id>
-      </configuration>
-    </component>
-    <component>
-      <role>org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer</role>
-      <role-hint>move-to-trash-then-notify</role-hint>
-      <implementation>org.apache.archiva.repository.scanner.InvalidScanConsumer</implementation>
-      <configuration>
-        <id>move-to-trash-then-notify</id>
-      </configuration>
-    </component>
-    <component>
-      <role>org.apache.archiva.repository.scanner.RepositoryContentConsumers</role>
-      <role-hint>test</role-hint>
-      <implementation>org.apache.archiva.repository.scanner.RepositoryContentConsumersStub</implementation>  
-    </component>
-  </components>
-
-</component-set>
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/resources/spring-context.xml
new file mode 100644 (file)
index 0000000..69c2d28
--- /dev/null
@@ -0,0 +1,92 @@
+<?xml version="1.0"?>
+
+<!--
+  ~ 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.
+  -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       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">
+
+  <bean name="archivaConfiguration#test-conf" class="org.apache.maven.archiva.configuration.DefaultArchivaConfiguration">
+    <property name="registry" ref="registry#configured"/>
+  </bean>
+
+  <bean name="registry#configured" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
+    <property name="properties">
+      <value>
+        <![CDATA[
+      <configuration>
+          <system/>
+          <xml fileName="${basedir}/src/test/resources/scanner-archiva.xml"
+               config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
+      </configuration>
+        ]]>
+      </value>
+    </property>
+  </bean>
+  <bean name="knownRepositoryContentConsumer#update-db-artifact" class="org.apache.archiva.repository.scanner.SampleKnownConsumer">
+    <property name="id" value="update-db-artifact"/>
+  </bean>
+  <bean name="knownRepositoryContentConsumer#create-missing-checksums" class="org.apache.archiva.repository.scanner.SampleKnownConsumer">
+    <property name="id" value="create-missing-checksums"/>
+  </bean>
+
+  <bean name="knownRepositoryContentConsumer#update-db-repository-metadata" class="org.apache.archiva.repository.scanner.SampleKnownConsumer">
+    <property name="id" value="update-db-repository-metadata"/>
+  </bean>
+
+  <bean name="knownRepositoryContentConsumer#validate-checksum" class="org.apache.archiva.repository.scanner.SampleKnownConsumer">
+    <property name="id" value="validate-checksum"/>
+  </bean>
+
+  <bean name="knownRepositoryContentConsumer#index-content" class="org.apache.archiva.repository.scanner.SampleKnownConsumer">
+    <property name="id" value="index-content"/>
+  </bean>
+
+  <bean name="knownRepositoryContentConsumer#auto-remove" class="org.apache.archiva.repository.scanner.SampleKnownConsumer">
+    <property name="id" value="auto-remove"/>
+  </bean>
+
+  <bean name="knownRepositoryContentConsumer#auto-rename" class="org.apache.archiva.repository.scanner.SampleKnownConsumer">
+    <property name="id" value="auto-rename"/>
+  </bean>
+
+  <bean name="knownRepositoryContentConsumer#available-but-unselected" class="org.apache.archiva.repository.scanner.SampleKnownConsumer">
+    <property name="id" value="available-but-unselected"/>
+  </bean>
+
+  <bean name="invalidRepositoryContentConsumer#update-db-bad-content" class="org.apache.archiva.repository.scanner.InvalidScanConsumer">
+    <property name="id" value="update-db-bad-content"/>
+  </bean>
+
+  <bean name="invalidRepositoryContentConsumer#move-to-trash-then-notify" class="org.apache.archiva.repository.scanner.InvalidScanConsumer">
+    <property name="id" value="move-to-trash-then-notify"/>
+  </bean>
+
+  <bean name="repositoryContentConsumers#test" class="org.apache.archiva.repository.scanner.RepositoryContentConsumersStub">
+    <constructor-arg ref="archivaConfiguration#test-conf"/>
+  </bean>
+
+
+
+</beans>