fix unit tests with adding some names for injected beans

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1129122 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-05-30 10:54:47 +00:00
parent 188f5fbd05
commit 7e78123c09
5 changed files with 19 additions and 7 deletions

View File

@ -42,6 +42,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@ -75,12 +76,14 @@ public class RepositoryPurgeConsumer
* plexus.requirement
*/
@Inject
@Named( value = "archivaConfiguration#default" )
private ArchivaConfiguration configuration;
/**
* plexus.requirement
*/
@Inject
@Named(value = "repositoryContentFactory#default")
private RepositoryContentFactory repositoryContentFactory;
/**
@ -93,6 +96,7 @@ public class RepositoryPurgeConsumer
* plexus.requirement
*/
@Inject
@Named(value = "fileTypes")
private FileTypes filetypes;
private List<String> includes = new ArrayList<String>();
@ -113,7 +117,7 @@ public class RepositoryPurgeConsumer
/**
* TODO: this could be multiple implementations and needs to be configured.
*
* <p/>
* plexus.requirement
*/
@Inject

View File

@ -19,7 +19,6 @@ package org.apache.maven.archiva.consumers.core.repository;
* under the License.
*/
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.metadata.repository.TestRepositorySessionFactory;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.common.utils.BaseFile;
@ -39,7 +38,8 @@ import java.io.File;
/**
*/
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-purge-consumer-test.xml" } )
@ContextConfiguration(
locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-purge-consumer-test.xml" } )
public class RepositoryPurgeConsumerTest
extends AbstractRepositoryPurgeTest
{
@ -60,10 +60,10 @@ public class RepositoryPurgeConsumerTest
private void assertNotConsumed( String path )
throws Exception
{
ArchivaConfiguration archivaConfiguration = applicationContext.getBean( ArchivaConfiguration.class );
ArchivaConfiguration archivaConfiguration =
applicationContext.getBean( "archivaConfiguration#default", ArchivaConfiguration.class );
FileType fileType =
(FileType) archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 );
FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 );
assertEquals( FileTypes.ARTIFACTS, fileType.getId() );
fileType.addPattern( "**/*.xml" );
@ -307,7 +307,7 @@ public class RepositoryPurgeConsumerTest
{
super.setUp();
TestRepositorySessionFactory factory = applicationContext.getBean( TestRepositorySessionFactory.class );
TestRepositorySessionFactory factory = applicationContext.getBean( TestRepositorySessionFactory.class );
factory.setRepository( metadataRepository );
}
}

View File

@ -42,6 +42,9 @@
<property name="registry" ref="registry#retention-count"/>
</bean>
<alias name="archivaConfiguration#retention-count" alias="archivaConfiguration"/>
<alias name="archivaConfiguration#retention-count" alias="archivaConfiguration#default"/>
<bean name="repositoryContentFactory#retention-count" class="org.apache.maven.archiva.repository.RepositoryContentFactory">
<property name="archivaConfiguration" ref="archivaConfiguration#retention-count"/>
</bean>
@ -63,6 +66,8 @@
<property name="archivaConfiguration" ref="archivaConfiguration#retention-count"/>
</bean>
<alias name="filetypes#retention-count" alias="filetypes"/>
<!-- for testing repo purge by # of days old and delete cleanupSnapshots -->
<bean name="knownRepositoryContentConsumer#repo-purge-consumer-by-days-old" class="org.apache.maven.archiva.consumers.core.repository.RepositoryPurgeConsumer">
<property name="configuration" ref="archivaConfiguration#days-old"/>

View File

@ -35,6 +35,7 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
@ -58,6 +59,7 @@ public class ManagedDefaultRepositoryContent
implements ManagedRepositoryContent
{
@Inject
@Named(value = "fileTypes" )
private FileTypes filetypes;
private ManagedRepositoryConfiguration repository;

View File

@ -100,6 +100,7 @@ public class MetadataTools
* plexus.requirement
*/
@Inject
@Named(value = "fileTypes")
private FileTypes filetypes;
private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };