mirror of https://github.com/apache/lucene.git
LUCENE-8742: add 'missing slop attribute' test coverage for SpanNearBuilder
This commit is contained in:
parent
1bf413ebc8
commit
de13c8e79d
|
@ -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>
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue