diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 7dabcf95396..9eac40339ea 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -146,6 +146,10 @@ Other * LUCENE-6923: Fix RamUsageEstimator to access private fields inside AccessController block for computing size. (Robert Muir) +* LUCENE-6907: make TestParser extendable, rename test/.../xml/ + NumericRangeQueryQuery.xml to NumericRangeQuery.xml + (Christine Poerschke) + ======================= Lucene 5.4.0 ======================= New Features diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/NumericRangeQueryQuery.xml b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/NumericRangeQuery.xml similarity index 100% rename from lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/NumericRangeQueryQuery.xml rename to lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/NumericRangeQuery.xml diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java index 1d33f2800db..f3f7599d7ee 100644 --- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java +++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java @@ -50,7 +50,8 @@ import java.util.List; public class TestParser extends LuceneTestCase { - private static CoreParser builder; + private static Analyzer analyzer; + private static CoreParser coreParser; private static Directory dir; private static IndexReader reader; private static IndexSearcher searcher; @@ -58,9 +59,9 @@ public class TestParser extends LuceneTestCase { @BeforeClass public static void beforeClass() throws Exception { // TODO: rewrite test (this needs to set QueryParser.enablePositionIncrements, too, for work with CURRENT): - Analyzer analyzer = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, true, MockTokenFilter.ENGLISH_STOPSET); + analyzer = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, true, MockTokenFilter.ENGLISH_STOPSET); //initialize the parser - builder = new CorePlusExtensionsParser("contents", analyzer); + coreParser = new CorePlusExtensionsParser("contents", analyzer); BufferedReader d = new BufferedReader(new InputStreamReader( TestParser.class.getResourceAsStream("reuters21578.txt"), StandardCharsets.US_ASCII)); @@ -92,7 +93,8 @@ public class TestParser extends LuceneTestCase { reader = null; searcher = null; dir = null; - builder = null; + coreParser = null; + analyzer = null; } public void testSimpleXML() throws ParserException, IOException { @@ -181,16 +183,24 @@ public class TestParser extends LuceneTestCase { dumpResults("Nested Boolean query", q, 5); } - public void testNumericRangeQueryQueryXML() throws ParserException, IOException { - Query q = parse("NumericRangeQueryQuery.xml"); + public void testNumericRangeQueryXML() throws ParserException, IOException { + Query q = parse("NumericRangeQuery.xml"); dumpResults("NumericRangeQuery", q, 5); } //================= Helper methods =================================== + protected Analyzer analyzer() { + return analyzer; + } + + protected CoreParser coreParser() { + return coreParser; + } + private Query parse(String xmlFileName) throws ParserException, IOException { InputStream xmlStream = TestParser.class.getResourceAsStream(xmlFileName); - Query result = builder.parse(xmlStream); + Query result = coreParser().parse(xmlStream); xmlStream.close(); return result; }