From aae5cff6dd75b961ba1116275359215b79e270f7 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Sat, 18 Dec 2010 23:13:03 +0000 Subject: [PATCH] speed up test: convert to junit4 git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1050733 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/xmlparser/TestParser.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java index 9b656c2339d..ad266b52f19 100644 --- a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java +++ b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java @@ -20,6 +20,8 @@ import org.apache.lucene.search.TopDocs; import org.apache.lucene.store.Directory; import org.apache.lucene.util.Version; import org.apache.lucene.util.LuceneTestCase; +import org.junit.AfterClass; +import org.junit.BeforeClass; /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -38,23 +40,17 @@ import org.apache.lucene.util.LuceneTestCase; */ public class TestParser extends LuceneTestCase { + private static CoreParser builder; + private static Directory dir; + private static IndexReader reader; + private static IndexSearcher searcher; - CoreParser builder; - static Directory dir; - // TODO: rewrite test (this needs to set QueryParser.enablePositionIncrements, too, for work with CURRENT): - Analyzer analyzer=new MockAnalyzer(MockTokenizer.WHITESPACE, true, MockTokenFilter.ENGLISH_STOPSET, false); - IndexReader reader; - private IndexSearcher searcher; - - /* - * @see TestCase#setUp() - */ - @Override - public void setUp() throws Exception { - super.setUp(); - - //initialize the parser - builder=new CorePlusExtensionsParser("contents",analyzer); + @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(MockTokenizer.WHITESPACE, true, MockTokenFilter.ENGLISH_STOPSET, false); + //initialize the parser + builder=new CorePlusExtensionsParser("contents",analyzer); BufferedReader d = new BufferedReader(new InputStreamReader(TestParser.class.getResourceAsStream("reuters21578.txt"))); dir=newDirectory(); @@ -84,13 +80,17 @@ public class TestParser extends LuceneTestCase { - @Override - public void tearDown() throws Exception { + @AfterClass + public static void afterClass() throws Exception { reader.close(); searcher.close(); dir.close(); - super.tearDown(); + reader = null; + searcher = null; + dir = null; + builder = null; } + public void testSimpleXML() throws ParserException, IOException { Query q=parse("TermQuery.xml");