lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r922886 - in /lucene/java/trunk: ./ contrib/analyzers/common/src/test/org/apache/lucene/analysis/compound/ contrib/analyzers/common/src/test/org/apache/lucene/analysis/cz/ contrib/analyzers/common/src/test/org/apache/lucene/analysis/de/ con...
Date Sun, 14 Mar 2010 16:19:52 GMT
Author: uschindler
Date: Sun Mar 14 16:19:51 2010
New Revision: 922886

URL: http://svn.apache.org/viewvc?rev=922886&view=rev
Log:
LUCENE-2318: Remove inconsistent system property code for retrieving temp and data directories inside test cases

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/common-build.xml
    lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/compound/TestCompoundWordTokenFilter.java
    lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/cz/TestCzechAnalyzer.java
    lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/de/TestGermanStemFilter.java
    lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/nl/TestDutchStemmer.java
    lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/ru/TestRussianAnalyzer.java
    lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/ru/TestRussianStem.java
    lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java
    lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
    lucene/java/trunk/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java
    lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java
    lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
    lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java
    lucene/java/trunk/contrib/wordnet/src/test/org/apache/lucene/wordnet/TestSynonymTokenFilter.java
    lucene/java/trunk/contrib/wordnet/src/test/org/apache/lucene/wordnet/TestWordnet.java
    lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestCompoundFile.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestThreadedOptimize.java
    lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
    lucene/java/trunk/src/test/org/apache/lucene/store/TestDirectory.java
    lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java
    lucene/java/trunk/src/test/org/apache/lucene/store/TestRAMDirectory.java
    lucene/java/trunk/src/test/org/apache/lucene/store/TestWindowsMMap.java
    lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java
    lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
    lucene/java/trunk/src/test/org/apache/lucene/util/_TestUtil.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Sun Mar 14 16:19:51 2010
@@ -263,6 +263,13 @@ Test Cases
   other than errors to System.(out|err). The setting can be changed with
   -Dtests.verbose=true on test invokation.  (Shai Erera via Uwe Schindler)
 
+* LUCENE-2318: Remove inconsistent system property code for retrieving
+  temp and data directories inside test cases. It is now centralized in
+  LuceneTestCase(J4). Also changed lots of tests to use
+  getClass().getResourceAsStream() to retrieve test data. Tests needing
+  access to "real" files from the test folder itsself, can use
+  LuceneTestCase(J4).getDataFile().  (Uwe Schindler)
+
 ================== Release 2.9.2 / 3.0.1 2010-02-26 ====================
 
 Changes in backwards compatibility policy

Modified: lucene/java/trunk/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/common-build.xml?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/common-build.xml (original)
+++ lucene/java/trunk/common-build.xml Sun Mar 14 16:19:51 2010
@@ -413,7 +413,6 @@
 	      <sysproperty key="tests.verbose" value="${tests.verbose}"/>
 	
 	      <!-- TODO: create propertyset for test properties, so each project can have its own set -->
-	      <sysproperty key="dataDir" file="@{dataDir}"/>
 	      <sysproperty key="tempDir" file="@{tempDir}"/>
 	      <sysproperty key="java.io.tmpdir" file="@{tempDir}"/>
 	      <sysproperty key="lucene.version" value="${dev.version}"/>

Modified: lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/compound/TestCompoundWordTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/compound/TestCompoundWordTokenFilter.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/compound/TestCompoundWordTokenFilter.java (original)
+++ lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/compound/TestCompoundWordTokenFilter.java Sun Mar 14 16:19:51 2010
@@ -30,9 +30,6 @@ import org.apache.lucene.analysis.compou
 import org.apache.lucene.analysis.tokenattributes.TermAttribute;
 
 public class TestCompoundWordTokenFilter extends BaseTokenStreamTestCase {
-  static final File dataDir = new File(System.getProperty("dataDir", "./bin"));
-  static final File testFile = new File(dataDir, "org/apache/lucene/analysis/compound/da_UTF8.xml");
-
   public void testHyphenationCompoundWordsDA() throws Exception {
     String[] dict = { "læse", "hest" };
 
@@ -143,6 +140,6 @@ public class TestCompoundWordTokenFilter
   }
 
   private Reader getHyphenationReader() throws Exception {
-    return new InputStreamReader(new FileInputStream(testFile), "UTF-8");
+    return new InputStreamReader(getClass().getResourceAsStream("da_UTF8.xml"), "UTF-8");
   }
 }

