1 package org.apache.lucene.search; 2 3 18 19 import junit.framework.TestCase; 20 import org.apache.lucene.store.Directory; 21 import org.apache.lucene.store.RAMDirectory; 22 import org.apache.lucene.index.IndexReader; 23 import org.apache.lucene.index.IndexWriter; 24 import org.apache.lucene.analysis.standard.StandardAnalyzer; 25 26 public class TestCachingWrapperFilter extends TestCase { 27 public void testCachingWorks() throws Exception { 28 Directory dir = new RAMDirectory(); 29 IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true); 30 writer.close(); 31 32 IndexReader reader = IndexReader.open(dir); 33 34 MockFilter filter = new MockFilter(); 35 CachingWrapperFilter cacher = new CachingWrapperFilter(filter); 36 37 cacher.bits(reader); 39 assertTrue("first time", filter.wasCalled()); 40 41 filter.clear(); 43 cacher.bits(reader); 44 assertFalse("second time", filter.wasCalled()); 45 46 reader.close(); 47 } 48 } 49 | Popular Tags |