FileDocCategorySizeDatePackage
IndexTaskTest.javaAPI DocApache Lucene 2.1.02743Wed Feb 14 10:45:44 GMT 2007org.apache.lucene.ant

IndexTaskTest

public class IndexTaskTest extends TestCase
Test cases for index task
author
Erik Hatcher

Fields Summary
private static final String
docHandler
private String
docsDir
private String
indexDir
private Searcher
searcher
private Analyzer
analyzer
Constructors Summary
Methods Summary
public voidsetUp()
The JUnit setup method

exception
IOException Description of Exception



                    
         
        Project project = new Project();

        IndexTask task = new IndexTask();
        FileSet fs = new FileSet();
        fs.setDir(new File(docsDir));
        task.addFileset(fs);
        task.setOverwrite(true);
        task.setDocumentHandler(docHandler);
        task.setIndex(new File(indexDir));
        task.setProject(project);
        task.execute();

        searcher = new IndexSearcher(indexDir);
        analyzer = new StopAnalyzer();
    
public voidtearDown()
The teardown method for JUnit

todo
remove indexDir?

        searcher.close();
    
public voidtestSearch()

        Query query = new QueryParser("contents",analyzer).parse("test");

        Hits hits = searcher.search(query);

        assertEquals("Find document(s)", 2, hits.length());