From 8233856ae41fe614e527773a278e6bd4e8a19f83 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 27 Jun 2011 07:45:32 +0000 Subject: [PATCH] retrieve IndexSearcher from NexusIndexer instead of manual creation to prevent lucene locks git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1140036 13f79535-47bb-0310-9956-ffa450edef68 --- .../indexing/ArchivaIndexingTaskExecutorTest.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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 c8cc90533..bdbc23feb 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 @@ -26,7 +26,6 @@ import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.TopDocs; -import org.apache.lucene.store.SimpleFSDirectory; import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; @@ -175,7 +174,7 @@ public class ArchivaIndexingTaskExecutorTest Set results = response.getResults(); - ArtifactInfo artifactInfo = (ArtifactInfo) results.iterator().next(); + ArtifactInfo artifactInfo = results.iterator().next(); assertEquals( "org.apache.archiva", artifactInfo.groupId ); assertEquals( "archiva-index-methods-jar-test", artifactInfo.artifactId ); assertEquals( "test-repo", artifactInfo.repository ); @@ -203,8 +202,7 @@ public class ArchivaIndexingTaskExecutorTest indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ), Occur.SHOULD ); - IndexSearcher searcher = - new IndexSearcher( new SimpleFSDirectory( new File( repositoryConfig.getLocation() + "/.indexer" ) ) ); + IndexSearcher searcher = nexusIndexer.getIndexingContexts().get( repositoryConfig.getId() ).getIndexSearcher(); TopDocs topDocs = searcher.search( q, null, 10 ); searcher.close(); @@ -236,8 +234,7 @@ public class ArchivaIndexingTaskExecutorTest indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ), Occur.SHOULD ); - IndexSearcher searcher = - new IndexSearcher( new SimpleFSDirectory( new File( repositoryConfig.getLocation() + "/.indexer" ) ) ); + IndexSearcher searcher = nexusIndexer.getIndexingContexts().get( repositoryConfig.getId() ).getIndexSearcher(); TopDocs topDocs = searcher.search( q, null, 10 ); @@ -267,8 +264,7 @@ public class ArchivaIndexingTaskExecutorTest indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ), Occur.SHOULD ); - searcher = - new IndexSearcher( new SimpleFSDirectory( new File( repositoryConfig.getLocation() + "/.indexer" ) ) ); + searcher = nexusIndexer.getIndexingContexts().get( repositoryConfig.getId() ).getIndexSearcher(); topDocs = searcher.search( q, null, 10 );