Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
13   56   2   6.5
0   27   0.15   2
2     1  
1    
 
  TestNot       Line # 33 13 2 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   
21    import org.apache.lucene.index.IndexWriter;
22    import org.apache.lucene.queryParser.QueryParser;
23    import org.apache.lucene.store.RAMDirectory;
24    import org.apache.lucene.analysis.SimpleAnalyzer;
25    import org.apache.lucene.document.Document;
26    import org.apache.lucene.document.Field;
27   
28    /** Similarity unit test.
29    *
30    * @author Doug Cutting
31    * @version $Revision: 387550 $
32    */
 
33    public class TestNot extends TestCase {
 
34  1 toggle public TestNot(String name) {
35  1 super(name);
36    }
37   
 
38  1 toggle public void testNot() throws Exception {
39  1 RAMDirectory store = new RAMDirectory();
40  1 IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true);
41   
42  1 Document d1 = new Document();
43  1 d1.add(new Field("field", "a b", Field.Store.YES, Field.Index.TOKENIZED));
44   
45  1 writer.addDocument(d1);
46  1 writer.optimize();
47  1 writer.close();
48   
49  1 Searcher searcher = new IndexSearcher(store);
50  1 QueryParser parser = new QueryParser("field", new SimpleAnalyzer());
51  1 Query query = parser.parse("a NOT b");
52    //System.out.println(query);
53  1 Hits hits = searcher.search(query);
54  1 assertEquals(0, hits.length());
55    }
56    }