Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
22   68   7   5.5
6   43   0.32   4
4     1.75  
1    
 
  TestStopAnalyzer       Line # 26 22 7 87.5% 0.875
 
  (2)
 
1    package org.apache.lucene.analysis;
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 java.io.StringReader;
22    import java.io.IOException;
23    import java.util.Set;
24    import java.util.HashSet;
25   
 
26    public class TestStopAnalyzer extends TestCase {
27   
28    private StopAnalyzer stop = new StopAnalyzer();
29    private Set inValidTokens = new HashSet();
30   
 
31  2 toggle public TestStopAnalyzer(String s) {
32  2 super(s);
33    }
34   
 
35  2 toggle protected void setUp() {
36  68 for (int i = 0; i < StopAnalyzer.ENGLISH_STOP_WORDS.length; i++) {
37  66 inValidTokens.add(StopAnalyzer.ENGLISH_STOP_WORDS[i]);
38    }
39    }
40   
 
41  1 toggle public void testDefaults() throws IOException {
42  1 assertTrue(stop != null);
43  1 StringReader reader = new StringReader("This is a test of the english stop analyzer");
44  1 TokenStream stream = stop.tokenStream("test", reader);
45  1 assertTrue(stream != null);
46  1 Token token = null;
47  ? while ((token = stream.next()) != null) {
48  4 assertFalse(inValidTokens.contains(token.termText()));
49    }
50    }
51   
 
52  1 toggle public void testStopList() throws IOException {
53  1 Set stopWordsSet = new HashSet();
54  1 stopWordsSet.add("good");
55  1 stopWordsSet.add("test");
56  1 stopWordsSet.add("analyzer");
57  1 StopAnalyzer newStop = new StopAnalyzer((String[])stopWordsSet.toArray(new String[3]));
58  1 StringReader reader = new StringReader("This is a good test of the english stop analyzer");
59  1 TokenStream stream = newStop.tokenStream("test", reader);
60  1 assertNotNull(stream);
61  1 Token token = null;
62  ? while ((token = stream.next()) != null) {
63  7 String text = token.termText();
64  7 assertFalse(stopWordsSet.contains(text));
65    }
66    }
67   
68    }