FileDocCategorySizeDatePackage
TestModifiedEntryFilter.javaAPI DocApache Lucene 2.1.02941Wed Feb 14 10:46:02 GMT 2007org.apache.lucene.gdata.storage.lucenestorage

TestModifiedEntryFilter

public class TestModifiedEntryFilter extends TestCase

Fields Summary
IndexWriter
writer
IndexReader
reader
List
excludeList
String
feedID
String
fieldFeedId
Constructors Summary
Methods Summary
protected voidsetUp()

 
          
        RAMDirectory dir = new RAMDirectory(); 
        this.writer = new IndexWriter(dir,new StandardAnalyzer(),true); 
        Document doc = new Document(); 
        doc.add(new Field(StorageEntryWrapper.FIELD_ENTRY_ID,"1",Field.Store.YES,Field.Index.UN_TOKENIZED)); 
        doc.add(new Field(fieldFeedId,feedID,Field.Store.YES,Field.Index.UN_TOKENIZED)); 
        Document doc1 = new Document(); 
        doc1.add(new Field(StorageEntryWrapper.FIELD_ENTRY_ID,"2",Field.Store.YES,Field.Index.UN_TOKENIZED)); 
        doc1.add(new Field(fieldFeedId,feedID,Field.Store.YES,Field.Index.UN_TOKENIZED)); 
        this.writer.addDocument(doc); 
        this.writer.addDocument(doc1); 
        this.writer.close(); 
        this.reader = IndexReader.open(dir); 
        this.excludeList = new ArrayList(); 
        this.excludeList.add("1"); 
         
         
    
protected voidtearDown()

 
        super.tearDown(); 
    
public voidtestFilter()

 
        Searcher s = new IndexSearcher(this.reader); 
        Query q = new TermQuery(new Term(fieldFeedId,feedID)); 
        Hits hits = s.search(q); 
        assertEquals(2,hits.length()); 
         
        hits = s.search(q,new ModifiedEntryFilter(this.excludeList.toArray(new String[0]),StorageEntryWrapper.FIELD_ENTRY_ID)); 
        assertEquals(1,hits.length()); 
        this.excludeList.add("2"); 
 
        hits = s.search(q,new ModifiedEntryFilter(this.excludeList.toArray(new String[0]),StorageEntryWrapper.FIELD_ENTRY_ID)); 
        assertEquals(0,hits.length());
        this.excludeList.add(null);
        this.excludeList.add("5"); 
        hits = s.search(q,new ModifiedEntryFilter(this.excludeList.toArray(new String[0]),StorageEntryWrapper.FIELD_ENTRY_ID)); 
        assertEquals(0,hits.length());