lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r383343 - in /lucene/java/trunk/src/test/org/apache/lucene/search: SingleDocTestFilter.java TestFilteredQuery.java
Date Sun, 05 Mar 2006 15:44:45 GMT
Author: ehatcher
Date: Sun Mar  5 07:44:44 2006
New Revision: 383343

URL: http://svn.apache.org/viewcvs?rev=383343&view=rev
Log:
test for FilteredQuery within BooleanQuery

Added:
    lucene/java/trunk/src/test/org/apache/lucene/search/SingleDocTestFilter.java
Modified:
    lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java

Added: lucene/java/trunk/src/test/org/apache/lucene/search/SingleDocTestFilter.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/SingleDocTestFilter.java?rev=383343&view=auto
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/SingleDocTestFilter.java (added)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/SingleDocTestFilter.java Sun Mar 
5 07:44:44 2006
@@ -0,0 +1,36 @@
+package org.apache.lucene.search;
+
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.index.IndexReader;
+
+import java.util.BitSet;
+import java.io.IOException;
+
+public class SingleDocTestFilter extends Filter {
+  private int doc;
+
+  public SingleDocTestFilter(int doc) {
+    this.doc = doc;
+  }
+
+  public BitSet bits(IndexReader reader) throws IOException {
+    BitSet bits = new BitSet(reader.maxDoc());
+    bits.set(doc);
+    return bits;
+  }
+}

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java?rev=383343&r1=383342&r2=383343&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java Sun Mar  5
07:44:44 2006
@@ -1,7 +1,7 @@
 package org.apache.lucene.search;
 
 /**
- * Copyright 2004 The Apache Software Foundation
+ * Copyright 2004,2006 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -126,5 +126,19 @@
     assertEquals(2, hits.length());
   }
 
+
+  public void testBoolean() throws Exception {
+    BooleanQuery bq = new BooleanQuery();
+    Query query = new FilteredQuery(new MatchAllDocsQuery(),
+        new SingleDocTestFilter(0));
+    bq.add(query, BooleanClause.Occur.MUST);
+    query = new FilteredQuery(new MatchAllDocsQuery(),
+        new SingleDocTestFilter(1));
+    bq.add(query, BooleanClause.Occur.MUST);
+    Hits hits = searcher.search(bq);
+    System.out.println(hits.id(0));
+    System.out.println(hits.id(1));
+    assertEquals(0, hits.length());
+  }
 }
 



Mime
View raw message