From 7e78123c09e44aa7d9cfcf6b6f548d6c7e764f3c Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 30 May 2011 10:54:47 +0000 Subject: [PATCH] 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 --- .../core/repository/RepositoryPurgeConsumer.java | 6 +++++- .../core/repository/RepositoryPurgeConsumerTest.java | 12 ++++++------ .../resources/spring-context-purge-consumer-test.xml | 5 +++++ .../content/ManagedDefaultRepositoryContent.java | 2 ++ .../archiva/repository/metadata/MetadataTools.java | 1 + 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java index 58391ef1b..0f1a99975 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java @@ -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 includes = new ArrayList(); @@ -113,7 +117,7 @@ public class RepositoryPurgeConsumer /** * TODO: this could be multiple implementations and needs to be configured. - * + *

* plexus.requirement */ @Inject diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java index 01a18b7f1..16f2c9e73 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java @@ -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 ); } } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml index 9c38603dd..ff3c158ff 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml @@ -42,6 +42,9 @@ + + + @@ -63,6 +66,8 @@ + + diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java index ea7e47795..3d2e68dec 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ManagedDefaultRepositoryContent.java @@ -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; diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java index becf93038..8491fdd30 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java @@ -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 };