LUCENE-8742: add 'missing slop attribute' test coverage for SpanNearBuilder

This commit is contained in:
Christine Poerschke 2019-04-02 19:31:03 +01:00
parent 1bf413ebc8
commit de13c8e79d
2 changed files with 37 additions and 0 deletions

View File

@ -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>

View File

@ -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);