Modified: lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/cz/TestCzechAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/cz/TestCzechAnalyzer.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/cz/TestCzechAnalyzer.java (original)
+++ lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/cz/TestCzechAnalyzer.java Sun Mar 14 16:19:51 2010
@@ -35,8 +35,6 @@ import org.apache.lucene.util.Version;
  *
  */
 public class TestCzechAnalyzer extends BaseTokenStreamTestCase {
-  File dataDir = new File(System.getProperty("dataDir", "./bin"));
-  File customStopFile = new File(dataDir, "org/apache/lucene/analysis/cz/customStopWordFile.txt");
   
   /**
    * @deprecated Remove this test when support for 3.0 indexes is no longer needed.
@@ -105,7 +103,7 @@ public class TestCzechAnalyzer extends B
     assertAnalyzesToReuse(cz, "Česká Republika", 
       new String[] { "česká", "republika" });
     
-    InputStream stopwords = new FileInputStream(customStopFile);
+    InputStream stopwords = getClass().getResourceAsStream("customStopWordFile.txt");
     cz.loadStopWords(stopwords, "UTF-8");
     
     assertAnalyzesToReuse(cz, "Česká Republika", new String[] { "česká" });

Modified: lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/de/TestGermanStemFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/de/TestGermanStemFilter.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/de/TestGermanStemFilter.java (original)
+++ lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/de/TestGermanStemFilter.java Sun Mar 14 16:19:51 2010
@@ -41,10 +41,7 @@ public class TestGermanStemFilter extend
     Tokenizer tokenizer = new KeywordTokenizer(new StringReader(""));
     TokenFilter filter = new GermanStemFilter(new LowerCaseFilter(TEST_VERSION_CURRENT, tokenizer));
     // read test cases from external file:
-    File dataDir = new File(System.getProperty("dataDir", "./bin"));
-    File testFile = new File(dataDir, "org/apache/lucene/analysis/de/data.txt");
-    FileInputStream fis = new FileInputStream(testFile);
-    InputStreamReader isr = new InputStreamReader(fis, "iso-8859-1");
+    InputStreamReader isr = new InputStreamReader(getClass().getResourceAsStream("data.txt"), "iso-8859-1");
     BufferedReader breader = new BufferedReader(isr);
     while(true) {
       String line = breader.readLine();
@@ -61,6 +58,5 @@ public class TestGermanStemFilter extend
     }
     breader.close();
     isr.close();
-    fis.close();
   }
 }

Modified: lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/nl/TestDutchStemmer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/nl/TestDutchStemmer.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/nl/TestDutchStemmer.java (original)
+++ lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/nl/TestDutchStemmer.java Sun Mar 14 16:19:51 2010
@@ -32,8 +32,6 @@ import org.apache.lucene.util.Version;
  * 
  */
 public class TestDutchStemmer extends BaseTokenStreamTestCase {
-  File dataDir = new File(System.getProperty("dataDir", "./bin"));
-  File customDictFile = new File(dataDir, "org/apache/lucene/analysis/nl/customStemDict.txt");
   
   public void testWithSnowballExamples() throws Exception {
 	 check("lichaamsziek", "lichaamsziek");
@@ -172,6 +170,7 @@ public class TestDutchStemmer extends Ba
   public void testStemDictionaryReuse() throws Exception {
     DutchAnalyzer a = new DutchAnalyzer(TEST_VERSION_CURRENT);
     checkOneTermReuse(a, "lichamelijk", "licham");
+    File customDictFile = getDataFile("customStemDict.txt");
     a.setStemDictionary(customDictFile);
     checkOneTermReuse(a, "lichamelijk", "somethingentirelydifferent");
   }

Modified: lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/ru/TestRussianAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/ru/TestRussianAnalyzer.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/ru/TestRussianAnalyzer.java (original)
+++ lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/ru/TestRussianAnalyzer.java Sun Mar 14 16:19:51 2010
@@ -41,14 +41,6 @@ public class TestRussianAnalyzer extends
 
     private InputStreamReader sampleUnicode;
 
-    private File dataDir;
-
-    @Override
-    protected void setUp() throws Exception {
-      super.setUp();
-      dataDir = new File(System.getProperty("dataDir", "./bin"));
-    }
-
     /**
      * @deprecated remove this test and its datafiles in Lucene 4.0
      * the Snowball version has its own data tests.
@@ -59,12 +51,12 @@ public class TestRussianAnalyzer extends
         RussianAnalyzer ra = new RussianAnalyzer(Version.LUCENE_30);
         inWords =
             new InputStreamReader(
-                new FileInputStream(new File(dataDir, "/org/apache/lucene/analysis/ru/testUTF8.txt")),
+                getClass().getResourceAsStream("testUTF8.txt"),
                 "UTF-8");
 
         sampleUnicode =
             new InputStreamReader(
-                new FileInputStream(new File(dataDir, "/org/apache/lucene/analysis/ru/resUTF8.htm")),
+                getClass().getResourceAsStream("resUTF8.htm"),
                 "UTF-8");
 
         TokenStream in = ra.tokenStream("all", inWords);

Modified: lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/ru/TestRussianStem.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/ru/TestRussianStem.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/ru/TestRussianStem.java (original)
+++ lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/ru/TestRussianStem.java Sun Mar 14 16:19:51 2010
@@ -47,13 +47,11 @@ public class TestRussianStem extends Luc
         //System.out.println(new java.util.Date());
         String str;
         
-        File dataDir = new File(System.getProperty("dataDir", "./bin"));
-
         // open and read words into an array list
         BufferedReader inWords =
             new BufferedReader(
                 new InputStreamReader(
-                    new FileInputStream(new File(dataDir, "/org/apache/lucene/analysis/ru/wordsUTF8.txt")),
+                    getClass().getResourceAsStream("wordsUTF8.txt"),
                     "UTF-8"));
         while ((str = inWords.readLine()) != null)
         {
@@ -65,7 +63,7 @@ public class TestRussianStem extends Luc
         BufferedReader inStems =
             new BufferedReader(
                 new InputStreamReader(
-                    new FileInputStream(new File(dataDir, "/org/apache/lucene/analysis/ru/stemsUTF8.txt")),
+                    getClass().getResourceAsStream("stemsUTF8.txt"),
                     "UTF-8"));
         while ((str = inStems.readLine()) != null)
         {

Modified: lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java (original)
+++ lucene/java/trunk/contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java Sun Mar 14 16:19:51 2010
@@ -35,18 +35,24 @@ import org.apache.lucene.analysis.Tokeni
  */
 public class TestSnowballVocab extends BaseTokenStreamTestCase {
   private Tokenizer tokenizer = new KeywordTokenizer(new StringReader(""));
-  static final File dataDir = new File(System.getProperty("dataDir", "./bin"));
-  static final File dataRoot = new File(dataDir, 
-      "org/apache/lucene/analysis/snowball/data");
+  File dataRoot = null;
+  
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
+    try {
+      dataRoot = getDataFile("data");
+    } catch (IOException ioe) {
+      dataRoot = null;
+      System.err.println("WARN: This test was disabled, as the svn checkout of snowball test files is not supported on your system!");
+    }
+  }
   
   /**
    * Run all languages against their snowball vocabulary tests.
    */
   public void testStemmers() throws IOException {
-    if (!dataRoot.exists()) {
-      System.err.println("WARN: This test was disabled, as the svn checkout of snowball test files is not supported on your system!");
-      return;
-    }
+    if (dataRoot == null) return;
     assertCorrectOutput("Danish", "danish");
     assertCorrectOutput("Dutch", "dutch");
     assertCorrectOutput("English", "english");

Modified: lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java (original)
+++ lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java Sun Mar 14 16:19:51 2010
@@ -378,7 +378,7 @@ public class TestPerfTasksLogic extends 
    * Test WriteLineDoc and LineDocSource.
    */
   public void testLineDocFile() throws Exception {
-    File lineFile = new File(System.getProperty("tempDir"), "test.reuters.lines.txt");
+    File lineFile = new File(TEMP_DIR, "test.reuters.lines.txt");
 
     // We will call WriteLineDocs this many times
     final int NUM_TRY_DOCS = 50;

Modified: lucene/java/trunk/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java (original)
+++ lucene/java/trunk/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java Sun Mar 14 16:19:51 2010
@@ -46,7 +46,7 @@ import com.sleepycat.je.Transaction;
  *
  */
 public class JEStoreTest extends LuceneTestCase {
-    protected File dbHome = new File(System.getProperty("java.io.tmpdir"),"index");
+    protected File dbHome = new File(TEMP_DIR,"index");
 
     protected Environment env;
 

Modified: lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java (original)
+++ lucene/java/trunk/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java Sun Mar 14 16:19:51 2010
@@ -43,7 +43,7 @@ import org.apache.lucene.util.LuceneTest
  * Adapted from org.apache.lucene.StoreTest with larger files and random bytes.
  */
 public class DbStoreTest extends LuceneTestCase {
-    protected File dbHome = new File(System.getProperty("java.io.tmpdir"),"index");
+    protected File dbHome = new File(TEMP_DIR,"index");
     protected Environment env;
     protected Database index, blocks;
     

Modified: lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java (original)
+++ lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java Sun Mar 14 16:19:51 2010
@@ -51,6 +51,7 @@ import org.apache.lucene.search.Searcher
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Similarity;
 import org.apache.lucene.store.RAMDirectory; // for javadocs
+import org.apache.lucene.util.Constants; // for javadocs
 
 /**
  * High-performance single-document main memory Apache Lucene fulltext search index. 
@@ -1207,7 +1208,7 @@ public class MemoryIndex implements Seri
   ///////////////////////////////////////////////////////////////////////////////
   private static final class VM {
         
-    public static final int PTR = is64BitVM() ? 8 : 4;    
+    public static final int PTR = Constants.JRE_IS_64BIT ? 8 : 4;    
 
     // bytes occupied by primitive data types
     public static final int BOOLEAN = 1;
@@ -1272,18 +1273,6 @@ public class MemoryIndex implements Seri
         return sizeOfObject(PTR + INT) + sizeOfIntArray(len);
     }
     
-    private static boolean is64BitVM() {
-        try {
-            int bits = Integer.getInteger("sun.arch.data.model", 0).intValue();
-            if (bits != 0) return bits == 64;
-
-            // fallback if sun.arch.data.model isn't available
-            return System.getProperty("java.vm.name").toLowerCase().indexOf("64") >= 0;
-        } catch (Throwable t) {
-            return false; // better safe than sorry (applets, security managers, etc.) ...
-        }
-    }
-    
     /** logarithm to the base 2. Example: log2(4) == 2, log2(8) == 3 */
     private static double log2(double value) {
       return Math.log(value) / Math.log(2);

Modified: lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java (original)
+++ lucene/java/trunk/contrib/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java Sun Mar 14 16:19:51 2010
@@ -27,11 +27,10 @@ import org.apache.lucene.util._TestUtil;
 
 public class TestIndexSplitter extends LuceneTestCase {
   public void test() throws Exception {
-    String tmpDir = System.getProperty("java.io.tmpdir");
-    File dir = new File(tmpDir, "testfilesplitter");
+    File dir = new File(TEMP_DIR, "testfilesplitter");
     _TestUtil.rmDir(dir);
     dir.mkdirs();
-    File destDir = new File(tmpDir, "testfilesplitterdest");
+    File destDir = new File(TEMP_DIR, "testfilesplitterdest");
     _TestUtil.rmDir(destDir);
     destDir.mkdirs();
     FSDirectory fsDir = FSDirectory.open(dir);
@@ -61,7 +60,7 @@ public class TestIndexSplitter extends L
     assertEquals(50, r.maxDoc());
     
     // now test cmdline
-    File destDir2 = new File(tmpDir, "testfilesplitterdest2");
+    File destDir2 = new File(TEMP_DIR, "testfilesplitterdest2");
     _TestUtil.rmDir(destDir2);
     destDir2.mkdirs();
     IndexSplitter.main(new String[] {dir.getAbsolutePath(), destDir2.getAbsolutePath(), splitSegName});

Modified: lucene/java/trunk/contrib/wordnet/src/test/org/apache/lucene/wordnet/TestSynonymTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/wordnet/src/test/org/apache/lucene/wordnet/TestSynonymTokenFilter.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/wordnet/src/test/org/apache/lucene/wordnet/TestSynonymTokenFilter.java (original)
+++ lucene/java/trunk/contrib/wordnet/src/test/org/apache/lucene/wordnet/TestSynonymTokenFilter.java Sun Mar 14 16:19:51 2010
@@ -30,11 +30,10 @@ import org.apache.lucene.analysis.Whites
 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
 
 public class TestSynonymTokenFilter extends BaseTokenStreamTestCase {
-  File dataDir = new File(System.getProperty("dataDir", "./bin"));
-  File testFile = new File(dataDir, "org/apache/lucene/wordnet/testSynonyms.txt");
+  final String testFile = "testSynonyms.txt";
   
   public void testSynonyms() throws Exception {
-    SynonymMap map = new SynonymMap(new FileInputStream(testFile));
+    SynonymMap map = new SynonymMap(getClass().getResourceAsStream(testFile));
     /* all expansions */
     Analyzer analyzer = new SynonymWhitespaceAnalyzer(map, Integer.MAX_VALUE);
     assertAnalyzesTo(analyzer, "Lost in the woods",
@@ -45,7 +44,7 @@ public class TestSynonymTokenFilter exte
   }
   
   public void testSynonymsSingleQuote() throws Exception {
-    SynonymMap map = new SynonymMap(new FileInputStream(testFile));
+    SynonymMap map = new SynonymMap(getClass().getResourceAsStream(testFile));
     /* all expansions */
     Analyzer analyzer = new SynonymWhitespaceAnalyzer(map, Integer.MAX_VALUE);
     assertAnalyzesTo(analyzer, "king",
@@ -53,7 +52,7 @@ public class TestSynonymTokenFilter exte
   }
   
   public void testSynonymsLimitedAmount() throws Exception {
-    SynonymMap map = new SynonymMap(new FileInputStream(testFile));
+    SynonymMap map = new SynonymMap(getClass().getResourceAsStream(testFile));
     /* limit to one synonym expansion */
     Analyzer analyzer = new SynonymWhitespaceAnalyzer(map, 1);
     assertAnalyzesTo(analyzer, "Lost in the woods",
@@ -67,7 +66,7 @@ public class TestSynonymTokenFilter exte
   }
   
   public void testReusableTokenStream() throws Exception {
-    SynonymMap map = new SynonymMap(new FileInputStream(testFile));
+    SynonymMap map = new SynonymMap(getClass().getResourceAsStream(testFile));
     /* limit to one synonym expansion */
     Analyzer analyzer = new SynonymWhitespaceAnalyzer(map, 1);
     assertAnalyzesToReuse(analyzer, "Lost in the woods",

Modified: lucene/java/trunk/contrib/wordnet/src/test/org/apache/lucene/wordnet/TestWordnet.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/wordnet/src/test/org/apache/lucene/wordnet/TestWordnet.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/contrib/wordnet/src/test/org/apache/lucene/wordnet/TestWordnet.java (original)
+++ lucene/java/trunk/contrib/wordnet/src/test/org/apache/lucene/wordnet/TestWordnet.java Sun Mar 14 16:19:51 2010
@@ -33,17 +33,15 @@ import org.apache.lucene.util.LuceneTest
 
 public class TestWordnet extends LuceneTestCase {
   private Searcher searcher;
-  
-  File dataDir = new File(System.getProperty("dataDir", "./bin"));
-  File testFile = new File(dataDir, "org/apache/lucene/wordnet/testSynonyms.txt");
-  
+    
   String storePathName = 
-    new File(System.getProperty("tempDir"),"testLuceneWordnet").getAbsolutePath();
+    new File(TEMP_DIR,"testLuceneWordnet").getAbsolutePath();
   
   @Override
   protected void setUp() throws Exception {
     super.setUp();
     // create a temporary synonym index
+    File testFile = getDataFile("testSynonyms.txt");
     String commandLineArgs[] = { testFile.getAbsolutePath(), storePathName };
     
     try {

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java Sun Mar 14 16:19:51 2010
@@ -36,8 +36,7 @@ public class TestPorterStemFilter extend
   public void testPorterStemFilter() throws Exception {
     Tokenizer tokenizer = new KeywordTokenizer(new StringReader(""));
     TokenStream filter = new PorterStemFilter(tokenizer);   
-    ZipFile zipFile = new ZipFile(
-        new File(getClass().getResource("porterTestData.zip").toURI()));
+    ZipFile zipFile = new ZipFile(getDataFile("porterTestData.zip"));
     InputStream voc = zipFile.getInputStream(zipFile.getEntry("voc.txt"));
     InputStream out = zipFile.getInputStream(zipFile.getEntry("output.txt"));
     BufferedReader vocReader = new BufferedReader(new InputStreamReader(

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Sun Mar 14 16:19:51 2010
@@ -623,7 +623,7 @@ public class TestBackwardsCompatibility 
   }
 
   public static String fullDir(String dirName) throws IOException {
-    return new File(System.getProperty("tempDir"), dirName).getCanonicalPath();
+    return new File(TEMP_DIR, dirName).getCanonicalPath();
   }
 
   static final String TEXT_TO_COMPRESS = "this is a compressed field and should appear in 3.0 as an uncompressed field after merge";

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestCompoundFile.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestCompoundFile.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestCompoundFile.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestCompoundFile.java Sun Mar 14 16:19:51 2010
@@ -57,7 +57,7 @@ public class TestCompoundFile extends Lu
     @Override
     protected void setUp() throws Exception {
        super.setUp();
-       File file = new File(System.getProperty("tempDir"), "testIndex");
+       File file = new File(TEMP_DIR, "testIndex");
        _TestUtil.rmDir(file);
        // use a simple FSDir here, to be sure to have SimpleFSInputs
        dir = new SimpleFSDirectory(file,null);
@@ -66,6 +66,7 @@ public class TestCompoundFile extends Lu
     @Override
     protected void tearDown() throws Exception {
        dir.close();
+       _TestUtil.rmDir(new File(TEMP_DIR, "testIndex"));
        super.tearDown();
     }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java Sun Mar 14 16:19:51 2010
@@ -58,7 +58,7 @@ public class TestDoc extends LuceneTestC
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        workDir = new File(System.getProperty("tempDir"),"TestDoc");
+        workDir = new File(TEMP_DIR,"TestDoc");
         workDir.mkdirs();
 
         indexDir = new File(workDir, "testIndex");

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestFieldsReader.java Sun Mar 14 16:19:51 2010
@@ -210,10 +210,8 @@ public class TestFieldsReader extends Lu
    * @throws Exception
    */
   public void testLazyPerformance() throws Exception {
-    String tmpIODir = System.getProperty("tempDir");
     String userName = System.getProperty("user.name");
-    String path = tmpIODir + File.separator + "lazyDir" + userName;
-    File file = new File(path);
+    File file = new File(TEMP_DIR, "lazyDir" + userName);
     _TestUtil.rmDir(file);
     FSDirectory tmpDir = FSDirectory.open(file);
     assertTrue(tmpDir != null);
@@ -391,10 +389,7 @@ public class TestFieldsReader extends Lu
 
   // LUCENE-1262
   public void testExceptions() throws Throwable {
-    String tempDir = System.getProperty("java.io.tmpdir");
-    if (tempDir == null)
-      throw new IOException("java.io.tmpdir undefined, cannot run test");
-    File indexDir = new File(tempDir, "testfieldswriterexceptions");
+    File indexDir = new File(TEMP_DIR, "testfieldswriterexceptions");
 
     try {
       Directory dir = new FaultyFSDirectory(indexDir);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java Sun Mar 14 16:19:51 2010
@@ -507,7 +507,7 @@ public class TestIndexReader extends Luc
     // Make sure you can set norms & commit even if a reader
     // is open against the index:
     public void testWritingNorms() throws IOException {
-        File indexDir = new File(System.getProperty("tempDir"), "lucenetestnormwriter");
+        File indexDir = new File(TEMP_DIR, "lucenetestnormwriter");
         Directory dir = FSDirectory.open(indexDir);
         IndexWriter writer;
         IndexReader reader;
@@ -685,12 +685,12 @@ public class TestIndexReader extends Luc
     }
 
   private Directory getDirectory() throws IOException {
-    return FSDirectory.open(new File(System.getProperty("tempDir"), "testIndex"));
+    return FSDirectory.open(new File(TEMP_DIR, "testIndex"));
   }
 
   public void testFilesOpenClose() throws IOException {
         // Create initial data set
-        File dirFile = new File(System.getProperty("tempDir"), "testIndex");
+        File dirFile = new File(TEMP_DIR, "testIndex");
         Directory dir = getDirectory();
         IndexWriter writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)));
         addDoc(writer, "test");
@@ -719,7 +719,7 @@ public class TestIndexReader extends Luc
     }
 
     public void testLastModified() throws Exception {
-      final File fileDir = new File(System.getProperty("tempDir"), "testIndex");
+      final File fileDir = new File(TEMP_DIR, "testIndex");
       for(int i=0;i<2;i++) {
         try {
           final Directory dir;
@@ -1148,8 +1148,7 @@ public class TestIndexReader extends Luc
     }
 
     public void testOpenReaderAfterDelete() throws IOException {
-      File dirFile = new File(System.getProperty("tempDir"),
-                          "deletetest");
+      File dirFile = new File(TEMP_DIR, "deletetest");
       Directory dir = FSDirectory.open(dirFile);
       try {
         IndexReader.open(dir, false);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java Sun Mar 14 16:19:51 2010
@@ -82,14 +82,8 @@ public class TestIndexReaderCloneNorms e
    * optimize.
    */
   public void testNorms() throws IOException {
-    // tmp dir
-    String tempDir = System.getProperty("java.io.tmpdir");
-    if (tempDir == null) {
-      throw new IOException("java.io.tmpdir undefined, cannot run test");
-    }
-
     // test with a single index: index1
-    File indexDir1 = new File(tempDir, "lucenetestindex1");
+    File indexDir1 = new File(TEMP_DIR, "lucenetestindex1");
     Directory dir1 = FSDirectory.open(indexDir1);
     IndexWriter.unlock(dir1);
 
@@ -108,14 +102,14 @@ public class TestIndexReaderCloneNorms e
     modifiedNorms = new ArrayList<Float>();
     numDocNorms = 0;
 
-    File indexDir2 = new File(tempDir, "lucenetestindex2");
+    File indexDir2 = new File(TEMP_DIR, "lucenetestindex2");
     Directory dir2 = FSDirectory.open(indexDir2);
 
     createIndex(dir2);
     doTestNorms(dir2);
 
     // add index1 and index2 to a third index: index3
-    File indexDir3 = new File(tempDir, "lucenetestindex3");
+    File indexDir3 = new File(TEMP_DIR, "lucenetestindex3");
     Directory dir3 = FSDirectory.open(indexDir3);
 
     createIndex(dir3);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java Sun Mar 14 16:19:51 2010
@@ -1097,10 +1097,7 @@ public class TestIndexReaderReopen exten
   @Override
   protected void setUp() throws Exception {
     super.setUp();
-    String tempDir = System.getProperty("java.io.tmpdir");
-    if (tempDir == null)
-      throw new IOException("java.io.tmpdir undefined, cannot run test");
-    indexDir = new File(tempDir, "IndexReaderReopen");
+    indexDir = new File(TEMP_DIR, "IndexReaderReopen");
   }
   
   public void testCloseOrig() throws Throwable {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java Sun Mar 14 16:19:51 2010
@@ -4322,7 +4322,7 @@ public class TestIndexWriter extends Luc
   // create=true does not remove non-index files
   
   public void testOtherFiles() throws Throwable {
-    File indexDir = new File(System.getProperty("tempDir"), "otherfiles");
+    File indexDir = new File(TEMP_DIR, "otherfiles");
     Directory dir = FSDirectory.open(indexDir);
     try {
       // Create my own random file:

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java Sun Mar 14 16:19:51 2010
@@ -39,8 +39,7 @@ public class TestIndexWriterLockRelease 
     protected void setUp() throws Exception {
         super.setUp();
         if (this.__test_dir == null) {
-            String tmp_dir = System.getProperty("java.io.tmpdir", "tmp");
-            this.__test_dir = new File(tmp_dir, "testIndexWriter");
+            this.__test_dir = new File(TEMP_DIR, "testIndexWriter");
 
             if (this.__test_dir.exists()) {
                 throw new IOException("test directory \"" + this.__test_dir.getPath() + "\" already exists (please remove by hand)");

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestThreadedOptimize.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestThreadedOptimize.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestThreadedOptimize.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestThreadedOptimize.java Sun Mar 14 16:19:51 2010
@@ -141,12 +141,8 @@ public class TestThreadedOptimize extend
     runTest(directory, new ConcurrentMergeScheduler());
     directory.close();
 
-    String tempDir = System.getProperty("tempDir");
-    if (tempDir == null)
-      throw new IOException("tempDir undefined, cannot run test");
-
-    String dirName = tempDir + "/luceneTestThreadedOptimize";
-    directory = FSDirectory.open(new File(dirName));
+    File dirName = new File(TEMP_DIR, "luceneTestThreadedOptimize");
+    directory = FSDirectory.open(dirName);
     runTest(directory, new SerialMergeScheduler());
     runTest(directory, new ConcurrentMergeScheduler());
     directory.close();

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java Sun Mar 14 16:19:51 2010
@@ -242,7 +242,7 @@ public class TestBufferedIndexInput exte
     }
 
     public void testSetBufferSize() throws IOException {
-      File indexDir = new File(System.getProperty("tempDir"), "testSetBufferSize");
+      File indexDir = new File(TEMP_DIR, "testSetBufferSize");
       MockFSDirectory dir = new MockFSDirectory(indexDir, newRandom());
       try {
         IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestDirectory.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestDirectory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestDirectory.java Sun Mar 14 16:19:51 2010
@@ -35,7 +35,7 @@ public class TestDirectory extends Lucen
     } catch (AlreadyClosedException ace) {
     }
 
-    dir = FSDirectory.open(new File(System.getProperty("tempDir")));
+    dir = FSDirectory.open(TEMP_DIR);
     dir.close();
     try {
       dir.createOutput("test");
@@ -48,7 +48,7 @@ public class TestDirectory extends Lucen
   // Test that different instances of FSDirectory can coexist on the same
   // path, can read, write, and lock files.
   public void testDirectInstantiation() throws Exception {
-    File path = new File(System.getProperty("tempDir"));
+    File path = new File(TEMP_DIR, "testDirectInstantiation");
 
     int sz = 3;
     Directory[] dirs = new Directory[sz];
@@ -116,11 +116,13 @@ public class TestDirectory extends Lucen
       dir.close();
       assertFalse(dir.isOpen);
     }
+    
+    _TestUtil.rmDir(path);
   }
 
   // LUCENE-1464
   public void testDontCreate() throws Throwable {
-    File path = new File(System.getProperty("tempDir"), "doesnotexist");
+    File path = new File(TEMP_DIR, "doesnotexist");
     try {
       assertTrue(!path.exists());
       Directory dir = new SimpleFSDirectory(path, null);
@@ -138,7 +140,7 @@ public class TestDirectory extends Lucen
 
   // LUCENE-1468
   public void testFSDirectoryFilter() throws IOException {
-    checkDirectoryFilter(FSDirectory.open(new File(System.getProperty("tempDir"),"test")));
+    checkDirectoryFilter(FSDirectory.open(new File(TEMP_DIR,"test")));
   }
 
   // LUCENE-1468
@@ -155,7 +157,7 @@ public class TestDirectory extends Lucen
 
   // LUCENE-1468
   public void testCopySubdir() throws Throwable {
-    File path = new File(System.getProperty("tempDir"), "testsubdir");
+    File path = new File(TEMP_DIR, "testsubdir");
     try {
       path.mkdirs();
       new File(path, "subdir").mkdirs();
@@ -168,7 +170,7 @@ public class TestDirectory extends Lucen
 
   // LUCENE-1468
   public void testNotDirectory() throws Throwable {
-    File path = new File(System.getProperty("tempDir"), "testnotdir");
+    File path = new File(TEMP_DIR, "testnotdir");
     Directory fsDir = new SimpleFSDirectory(path, null);
     try {
       IndexOutput out = fsDir.createOutput("afile");

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java Sun Mar 14 16:19:51 2010
@@ -171,7 +171,7 @@ public class TestLockFactory extends Luc
     // Verify: NativeFSLockFactory works correctly
     public void testNativeFSLockFactory() throws IOException {
 
-      NativeFSLockFactory f = new NativeFSLockFactory(System.getProperty("tempDir"));
+      NativeFSLockFactory f = new NativeFSLockFactory(TEMP_DIR);
 
       f.setLockPrefix("test");
       Lock l = f.makeLock("commit");
@@ -195,7 +195,7 @@ public class TestLockFactory extends Luc
 
     public void testNativeFSLockReleaseByOtherLock() throws IOException {
 
-      NativeFSLockFactory f = new NativeFSLockFactory(System.getProperty("tempDir"));
+      NativeFSLockFactory f = new NativeFSLockFactory(TEMP_DIR);
 
       f.setLockPrefix("test");
       Lock l = f.makeLock("commit");

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestRAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestRAMDirectory.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestRAMDirectory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestRAMDirectory.java Sun Mar 14 16:19:51 2010
@@ -49,10 +49,7 @@ public class TestRAMDirectory extends Lu
   @Override
   protected void setUp () throws Exception {
     super.setUp();
-    String tempDir = System.getProperty("java.io.tmpdir");
-    if (tempDir == null)
-      throw new IOException("java.io.tmpdir undefined, cannot run test");
-    indexDir = new File(tempDir, "RAMDirIndex");
+    indexDir = new File(TEMP_DIR, "RAMDirIndex");
     
     Directory dir = FSDirectory.open(indexDir);
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestWindowsMMap.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestWindowsMMap.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestWindowsMMap.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestWindowsMMap.java Sun Mar 14 16:19:51 2010
@@ -63,7 +63,7 @@ public class TestWindowsMMap extends Luc
   }
   
   private final static String storePathname = 
-    new File(System.getProperty("tempDir"),"testLuceneMmap").getAbsolutePath();
+    new File(TEMP_DIR,"testLuceneMmap").getAbsolutePath();
 
   public void testMmapIndex() throws Exception {
     FSDirectory storeDirectory;

Modified: lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCase.java Sun Mar 14 16:19:51 2010
@@ -17,7 +17,9 @@ package org.apache.lucene.util;
  * limitations under the License.
  */
 
+import java.io.File;
 import java.io.PrintStream;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.Random;
@@ -60,8 +62,12 @@ public abstract class LuceneTestCase ext
    */
   public static final boolean VERBOSE = LuceneTestCaseJ4.VERBOSE;
 
+  /** Use this constant when creating Analyzers and any other version-dependent stuff. */
   public static final Version TEST_VERSION_CURRENT = LuceneTestCaseJ4.TEST_VERSION_CURRENT;
 
+  /** Create indexes in this directory, optimally use a subdir, named after the test */
+  public static final File TEMP_DIR = LuceneTestCaseJ4.TEMP_DIR;
+
   private int savedBoolMaxClauseCount;
   
   private volatile Thread.UncaughtExceptionHandler savedUncaughtExceptionHandler = null;
@@ -250,6 +256,18 @@ public abstract class LuceneTestCase ext
     return new Random(seed);
   }
   
+  /** Gets a resource from the classpath as {@link File}. This method should only be used,
+   * if a real file is needed. To get a stream, code should prefer
+   * {@link Class#getResourceAsStream} using {@code this.getClass()}.
+   */
+  protected File getDataFile(String name) throws IOException {
+    try {
+      return new File(this.getClass().getResource(name).toURI());
+    } catch (Exception e) {
+      throw new IOException("Cannot find resource: " + name);
+    }
+  }
+  
   @Override
   public void runBare() throws Throwable {
     //long t0 = System.currentTimeMillis();

Modified: lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java Sun Mar 14 16:19:51 2010
@@ -28,7 +28,9 @@ import org.junit.Rule;
 import org.junit.rules.TestWatchman;
 import org.junit.runners.model.FrameworkMethod;
 
+import java.io.File;
 import java.io.PrintStream;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.Random;
@@ -58,8 +60,7 @@ import static org.junit.Assert.fail;
  * of its name
  * <p>
  * <p>
- * See Junit4 documentation for a complete list of features at
- * http://junit.org/junit/javadoc/4.7/
+ * See Junit4 <a href="http://junit.org/junit/javadoc/4.7/">documentation</a> for a complete list of features.
  * <p>
  * Import from org.junit rather than junit.framework.
  * <p>
@@ -83,8 +84,19 @@ public class LuceneTestCaseJ4 {
    */
   public static final boolean VERBOSE = Boolean.getBoolean("tests.verbose");
 
-  /** Change this when development starts for new Lucene version: */
+  /** Use this constant when creating Analyzers and any other version-dependent stuff.
+   * <p><b>NOTE:</b> Change this when development starts for new Lucene version:
+   */
   public static final Version TEST_VERSION_CURRENT = Version.LUCENE_31;
+  
+  /** Create indexes in this directory, optimally use a subdir, named after the test */
+  public static final File TEMP_DIR;
+  static {
+    String s = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
+    if (s == null)
+      throw new RuntimeException("To run tests, you need to define system property 'tempDir' or 'java.io.tmpdir'.");
+    TEMP_DIR = new File(s);
+  }
 
   private int savedBoolMaxClauseCount;
 
@@ -100,7 +112,7 @@ public class LuceneTestCaseJ4 {
     }
   }
   private List<UncaughtExceptionEntry> uncaughtExceptions = Collections.synchronizedList(new ArrayList<UncaughtExceptionEntry>());
-
+  
   // This is how we get control when errors occur.
   // Think of this as start/end/success/failed
   // events.
@@ -291,6 +303,18 @@ public class LuceneTestCaseJ4 {
   public String getName() {
     return this.name;
   }
+  
+  /** Gets a resource from the classpath as {@link File}. This method should only be used,
+   * if a real file is needed. To get a stream, code should prefer
+   * {@link Class#getResourceAsStream} using {@code this.getClass()}.
+   */
+  protected File getDataFile(String name) throws IOException {
+    try {
+      return new File(this.getClass().getResource(name).toURI());
+    } catch (Exception e) {
+      throw new IOException("Cannot find resource: " + name);
+    }
+  }
 
   // We get here from InterceptTestCaseEvents on the 'failed' event....
   public void reportAdditionalFailureInfo() {

Modified: lucene/java/trunk/src/test/org/apache/lucene/util/_TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/_TestUtil.java?rev=922886&r1=922885&r2=922886&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/_TestUtil.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/_TestUtil.java Sun Mar 14 16:19:51 2010
@@ -33,10 +33,7 @@ public class _TestUtil {
   /** Returns temp dir, containing String arg in its name;
    *  does not create the directory. */
   public static File getTempDir(String desc) {
-    String tempDir = System.getProperty("java.io.tmpdir");
-    if (tempDir == null)
-      throw new RuntimeException("java.io.tmpdir undefined, cannot run test");
-    return new File(tempDir, desc + "." + new Random().nextLong());
+    return new File(LuceneTestCaseJ4.TEMP_DIR, desc + "." + new Random().nextLong());
   }
 
   public static void rmDir(File dir) throws IOException {



Mime
View raw message