fix for LUCENE-4890

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1495757 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adriano Crestani Campos 2013-06-22 17:15:47 +00:00
parent be9bf006c2
commit b575956f21
2 changed files with 25 additions and 1 deletions

View File

@ -150,7 +150,7 @@ public class QueryTreeBuilder implements QueryBuilder {
builder = getQueryBuilder(clazz);
if (builder == null) {
Class<?>[] classes = node.getClass().getInterfaces();
Class<?>[] classes = clazz.getInterfaces();
for (Class<?> actualClass : classes) {
builder = getQueryBuilder(actualClass);

View File

@ -22,6 +22,8 @@ import junit.framework.Assert;
import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode;
import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode;
import org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl;
import org.apache.lucene.queryparser.flexible.core.parser.EscapeQuerySyntax;
import org.apache.lucene.queryparser.flexible.core.util.UnescapedCharSequence;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test;
@ -35,6 +37,28 @@ public class TestQueryTreeBuilder extends LuceneTestCase {
Object result = qtb.build(new FieldQueryNode(new UnescapedCharSequence("field"), "foo", 0, 0));
Assert.assertEquals("OK", result);
// LUCENE-4890
qtb = new QueryTreeBuilder();
qtb.setBuilder(DummyQueryNodeInterface.class, new DummyBuilder());
result = qtb.build(new DummyQueryNode());
Assert.assertEquals("OK", result);
}
private static interface DummyQueryNodeInterface extends QueryNode {
}
private static abstract class AbstractDummyQueryNode extends QueryNodeImpl implements DummyQueryNodeInterface {
}
private static class DummyQueryNode extends AbstractDummyQueryNode {
@Override
public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) {
return "DummyQueryNode";
}
}
private static class DummyBuilder implements QueryBuilder {