You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2019/04/02 18:53:35 UTC
[lucene-solr] 03/03: LUCENE-8742: add 'missing slop attribute' test
coverage for SpanNearBuilder
This is an automated email from the ASF dual-hosted git repository.
cpoerschke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit de13c8e79d7477d8a428c1c432f91072ccc4e9a2
Author: Christine Poerschke <cp...@apache.org>
AuthorDate: Tue Apr 2 19:31:03 2019 +0100
LUCENE-8742: add 'missing slop attribute' test coverage for SpanNearBuilder
---
.../queryparser/xml/SpanNearQueryWithoutSlop.xml | 21 +++++++++++++++++++++
.../lucene/queryparser/xml/TestCoreParser.java | 16 ++++++++++++++++
2 files changed, 37 insertions(+)
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.xml
new file mode 100644
index 0000000..977ac4b
--- /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.java
index 1b434bb..3fe3ccb 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);