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 2016/04/06 14:43:23 UTC
lucene-solr:master: LUCENE-7178: TestCoreParser tweaks
Repository: lucene-solr
Updated Branches:
refs/heads/master 4205b1c80 -> 2259288ca
LUCENE-7178: TestCoreParser tweaks
Summary:
* rename testSimpleXML to testTermQueryXML
* rename testSimpleTermsQueryXML to testTermsQueryXML
* try-with-resources and file-not-found-assert for TestCoreParser.parse
* TestCoreParser.dumpResults verbose logging now includes qType and numDocs
(Ramkumar Aiyengar, Nathan Visagan, Christine Poerschke)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/2259288c
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/2259288c
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/2259288c
Branch: refs/heads/master
Commit: 2259288ca0702cb1f55bc92ae1eb8e00887488d6
Parents: 4205b1c
Author: Christine Poerschke <cp...@apache.org>
Authored: Wed Apr 6 12:48:52 2016 +0100
Committer: Christine Poerschke <cp...@apache.org>
Committed: Wed Apr 6 13:38:47 2016 +0100
----------------------------------------------------------------------
.../lucene/queryparser/xml/TestCoreParser.java | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2259288c/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestCoreParser.java
----------------------------------------------------------------------
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 c8b357e..04faa7d 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
@@ -95,12 +95,12 @@ public class TestCoreParser extends LuceneTestCase {
analyzer = null;
}
- public void testSimpleXML() throws ParserException, IOException {
+ public void testTermQueryXML() throws ParserException, IOException {
Query q = parse("TermQuery.xml");
dumpResults("TermQuery", q, 5);
}
- public void testSimpleTermsQueryXML() throws ParserException, IOException {
+ public void testTermsQueryXML() throws ParserException, IOException {
Query q = parse("TermsQuery.xml");
dumpResults("TermsQuery", q, 5);
}
@@ -187,10 +187,11 @@ public class TestCoreParser extends LuceneTestCase {
}
protected Query parse(String xmlFileName) throws ParserException, IOException {
- InputStream xmlStream = TestCoreParser.class.getResourceAsStream(xmlFileName);
- Query result = coreParser().parse(xmlStream);
- xmlStream.close();
- return result;
+ try (InputStream xmlStream = TestCoreParser.class.getResourceAsStream(xmlFileName)) {
+ assertNotNull("Test XML file " + xmlFileName + " cannot be found", xmlStream);
+ Query result = coreParser().parse(xmlStream);
+ return result;
+ }
}
protected Query rewrite(Query q) throws IOException {
@@ -199,7 +200,7 @@ public class TestCoreParser extends LuceneTestCase {
protected void dumpResults(String qType, Query q, int numDocs) throws IOException {
if (VERBOSE) {
- System.out.println("TEST: query=" + q);
+ System.out.println("TEST: qType=" + qType + " query=" + q + " numDocs=" + numDocs);
}
TopDocs hits = searcher.search(q, numDocs);
assertTrue(qType + " should produce results ", hits.totalHits > 0);