add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / queryparser / src / test / org / apache / lucene / queryParser / surround / query / Test02Boolean.java
1 package org.apache.lucene.queryParser.surround.query;
2
3 /**
4  * Licensed to the Apache Software Foundation (ASF) under one or more
5  * contributor license agreements.  See the NOTICE file distributed with
6  * this work for additional information regarding copyright ownership.
7  * The ASF licenses this file to You under the Apache License, Version 2.0
8  * (the "License"); you may not use this file except in compliance with
9  * the License.  You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 import junit.framework.TestSuite;
21 import junit.textui.TestRunner;
22
23 import org.apache.lucene.util.LuceneTestCase;
24
25 public class Test02Boolean extends LuceneTestCase {
26   public static void main(String args[]) {
27     TestRunner.run(new TestSuite(Test02Boolean.class));
28   }
29
30   final String fieldName = "bi";
31   boolean verbose = false;
32   int maxBasicQueries = 16;
33
34   String[] docs1 = {
35     "word1 word2 word3",
36     "word4 word5",
37     "ord1 ord2 ord3",
38     "orda1 orda2 orda3 word2 worda3",
39     "a c e a b c"
40   };
41
42   SingleFieldTestDb db1 = new SingleFieldTestDb(random, docs1, fieldName);
43
44   public void normalTest1(String query, int[] expdnrs) throws Exception {
45     BooleanQueryTst bqt = new BooleanQueryTst( query, expdnrs, db1, fieldName, this,
46                                                 new BasicQueryFactory(maxBasicQueries));
47     bqt.setVerbose(verbose);
48     bqt.doTest();
49   }
50
51   public void test02Terms01() throws Exception {
52     int[] expdnrs = {0}; normalTest1( "word1", expdnrs);
53   }
54   public void test02Terms02() throws Exception {
55     int[] expdnrs = {0, 1, 3}; normalTest1( "word*", expdnrs);
56   }
57   public void test02Terms03() throws Exception {
58     int[] expdnrs = {2}; normalTest1( "ord2", expdnrs);
59   }
60   public void test02Terms04() throws Exception {
61     int[] expdnrs = {}; normalTest1( "kxork*", expdnrs);
62   }
63   public void test02Terms05() throws Exception {
64     int[] expdnrs = {0, 1, 3}; normalTest1( "wor*", expdnrs);
65   }
66   public void test02Terms06() throws Exception {
67     int[] expdnrs = {}; normalTest1( "ab", expdnrs);
68   }
69   
70   public void test02Terms10() throws Exception {
71     int[] expdnrs = {}; normalTest1( "abc?", expdnrs);
72   }
73   public void test02Terms13() throws Exception {
74     int[] expdnrs = {0,1,3}; normalTest1( "word?", expdnrs);
75   }
76   public void test02Terms14() throws Exception {
77     int[] expdnrs = {0,1,3}; normalTest1( "w?rd?", expdnrs);
78   }
79   public void test02Terms20() throws Exception {
80     int[] expdnrs = {0,1,3}; normalTest1( "w*rd?", expdnrs);
81   }
82   public void test02Terms21() throws Exception {
83     int[] expdnrs = {3}; normalTest1( "w*rd??", expdnrs);
84   }
85   public void test02Terms22() throws Exception {
86     int[] expdnrs = {3}; normalTest1( "w*?da?", expdnrs);
87   }
88   public void test02Terms23() throws Exception {
89     int[] expdnrs = {}; normalTest1( "w?da?", expdnrs);
90   }
91   
92   public void test03And01() throws Exception {
93     int[] expdnrs = {0}; normalTest1( "word1 AND word2", expdnrs);
94   }
95   public void test03And02() throws Exception {
96     int[] expdnrs = {3}; normalTest1( "word* and ord*", expdnrs);
97   }
98   public void test03And03() throws Exception {
99     int[] expdnrs = {0}; normalTest1( "and(word1,word2)", expdnrs);
100   }
101   public void test04Or01() throws Exception {
102     int[] expdnrs = {0, 3}; normalTest1( "word1 or word2", expdnrs);
103   }
104   public void test04Or02() throws Exception {
105     int[] expdnrs = {0, 1, 2, 3}; normalTest1( "word* OR ord*", expdnrs);
106   }
107   public void test04Or03() throws Exception {
108     int[] expdnrs = {0, 3}; normalTest1( "OR (word1, word2)", expdnrs);
109   }
110   public void test05Not01() throws Exception {
111     int[] expdnrs = {3}; normalTest1( "word2 NOT word1", expdnrs);
112   }
113   public void test05Not02() throws Exception {
114     int[] expdnrs = {0}; normalTest1( "word2* not ord*", expdnrs);
115   }
116   public void test06AndOr01() throws Exception {
117     int[] expdnrs = {0}; normalTest1( "(word1 or ab)and or(word2,xyz, defg)", expdnrs);
118   }
119   public void test07AndOrNot02() throws Exception {
120     int[] expdnrs = {0}; normalTest1( "or( word2* not ord*, and(xyz,def))", expdnrs);
121   }
122 }