FileDocCategorySizeDatePackage
IndexTaskTest.javaAPI DocApache Lucene 1.92552Mon Feb 20 09:17:56 GMT 2006org.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 = QueryParser.parse("test", "contents", analyzer);

        Hits hits = searcher.search(query);

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