Apache Lucene open-source search software
LUCENE-8742: add 'missing slop attribute' test coverage for SpanNearBuilder
Christine Poerschkede13c8e79d74
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/SpanNearQueryWithoutSlop.xml b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/SpanNearQueryWithoutSlop.xmlnew file mode 100644index 00000000000..977ac4b8e18--- /dev/null+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/SpanNearQueryWithoutSlop.xml@@ -0,0 +1,21 @@+<?xml version="1.0" encoding="UTF-8"?>+<!--+ Licensed to the Apache Software Foundation (ASF) under one or more+ contributor license agreements. See the NOTICE file distributed with+ this work for additional information regarding copyright ownership.+ The ASF licenses this file to You 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.+-->+<SpanNear fieldName="contents" inOrder="false">+ <SpanTerm>foo</SpanTerm>+ <SpanTerm>bar</SpanTerm>+</SpanNear>diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestCoreParser.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestCoreParser.javaindex 1b434bb3d15..3fe3ccb6ed0 100644--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestCoreParser.java+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestCoreParser.java@@ -135,6 +135,22 @@ public class TestCoreParser extends LuceneTestCase {assertEquals(q, sq);}+ public void testSpanNearQueryWithoutSlopXML() throws Exception {+ Exception expectedException = new NumberFormatException("For input string: \"\"");+ try {+ Query q = parse("SpanNearQueryWithoutSlop.xml");+ fail("got query "+q+" instead of expected exception "+expectedException);+ } catch (Exception e) {+ assertEquals(expectedException.toString(), e.toString());+ }+ try {+ SpanQuery sq = parseAsSpan("SpanNearQueryWithoutSlop.xml");+ fail("got span query "+sq+" instead of expected exception "+expectedException);+ } catch (Exception e) {+ assertEquals(expectedException.toString(), e.toString());+ }+ }+public void testConstantScoreQueryXML() throws Exception {Query q = parse("ConstantScoreQuery.xml");dumpResults("ConstantScoreQuery", q, 5);