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 15:02:57 UTC
lucene-solr:branch_6x: LUCENE-7178: TestCoreParser tweaks
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x 6c7487351 -> 3d6f2aa31
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/3d6f2aa3
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/3d6f2aa3
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/3d6f2aa3
Branch: refs/heads/branch_6x
Commit: 3d6f2aa31cee0251521f976276cc349ebe6f45c0
Parents: 6c74873
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:44:34 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/3d6f2aa3/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);