You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2014/04/05 12:09:47 UTC

svn commit: r1585035 [2/5] - in /lucene/dev/branches/branch_4x: ./ dev-tools/ lucene/ lucene/analysis/ lucene/analysis/common/src/test/org/apache/lucene/analysis/util/ lucene/analysis/stempel/src/test/org/egothor/stemmer/ lucene/benchmark/ lucene/bench...

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestBufferedIndexInput.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestBufferedIndexInput.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestBufferedIndexInput.java Sat Apr  5 10:09:42 2014
@@ -224,7 +224,7 @@ public class TestBufferedIndexInput exte
     }
 
     public void testSetBufferSize() throws IOException {
-      File indexDir = TestUtil.getTempDir("testSetBufferSize");
+      File indexDir = createTempDir("testSetBufferSize");
       MockFSDirectory dir = new MockFSDirectory(indexDir, random());
       try {
         IndexWriter writer = new IndexWriter(
@@ -276,7 +276,7 @@ public class TestBufferedIndexInput exte
         writer.close();
         reader.close();
       } finally {
-        TestUtil.rmDir(indexDir);
+        TestUtil.rm(indexDir);
       }
     }
 

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java Sat Apr  5 10:09:42 2014
@@ -30,10 +30,11 @@ import org.apache.lucene.util.TestUtil;
 
 public class TestDirectory extends LuceneTestCase {
   public void testDetectClose() throws Throwable {
+    File tempDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
     Directory[] dirs = new Directory[] { 
         new RAMDirectory(), 
-        new SimpleFSDirectory(TEMP_DIR), 
-        new NIOFSDirectory(TEMP_DIR)
+        new SimpleFSDirectory(tempDir), 
+        new NIOFSDirectory(tempDir)
     };
 
     for (Directory dir : dirs) {
@@ -135,7 +136,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 {
-    final File path = TestUtil.getTempDir("testDirectInstantiation");
+    final File path = createTempDir("testDirectInstantiation");
     
     final byte[] largeBuffer = new byte[random().nextInt(256*1024)], largeReadBuffer = new byte[largeBuffer.length];
     for (int i = 0; i < largeBuffer.length; i++) {
@@ -218,19 +219,19 @@ public class TestDirectory extends Lucen
       assertFalse(dir.isOpen);
     }
     
-    TestUtil.rmDir(path);
+    TestUtil.rm(path);
   }
 
   // LUCENE-1464
   public void testDontCreate() throws Throwable {
-    File path = new File(TEMP_DIR, "doesnotexist");
+    File path = new File(createTempDir(LuceneTestCase.getTestClass().getSimpleName()), "doesnotexist");
     try {
       assertTrue(!path.exists());
       Directory dir = new SimpleFSDirectory(path, null);
       assertTrue(!path.exists());
       dir.close();
     } finally {
-      TestUtil.rmDir(path);
+      TestUtil.rm(path);
     }
   }
 
@@ -241,7 +242,7 @@ public class TestDirectory extends Lucen
 
   // LUCENE-1468
   public void testFSDirectoryFilter() throws IOException {
-    checkDirectoryFilter(newFSDirectory(TestUtil.getTempDir("test")));
+    checkDirectoryFilter(newFSDirectory(createTempDir("test")));
   }
 
   // LUCENE-1468
@@ -258,20 +259,20 @@ public class TestDirectory extends Lucen
 
   // LUCENE-1468
   public void testCopySubdir() throws Throwable {
-    File path = TestUtil.getTempDir("testsubdir");
+    File path = createTempDir("testsubdir");
     try {
       path.mkdirs();
       new File(path, "subdir").mkdirs();
       Directory fsDir = new SimpleFSDirectory(path, null);
       assertEquals(0, new RAMDirectory(fsDir, newIOContext(random())).listAll().length);
     } finally {
-      TestUtil.rmDir(path);
+      TestUtil.rm(path);
     }
   }
 
   // LUCENE-1468
   public void testNotDirectory() throws Throwable {
-    File path = TestUtil.getTempDir("testnotdir");
+    File path = createTempDir("testnotdir");
     Directory fsDir = new SimpleFSDirectory(path, null);
     try {
       IndexOutput out = fsDir.createOutput("afile", newIOContext(random()));
@@ -285,12 +286,13 @@ public class TestDirectory extends Lucen
       }
     } finally {
       fsDir.close();
-      TestUtil.rmDir(path);
+      TestUtil.rm(path);
     }
   }
   
   public void testFsyncDoesntCreateNewFiles() throws Exception {
-    File path = TestUtil.getTempDir("nocreate");
+    File path = createTempDir("nocreate");
+    System.out.println(path.getAbsolutePath());
     Directory fsdir = new SimpleFSDirectory(path);
     
     // write a file

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java Sat Apr  5 10:09:42 2014
@@ -88,8 +88,8 @@ public class TestFileSwitchDirectory ext
   }
   
   private Directory newFSSwitchDirectory(Set<String> primaryExtensions) throws IOException {
-    File primDir = TestUtil.getTempDir("foo");
-    File secondDir = TestUtil.getTempDir("bar");
+    File primDir = createTempDir("foo");
+    File secondDir = createTempDir("bar");
     return newFSSwitchDirectory(primDir, secondDir, primaryExtensions);
   }
 
@@ -102,10 +102,10 @@ public class TestFileSwitchDirectory ext
   
   // LUCENE-3380 -- make sure we get exception if the directory really does not exist.
   public void testNoDir() throws Throwable {
-    File primDir = TestUtil.getTempDir("foo");
-    File secondDir = TestUtil.getTempDir("bar");
-    TestUtil.rmDir(primDir);
-    TestUtil.rmDir(secondDir);
+    File primDir = createTempDir("foo");
+    File secondDir = createTempDir("bar");
+    TestUtil.rm(primDir);
+    TestUtil.rm(secondDir);
     Directory dir = newFSSwitchDirectory(primDir, secondDir, Collections.<String>emptySet());
     try {
       DirectoryReader.open(dir);

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestLockFactory.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestLockFactory.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestLockFactory.java Sat Apr  5 10:09:42 2014
@@ -136,7 +136,7 @@ public class TestLockFactory extends Luc
     // no unexpected exceptions are raised:
     @Nightly
     public void testStressLocks() throws Exception {
-      _testStressLocks(null, TestUtil.getTempDir("index.TestLockFactory6"));
+      _testStressLocks(null, createTempDir("index.TestLockFactory6"));
     }
 
     // Verify: do stress test, by opening IndexReaders and
@@ -145,7 +145,7 @@ public class TestLockFactory extends Luc
     // NativeFSLockFactory:
     @Nightly
     public void testStressLocksNativeFSLockFactory() throws Exception {
-      File dir = TestUtil.getTempDir("index.TestLockFactory7");
+      File dir = createTempDir("index.TestLockFactory7");
       _testStressLocks(new NativeFSLockFactory(dir), dir);
     }
 
@@ -171,13 +171,12 @@ public class TestLockFactory extends Luc
 
         dir.close();
         // Cleanup
-        TestUtil.rmDir(indexDir);
+        TestUtil.rm(indexDir);
     }
 
     // Verify: NativeFSLockFactory works correctly
     public void testNativeFSLockFactory() throws IOException {
-
-      NativeFSLockFactory f = new NativeFSLockFactory(TEMP_DIR);
+      NativeFSLockFactory f = new NativeFSLockFactory(createTempDir(LuceneTestCase.getTestClass().getSimpleName()));
 
       f.setLockPrefix("test");
       Lock l = f.makeLock("commit");
@@ -202,11 +201,11 @@ public class TestLockFactory extends Luc
     
     // Verify: NativeFSLockFactory works correctly if the lock file exists
     public void testNativeFSLockFactoryLockExists() throws IOException {
-      
-      File lockFile = new File(TEMP_DIR, "test.lock");
+      File tempDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
+      File lockFile = new File(tempDir, "test.lock");
       lockFile.createNewFile();
       
-      Lock l = new NativeFSLockFactory(TEMP_DIR).makeLock("test.lock");
+      Lock l = new NativeFSLockFactory(tempDir).makeLock("test.lock");
       assertTrue("failed to obtain lock", l.obtain());
       l.close();
       assertFalse("failed to release lock", l.isLocked());
@@ -216,8 +215,7 @@ public class TestLockFactory extends Luc
     }
 
     public void testNativeFSLockReleaseByOtherLock() throws IOException {
-
-      NativeFSLockFactory f = new NativeFSLockFactory(TEMP_DIR);
+      NativeFSLockFactory f = new NativeFSLockFactory(createTempDir(LuceneTestCase.getTestClass().getSimpleName()));
 
       f.setLockPrefix("test");
       Lock l = f.makeLock("commit");
@@ -238,8 +236,8 @@ public class TestLockFactory extends Luc
     // Verify: NativeFSLockFactory assigns null as lockPrefix if the lockDir is inside directory
     public void testNativeFSLockFactoryPrefix() throws IOException {
 
-      File fdir1 = TestUtil.getTempDir("TestLockFactory.8");
-      File fdir2 = TestUtil.getTempDir("TestLockFactory.8.Lockdir");
+      File fdir1 = createTempDir("TestLockFactory.8");
+      File fdir2 = createTempDir("TestLockFactory.8.Lockdir");
       Directory dir1 = newFSDirectory(fdir1, new NativeFSLockFactory(fdir1));
       // same directory, but locks are stored somewhere else. The prefix of the lock factory should != null
       Directory dir2 = newFSDirectory(fdir1, new NativeFSLockFactory(fdir2));
@@ -252,8 +250,8 @@ public class TestLockFactory extends Luc
 
       dir1.close();
       dir2.close();
-      TestUtil.rmDir(fdir1);
-      TestUtil.rmDir(fdir2);
+      TestUtil.rm(fdir1);
+      TestUtil.rm(fdir2);
     }
 
     // Verify: default LockFactory has no prefix (ie
@@ -261,7 +259,7 @@ public class TestLockFactory extends Luc
     public void testDefaultFSLockFactoryPrefix() throws IOException {
 
       // Make sure we get null prefix, which wont happen if setLockFactory is ever called.
-      File dirName = TestUtil.getTempDir("TestLockFactory.10");
+      File dirName = createTempDir("TestLockFactory.10");
 
       Directory dir = new SimpleFSDirectory(dirName);
       assertNull("Default lock prefix should be null", dir.getLockFactory().getLockPrefix());
@@ -275,7 +273,7 @@ public class TestLockFactory extends Luc
       assertNull("Default lock prefix should be null", dir.getLockFactory().getLockPrefix());
       dir.close();
  
-      TestUtil.rmDir(dirName);
+      TestUtil.rm(dirName);
     }
 
     private class WriterThread extends Thread { 

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java Sat Apr  5 10:09:42 2014
@@ -38,18 +38,15 @@ import org.apache.lucene.util.TestUtil;
  * Integer.MAX_VALUE in size using multiple byte buffers.
  */
 public class TestMultiMMap extends LuceneTestCase {
-  File workDir;
   
   @Override
   public void setUp() throws Exception {
     super.setUp();
     assumeTrue("test requires a jre that supports unmapping", MMapDirectory.UNMAP_SUPPORTED);
-    workDir = TestUtil.getTempDir("TestMultiMMap");
-    workDir.mkdirs();
   }
   
   public void testCloneSafety() throws Exception {
-    MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testCloneSafety"));
+    MMapDirectory mmapDir = new MMapDirectory(createTempDir("testCloneSafety"));
     IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
     io.writeVInt(5);
     io.close();
@@ -83,7 +80,7 @@ public class TestMultiMMap extends Lucen
   }
   
   public void testCloneClose() throws Exception {
-    MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testCloneClose"));
+    MMapDirectory mmapDir = new MMapDirectory(createTempDir("testCloneClose"));
     IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
     io.writeVInt(5);
     io.close();
@@ -105,7 +102,7 @@ public class TestMultiMMap extends Lucen
   }
   
   public void testCloneSliceSafety() throws Exception {
-    MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testCloneSliceSafety"));
+    MMapDirectory mmapDir = new MMapDirectory(createTempDir("testCloneSliceSafety"));
     IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
     io.writeInt(1);
     io.writeInt(2);
@@ -150,7 +147,7 @@ public class TestMultiMMap extends Lucen
   }
 
   public void testCloneSliceClose() throws Exception {
-    MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testCloneSliceClose"));
+    MMapDirectory mmapDir = new MMapDirectory(createTempDir("testCloneSliceClose"));
     IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
     io.writeInt(1);
     io.writeInt(2);
@@ -177,7 +174,7 @@ public class TestMultiMMap extends Lucen
 
   public void testSeekZero() throws Exception {
     for (int i = 0; i < 31; i++) {
-      MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testSeekZero"), null, 1<<i);
+      MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSeekZero"), null, 1<<i);
       IndexOutput io = mmapDir.createOutput("zeroBytes", newIOContext(random()));
       io.close();
       IndexInput ii = mmapDir.openInput("zeroBytes", newIOContext(random()));
@@ -189,7 +186,7 @@ public class TestMultiMMap extends Lucen
   
   public void testSeekSliceZero() throws Exception {
     for (int i = 0; i < 31; i++) {
-      MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testSeekSliceZero"), null, 1<<i);
+      MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSeekSliceZero"), null, 1<<i);
       IndexOutput io = mmapDir.createOutput("zeroBytes", newIOContext(random()));
       io.close();
       IndexInputSlicer slicer = mmapDir.createSlicer("zeroBytes", newIOContext(random()));
@@ -203,7 +200,7 @@ public class TestMultiMMap extends Lucen
   
   public void testSeekEnd() throws Exception {
     for (int i = 0; i < 17; i++) {
-      MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testSeekEnd"), null, 1<<i);
+      MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSeekEnd"), null, 1<<i);
       IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
       byte bytes[] = new byte[1<<i];
       random().nextBytes(bytes);
@@ -221,7 +218,7 @@ public class TestMultiMMap extends Lucen
   
   public void testSeekSliceEnd() throws Exception {
     for (int i = 0; i < 17; i++) {
-      MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testSeekSliceEnd"), null, 1<<i);
+      MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSeekSliceEnd"), null, 1<<i);
       IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
       byte bytes[] = new byte[1<<i];
       random().nextBytes(bytes);
@@ -241,7 +238,7 @@ public class TestMultiMMap extends Lucen
   
   public void testSeeking() throws Exception {
     for (int i = 0; i < 10; i++) {
-      MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testSeeking"), null, 1<<i);
+      MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSeeking"), null, 1<<i);
       IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
       byte bytes[] = new byte[1<<(i+1)]; // make sure we switch buffers
       random().nextBytes(bytes);
@@ -268,7 +265,7 @@ public class TestMultiMMap extends Lucen
   // the various offset+length and just does readBytes.
   public void testSlicedSeeking() throws Exception {
     for (int i = 0; i < 10; i++) {
-      MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testSlicedSeeking"), null, 1<<i);
+      MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSlicedSeeking"), null, 1<<i);
       IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
       byte bytes[] = new byte[1<<(i+1)]; // make sure we switch buffers
       random().nextBytes(bytes);
@@ -301,9 +298,7 @@ public class TestMultiMMap extends Lucen
   }
   
   private void assertChunking(Random random, int chunkSize) throws Exception {
-    File path = TestUtil.createTempFile("mmap" + chunkSize, "tmp", workDir);
-    path.delete();
-    path.mkdirs();
+    File path = createTempDir("mmap" + chunkSize);
     MMapDirectory mmapDir = new MMapDirectory(path, null, chunkSize);
     // we will map a lot, try to turn on the unmap hack
     if (MMapDirectory.UNMAP_SUPPORTED)

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java Sat Apr  5 10:09:42 2014
@@ -124,8 +124,8 @@ public class TestNRTCachingDirectory ext
   
   // LUCENE-3382 -- make sure we get exception if the directory really does not exist.
   public void testNoDir() throws Throwable {
-    File tempDir = TestUtil.getTempDir("doesnotexist");
-    TestUtil.rmDir(tempDir);
+    File tempDir = createTempDir("doesnotexist");
+    TestUtil.rm(tempDir);
     Directory dir = new NRTCachingDirectory(newFSDirectory(tempDir), 2.0, 25.0);
     try {
       DirectoryReader.open(dir);
@@ -138,7 +138,7 @@ public class TestNRTCachingDirectory ext
   
   // LUCENE-3382 test that we can add a file, and then when we call list() we get it back
   public void testDirectoryFilter() throws IOException {
-    Directory dir = new NRTCachingDirectory(newFSDirectory(TestUtil.getTempDir("foo")), 2.0, 25.0);
+    Directory dir = new NRTCachingDirectory(newFSDirectory(createTempDir("foo")), 2.0, 25.0);
     String name = "file";
     try {
       dir.createOutput(name, newIOContext(random())).close();

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java Sat Apr  5 10:09:42 2014
@@ -49,7 +49,7 @@ public class TestRAMDirectory extends Lu
   @Override
   public void setUp() throws Exception {
     super.setUp();
-    indexDir = TestUtil.getTempDir("RAMDirIndex");
+    indexDir = createTempDir("RAMDirIndex");
     
     Directory dir = newFSDirectory(indexDir);
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java Sat Apr  5 10:09:42 2014
@@ -65,7 +65,7 @@ public class TestWindowsMMap extends Luc
     // sometimes the directory is not cleaned by rmDir, because on Windows it
     // may take some time until the files are finally dereferenced. So clean the
     // directory up front, or otherwise new IndexWriter will fail.
-    File dirPath = TestUtil.getTempDir("testLuceneMmap");
+    File dirPath = createTempDir("testLuceneMmap");
     rmDir(dirPath);
     MMapDirectory dir = new MMapDirectory(dirPath, null);
     

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/Test2BPagedBytes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/Test2BPagedBytes.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/Test2BPagedBytes.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/Test2BPagedBytes.java Sat Apr  5 10:09:42 2014
@@ -30,7 +30,7 @@ import org.junit.Ignore;
 public class Test2BPagedBytes extends LuceneTestCase {
 
   public void test() throws Exception {
-    BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("test2BPagedBytes"));
+    BaseDirectoryWrapper dir = newFSDirectory(createTempDir("test2BPagedBytes"));
     if (dir instanceof MockDirectoryWrapper) {
       ((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
     }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java Sat Apr  5 10:09:42 2014
@@ -43,15 +43,15 @@ public class TestOfflineSorter extends L
   @Override
   public void setUp() throws Exception {
     super.setUp();
-    tempDir = TestUtil.getTempDir("mergesort");
-    TestUtil.rmDir(tempDir);
+    tempDir = createTempDir("mergesort");
+    TestUtil.rm(tempDir);
     tempDir.mkdirs();
   }
   
   @Override
   public void tearDown() throws Exception {
     if (tempDir != null)
-      TestUtil.rmDir(tempDir);
+      TestUtil.rm(tempDir);
     super.tearDown();
   }
 

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestPagedBytes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestPagedBytes.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestPagedBytes.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestPagedBytes.java Sat Apr  5 10:09:42 2014
@@ -37,7 +37,7 @@ public class TestPagedBytes extends Luce
   public void testDataInputOutput() throws Exception {
     Random random = random();
     for(int iter=0;iter<5*RANDOM_MULTIPLIER;iter++) {
-      BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("testOverflow"));
+      BaseDirectoryWrapper dir = newFSDirectory(createTempDir("testOverflow"));
       if (dir instanceof MockDirectoryWrapper) {
         ((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
       }
@@ -150,7 +150,7 @@ public class TestPagedBytes extends Luce
 
   @Ignore // memory hole
   public void testOverflow() throws IOException {
-    BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("testOverflow"));
+    BaseDirectoryWrapper dir = newFSDirectory(createTempDir("testOverflow"));
     if (dir instanceof MockDirectoryWrapper) {
       ((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
     }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/fst/Test2BFST.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/fst/Test2BFST.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/fst/Test2BFST.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/fst/Test2BFST.java Sat Apr  5 10:09:42 2014
@@ -45,7 +45,7 @@ public class Test2BFST extends LuceneTes
     IntsRef input = new IntsRef(ints, 0, ints.length);
     long seed = random().nextLong();
 
-    Directory dir = new MMapDirectory(TestUtil.getTempDir("2BFST"));
+    Directory dir = new MMapDirectory(createTempDir("2BFST"));
 
     for(int doPackIter=0;doPackIter<2;doPackIter++) {
       boolean doPack = doPackIter == 1;

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java Sat Apr  5 10:09:42 2014
@@ -310,7 +310,7 @@ public class TestFSTs extends LuceneTest
     analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));
 
     final IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(-1).setRAMBufferSizeMB(64);
-    final File tempDir = TestUtil.getTempDir("fstlines");
+    final File tempDir = createTempDir("fstlines");
     final Directory dir = newFSDirectory(tempDir);
     final IndexWriter writer = new IndexWriter(dir, conf);
     final long stopTime = System.currentTimeMillis() + RUN_TIME_MSEC;

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestLeaveFilesIfTestFails.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestLeaveFilesIfTestFails.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestLeaveFilesIfTestFails.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestLeaveFilesIfTestFails.java Sat Apr  5 10:09:42 2014
@@ -18,13 +18,19 @@ package org.apache.lucene.util.junitcomp
  */
 
 import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
 
+import org.apache.lucene.util.Constants;
+import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.JUnitCore;
 import org.junit.runner.Result;
 
+import com.carrotsearch.randomizedtesting.RandomizedTest;
+
 public class TestLeaveFilesIfTestFails extends WithNestedTests {
   public TestLeaveFilesIfTestFails() {
     super(true);
@@ -33,8 +39,7 @@ public class TestLeaveFilesIfTestFails e
   public static class Nested1 extends WithNestedTests.AbstractNestedTest {
     static File file;
     public void testDummy() {
-      file = TestUtil.getTempDir("leftover");
-      file.mkdirs();
+      file = createTempDir("leftover");
       fail();
     }
   }
@@ -43,7 +48,33 @@ public class TestLeaveFilesIfTestFails e
   public void testLeaveFilesIfTestFails() {
     Result r = JUnitCore.runClasses(Nested1.class);
     Assert.assertEquals(1, r.getFailureCount());
-    Assert.assertTrue(Nested1.file.exists());
+    Assert.assertTrue(Nested1.file != null && Nested1.file.exists());
     Nested1.file.delete();
   }
+  
+  public static class Nested2 extends WithNestedTests.AbstractNestedTest {
+    static File file;
+    static File parent;
+    static RandomAccessFile openFile;
+
+    @SuppressWarnings("deprecation")
+    public void testDummy() throws Exception {
+      file = new File(createTempDir("leftover"), "child.locked");
+      openFile = new RandomAccessFile(file, "rw");
+
+      parent = LuceneTestCase.getBaseTempDirForTestClass();
+    }
+  }
+
+  @Test
+  public void testWindowsUnremovableFile() throws IOException {
+    RandomizedTest.assumeTrue("Requires Windows.", Constants.WINDOWS);
+
+    Result r = JUnitCore.runClasses(Nested2.class);
+    super.prevSysErr.println(r.getFailures().get(0).getMessage());
+    Assert.assertEquals(1, r.getFailureCount());
+
+    Nested2.openFile.close();
+    TestUtil.rm(Nested2.parent);
+  }  
 }

Modified: lucene/dev/branches/branch_4x/lucene/demo/src/test/org/apache/lucene/demo/TestDemo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/demo/src/test/org/apache/lucene/demo/TestDemo.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/demo/src/test/org/apache/lucene/demo/TestDemo.java (original)
+++ lucene/dev/branches/branch_4x/lucene/demo/src/test/org/apache/lucene/demo/TestDemo.java Sat Apr  5 10:09:42 2014
@@ -44,7 +44,7 @@ public class TestDemo extends LuceneTest
 
   public void testIndexSearch() throws Exception {
     File dir = getDataFile("test-files/docs");
-    File indexDir = TestUtil.getTempDir("ContribDemoTest");
+    File indexDir = createTempDir("ContribDemoTest");
     IndexFiles.main(new String[] { "-create", "-docs", dir.getPath(), "-index", indexDir.getPath()});
     testOneSearch(indexDir, "apache", 3);
     testOneSearch(indexDir, "patent", 8);

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java Sat Apr  5 10:09:42 2014
@@ -942,10 +942,12 @@ public class DirectoryTaxonomyWriter imp
         map[origordinal] = newordinal;
       }
       in.close();
+
       // Delete the temporary file, which is no longer needed.
       if (!tmpfile.delete()) {
         tmpfile.deleteOnExit();
       }
+
       return map;
     }
   }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestAddTaxonomy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestAddTaxonomy.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestAddTaxonomy.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestAddTaxonomy.java Sat Apr  5 10:09:42 2014
@@ -74,7 +74,7 @@ public class TestAddTaxonomy extends Fac
   
   private OrdinalMap randomOrdinalMap() throws IOException {
     if (random().nextBoolean()) {
-      return new DiskOrdinalMap(TestUtil.createTempFile("taxoMap", "", TEMP_DIR));
+      return new DiskOrdinalMap(createTempFile("taxoMap", ""));
     } else {
       return new MemoryOrdinalMap();
     }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCharBlockArray.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCharBlockArray.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCharBlockArray.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCharBlockArray.java Sat Apr  5 10:09:42 2014
@@ -85,7 +85,7 @@ public class TestCharBlockArray extends 
 
     assertEqualsInternal("GrowingCharArray<->StringBuilder mismatch.", builder, array);
 
-    File tempDir = TestUtil.getTempDir("growingchararray");
+    File tempDir = createTempDir("growingchararray");
     File f = new File(tempDir, "GrowingCharArrayTest.tmp");
     BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));
     array.flush(out);

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCompactLabelToOrdinal.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCompactLabelToOrdinal.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCompactLabelToOrdinal.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCompactLabelToOrdinal.java Sat Apr  5 10:09:42 2014
@@ -68,7 +68,7 @@ public class TestCompactLabelToOrdinal e
       }
     }
 
-    File tmpDir = TestUtil.getTempDir("testLableToOrdinal");
+    File tmpDir = createTempDir("testLableToOrdinal");
     File f = new File(tmpDir, "CompactLabelToOrdinalTest.tmp");
     int flushInterval = 10;
 

Modified: lucene/dev/branches/branch_4x/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java (original)
+++ lucene/dev/branches/branch_4x/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java Sat Apr  5 10:09:42 2014
@@ -28,12 +28,8 @@ import org.apache.lucene.util.TestUtil;
 
 public class TestIndexSplitter extends LuceneTestCase {
   public void test() throws Exception {
-    File dir = new File(TEMP_DIR, "testfilesplitter");
-    TestUtil.rmDir(dir);
-    dir.mkdirs();
-    File destDir = new File(TEMP_DIR, "testfilesplitterdest");
-    TestUtil.rmDir(destDir);
-    destDir.mkdirs();
+    File dir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
+    File destDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
     Directory fsDir = newFSDirectory(dir);
     // IndexSplitter.split makes its own commit directly with SIPC/SegmentInfos,
     // so the unreferenced files are expected.
@@ -80,9 +76,7 @@ public class TestIndexSplitter extends L
     fsDirDest.close();
     
     // now test cmdline
-    File destDir2 = new File(TEMP_DIR, "testfilesplitterdest2");
-    TestUtil.rmDir(destDir2);
-    destDir2.mkdirs();
+    File destDir2 = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
     IndexSplitter.main(new String[] {dir.getAbsolutePath(), destDir2.getAbsolutePath(), splitSegName});
     assertEquals(5, destDir2.listFiles().length);
     Directory fsDirDest2 = newFSDirectory(destDir2);

Modified: lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java Sat Apr  5 10:09:42 2014
@@ -192,7 +192,7 @@ public class IndexAndTaxonomyReplication
     publishTaxoDir = newDirectory();
     handlerIndexDir = newMockDirectory();
     handlerTaxoDir = newMockDirectory();
-    clientWorkDir = TestUtil.getTempDir("replicationClientTest");
+    clientWorkDir = createTempDir("replicationClientTest");
     sourceDirFactory = new PerSessionDirectoryFactory(clientWorkDir);
     replicator = new LocalReplicator();
     callback = new IndexAndTaxonomyReadyCallback(handlerIndexDir, handlerTaxoDir);

Modified: lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java Sat Apr  5 10:09:42 2014
@@ -136,7 +136,7 @@ public class IndexReplicationClientTest 
     super.setUp();
     publishDir = newMockDirectory();
     handlerDir = newMockDirectory();
-    sourceDirFactory = new PerSessionDirectoryFactory(TestUtil.getTempDir("replicationClientTest"));
+    sourceDirFactory = new PerSessionDirectoryFactory(createTempDir("replicationClientTest"));
     replicator = new LocalReplicator();
     callback = new IndexReadyCallback(handlerDir);
     handler = new IndexReplicationHandler(handlerDir, callback);

Modified: lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java Sat Apr  5 10:09:42 2014
@@ -68,7 +68,7 @@ public class HttpReplicatorTest extends 
   public void setUp() throws Exception {
     super.setUp();
     System.setProperty("org.eclipse.jetty.LEVEL", "DEBUG"); // sets stderr logging to DEBUG level
-    clientWorkDir = TestUtil.getTempDir("httpReplicatorTest");
+    clientWorkDir = createTempDir("httpReplicatorTest");
     handlerIndexDir = newDirectory();
     serverIndexDir = newDirectory();
     serverReplicator = new LocalReplicator();

Modified: lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/LookupBenchmarkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/LookupBenchmarkTest.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/LookupBenchmarkTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/LookupBenchmarkTest.java Sat Apr  5 10:09:42 2014
@@ -163,7 +163,7 @@ public class LookupBenchmarkTest extends
     } catch (InstantiationException e) {
       Analyzer a = new MockAnalyzer(random, MockTokenizer.KEYWORD, false);
       if (cls == AnalyzingInfixSuggester.class) {
-        lookup = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, FSDirectory.open(TestUtil.getTempDir("LookupBenchmarkTest")), a);
+        lookup = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, FSDirectory.open(createTempDir("LookupBenchmarkTest")), a);
       } else {
         Constructor<? extends Lookup> ctor = cls.getConstructor(Analyzer.class);
         lookup = ctor.newInstance(a);

Modified: lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/PersistenceTest.java Sat Apr  5 10:09:42 2014
@@ -70,7 +70,7 @@ public class PersistenceTest extends Luc
     lookup.build(new InputArrayIterator(keys));
 
     // Store the suggester.
-    File storeDir = TEMP_DIR;
+    File storeDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
     lookup.store(new FileOutputStream(new File(storeDir, "lookup.dat")));
 
     // Re-read it from disk.

Modified: lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java Sat Apr  5 10:09:42 2014
@@ -96,7 +96,7 @@ public class AnalyzingInfixSuggesterTest
       new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz")),
     };
 
-    File tempDir = TestUtil.getTempDir("AnalyzingInfixSuggesterTest");
+    File tempDir = createTempDir("AnalyzingInfixSuggesterTest");
 
     Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
     AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, newFSDirectory(tempDir), a, a, 3);
@@ -218,7 +218,7 @@ public class AnalyzingInfixSuggesterTest
       new Input("lend me your ear", 8, new BytesRef("foobar")),
       new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz")),
     };
-    File tempDir = TestUtil.getTempDir("AnalyzingInfixSuggesterTest");
+    File tempDir = createTempDir("AnalyzingInfixSuggesterTest");
 
     Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
     int minPrefixLength = random().nextInt(10);
@@ -479,7 +479,7 @@ public class AnalyzingInfixSuggesterTest
   }
 
   public void testRandomNRT() throws Exception {
-    final File tempDir = TestUtil.getTempDir("AnalyzingInfixSuggesterTest");
+    final File tempDir = createTempDir("AnalyzingInfixSuggesterTest");
     Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
     int minPrefixChars = random().nextInt(7);
     if (VERBOSE) {
@@ -814,7 +814,7 @@ public class AnalyzingInfixSuggesterTest
       new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz"), asSet("foo", "baz"))
     };
 
-    File tempDir = TestUtil.getTempDir("analyzingInfixContext");
+    File tempDir = createTempDir("analyzingInfixContext");
 
     for(int iter=0;iter<2;iter++) {
       AnalyzingInfixSuggester suggester;

Modified: lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java Sat Apr  5 10:09:42 2014
@@ -921,7 +921,7 @@ public class AnalyzingSuggesterTest exte
     assertEquals(3, results.get(2).value);
 
     // Try again after save/load:
-    File tmpDir = TestUtil.getTempDir("AnalyzingSuggesterTest");
+    File tmpDir = createTempDir("AnalyzingSuggesterTest");
     tmpDir.mkdir();
 
     File path = new File(tmpDir, "suggester");
@@ -983,7 +983,7 @@ public class AnalyzingSuggesterTest exte
     assertEquals(5, results.get(1).value);
 
     // Try again after save/load:
-    File tmpDir = TestUtil.getTempDir("AnalyzingSuggesterTest");
+    File tmpDir = createTempDir("AnalyzingSuggesterTest");
     tmpDir.mkdir();
 
     File path = new File(tmpDir, "suggester");
@@ -1053,7 +1053,7 @@ public class AnalyzingSuggesterTest exte
     assertEquals(5, results.get(1).value);
 
     // Try again after save/load:
-    File tmpDir = TestUtil.getTempDir("AnalyzingSuggesterTest");
+    File tmpDir = createTempDir("AnalyzingSuggesterTest");
     tmpDir.mkdir();
 
     File path = new File(tmpDir, "suggester");

Modified: lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/BlendedInfixSuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/BlendedInfixSuggesterTest.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/BlendedInfixSuggesterTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/BlendedInfixSuggesterTest.java Sat Apr  5 10:09:42 2014
@@ -17,6 +17,10 @@ package org.apache.lucene.search.suggest
  * limitations under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.analysis.util.CharArraySet;
@@ -25,11 +29,6 @@ import org.apache.lucene.search.suggest.
 import org.apache.lucene.search.suggest.Lookup;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.TestUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
 
 public class BlendedInfixSuggesterTest extends LuceneTestCase {
 
@@ -45,7 +44,7 @@ public class BlendedInfixSuggesterTest e
         new Input("star wars: episode v - the empire strikes back", 8, payload)
     };
 
-    File tempDir = TestUtil.getTempDir("BlendedInfixSuggesterTest");
+    File tempDir = createTempDir("BlendedInfixSuggesterTest");
 
     Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
     BlendedInfixSuggester suggester = new BlendedInfixSuggester(TEST_VERSION_CURRENT, newFSDirectory(tempDir), a, a,
@@ -84,7 +83,7 @@ public class BlendedInfixSuggesterTest e
         new Input("top of the lake", w, pl)
     };
 
-    File tempDir = TestUtil.getTempDir("BlendedInfixSuggesterTest");
+    File tempDir = createTempDir("BlendedInfixSuggesterTest");
     Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
 
     // BlenderType.LINEAR is used by default (remove position*10%)
@@ -125,7 +124,7 @@ public class BlendedInfixSuggesterTest e
         new Input("the returned", 10, ret),
     };
 
-    File tempDir = TestUtil.getTempDir("BlendedInfixSuggesterTest");
+    File tempDir = createTempDir("BlendedInfixSuggesterTest");
     Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
 
     // if factor is small, we don't get the expected element
@@ -175,7 +174,7 @@ public class BlendedInfixSuggesterTest e
         new Input("the returned", 10, ret),
     };
 
-    File tempDir = TestUtil.getTempDir("BlendedInfixSuggesterTest");
+    File tempDir = createTempDir("BlendedInfixSuggesterTest");
     Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
 
     // if factor is small, we don't get the expected element

Modified: lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java (original)
+++ lucene/dev/branches/branch_4x/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java Sat Apr  5 10:09:42 2014
@@ -85,7 +85,7 @@ public class TestFreeTextSuggester exten
                    toString(sug.lookup("b", 10)));
 
       // Try again after save/load:
-      File tmpDir = TestUtil.getTempDir("FreeTextSuggesterTest");
+      File tmpDir = createTempDir("FreeTextSuggesterTest");
       tmpDir.mkdir();
 
       File path = new File(tmpDir, "suggester");

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java Sat Apr  5 10:09:42 2014
@@ -503,7 +503,7 @@ public abstract class BaseTokenStreamTes
         !(postingsFormat.equals("Memory") ||
             postingsFormat.equals("SimpleText"));
     if (rarely(random) && codecOk) {
-      dir = newFSDirectory(TestUtil.getTempDir("bttc"));
+      dir = newFSDirectory(createTempDir("bttc"));
       iw = new RandomIndexWriter(new Random(seed), dir, a);
     }
     boolean success = false;

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java Sat Apr  5 10:09:42 2014
@@ -2615,7 +2615,7 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
     // FSDirectory because SimpleText will consume gobbs of
     // space when storing big binary values:
-    Directory d = newFSDirectory(TestUtil.getTempDir("hugeBinaryValues"));
+    Directory d = newFSDirectory(createTempDir("hugeBinaryValues"));
     boolean doFixed = random().nextBoolean();
     int numDocs;
     int fixedLength = 0;
@@ -2713,7 +2713,7 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
     // FSDirectory because SimpleText will consume gobbs of
     // space when storing big binary values:
-    Directory d = newFSDirectory(TestUtil.getTempDir("hugeBinaryValues"));
+    Directory d = newFSDirectory(createTempDir("hugeBinaryValues"));
     boolean doFixed = random().nextBoolean();
     int numDocs;
     int fixedLength = 0;

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java Sat Apr  5 10:09:42 2014
@@ -1064,7 +1064,7 @@ public abstract class BasePostingsFormat
   /** Indexes all fields/terms at the specified
    *  IndexOptions, and fully tests at that IndexOptions. */
   private void testFull(IndexOptions options, boolean withPayloads) throws Exception {
-    File path = TestUtil.getTempDir("testPostingsFormat.testExact");
+    File path = createTempDir("testPostingsFormat.testExact");
     Directory dir = newFSDirectory(path);
 
     // TODO test thread safety of buildIndex too
@@ -1085,7 +1085,7 @@ public abstract class BasePostingsFormat
 
     fieldsProducer.close();
     dir.close();
-    TestUtil.rmDir(path);
+    TestUtil.rm(path);
   }
 
   public void testDocsOnly() throws Exception {
@@ -1117,7 +1117,7 @@ public abstract class BasePostingsFormat
     int iters = 5;
 
     for(int iter=0;iter<iters;iter++) {
-      File path = TestUtil.getTempDir("testPostingsFormat");
+      File path = createTempDir("testPostingsFormat");
       Directory dir = newFSDirectory(path);
 
       boolean indexPayloads = random().nextBoolean();
@@ -1134,7 +1134,7 @@ public abstract class BasePostingsFormat
       fieldsProducer = null;
 
       dir.close();
-      TestUtil.rmDir(path);
+      TestUtil.rm(path);
     }
   }
 }

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java Sat Apr  5 10:09:42 2014
@@ -599,7 +599,7 @@ public abstract class BaseStoredFieldsFo
     // for this test we force a FS dir
     // we can't just use newFSDirectory, because this test doesn't really index anything.
     // so if we get NRTCachingDir+SimpleText, we make massive stored fields and OOM (LUCENE-4484)
-    Directory dir = new MockDirectoryWrapper(random(), new MMapDirectory(TestUtil.getTempDir("testBigDocuments")));
+    Directory dir = new MockDirectoryWrapper(random(), new MMapDirectory(createTempDir("testBigDocuments")));
     IndexWriterConfig iwConf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConf);

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java Sat Apr  5 10:09:42 2014
@@ -435,7 +435,7 @@ public abstract class ThreadedIndexingAn
 
     Random random = new Random(random().nextLong());
     final LineFileDocs docs = new LineFileDocs(random, defaultCodecSupportsDocValues());
-    final File tempDir = TestUtil.getTempDir(testName);
+    final File tempDir = createTempDir(testName);
     dir = getDirectory(newMockFSDirectory(tempDir)); // some subclasses rely on this being MDW
     if (dir instanceof BaseDirectoryWrapper) {
       ((BaseDirectoryWrapper) dir).setCheckIndexOnClose(false); // don't double-checkIndex, we do it ourselves.
@@ -645,7 +645,7 @@ public abstract class ThreadedIndexingAn
 
     TestUtil.checkIndex(dir);
     dir.close();
-    TestUtil.rmDir(tempDir);
+    TestUtil.rm(tempDir);
 
     if (VERBOSE) {
       System.out.println("TEST: done [" + (System.currentTimeMillis()-t0) + " ms]");

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java Sat Apr  5 10:09:42 2014
@@ -447,7 +447,7 @@ public abstract class ShardSearchingTest
 
     public NodeState(Random random, int nodeID, int numNodes) throws IOException {
       myNodeID = nodeID;
-      dir = newFSDirectory(TestUtil.getTempDir("ShardSearchingTestBase"));
+      dir = newFSDirectory(createTempDir("ShardSearchingTestBase"));
       // TODO: set warmer
       MockAnalyzer analyzer = new MockAnalyzer(random());
       analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Sat Apr  5 10:09:42 2014
@@ -17,57 +17,152 @@ package org.apache.lucene.util;
  * limitations under the License.
  */
 
-import java.io.*;
-import java.nio.file.NoSuchFileException;
-import java.lang.annotation.*;
+import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
+import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsInt;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.*;
-import java.util.concurrent.*;
+import java.nio.file.NoSuchFileException;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Deque;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Random;
+import java.util.Set;
+import java.util.TimeZone;
+import java.util.TreeSet;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.logging.Logger;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.codecs.Codec;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.codecs.DocValuesFormat;
-import org.apache.lucene.document.Field.Store;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Field.Store;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.StringField;
 import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.*;
+import org.apache.lucene.index.AlcoholicMergePolicy;
+import org.apache.lucene.index.AssertingAtomicReader;
+import org.apache.lucene.index.AssertingDirectoryReader;
+import org.apache.lucene.index.AtomicReader;
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.BinaryDocValues;
+import org.apache.lucene.index.CompositeReader;
+import org.apache.lucene.index.ConcurrentMergeScheduler;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.DocsAndPositionsEnum;
+import org.apache.lucene.index.DocsEnum;
+import org.apache.lucene.index.FieldFilterAtomicReader;
+import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.FieldInfos;
+import org.apache.lucene.index.Fields;
+import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexReader.ReaderClosedListener;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.LogByteSizeMergePolicy;
+import org.apache.lucene.index.LogDocMergePolicy;
+import org.apache.lucene.index.LogMergePolicy;
+import org.apache.lucene.index.MergePolicy;
+import org.apache.lucene.index.MockRandomMergePolicy;
+import org.apache.lucene.index.MultiDocValues;
+import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.NumericDocValues;
+import org.apache.lucene.index.ParallelAtomicReader;
+import org.apache.lucene.index.ParallelCompositeReader;
+import org.apache.lucene.index.SegmentReader;
+import org.apache.lucene.index.SerialMergeScheduler;
+import org.apache.lucene.index.SimpleMergedSegmentWarmer;
+import org.apache.lucene.index.SlowCompositeReaderWrapper;
+import org.apache.lucene.index.SortedDocValues;
+import org.apache.lucene.index.SortedSetDocValues;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.index.TermsEnum.SeekStatus;
-import org.apache.lucene.search.*;
+import org.apache.lucene.index.TieredMergePolicy;
+import org.apache.lucene.search.AssertingIndexSearcher;
+import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.FieldCache;
 import org.apache.lucene.search.FieldCache.CacheEntry;
+import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.QueryUtils.FCInvisibleMultiReader;
-import org.apache.lucene.store.*;
+import org.apache.lucene.store.BaseDirectoryWrapper;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.FlushInfo;
+import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IOContext.Context;
+import org.apache.lucene.store.LockFactory;
+import org.apache.lucene.store.MergeInfo;
+import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.store.MockDirectoryWrapper.Throttling;
+import org.apache.lucene.store.NRTCachingDirectory;
+import org.apache.lucene.store.RateLimitedDirectoryWrapper;
 import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
 import org.apache.lucene.util.automaton.AutomatonTestUtil;
 import org.apache.lucene.util.automaton.CompiledAutomaton;
 import org.apache.lucene.util.automaton.RegExp;
-import org.junit.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TestRule;
 import org.junit.runner.RunWith;
-import com.carrotsearch.randomizedtesting.*;
-import com.carrotsearch.randomizedtesting.annotations.*;
+
+import com.carrotsearch.randomizedtesting.JUnit4MethodProvider;
+import com.carrotsearch.randomizedtesting.LifecycleScope;
+import com.carrotsearch.randomizedtesting.MixWithSuiteName;
+import com.carrotsearch.randomizedtesting.RandomizedContext;
+import com.carrotsearch.randomizedtesting.RandomizedRunner;
+import com.carrotsearch.randomizedtesting.RandomizedTest;
+import com.carrotsearch.randomizedtesting.annotations.Listeners;
+import com.carrotsearch.randomizedtesting.annotations.SeedDecorators;
+import com.carrotsearch.randomizedtesting.annotations.TestGroup;
+import com.carrotsearch.randomizedtesting.annotations.TestMethodProviders;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;
 import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction.Action;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakGroup;
 import com.carrotsearch.randomizedtesting.annotations.ThreadLeakGroup.Group;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
 import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;
 import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;
+import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 import com.carrotsearch.randomizedtesting.rules.NoClassHooksShadowingRule;
 import com.carrotsearch.randomizedtesting.rules.NoInstanceHooksOverridesRule;
 import com.carrotsearch.randomizedtesting.rules.StaticFieldsInvariantRule;
 import com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule;
-
-import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
-import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsInt;
+import com.carrotsearch.randomizedtesting.rules.TestRuleAdapter;
 
 /**
  * Base class for all Lucene unit tests, Junit3 or Junit4 variant.
@@ -114,13 +209,6 @@ import static com.carrotsearch.randomize
  *   context ({@link RandomizedContext#current()}) and then calling
  *   {@link RandomizedContext#getRunnerSeedAsString()}.</li>
  * </ul>
- * 
- * <p>There is a number of other facilities tests can use, like:
- * <ul>
- *   <li>{@link #closeAfterTest(Closeable)} and {@link #closeAfterSuite(Closeable)} to
- *   register resources to be closed after each scope (if close fails, the scope
- *   will fail too).</li>
- * </ul> 
  */
 @RunWith(RandomizedRunner.class)
 @TestMethodProviders({
@@ -230,6 +318,23 @@ public abstract class LuceneTestCase ext
     String[] value();
   }
   
+  /**
+   * Marks any suites which are known not to close all the temporary
+   * files. This may prevent temp. files and folders from being cleaned
+   * up after the suite is completed.
+   * 
+   * @see LuceneTestCase#createTempDir()
+   * @see LuceneTestCase#createTempFile(String, String)
+   */
+  @Documented
+  @Inherited
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.TYPE)
+  public @interface SuppressTempFileChecks {
+    /** Point to JIRA entry. */
+    public String bugUrl() default "None";
+  }
+
   // -----------------------------------------------------------------
   // Truly immutable fields and constants, initialized once and valid 
   // for all suites ever since.
@@ -293,14 +398,18 @@ public abstract class LuceneTestCase ext
   /** Throttling, see {@link MockDirectoryWrapper#setThrottling(Throttling)}. */
   public static final Throttling TEST_THROTTLING = TEST_NIGHTLY ? Throttling.SOMETIMES : Throttling.NEVER;
 
-  /** Create indexes in this directory, optimally use a subdir, named after the test */
-  public static final File TEMP_DIR;
+  /** Leave temporary files on disk, even on successful runs. */
+  public static final boolean LEAVE_TEMPORARY;
   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);
-    TEMP_DIR.mkdirs();
+    boolean defaultValue = false;
+    for (String property : Arrays.asList(
+        "tests.leaveTemporary" /* ANT tasks's (junit4) flag. */,
+        "tests.leavetemporary" /* lowercase */,
+        "tests.leavetmpdir" /* default */,
+        "solr.test.leavetmpdir" /* Solr's legacy */)) {
+      defaultValue |= systemPropertyAsBoolean(property, false);
+    }
+    LEAVE_TEMPORARY = defaultValue;
   }
 
   /**
@@ -432,6 +541,7 @@ public abstract class LuceneTestCase ext
     .around(ignoreAfterMaxFailures)
     .around(suiteFailureMarker = new TestRuleMarkFailure())
     .around(new TestRuleAssertionsRequired())
+    .around(new TemporaryFilesCleanupRule())
     .around(new StaticFieldsInvariantRule(STATIC_LEAK_THRESHOLD, true) {
       @Override
       protected boolean accept(java.lang.reflect.Field field) {
@@ -1166,7 +1276,7 @@ public abstract class LuceneTestCase ext
       final Class<? extends Directory> clazz = CommandLineUtil.loadDirectoryClass(clazzName);
       // If it is a FSDirectory type, try its ctor(File)
       if (FSDirectory.class.isAssignableFrom(clazz)) {
-        final File dir = TestUtil.getTempDir("index");
+        final File dir = createTempDir("index-" + clazzName);
         dir.mkdirs(); // ensure it's created so we 'have' it.
         return newFSDirectoryImpl(clazz.asSubclass(FSDirectory.class), dir);
       }
@@ -2111,4 +2221,175 @@ public abstract class LuceneTestCase ext
       return false;
     }
   }
+
+  /**
+   * A base location for temporary files of a given test. Helps in figuring out
+   * which tests left which files and where.
+   */
+  private static File tempDirBase;
+  
+  /**
+   * Retry to create temporary file name this many times.
+   */
+  private static final int TEMP_NAME_RETRY_THRESHOLD = 9999;
+
+  /**
+   * This method is deprecated for a reason. Do not use it. Call {@link #createTempDir()}
+   * or {@link #createTempDir(String)} or {@link #createTempFile(String, String)}.
+   */
+  @Deprecated
+  public static File getBaseTempDirForTestClass() {
+    synchronized (LuceneTestCase.class) {
+      if (tempDirBase == null) {
+        File directory = new File(System.getProperty("tempDir", System.getProperty("java.io.tmpdir")));
+        assert directory.exists() && 
+               directory.isDirectory() && 
+               directory.canWrite();
+
+        RandomizedContext ctx = RandomizedContext.current();
+        Class<?> clazz = ctx.getTargetClass();
+        String prefix = clazz.getName();
+        prefix = prefix.replaceFirst("^org.apache.lucene.", "lucene.");
+        prefix = prefix.replaceFirst("^org.apache.solr.", "solr.");
+
+        int attempt = 0;
+        File f;
+        do {
+          if (attempt++ >= TEMP_NAME_RETRY_THRESHOLD) {
+            throw new RuntimeException(
+                "Failed to get a temporary name too many times, check your temp directory and consider manually cleaning it: "
+                  + directory.getAbsolutePath());            
+          }
+          f = new File(directory, prefix + "-" + ctx.getRunnerSeedAsString() 
+                + "-" + String.format(Locale.ENGLISH, "%03d", attempt));
+        } while (!f.mkdirs());
+
+        tempDirBase = f;
+        registerToRemoveAfterSuite(tempDirBase);
+      }
+    }
+    return tempDirBase;
+  }
+
+
+  /**
+   * Creates an empty, temporary folder (when the name of the folder is of no importance).
+   * 
+   * @see #createTempDir(String)
+   */
+  public static File createTempDir() {
+    return createTempDir("tempDir");
+  }
+
+  /**
+   * Creates an empty, temporary folder with the given name prefix under the 
+   * test class's {@link #getBaseTempDirForTestClass()}.
+   *  
+   * <p>The folder will be automatically removed after the
+   * test class completes successfully. The test should close any file handles that would prevent
+   * the folder from being removed. 
+   */
+  public static File createTempDir(String prefix) {
+    File base = getBaseTempDirForTestClass();
+
+    int attempt = 0;
+    File f;
+    do {
+      if (attempt++ >= TEMP_NAME_RETRY_THRESHOLD) {
+        throw new RuntimeException(
+            "Failed to get a temporary name too many times, check your temp directory and consider manually cleaning it: "
+              + base.getAbsolutePath());            
+      }
+      f = new File(base, prefix + "-" + String.format(Locale.ENGLISH, "%03d", attempt));
+    } while (!f.mkdirs());
+
+    registerToRemoveAfterSuite(f);
+    return f;
+  }
+  
+  /**
+   * Creates an empty file with the given prefix and suffix under the 
+   * test class's {@link #getBaseTempDirForTestClass()}.
+   * 
+   * <p>The file will be automatically removed after the
+   * test class completes successfully. The test should close any file handles that would prevent
+   * the folder from being removed. 
+   */
+  public static File createTempFile(String prefix, String suffix) throws IOException {
+    File base = getBaseTempDirForTestClass();
+
+    int attempt = 0;
+    File f;
+    do {
+      if (attempt++ >= TEMP_NAME_RETRY_THRESHOLD) {
+        throw new RuntimeException(
+            "Failed to get a temporary name too many times, check your temp directory and consider manually cleaning it: "
+              + base.getAbsolutePath());            
+      }
+      f = new File(base, prefix + "-" + String.format(Locale.ENGLISH, "%03d", attempt) + suffix);
+    } while (!f.createNewFile());
+
+    registerToRemoveAfterSuite(f);
+    return f;
+  }
+
+  /**
+   * Creates an empty temporary file.
+   * 
+   * @see #createTempFile(String, String) 
+   */
+  public static File createTempFile() throws IOException {
+    return createTempFile("tempFile", ".tmp");
+  }
+
+  /**
+   * A queue of temporary resources to be removed after the
+   * suite completes.
+   * @see #registerToRemoveAfterSuite(File)
+   */
+  private final static Deque<File> cleanupQueue = new ArrayDeque<File>();
+
+  /**
+   * Register temporary folder for removal after the suite completes.
+   */
+  private static void registerToRemoveAfterSuite(File f) {
+    assert f != null;
+
+    if (LuceneTestCase.LEAVE_TEMPORARY) {
+      System.err.println("INFO: Will leave temporary file: " + f.getAbsolutePath());
+      return;
+    }
+
+    synchronized (cleanupQueue) {
+      cleanupQueue.addLast(f);
+    }
+  }
+
+  private static class TemporaryFilesCleanupRule extends TestRuleAdapter {
+    @Override
+    protected void afterAlways(List<Throwable> errors) throws Throwable {
+      if (LuceneTestCase.suiteFailureMarker.wasSuccessful()) {
+        synchronized (cleanupQueue) {
+          File [] everything = new File [cleanupQueue.size()];
+          for (int i = 0; !cleanupQueue.isEmpty(); i++) {
+            everything[i] = cleanupQueue.removeLast();
+          }
+
+          // Will throw an IOException on un-removable files.
+          try {
+            TestUtil.rm(everything);
+          } catch (IOException e) {
+            Class<?> suiteClass = RandomizedContext.current().getTargetClass();
+            if (suiteClass.isAnnotationPresent(SuppressTempFileChecks.class)) {
+              System.err.println("WARNING: Leftover undeleted temporary files (bugUrl: "
+                  + suiteClass.getAnnotation(SuppressTempFileChecks.class).bugUrl() + "): "
+                  + e.getMessage());
+              return;
+            }
+            throw e;
+          }
+        }
+      }
+    }
+  }
 }

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java Sat Apr  5 10:09:42 2014
@@ -28,9 +28,11 @@ import java.io.PrintStream;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.nio.CharBuffer;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
@@ -87,7 +89,6 @@ import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.junit.Assert;
 
-import com.carrotsearch.randomizedtesting.RandomizedContext;
 import com.carrotsearch.randomizedtesting.generators.RandomInts;
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 
@@ -99,73 +100,50 @@ public final class TestUtil {
     //
   }
 
-  // the max number of retries we're going to do in getTempDir
-  private static final int GET_TEMP_DIR_RETRY_THRESHOLD = 1000;
-  
   /**
-   * Returns a temp directory, based on the given description. Creates the
-   * directory.
+   * Deletes one or more files or directories (and everything underneath it).
+   * 
+   * @throws IOException if any of the given files (or their subhierarchy files in case
+   * of directories) cannot be removed.
    */
-  public static File getTempDir(String desc) {
-    if (desc.length() < 3) {
-      throw new IllegalArgumentException("description must be at least 3 characters");
-    }
-    // always pull a long from master random. that way, the randomness of the test
-    // is not affected by whether it initialized the counter (in genTempFile) or not.
-    // note that the Random used by genTempFile is *not* the master Random, and therefore
-    // does not affect the randomness of the test.
-    final Random random = new Random(RandomizedContext.current().getRandom().nextLong());
-    int attempt = 0;
-    File f;
-    do {
-      f = genTempFile(random, desc, "tmp", LuceneTestCase.TEMP_DIR);
-    } while (!f.mkdir() && (attempt++) < GET_TEMP_DIR_RETRY_THRESHOLD);
-    
-    if (attempt > GET_TEMP_DIR_RETRY_THRESHOLD) {
-      throw new RuntimeException(
-          "failed to get a temporary dir too many times. check your temp directory and consider manually cleaning it.");
+  public static void rm(File... locations) throws IOException {
+    LinkedHashSet<File> unremoved = rm(new LinkedHashSet<File>(), locations);
+    if (!unremoved.isEmpty()) {
+      StringBuilder b = new StringBuilder("Could not remove the following files (in the order of attempts):\n");
+      for (File f : unremoved) {
+        b.append("   ")
+         .append(f.getAbsolutePath())
+         .append("\n");
+      }
+      throw new IOException(b.toString());
     }
-    
-    LuceneTestCase.closeAfterSuite(new CloseableFile(f, LuceneTestCase.suiteFailureMarker));
-    return f;
   }
 
-  /**
-   * Deletes a directory and everything underneath it.
-   */
-  public static void rmDir(File dir) throws IOException {
-    if (dir.exists()) {
-      if (dir.isFile() && !dir.delete()) {
-        throw new IOException("could not delete " + dir);
-      }
-      for (File f : dir.listFiles()) {
-        if (f.isDirectory()) {
-          rmDir(f);
-        } else {
-          if (!f.delete()) {
-            throw new IOException("could not delete " + f);
-          }
+  private static LinkedHashSet<File> rm(LinkedHashSet<File> unremoved, File... locations) {
+    for (File location : locations) {
+      if (location.exists()) {
+        if (location.isDirectory()) {
+          rm(unremoved, location.listFiles());
+        }
+
+        if (!location.delete()) {
+          unremoved.add(location);
         }
-      }
-      if (!dir.delete()) {
-        throw new IOException("could not delete " + dir);
       }
     }
+    return unremoved;
   }
 
   /** 
-   * Convenience method: Unzip zipName + ".zip" under destDir, removing destDir first 
+   * Convenience method unzipping zipName into destDir, cleaning up 
+   * destDir first. 
    */
   public static void unzip(File zipName, File destDir) throws IOException {
-    
+    rm(destDir);
+    destDir.mkdir();
+
     ZipFile zipFile = new ZipFile(zipName);
-    
     Enumeration<? extends ZipEntry> entries = zipFile.entries();
-    
-    rmDir(destDir);
-
-    destDir.mkdir();
-    LuceneTestCase.closeAfterSuite(new CloseableFile(destDir, LuceneTestCase.suiteFailureMarker));
 
     while (entries.hasMoreElements()) {
       ZipEntry entry = entries.nextElement();
@@ -809,52 +787,6 @@ public final class TestUtil {
     });
     Assert.assertEquals("Reflection does not produce same map", reflectedValues, map);
   }
-  
-  /** 
-   * insecure, fast version of File.createTempFile
-   * uses Random instead of SecureRandom.
-   */
-  public static File createTempFile(String prefix, String suffix, File directory)
-      throws IOException {
-    if (prefix.length() < 3) {
-      throw new IllegalArgumentException("prefix must be at least 3 characters");
-    }
-    String newSuffix = suffix == null ? ".tmp" : suffix;
-    // always pull a long from master random. that way, the randomness of the test
-    // is not affected by whether it initialized the counter (in genTempFile) or not.
-    // note that the Random used by genTempFile is *not* the master Random, and therefore
-    // does not affect the randomness of the test.
-    final Random random = new Random(RandomizedContext.current().getRandom().nextLong());
-    File result;
-    do {
-      result = genTempFile(random, prefix, newSuffix, directory);
-    } while (!result.createNewFile());
-    return result;
-  }
-
-  /* identify for differnt VM processes */
-  private static String counterBase;
-  
-  /* Temp file counter */
-  private static int counter;
-  private static final Object counterLock = new Object();
-
-  private static File genTempFile(Random random, String prefix, String suffix, File directory) {
-    final int identify;
-    synchronized (counterLock) {
-      if (counterBase == null) { // init once
-        counter = random.nextInt() & 0xFFFF; // up to five digits number
-        counterBase = Integer.toString(counter);
-      }
-      identify = counter++;
-    }
-    StringBuilder newName = new StringBuilder();
-    newName.append(prefix);
-    newName.append(counterBase);
-    newName.append(identify);
-    newName.append(suffix);
-    return new File(directory, newName.toString());
-  }
 
   public static void assertEquals(TopDocs expected, TopDocs actual) {
     Assert.assertEquals("wrong total hits", expected.totalHits, actual.totalHits);

Modified: lucene/dev/branches/branch_4x/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationField.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationField.java (original)
+++ lucene/dev/branches/branch_4x/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationField.java Sat Apr  5 10:09:42 2014
@@ -63,13 +63,9 @@ public class TestICUCollationField exten
    * So its preferable to create this file on-the-fly.
    */
   public static String setupSolrHome() throws Exception {
-    // make a solr home underneath the test's TEMP_DIR
-    File tmpFile = File.createTempFile("test", "tmp", dataDir);
-    tmpFile.delete();
-    tmpFile.mkdir();
-    
+    String tmpFile = createTempDir().getAbsolutePath();
     // make data and conf dirs
-    new File(tmpFile + "/collection1", "data").mkdirs();
+    new File(tmpFile  + "/collection1", "data").mkdirs();
     File confDir = new File(tmpFile + "/collection1", "conf");
     confDir.mkdirs();
     
@@ -91,7 +87,7 @@ public class TestICUCollationField exten
     IOUtils.write(tailoredRules, os, "UTF-8");
     os.close();
 
-    return tmpFile.getAbsolutePath();
+    return tmpFile;
   }
 
   /** 

Modified: lucene/dev/branches/branch_4x/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationFieldDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationFieldDocValues.java?rev=1585035&r1=1585034&r2=1585035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationFieldDocValues.java (original)
+++ lucene/dev/branches/branch_4x/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationFieldDocValues.java Sat Apr  5 10:09:42 2014
@@ -22,6 +22,8 @@ import java.io.FileOutputStream;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
 import org.apache.solr.SolrTestCaseJ4;
 import org.junit.BeforeClass;
@@ -63,10 +65,7 @@ public class TestICUCollationFieldDocVal
    * So its preferable to create this file on-the-fly.
    */
   public static String setupSolrHome() throws Exception {
-    // make a solr home underneath the test's TEMP_DIR
-    File tmpFile = File.createTempFile("test", "tmp", dataDir);
-    tmpFile.delete();
-    tmpFile.mkdir();
+    File tmpFile = createTempDir();
     
     // make data and conf dirs
     new File(tmpFile + "/collection1", "data").mkdirs();