Author: metskem
Date: Sat Jun  9 11:12:41 2012
New Revision: 1348358

URL: http://svn.apache.org/viewvc?rev=1348358&view=rev
Log:
2012-06-08  Harry Metske <[email protected]>

       * 2.9.0-incubating-3, fixed JSPWIKI-729 Update Lucene to current version 
 3.6.0

Added:
    incubator/jspwiki/trunk/lib/lucene-core-3.6.0.jar   (with props)
    incubator/jspwiki/trunk/lib/lucene-highlighter-3.6.0.jar   (with props)
    incubator/jspwiki/trunk/lib/lucene-memory-3.6.0.jar   (with props)
Removed:
    incubator/jspwiki/trunk/lib/lucene-highlighter.jar
    incubator/jspwiki/trunk/lib/lucene.jar
Modified:
    incubator/jspwiki/trunk/.classpath
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/build.xml
    incubator/jspwiki/trunk/src/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/src/org/apache/wiki/search/LuceneSearchProvider.java
    incubator/jspwiki/trunk/src/org/apache/wiki/search/SearchManager.java
    incubator/jspwiki/trunk/tests/org/apache/wiki/search/SearchManagerTest.java

Modified: incubator/jspwiki/trunk/.classpath
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/.classpath?rev=1348358&r1=1348357&r2=1348358&view=diff
==============================================================================
--- incubator/jspwiki/trunk/.classpath (original)
+++ incubator/jspwiki/trunk/.classpath Sat Jun  9 11:12:41 2012
@@ -16,12 +16,12 @@
        <classpathentry kind="lib" path="lib/oscache.jar" 
sourcepath="/Users/jalkanen/Java/oscache-2.2/src/java"/>
        <classpathentry kind="lib" path="lib/oro.jar"/>
        <classpathentry kind="lib" path="lib/nekohtml.jar"/>
-       <classpathentry kind="lib" path="lib/lucene.jar"/>
+       <classpathentry kind="lib" path="lib/lucene-core-3.6.0.jar"/>
        <classpathentry kind="lib" path="tests/lib/junit.jar"/>
        <classpathentry kind="lib" path="tests/etc"/>
        <classpathentry kind="lib" path="lib/jaxen.jar"/>
        <classpathentry kind="lib" path="tests/lib/xml-apis-1.0.b2.jar"/>
-       <classpathentry kind="lib" path="lib/lucene-highlighter.jar"/>
+       <classpathentry kind="lib" path="lib/lucene-highlighter-3.6.0.jar"/>
        <classpathentry kind="lib" path="lib/mail.jar"/>
        <classpathentry kind="lib" path="lib/activation.jar"/>
        <classpathentry kind="lib" path="etc/i18n"/>

Modified: incubator/jspwiki/trunk/ChangeLog
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=1348358&r1=1348357&r2=1348358&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sat Jun  9 11:12:41 2012
@@ -1,3 +1,7 @@
+2012-06-08  Harry Metske <[email protected]>
+
+       * 2.9.0-incubating-3, fixed JSPWIKI-729 Update Lucene to current 
version  3.6.0
+
 2012-06-06  Harry Metske <[email protected]>
 
        * 2.9.0-incubating-2, fixed jsp compile error in rss.jsp ( we forgot 
one occurrence of com.ecyrd.jspwiki)

Modified: incubator/jspwiki/trunk/build.xml
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/build.xml?rev=1348358&r1=1348357&r2=1348358&view=diff
==============================================================================
--- incubator/jspwiki/trunk/build.xml (original)
+++ incubator/jspwiki/trunk/build.xml Sat Jun  9 11:12:41 2012
@@ -233,6 +233,7 @@
            deprecation="${deprecation}"
            source="1.5"
            target="1.5"
+          includeantruntime="false"
            >
       <classpath refid="path.base" />
       <classpath refid="path.tests" />
@@ -249,6 +250,7 @@
            deprecation="${deprecation}"
            source="1.5"
            target="1.5"
+          includeantruntime="false"
            >
       <classpath refid="path.base" />
       <classpath refid="path.tests" />

