assertTrue("expected instance of BooleanQuery but was "
+ query.getClass(), query instanceof BooleanQuery);
BooleanQuery bquery = (BooleanQuery) query;
BooleanClause[] clauses = bquery.getClauses();
assertEquals(2, clauses.length);
BooleanClause booleanClause = clauses[0];
query = booleanClause.getQuery();
assertTrue("expected instance of TermQuery but was " + query.getClass(),
query instanceof TermQuery);
TermQuery tquery = (TermQuery) query;
assertEquals("aField", tquery.getTerm()
.field());
assertEquals("foo", tquery.getTerm().text());
booleanClause = clauses[1];
query = booleanClause.getQuery();
assertTrue("expected instance of TermQuery but was " + query.getClass(),
query instanceof TermQuery);
tquery = (TermQuery) query;
assertEquals("field", tquery.getTerm().field());
assertEquals("bar", tquery.getTerm().text());