diff options
author | Olivier Lamy <olamy@apache.org> | 2011-05-30 21:36:05 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2011-05-30 21:36:05 +0000 |
commit | 39ecc7836c581e56d068149103f9573e409619a1 (patch) | |
tree | a5652b74e71ad7838d99af55eab3974028685687 /archiva-modules | |
parent | 949cb108d86de3b9d90f04f0870787a23259fef9 (diff) | |
download | archiva-39ecc7836c581e56d068149103f9573e409619a1.tar.gz archiva-39ecc7836c581e56d068149103f9573e409619a1.zip |
remove plexus-spring use : archiva-scheduler-indexing
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1129386 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
12 files changed, 207 insertions, 83 deletions
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java index eccd7cb5e..8205bda4a 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java @@ -1170,4 +1170,83 @@ public class DefaultRepositoryProxyConnectors /* do nothing */ } + public ArchivaConfiguration getArchivaConfiguration() + { + return archivaConfiguration; + } + + public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration ) + { + this.archivaConfiguration = archivaConfiguration; + } + + public RepositoryContentFactory getRepositoryFactory() + { + return repositoryFactory; + } + + public void setRepositoryFactory( RepositoryContentFactory repositoryFactory ) + { + this.repositoryFactory = repositoryFactory; + } + + public MetadataTools getMetadataTools() + { + return metadataTools; + } + + public void setMetadataTools( MetadataTools metadataTools ) + { + this.metadataTools = metadataTools; + } + + public UrlFailureCache getUrlFailureCache() + { + return urlFailureCache; + } + + public void setUrlFailureCache( UrlFailureCache urlFailureCache ) + { + this.urlFailureCache = urlFailureCache; + } + + public WagonFactory getWagonFactory() + { + return wagonFactory; + } + + public void setWagonFactory( WagonFactory wagonFactory ) + { + this.wagonFactory = wagonFactory; + } + + public Map<String, PreDownloadPolicy> getPreDownloadPolicies() + { + return preDownloadPolicies; + } + + public void setPreDownloadPolicies( Map<String, PreDownloadPolicy> preDownloadPolicies ) + { + this.preDownloadPolicies = preDownloadPolicies; + } + + public Map<String, PostDownloadPolicy> getPostDownloadPolicies() + { + return postDownloadPolicies; + } + + public void setPostDownloadPolicies( Map<String, PostDownloadPolicy> postDownloadPolicies ) + { + this.postDownloadPolicies = postDownloadPolicies; + } + + public Map<String, DownloadErrorPolicy> getDownloadErrorPolicies() + { + return downloadErrorPolicies; + } + + public void setDownloadErrorPolicies( Map<String, DownloadErrorPolicy> downloadErrorPolicies ) + { + this.downloadErrorPolicies = downloadErrorPolicies; + } } diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index 73b8616cc..a40c79da3 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -24,6 +24,7 @@ import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectVersionReference; +import org.springframework.stereotype.Service; import java.util.Collection; import java.util.Collections; @@ -31,6 +32,8 @@ import java.util.Date; import java.util.List; // TODO: remove, it does nothing + +@Service public class TestMetadataRepository implements MetadataRepository { diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java index a2135c48d..7d206b0b7 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java @@ -135,7 +135,7 @@ public abstract class AbstractProxyTestCase { super.setUp(); - proxyHandler = applicationContext.getBean( RepositoryProxyConnectors.class ); + proxyHandler = applicationContext.getBean("repositoryProxyConnectors#default", RepositoryProxyConnectors.class ); config = (MockConfiguration) applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class ); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java index ebcf5cb4e..7c56b61d4 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java @@ -103,7 +103,7 @@ public class MetadataTransferTest public void init() throws Exception { - //super.setUp(); + super.setUp(); //metadataTools = applicationContext.getBean( MetadataTools.class ); } diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/WagonDelegate.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/WagonDelegate.java index 901567022..d601e31b5 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/WagonDelegate.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/WagonDelegate.java @@ -57,7 +57,7 @@ public class WagonDelegate public void get( String resourceName, File destination ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { - log.debug( ".get(" + resourceName + ", " + destination + ")" ); + log.debug( ".get({}, {})", resourceName, destination ); delegate.get( resourceName, destination ); create( destination ); } diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/MetadataTransferTest.xml b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/MetadataTransferTest.xml index 97423198d..6830d1ee4 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/MetadataTransferTest.xml +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/MetadataTransferTest.xml @@ -29,6 +29,7 @@ <role-hint>mock</role-hint> <implementation>org.apache.maven.archiva.proxy.MockConfiguration</implementation> </component> + <component> <role>org.apache.maven.archiva.repository.RepositoryContentFactory</role> <role-hint>mocked</role-hint> diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/spring-context.xml index 84f08847d..319666892 100755 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/spring-context.xml +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/spring-context.xml @@ -45,4 +45,14 @@ </property> </bean> + <bean name="repositoryProxyConnectors#default" class="org.apache.maven.archiva.proxy.DefaultRepositoryProxyConnectors"> + <property name="archivaConfiguration" ref="archivaConfiguration#mock"/> + </bean> + + <bean name="metadataTools#default" class="org.apache.maven.archiva.repository.metadata.MetadataTools"> + <property name="configuration" ref="archivaConfiguration#mock"/> + </bean> + + + </beans>
\ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml index 52547cc20..4c3dbabf7 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml @@ -27,6 +27,10 @@ <artifactId>javax.inject</artifactId> </dependency> <dependency> + <groupId>org.apache.archiva</groupId> + <artifactId>archiva-plexus-bridge</artifactId> + </dependency> + <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> @@ -36,26 +40,4 @@ <scope>test</scope> </dependency> </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-component-metadata</artifactId> - <executions> - <execution> - <id>merge</id> - <goals> - <goal>merge-metadata</goal> - </goals> - <configuration> - <descriptors> - <descriptor>${basedir}/src/main/resources/META-INF/plexus/components.xml</descriptor> - <descriptor>${project.build.outputDirectory}/META-INF/plexus/components.xml</descriptor> - </descriptors> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> </project> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java index c4a3e2f32..beef4434b 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java @@ -19,16 +19,13 @@ package org.apache.archiva.scheduler.indexing; * under the License. */ -import java.io.File; -import java.io.IOException; - +import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; +import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.taskqueue.Task; import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; import org.codehaus.plexus.taskqueue.execution.TaskExecutor; @@ -44,32 +41,52 @@ import org.sonatype.nexus.index.context.IndexingContext; import org.sonatype.nexus.index.context.UnsupportedExistingLuceneIndexException; import org.sonatype.nexus.index.packer.IndexPacker; import org.sonatype.nexus.index.packer.IndexPackingRequest; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; +import java.io.File; +import java.io.IOException; /** * ArchivaIndexingTaskExecutor Executes all indexing tasks. Adding, updating and removing artifacts from the index are * all performed by this executor. Add and update artifact in index tasks are added in the indexing task queue by the * NexusIndexerConsumer while remove artifact from index tasks are added by the LuceneCleanupRemoveIndexedConsumer. - * - * @plexus.component role="org.codehaus.plexus.taskqueue.execution.TaskExecutor" role-hint="indexing" - * instantiation-strategy="singleton" + * <p/> + * plexus.component role="org.codehaus.plexus.taskqueue.execution.TaskExecutor" role-hint="indexing" + * instantiation-strategy="singleton" */ +@Service( "taskExecutor#indexing" ) public class ArchivaIndexingTaskExecutor - implements TaskExecutor, Initializable + implements TaskExecutor { private Logger log = LoggerFactory.getLogger( ArchivaIndexingTaskExecutor.class ); /** - * @plexus.requirement + * plexus.requirement */ private IndexerEngine indexerEngine; /** - * @plexus.requirement + * plexus.requirement */ private IndexPacker indexPacker; private ArtifactContextProducer artifactContextProducer; + private PlexusSisuBridge plexusSisuBridge; + + public void initialize() + throws PlexusSisuBridgeException + { + log.info( "Initialized {}", this.getClass().getName() ); + + artifactContextProducer = new DefaultArtifactContextProducer(); + + indexerEngine = plexusSisuBridge.lookup( IndexerEngine.class ); + + indexPacker = plexusSisuBridge.lookup( IndexPacker.class ); + } + public void executeTask( Task task ) throws TaskExecutionException { @@ -89,22 +106,23 @@ public class ArchivaIndexingTaskExecutor else { // create context if not a repo scan request - if( !indexingTask.isExecuteOnEntireRepo() ) + if ( !indexingTask.isExecuteOnEntireRepo() ) { try { - log.debug( "Creating indexing context on resource: " + indexingTask.getResourceFile().getPath() ); + log.debug( + "Creating indexing context on resource: {}", indexingTask.getResourceFile().getPath() ); context = ArtifactIndexingTask.createContext( repository ); } - catch( IOException e ) + catch ( IOException e ) { log.error( "Error occurred while creating context: " + e.getMessage() ); throw new TaskExecutionException( "Error occurred while creating context: " + e.getMessage() ); } - catch( UnsupportedExistingLuceneIndexException e ) + catch ( UnsupportedExistingLuceneIndexException e ) { log.error( "Error occurred while creating context: " + e.getMessage() ); - throw new TaskExecutionException( "Error occurred while creating context: " + e.getMessage() ); + throw new TaskExecutionException( "Error occurred while creating context: " + e.getMessage() ); } } @@ -112,7 +130,7 @@ public class ArchivaIndexingTaskExecutor { throw new TaskExecutionException( "Trying to index an artifact but the context is already closed" ); } - + try { File artifactFile = indexingTask.getResourceFile(); @@ -127,27 +145,28 @@ public class ArchivaIndexingTaskExecutor TopDocs d = s.search( new TermQuery( new Term( ArtifactInfo.UINFO, uinfo ) ), 1 ); if ( d.totalHits == 0 ) { - log.debug( "Adding artifact '" + ac.getArtifactInfo() + "' to index.." ); + log.debug( "Adding artifact '{}' to index..", ac.getArtifactInfo() ); indexerEngine.index( context, ac ); context.getIndexWriter().commit(); } else { - log.debug( "Updating artifact '" + ac.getArtifactInfo() + "' in index.." ); + log.debug( "Updating artifact '{}' in index..", ac.getArtifactInfo() ); indexerEngine.update( context, ac ); context.getIndexWriter().commit(); } // close the context if not a repo scan request - if( !indexingTask.isExecuteOnEntireRepo() ) + if ( !indexingTask.isExecuteOnEntireRepo() ) { - log.debug( "Finishing indexing task on resource file : " + indexingTask.getResourceFile().getPath() ); - finishIndexingTask( indexingTask, repository, context ); + log.debug( "Finishing indexing task on resource file : {}", + indexingTask.getResourceFile().getPath() ); + finishIndexingTask( indexingTask, repository, context ); } } else { - log.debug( "Removing artifact '" + ac.getArtifactInfo() + "' from index.." ); + log.debug( "Removing artifact '{}' from index..", ac.getArtifactInfo() ); indexerEngine.remove( context, ac ); context.getIndexWriter().commit(); } @@ -155,9 +174,10 @@ public class ArchivaIndexingTaskExecutor } catch ( IOException e ) { - log.error( "Error occurred while executing indexing task '" + indexingTask + "': " + e.getMessage() ); - throw new TaskExecutionException( "Error occurred while executing indexing task '" + indexingTask - + "'", e ); + log.error( + "Error occurred while executing indexing task '" + indexingTask + "': " + e.getMessage() ); + throw new TaskExecutionException( + "Error occurred while executing indexing task '" + indexingTask + "'", e ); } catch ( IllegalArtifactCoordinateException e ) { @@ -181,13 +201,13 @@ public class ArchivaIndexingTaskExecutor IndexPackingRequest request = new IndexPackingRequest( context, indexLocation ); indexPacker.packIndex( request ); - log.debug( "Index file packaged at '" + indexLocation.getPath() + "'." ); + log.debug( "Index file packaged at '{}'.", indexLocation.getPath() ); } catch ( IOException e ) { log.error( "Error occurred while executing indexing task '" + indexingTask + "': " + e.getMessage() ); - throw new TaskExecutionException( "Error occurred while executing indexing task '" + indexingTask - + "'", e ); + throw new TaskExecutionException( "Error occurred while executing indexing task '" + indexingTask + "'", + e ); } finally { @@ -206,13 +226,7 @@ public class ArchivaIndexingTaskExecutor } } - public void initialize() - throws InitializationException - { - log.info( "Initialized " + this.getClass().getName() ); - artifactContextProducer = new DefaultArtifactContextProducer(); - } public void setIndexerEngine( IndexerEngine indexerEngine ) { diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/IndexingArchivaTaskScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/IndexingArchivaTaskScheduler.java index a0280ee53..46282c21f 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/IndexingArchivaTaskScheduler.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/IndexingArchivaTaskScheduler.java @@ -24,6 +24,10 @@ import org.codehaus.plexus.taskqueue.TaskQueue; import org.codehaus.plexus.taskqueue.TaskQueueException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.inject.Inject; +import javax.inject.Named; /** * Default implementation of a scheduling component for archiva. @@ -31,14 +35,17 @@ import org.slf4j.LoggerFactory; * @todo TODO - consider just folding in, not really scheduled * @plexus.component role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="indexing" */ +@Service("archivaTaskScheduler#indexing") public class IndexingArchivaTaskScheduler implements ArchivaTaskScheduler<ArtifactIndexingTask> { private Logger log = LoggerFactory.getLogger( IndexingArchivaTaskScheduler.class ); /** - * @plexus.requirement role-hint="indexing" + * plexus.requirement role-hint="indexing" */ + @Inject + @Named(value = "taskQueue#indexing") private TaskQueue indexingQueue; public void queueTask( ArtifactIndexingTask task ) diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/spring-context.xml index 0b06d1c6c..32a077bab 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/spring-context.xml @@ -26,7 +26,19 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-lazy-init="true"> - <bean id="logger" class="org.apache.maven.archiva.common.utils.Slf4JPlexusLogger"> - <constructor-arg type="java.lang.Class"><value>org.sonatype.nexus.index.DefaultNexusIndexer</value></constructor-arg> - </bean> + <context:annotation-config/> + <context:component-scan base-package="org.apache.archiva.scheduler.indexing"/> + + <bean id="logger" class="org.apache.maven.archiva.common.utils.Slf4JPlexusLogger"> + <constructor-arg type="java.lang.Class"><value>org.sonatype.nexus.index.DefaultNexusIndexer</value></constructor-arg> + </bean> + + <bean name="taskQueue#indexing" class="org.codehaus.plexus.taskqueue.DefaultTaskQueue"/> + + <bean name="taskQueueExecutor#indexing" class="org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor"> + <property name="executor" ref="taskExecutor#indexing"/> + <property name="queue" ref="taskQueue#indexing"/> + <property name="name" value="indexing"/> + </bean> + </beans>
\ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java index 077299c39..55cfaabfd 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java @@ -19,17 +19,8 @@ package org.apache.archiva.scheduler.indexing; * under the License. */ -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Set; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - +import junit.framework.TestCase; +import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.commons.io.FileUtils; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanQuery; @@ -38,7 +29,9 @@ import org.apache.lucene.search.TopDocs; import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.sonatype.nexus.index.ArtifactInfo; import org.sonatype.nexus.index.FlatSearchRequest; import org.sonatype.nexus.index.FlatSearchResponse; @@ -46,12 +39,26 @@ import org.sonatype.nexus.index.IndexerEngine; import org.sonatype.nexus.index.NexusIndexer; import org.sonatype.nexus.index.context.IndexingContext; import org.sonatype.nexus.index.packer.IndexPacker; +import org.springframework.test.context.ContextConfiguration; + +import javax.inject.Inject; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; /** * ArchivaIndexingTaskExecutorTest */ +@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath*:/spring-context.xml"} ) public class ArchivaIndexingTaskExecutorTest - extends PlexusInSpringTestCase + extends TestCase { private ArchivaIndexingTaskExecutor indexingExecutor; @@ -67,7 +74,11 @@ public class ArchivaIndexingTaskExecutorTest private IndexingContext context; - protected void setUp() + @Inject + PlexusSisuBridge plexusSisuBridge; + + @Before + public void setUp() throws Exception { super.setUp(); @@ -77,7 +88,7 @@ public class ArchivaIndexingTaskExecutorTest repositoryConfig = new ManagedRepositoryConfiguration(); repositoryConfig.setId( "test-repo" ); - repositoryConfig.setLocation( getBasedir() + "/target/test-classes/test-repo" ); + repositoryConfig.setLocation( "/target/test-classes/test-repo" ); repositoryConfig.setLayout( "default" ); repositoryConfig.setName( "Test Repository" ); repositoryConfig.setScanned( true ); @@ -87,9 +98,9 @@ public class ArchivaIndexingTaskExecutorTest configuration = new Configuration(); configuration.addManagedRepository( repositoryConfig ); - indexer = (NexusIndexer) lookup( NexusIndexer.class ); - indexerEngine = (IndexerEngine) lookup( IndexerEngine.class ); - indexPacker = (IndexPacker) lookup( IndexPacker.class ); + indexer = plexusSisuBridge.lookup( NexusIndexer.class ); + indexerEngine = plexusSisuBridge.lookup( IndexerEngine.class ); + indexPacker = plexusSisuBridge.lookup( IndexPacker.class ); indexingExecutor.setIndexerEngine( indexerEngine ); indexingExecutor.setIndexPacker( indexPacker ); @@ -97,7 +108,8 @@ public class ArchivaIndexingTaskExecutorTest context = ArtifactIndexingTask.createContext( repositoryConfig ); } - protected void tearDown() + @After + public void tearDown() throws Exception { context.close( true ); @@ -115,6 +127,7 @@ public class ArchivaIndexingTaskExecutorTest super.tearDown(); } + @Test public void testAddArtifactToIndex() throws Exception { @@ -155,6 +168,7 @@ public class ArchivaIndexingTaskExecutorTest context.close( true ); } + @Test public void testUpdateArtifactInIndex() throws Exception { @@ -184,6 +198,7 @@ public class ArchivaIndexingTaskExecutorTest assertEquals( 1, topDocs.totalHits ); } + @Test public void testRemoveArtifactFromIndex() throws Exception { @@ -241,6 +256,7 @@ public class ArchivaIndexingTaskExecutorTest // TODO: test it was removed from the packaged index also } + @Test public void testPackagedIndex() throws Exception { |