- Added testQueryFilter test for bug 20290

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20290
- Made search(Query) private.


git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150031 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Otis Gospodnetic 2003-09-16 12:49:30 +00:00
parent bdcea5f2ed
commit 355e66eb34
1 changed files with 19 additions and 6 deletions

View File

@ -79,7 +79,7 @@ public class TestRemoteSearchable extends TestCase {
return lookupRemote();
}
}
private static Searchable lookupRemote() throws Exception {
return (Searchable)Naming.lookup("//localhost/Searchable");
}
@ -101,7 +101,7 @@ public class TestRemoteSearchable extends TestCase {
Naming.rebind("//localhost/Searchable", impl);
}
public static void search(Query query) throws Exception {
private static void search(Query query) throws Exception {
// try to search the published index
Searchable[] searchables = { getRemote() };
Searcher searcher = new MultiSearcher(searchables);
@ -110,22 +110,35 @@ public class TestRemoteSearchable extends TestCase {
assertEquals(1, result.length());
assertEquals("test text", result.doc(0).get("test"));
}
public void testTermQuery() throws Exception {
public void testTermQuery() throws Exception {
search(new TermQuery(new Term("test", "test")));
}
public void testBooleanQuery() throws Exception {
public void testBooleanQuery() throws Exception {
BooleanQuery query = new BooleanQuery();
query.add(new TermQuery(new Term("test", "test")), true, false);
search(query);
}
public void testPhraseQuery() throws Exception {
public void testPhraseQuery() throws Exception {
PhraseQuery query = new PhraseQuery();
query.add(new Term("test", "test"));
query.add(new Term("test", "text"));
search(query);
}
// Tests bug fix at http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20290
public void testQueryFilter() throws Exception {
// try to search the published index
Searchable[] searchables = { getRemote() };
Searcher searcher = new MultiSearcher(searchables);
Hits hits = searcher.search(
new TermQuery(new Term("test", "text")),
new QueryFilter(new TermQuery(new Term("test", "test"))));
Hits nohits = searcher.search(
new TermQuery(new Term("test", "text")),
new QueryFilter(new TermQuery(new Term("test", "non-existent-term"))));
assertEquals(0, nohits.length());
}
}