1 package org.apache.lucene.queryParser.surround.query;
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 import junit.framework.TestSuite;
21 import junit.textui.TestRunner;
23 import org.apache.lucene.util.LuceneTestCase;
25 public class Test02Boolean extends LuceneTestCase {
26 public static void main(String args[]) {
27 TestRunner.run(new TestSuite(Test02Boolean.class));
30 final String fieldName = "bi";
31 boolean verbose = false;
32 int maxBasicQueries = 16;
38 "orda1 orda2 orda3 word2 worda3",
42 SingleFieldTestDb db1 = new SingleFieldTestDb(random, docs1, fieldName);
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);
51 public void test02Terms01() throws Exception {
52 int[] expdnrs = {0}; normalTest1( "word1", expdnrs);
54 public void test02Terms02() throws Exception {
55 int[] expdnrs = {0, 1, 3}; normalTest1( "word*", expdnrs);
57 public void test02Terms03() throws Exception {
58 int[] expdnrs = {2}; normalTest1( "ord2", expdnrs);
60 public void test02Terms04() throws Exception {
61 int[] expdnrs = {}; normalTest1( "kxork*", expdnrs);
63 public void test02Terms05() throws Exception {
64 int[] expdnrs = {0, 1, 3}; normalTest1( "wor*", expdnrs);
66 public void test02Terms06() throws Exception {
67 int[] expdnrs = {}; normalTest1( "ab", expdnrs);
70 public void test02Terms10() throws Exception {
71 int[] expdnrs = {}; normalTest1( "abc?", expdnrs);
73 public void test02Terms13() throws Exception {
74 int[] expdnrs = {0,1,3}; normalTest1( "word?", expdnrs);
76 public void test02Terms14() throws Exception {
77 int[] expdnrs = {0,1,3}; normalTest1( "w?rd?", expdnrs);
79 public void test02Terms20() throws Exception {
80 int[] expdnrs = {0,1,3}; normalTest1( "w*rd?", expdnrs);
82 public void test02Terms21() throws Exception {
83 int[] expdnrs = {3}; normalTest1( "w*rd??", expdnrs);
85 public void test02Terms22() throws Exception {
86 int[] expdnrs = {3}; normalTest1( "w*?da?", expdnrs);
88 public void test02Terms23() throws Exception {
89 int[] expdnrs = {}; normalTest1( "w?da?", expdnrs);
92 public void test03And01() throws Exception {
93 int[] expdnrs = {0}; normalTest1( "word1 AND word2", expdnrs);
95 public void test03And02() throws Exception {
96 int[] expdnrs = {3}; normalTest1( "word* and ord*", expdnrs);
98 public void test03And03() throws Exception {
99 int[] expdnrs = {0}; normalTest1( "and(word1,word2)", expdnrs);
101 public void test04Or01() throws Exception {
102 int[] expdnrs = {0, 3}; normalTest1( "word1 or word2", expdnrs);
104 public void test04Or02() throws Exception {
105 int[] expdnrs = {0, 1, 2, 3}; normalTest1( "word* OR ord*", expdnrs);
107 public void test04Or03() throws Exception {
108 int[] expdnrs = {0, 3}; normalTest1( "OR (word1, word2)", expdnrs);
110 public void test05Not01() throws Exception {
111 int[] expdnrs = {3}; normalTest1( "word2 NOT word1", expdnrs);
113 public void test05Not02() throws Exception {
114 int[] expdnrs = {0}; normalTest1( "word2* not ord*", expdnrs);
116 public void test06AndOr01() throws Exception {
117 int[] expdnrs = {0}; normalTest1( "(word1 or ab)and or(word2,xyz, defg)", expdnrs);
119 public void test07AndOrNot02() throws Exception {
120 int[] expdnrs = {0}; normalTest1( "or( word2* not ord*, and(xyz,def))", expdnrs);