FileDocCategorySizeDatePackage
TestModifiedEntryFilter.javaAPI DocApache Lucene 2.2.03744Sat Jun 16 22:20:52 BST 2007org.apache.lucene.gdata.storage.lucenestorage

TestModifiedEntryFilter

public class TestModifiedEntryFilter extends TestCase
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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());