throw IllegalArgumentExeception if value doesn't make sense

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@332762 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Daniel Naber 2005-11-12 11:57:35 +00:00
parent 11866ad09d
commit 7017c1b701
2 changed files with 13 additions and 0 deletions

View File

@ -63,6 +63,8 @@ public class BooleanQuery extends Query {
* the operating system.
*/
public static void setMaxClauseCount(int maxClauseCount) {
if (maxClauseCount < 1)
throw new IllegalArgumentException("maxClauseCount must be >= 1");
BooleanQuery.maxClauseCount = maxClauseCount;
}

View File

@ -20,6 +20,7 @@ import junit.framework.TestCase;
import org.apache.lucene.index.Term;
public class TestBooleanQuery extends TestCase {
public void testEquality() throws Exception {
BooleanQuery bq1 = new BooleanQuery();
bq1.add(new TermQuery(new Term("field", "value1")), BooleanClause.Occur.SHOULD);
@ -39,4 +40,14 @@ public class TestBooleanQuery extends TestCase {
assertEquals(bq1, bq2);
}
public void testException() {
try {
BooleanQuery.setMaxClauseCount(0);
fail();
} catch (IllegalArgumentException e) {
// okay
}
}
}