Added: incubator/jspwiki/trunk/lib/lucene-core-3.6.0.jar
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/lib/lucene-core-3.6.0.jar?rev=1348358&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/jspwiki/trunk/lib/lucene-core-3.6.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/jspwiki/trunk/lib/lucene-highlighter-3.6.0.jar
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/lib/lucene-highlighter-3.6.0.jar?rev=1348358&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/jspwiki/trunk/lib/lucene-highlighter-3.6.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/jspwiki/trunk/lib/lucene-memory-3.6.0.jar
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/lib/lucene-memory-3.6.0.jar?rev=1348358&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/jspwiki/trunk/lib/lucene-memory-3.6.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/jspwiki/trunk/src/org/apache/wiki/Release.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/Release.java?rev=1348358&r1=1348357&r2=1348358&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/Release.java Sat Jun  9 
11:12:41 2012
@@ -77,7 +77,7 @@ public final class Release
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "2";
+    public static final String     BUILD         = "3";
     
     /**
      *  This is the generic version string you should use

Modified: 
incubator/jspwiki/trunk/src/org/apache/wiki/search/LuceneSearchProvider.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/search/LuceneSearchProvider.java?rev=1348358&r1=1348357&r2=1348358&view=diff
==============================================================================
--- 
incubator/jspwiki/trunk/src/org/apache/wiki/search/LuceneSearchProvider.java 
(original)
+++ 
incubator/jspwiki/trunk/src/org/apache/wiki/search/LuceneSearchProvider.java 
Sat Jun  9 11:12:41 2012
@@ -21,6 +21,7 @@
 package org.apache.wiki.search;
 
 import java.io.*;
+import java.lang.reflect.Constructor;
 import java.util.*;
 
 import org.apache.commons.lang.StringUtils;
@@ -29,23 +30,19 @@ import org.apache.lucene.analysis.Analyz
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.Term;
+import org.apache.lucene.index.*;
+import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.queryParser.MultiFieldQueryParser;
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Searcher;
-import org.apache.lucene.search.highlight.Highlighter;
-import org.apache.lucene.search.highlight.QueryScorer;
-import org.apache.lucene.search.highlight.SimpleHTMLEncoder;
-import org.apache.lucene.search.highlight.SimpleHTMLFormatter;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.highlight.*;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.FSDirectory;
-
+import org.apache.lucene.store.SimpleFSDirectory;
+import org.apache.lucene.util.Version;
 import org.apache.wiki.*;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.attachment.AttachmentManager;
@@ -75,14 +72,10 @@ public class LuceneSearchProvider implem
     private static final String PROP_LUCENE_INDEXDELAY   = 
"jspwiki.lucene.indexdelay";
     private static final String PROP_LUCENE_INITIALDELAY = 
"jspwiki.lucene.initialdelay";
 
-    private String m_analyzerClass = 
"org.apache.lucene.analysis.standard.StandardAnalyzer";
+    private String m_analyzerClass = 
"org.apache.lucene.analysis.standard.ClassicAnalyzer";
 
     private static final String LUCENE_DIR             = "lucene";
 
-    /**
-     *  Number of page updates before we optimize the index.
-     */
-    public static final int LUCENE_OPTIMIZE_COUNT      = 10;
     /** These attachment file suffixes will be indexed. */
     public static final String[] SEARCHABLE_FILE_SUFFIXES = new String[] { 
".txt", ".ini", ".xml", ".html", "htm", ".mm", ".htm",
                                                                           
".xhtml", ".java", ".c", ".cpp", ".php", ".asm", ".sh",
@@ -94,8 +87,7 @@ public class LuceneSearchProvider implem
     protected static final String LUCENE_ATTACHMENTS   = "attachment";
     protected static final String LUCENE_PAGE_NAME     = "name";
 
-    private String           m_luceneDirectory = null;
-    private int              m_updateCount = 0;
+    private String           m_luceneDirectory;
     protected Vector<Object[]> m_updates = new Vector<Object[]>(); // Vector 
because multi-threaded.
 
     /** Maximum number of fragments from search matches. */
@@ -195,22 +187,13 @@ public class LuceneSearchProvider implem
 
                 log.info("Starting Lucene reindexing, this can take a couple 
minutes...");
 
-                //
-                //  Do lock recovery, in case JSPWiki was shut down forcibly
-                //
-                Directory luceneDir = FSDirectory.getDirectory(dir,false);
-
-                if( IndexReader.isLocked(luceneDir) )
-                {
-                    log.info("JSPWiki was shut down while Lucene was indexing 
- unlocking now.");
-                    IndexReader.unlock( luceneDir );
-                }
-
+                Directory luceneDir = new SimpleFSDirectory(dir, null);
+                
                 try
                 {
-                    writer = new IndexWriter( m_luceneDirectory,
-                                              getLuceneAnalyzer(),
-                                              true );
+                    IndexWriterConfig writerConfig = new IndexWriterConfig( 
Version.LUCENE_36, getLuceneAnalyzer());
+                    writerConfig.setOpenMode( OpenMode.CREATE_OR_APPEND );
+                    writer = new IndexWriter( luceneDir, writerConfig);
                     Collection allPages = 
m_engine.getPageManager().getAllPages();
 
                     for( Iterator iterator = allPages.iterator(); 
iterator.hasNext(); )
@@ -236,8 +219,7 @@ public class LuceneSearchProvider implem
                         
                         try
                         {
-                            String text = getAttachmentContent( att.getName(),
-                                                                
WikiProvider.LATEST_VERSION );
+                            String text = getAttachmentContent( att.getName(), 
WikiProvider.LATEST_VERSION );
                             luceneIndexPage( att, text, writer );
                         }
                         catch( IOException e )
@@ -246,7 +228,6 @@ public class LuceneSearchProvider implem
                         }
                     }
 
-                    writer.optimize();
                 }
                 finally
                 {
@@ -254,12 +235,13 @@ public class LuceneSearchProvider implem
                     {
                         if( writer != null ) writer.close();
                     }
-                    catch( IOException e ) {}
+                    catch( IOException e ) 
+                    {
+                    }
                 }
 
                 Date end = new Date();
-                log.info("Full Lucene index finished in " +
-                         (end.getTime() - start.getTime()) + " milliseconds.");
+                log.info( "Full Lucene index finished in " + (end.getTime() - 
start.getTime()) + " milliseconds." );
             }
             else
             {
@@ -279,10 +261,6 @@ public class LuceneSearchProvider implem
             log.error("Problem reading pages while creating Lucene index 
(JSPWiki won't start.)", e);
             throw new IllegalArgumentException("unable to create Lucene 
index");
         }
-        catch( ClassNotFoundException e )
-        {
-            log.error("Illegal Analyzer specified:",e);
-        }
         catch( Exception e )
         {
             log.error("Unable to start lucene",e);
@@ -390,14 +368,11 @@ public class LuceneSearchProvider implem
             pageRemoved(page);
 
             // Now add back the new version.
-            writer = new IndexWriter(m_luceneDirectory, getLuceneAnalyzer(), 
false);
+            Directory luceneDir = new SimpleFSDirectory(new 
File(m_luceneDirectory), null);
+            IndexWriterConfig writerConfig = new IndexWriterConfig( 
Version.LUCENE_36, getLuceneAnalyzer());
+            writerConfig.setOpenMode( OpenMode.CREATE_OR_APPEND);
+            writer = new IndexWriter(luceneDir, writerConfig);
             luceneIndexPage(page, text, writer);
-            m_updateCount++;
-            if( m_updateCount >= LUCENE_OPTIMIZE_COUNT )
-            {
-                writer.optimize();
-                m_updateCount = 0;
-            }
         }
         catch ( IOException e )
         {
@@ -420,14 +395,21 @@ public class LuceneSearchProvider implem
     }
 
 
-    private Analyzer getLuceneAnalyzer()
-        throws ClassNotFoundException,
-               InstantiationException,
-               IllegalAccessException
-    {
-        Class clazz = ClassUtil.findClass( "", m_analyzerClass );
-        Analyzer analyzer = (Analyzer)clazz.newInstance();
-        return analyzer;
+    private Analyzer getLuceneAnalyzer() throws ProviderException
+    {
+        try
+        {
+            Class clazz = ClassUtil.findClass( "", m_analyzerClass );
+            Constructor constructor = clazz.getConstructor( 
Version.LUCENE_36.getClass() );
+            Analyzer analyzer = (Analyzer) constructor.newInstance( 
Version.LUCENE_36 );
+            return analyzer;
+        }
+        catch( Exception e )
+        {
+            String msg = "Could not get LuceneAnalyzer class " + 
m_analyzerClass + ", reason: ";
+            log.error( msg, e );
+            throw new ProviderException( msg + e );
+        }
     }
 
     /**
@@ -450,12 +432,12 @@ public class LuceneSearchProvider implem
         if( text == null ) return doc;
 
         // Raw name is the keyword we'll use to refer to this document for 
updates.
-        Field field = new Field(LUCENE_ID, page.getName(), Field.Store.YES, 
Field.Index.UN_TOKENIZED);
+        Field field = new Field(LUCENE_ID, page.getName(), Field.Store.YES, 
Field.Index.NOT_ANALYZED);
         doc.add( field );
 
         // Body text.  It is stored in the doc for search contexts.
         field = new Field(LUCENE_PAGE_CONTENTS, text,
-                          Field.Store.YES, Field.Index.TOKENIZED, 
Field.TermVector.NO);
+                          Field.Store.YES, Field.Index.ANALYZED, 
Field.TermVector.NO);
         doc.add( field );
 
         // Allow searching by page name. Both beautified and raw
@@ -465,7 +447,7 @@ public class LuceneSearchProvider implem
 
         field = new Field(LUCENE_PAGE_NAME,
                           TextUtil.beautifyString( page.getName() ) + " " + 
unTokenizedTitle,
-                          Field.Store.YES, Field.Index.TOKENIZED, 
Field.TermVector.NO);
+                          Field.Store.YES, Field.Index.ANALYZED, 
Field.TermVector.NO);
         doc.add( field );
 
         // Allow searching by authorname
@@ -473,7 +455,7 @@ public class LuceneSearchProvider implem
         if( page.getAuthor() != null )
         {
             field = new Field(LUCENE_AUTHOR, page.getAuthor(),
-                              Field.Store.YES, Field.Index.TOKENIZED, 
Field.TermVector.NO);
+                              Field.Store.YES, Field.Index.ANALYZED, 
Field.TermVector.NO);
             doc.add( field );
         }
 
@@ -489,7 +471,7 @@ public class LuceneSearchProvider implem
                 attachmentNames += att.getName() + ";";
             }
             field = new Field(LUCENE_ATTACHMENTS, attachmentNames,
-                              Field.Store.YES, Field.Index.TOKENIZED, 
Field.TermVector.NO);
+                              Field.Store.YES, Field.Index.ANALYZED, 
Field.TermVector.NO);
             doc.add( field );
 
         }
@@ -508,16 +490,30 @@ public class LuceneSearchProvider implem
      */
     public void pageRemoved( WikiPage page )
     {
+        IndexWriter writer = null;
         try
         {
-            // Must first remove existing version of page.
-            IndexReader reader = IndexReader.open(m_luceneDirectory);
-            reader.deleteDocuments(new Term(LUCENE_ID, page.getName()));
-            reader.close();
+            Directory luceneDir = new SimpleFSDirectory(new 
File(m_luceneDirectory), null);
+            IndexWriterConfig writerConfig = new IndexWriterConfig( 
Version.LUCENE_36, getLuceneAnalyzer());
+            writerConfig.setOpenMode( OpenMode.CREATE_OR_APPEND);
+            writer = new IndexWriter( luceneDir, writerConfig);
+            Query query = new TermQuery( new Term( LUCENE_ID, page.getName() ) 
);
+            writer.deleteDocuments( query );
         }
-        catch ( IOException e )
+        catch ( Exception e )
         {
-            log.error("Unable to update page '" + page.getName() + "' from 
Lucene index", e);
+            log.error("Unable to remove page '" + page.getName() + "' from 
Lucene index", e);
+        }
+        finally
+        {
+            try
+            {
+                if( writer != null ) writer.close();
+            }
+            catch( IOException e )
+            {
+                log.error( e );
+            }
         }
     }
 
@@ -582,14 +578,14 @@ public class LuceneSearchProvider implem
     public Collection findPages( String query, int flags )
         throws ProviderException
     {
-        Searcher  searcher = null;
+        IndexSearcher  searcher = null;
         ArrayList<SearchResult> list = null;
         Highlighter highlighter = null;
 
         try
         {
             String[] queryfields = { LUCENE_PAGE_CONTENTS, LUCENE_PAGE_NAME, 
LUCENE_AUTHOR, LUCENE_ATTACHMENTS };
-            QueryParser qp = new MultiFieldQueryParser( queryfields, 
getLuceneAnalyzer() );
+            QueryParser qp = new MultiFieldQueryParser(Version.LUCENE_36, 
queryfields, getLuceneAnalyzer() );
 
             //QueryParser qp = new QueryParser( LUCENE_PAGE_CONTENTS, 
getLuceneAnalyzer() );
             Query luceneQuery = qp.parse( query );
@@ -603,7 +599,10 @@ public class LuceneSearchProvider implem
 
             try
             {
-                searcher = new IndexSearcher(m_luceneDirectory);
+                File dir = new File(m_luceneDirectory);
+                Directory luceneDir = new SimpleFSDirectory(dir, null);
+                IndexReader reader = IndexReader.open( luceneDir);
+                searcher = new IndexSearcher(reader);
             }
             catch( Exception ex )
             {
@@ -611,12 +610,13 @@ public class LuceneSearchProvider implem
                 return null;
             }
 
-            Hits hits = searcher.search(luceneQuery);
+            ScoreDoc[] hits = searcher.search(luceneQuery, 
MAX_FRAGMENTS).scoreDocs;
 
-            list = new ArrayList<SearchResult>(hits.length());
-            for ( int curr = 0; curr < hits.length(); curr++ )
+            list = new ArrayList<SearchResult>(hits.length);
+            for ( int curr = 0; curr < hits.length; curr++ )
             {
-                Document doc = hits.doc(curr);
+                int docID = hits[curr].doc;
+                Document doc = searcher.doc( docID );
                 String pageName = doc.get(LUCENE_ID);
                 WikiPage page = m_engine.getPage(pageName, 
WikiPageProvider.LATEST_VERSION);
 
@@ -628,7 +628,7 @@ public class LuceneSearchProvider implem
                         // When the search-results are cleaned up this can be 
enabled again.
                     }
 
-                    int score = (int)(hits.score(curr) * 100);
+                    int score = (int)(hits[curr].score * 100);
 
 
                     // Get highlighted search contexts
@@ -639,8 +639,7 @@ public class LuceneSearchProvider implem
                     {
                         TokenStream tokenStream = getLuceneAnalyzer()
                         .tokenStream(LUCENE_PAGE_CONTENTS, new 
StringReader(text));
-                        fragments = highlighter.getBestFragments(tokenStream,
-                                                                 text, 
MAX_FRAGMENTS);
+                        fragments = highlighter.getBestFragments(tokenStream, 
text, MAX_FRAGMENTS);
 
                     }
 
@@ -658,24 +657,16 @@ public class LuceneSearchProvider implem
         {
             log.error("Failed during lucene search",e);
         }
-        catch( InstantiationException e )
-        {
-            log.error("Unable to get a Lucene analyzer",e);
-        }
-        catch( IllegalAccessException e )
-        {
-            log.error("Unable to get a Lucene analyzer",e);
-        }
-        catch( ClassNotFoundException e )
-        {
-            log.error("Specified Lucene analyzer does not exist",e);
-        }
         catch( ParseException e )
         {
-            log.info("Broken query; cannot parse",e);
+            log.info("Broken query; cannot parse query ",e);
 
             throw new ProviderException("You have entered a query Lucene 
cannot process: "+e.getMessage());
         }
+        catch( InvalidTokenOffsetsException e )
+        {
+            log.error("Tokens are incompatible with provided text ",e);
+        }
         finally
         {
             if( searcher != null )
@@ -685,7 +676,9 @@ public class LuceneSearchProvider implem
                     searcher.close();
                 }
                 catch( IOException e )
-                {}
+                {
+                    log.error( e );
+                }
             }
         }
 

Modified: incubator/jspwiki/trunk/src/org/apache/wiki/search/SearchManager.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/search/SearchManager.java?rev=1348358&r1=1348357&r2=1348358&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/search/SearchManager.java 
(original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/search/SearchManager.java Sat 
Jun  9 11:12:41 2012
@@ -62,7 +62,7 @@ public class SearchManager
      */
     public static final String PROP_SEARCHPROVIDER     = 
"jspwiki.searchProvider";
 
-    private SearchProvider    m_searchProvider = null;
+    private SearchProvider    m_searchProvider;
 
     /**
      *  The name of the JSON object that manages search.

Modified: 
incubator/jspwiki/trunk/tests/org/apache/wiki/search/SearchManagerTest.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/org/apache/wiki/search/SearchManagerTest.java?rev=1348358&r1=1348357&r2=1348358&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/org/apache/wiki/search/SearchManagerTest.java 
(original)
+++ incubator/jspwiki/trunk/tests/org/apache/wiki/search/SearchManagerTest.java 
Sat Jun  9 11:12:41 2012
@@ -20,7 +20,6 @@
  */
 package org.apache.wiki.search;
 
-import java.io.File;
 import java.util.Collection;
 import java.util.Properties;
 
@@ -29,13 +28,13 @@ import net.sourceforge.stripes.mock.Mock
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-
 import org.apache.wiki.SearchResult;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 
 public class SearchManagerTest extends TestCase
 {
+    private static final long SLEEP_TIME = 10000L;
     TestEngine m_engine;
     SearchManager m_mgr;
     
@@ -49,11 +48,7 @@ public class SearchManagerTest extends T
         props.setProperty( SearchManager.PROP_SEARCHPROVIDER, 
"LuceneSearchProvider" );
         props.setProperty( "jspwiki.lucene.initialdelay", "1" );
 
-        String tmpdir = props.getProperty("jspwiki.workDir");
-        
-        assertNotNull(tmpdir);
-        // Empty the lucene work directory
-        TestEngine.deleteAll( new File(tmpdir, "lucene") );
+        TestEngine.emptyWorkDir();
         
         m_engine = new TestEngine( props );
         m_mgr = m_engine.getSearchManager();
@@ -81,7 +76,7 @@ public class SearchManagerTest extends T
 
         Thread.yield();
 
-        Thread.sleep( 10000L ); // Should cover for both index and initial 
delay
+        Thread.sleep( SLEEP_TIME ); // Should cover for both index and initial 
delay
         
         Collection res = m_mgr.findPages( "mankind" );
      
@@ -102,7 +97,7 @@ public class SearchManagerTest extends T
         
         Thread.yield();
 
-        Thread.sleep( 10000L ); // Should cover for both index and initial 
delay
+        Thread.sleep( SLEEP_TIME ); // Should cover for both index and initial 
delay
     
         Collection res = m_mgr.findPages( "mankind" );
  
@@ -128,7 +123,7 @@ public class SearchManagerTest extends T
      
         Thread.yield();
 
-        Thread.sleep( 10000L ); // Should cover for both index and initial 
delay
+        Thread.sleep( SLEEP_TIME ); // Should cover for both index and initial 
delay
  
         Collection res = m_mgr.findPages( "mankind" );
 
@@ -151,7 +146,7 @@ public class SearchManagerTest extends T
      
         Thread.yield();
 
-        Thread.sleep( 5000L ); // Should cover for both index and initial delay
+        Thread.sleep( SLEEP_TIME ); // Should cover for both index and initial 
delay
  
         Collection res = m_mgr.findPages( "Test" );
 
@@ -170,7 +165,7 @@ public class SearchManagerTest extends T
  
         Thread.yield();
 
-        Thread.sleep( 5000L ); // Should cover for both index and initial delay
+        Thread.sleep( SLEEP_TIME ); // Should cover for both index and initial 
delay
 
         Collection res = m_mgr.findPages( "TestPage" );
 


Reply via email to