From 269a68dc2d868d35d99db8671d4619f2a3aabc8b Mon Sep 17 00:00:00 2001 From: "Edwin L. Punzalan" Date: Thu, 22 Dec 2005 08:38:32 +0000 Subject: [PATCH] More unit tests git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@358530 13f79535-47bb-0310-9956-ffa450edef68 --- maven-repository-indexer/pom.xml | 5 ++ .../indexing/AbstractRepositoryIndexer.java | 59 ++++++++++++++----- .../indexing/ArtifactRepositoryIndexer.java | 1 - .../ArtifactRepositoryIndexingTest.java | 18 ++++++ 4 files changed, 68 insertions(+), 15 deletions(-) diff --git a/maven-repository-indexer/pom.xml b/maven-repository-indexer/pom.xml index ba6eea996..7d1fc5fd9 100644 --- a/maven-repository-indexer/pom.xml +++ b/maven-repository-indexer/pom.xml @@ -24,6 +24,11 @@ lucene 1.4.3 + + org.codehaus.plexus + plexus-utils + test + org.codehaus.plexus plexus-container-default diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndexer.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndexer.java index 79ba90b25..41f8494b4 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndexer.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndexer.java @@ -17,6 +17,7 @@ package org.apache.maven.repository.indexing; * limitations under the License. */ +import java.io.File; import java.io.IOException; import java.util.Collection; @@ -110,7 +111,7 @@ public abstract class AbstractRepositoryIndexer { if ( indexWriter == null ) { - indexWriter = new IndexWriter( indexPath, getAnalyzer(), true ); + indexWriter = new IndexWriter( indexPath, getAnalyzer(), false ); } } @@ -131,26 +132,56 @@ public abstract class AbstractRepositoryIndexer protected void validateIndex() throws RepositoryIndexerException { - indexOpen = true; - if ( true ) return; - try + File indexDir = new File( indexPath ); + if ( indexDir.exists() ) { - getIndexReader(); - Collection fields = indexReader.getFieldNames(); - String[] indexFields = getIndexFields(); - for( int idx=0; idx 1 ) + { + try + { + getIndexReader(); + Collection fields = indexReader.getFieldNames(); + String[] indexFields = getIndexFields(); + for( int idx=0; idx