Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
12   48   1   12
0   23   0.08   1
1     1  
1    
 
  TestCachingWrapperFilter       Line # 26 12 1 100% 1.0
 
  (1)
 
1    package org.apache.lucene.search;
2   
3    /**
4    * Copyright 2004 The Apache Software Foundation
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10    * http://www.apache.org/licenses/LICENSE-2.0
11    *
12    * Unless required by applicable law or agreed to in writing, software
13    * distributed under the License is distributed on an "AS IS" BASIS,
14    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    * See the License for the specific language governing permissions and
16    * limitations under the License.
17    */
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  1 toggle public void testCachingWorks() throws Exception {
28  1 Directory dir = new RAMDirectory();
29  1 IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true);
30  1 writer.close();
31   
32  1 IndexReader reader = IndexReader.open(dir);
33   
34  1 MockFilter filter = new MockFilter();
35  1 CachingWrapperFilter cacher = new CachingWrapperFilter(filter);
36   
37    // first time, nested filter is called
38  1 cacher.bits(reader);
39  1 assertTrue("first time", filter.wasCalled());
40   
41    // second time, nested filter should not be called
42  1 filter.clear();
43  1 cacher.bits(reader);
44  1 assertFalse("second time", filter.wasCalled());
45   
46  1 reader.close();
47    }
48    }