You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2010/12/19 00:13:03 UTC

svn commit: r1050733 - /lucene/dev/trunk/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java

Author: rmuir
Date: Sat Dec 18 23:13:03 2010
New Revision: 1050733

URL: http://svn.apache.org/viewvc?rev=1050733&view=rev
Log:
speed up test: convert to junit4

Modified:
    lucene/dev/trunk/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java

Modified: lucene/dev/trunk/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java?rev=1050733&r1=1050732&r2=1050733&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java (original)
+++ lucene/dev/trunk/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java Sat Dec 18 23:13:03 2010
@@ -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.LuceneTest
  */
 
 public class TestParser extends LuceneTestCase {
-
-	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);
+	private static CoreParser builder;
+	private static Directory dir;
+	private static IndexReader reader;
+	private static IndexSearcher searcher;
+
+	@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 LuceneTe
 	
 	
 	
-	@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");