Branch for solr5914

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/solr5914@1582248 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dawid Weiss 2014-03-27 10:45:40 +00:00
parent b7b0643115
commit 688addbd50
159 changed files with 616 additions and 646 deletions

View File

@ -61,7 +61,7 @@ public class TestFilesystemResourceLoader extends LuceneTestCase {
}
public void testBaseDir() throws Exception {
final File base = TestUtil.getTempDir("fsResourceLoaderBase").getAbsoluteFile();
final File base = TestUtil.createTempDir("fsResourceLoaderBase").getAbsoluteFile();
try {
base.mkdirs();
Writer os = new OutputStreamWriter(new FileOutputStream(new File(base, "template.txt")), IOUtils.CHARSET_UTF_8);

View File

@ -75,7 +75,7 @@ import org.apache.lucene.util.TestUtil;
public class TestCompile extends LuceneTestCase {
public void testCompile() throws Exception {
File dir = TestUtil.getTempDir("testCompile");
File dir = TestUtil.createTempDir("testCompile");
dir.mkdirs();
InputStream input = getClass().getResourceAsStream("testRules.txt");
File output = new File(dir, "testRules.txt");
@ -91,7 +91,7 @@ public class TestCompile extends LuceneTestCase {
}
public void testCompileBackwards() throws Exception {
File dir = TestUtil.getTempDir("testCompile");
File dir = TestUtil.createTempDir("testCompile");
dir.mkdirs();
InputStream input = getClass().getResourceAsStream("testRules.txt");
File output = new File(dir, "testRules.txt");
@ -107,7 +107,7 @@ public class TestCompile extends LuceneTestCase {
}
public void testCompileMulti() throws Exception {
File dir = TestUtil.getTempDir("testCompile");
File dir = TestUtil.createTempDir("testCompile");
dir.mkdirs();
InputStream input = getClass().getResourceAsStream("testRules.txt");
File output = new File(dir, "testRules.txt");

View File

@ -36,7 +36,7 @@ public abstract class BenchmarkTestCase extends LuceneTestCase {
@BeforeClass
public static void beforeClassBenchmarkTestCase() {
WORKDIR = TestUtil.getTempDir("benchmark");
WORKDIR = TestUtil.createTempDir("benchmark");
WORKDIR.delete();
WORKDIR.mkdirs();
}

View File

@ -386,7 +386,7 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
* Test WriteLineDoc and LineDocSource.
*/
public void testLineDocFile() throws Exception {
File lineFile = new File(TEMP_DIR, "test.reuters.lines.txt");
File lineFile = TestUtil.createTempFile("test.reuters.lines", ".txt");
// We will call WriteLineDocs this many times
final int NUM_TRY_DOCS = 50;

View File

@ -20,11 +20,9 @@ package org.apache.lucene.benchmark.byTask;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import org.apache.lucene.benchmark.byTask.feeds.AbstractQueryMaker;
@ -38,6 +36,9 @@ import org.apache.lucene.benchmark.byTask.utils.Config;
import org.apache.lucene.search.Query;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import conf.ConfLoader;
@ -123,13 +124,13 @@ public class TestPerfTasksParse extends LuceneTestCase {
Config config = new Config(new InputStreamReader(new FileInputStream(algFile), "UTF-8"));
String contentSource = config.get("content.source", null);
if (contentSource != null) { Class.forName(contentSource); }
config.set("work.dir", new File(TEMP_DIR,"work").getAbsolutePath());
config.set("work.dir", TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath());
config.set("content.source", MockContentSource.class.getName());
String dir = config.get("content.source", null);
if (dir != null) { Class.forName(dir); }
config.set("directory", RAMDirectory.class.getName());
if (config.get("line.file.out", null) != null) {
config.set("line.file.out", new File(TEMP_DIR,"o.txt").getAbsolutePath());
config.set("line.file.out", TestUtil.createTempFile("linefile", ".txt").getAbsolutePath());
}
if (config.get("query.maker", null) != null) {
Class.forName(config.get("query.maker", null));
@ -138,9 +139,7 @@ public class TestPerfTasksParse extends LuceneTestCase {
PerfRunData data = new PerfRunData(config);
new Algorithm(data);
} catch (Throwable t) {
t.printStackTrace();
fail("Could not parse sample file: " + algFile + " reason:"
+ t.getClass() + ":" + t.getMessage());
throw new AssertionError("Could not parse sample file: " + algFile, t);
}
foundFiles = true;
}

View File

@ -344,7 +344,7 @@ public class TrecContentSourceTest extends LuceneTestCase {
* supported formats - bzip, gzip, txt.
*/
public void testTrecFeedDirAllTypes() throws Exception {
File dataDir = TestUtil.getTempDir("trecFeedAllTypes");
File dataDir = TestUtil.createTempDir("trecFeedAllTypes");
TestUtil.unzip(getDataFile("trecdocs.zip"), dataDir);
TrecContentSource tcs = new TrecContentSource();
Properties props = new Properties();

View File

@ -41,7 +41,7 @@ public class AddIndexesTaskTest extends BenchmarkTestCase {
@BeforeClass
public static void beforeClassAddIndexesTaskTest() throws Exception {
testDir = TestUtil.getTempDir("addIndexesTask");
testDir = TestUtil.createTempDir("addIndexesTask");
// create a dummy index under inputDir
inputDir = new File(testDir, "input");

View File

@ -52,7 +52,7 @@ public class Test10KPulsings extends LuceneTestCase {
// we always run this test with pulsing codec.
Codec cp = TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat(1));
File f = TestUtil.getTempDir("10kpulsed");
File f = TestUtil.createTempDir("10kpulsed");
BaseDirectoryWrapper dir = newFSDirectory(f);
dir.setCheckIndexOnClose(false); // we do this ourselves explicitly
RandomIndexWriter iw = new RandomIndexWriter(random(), dir,
@ -103,7 +103,7 @@ public class Test10KPulsings extends LuceneTestCase {
int freqCutoff = TestUtil.nextInt(random(), 1, 10);
Codec cp = TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat(freqCutoff));
File f = TestUtil.getTempDir("10knotpulsed");
File f = TestUtil.createTempDir("10knotpulsed");
BaseDirectoryWrapper dir = newFSDirectory(f);
dir.setCheckIndexOnClose(false); // we do this ourselves explicitly
RandomIndexWriter iw = new RandomIndexWriter(random(), dir,

View File

@ -53,7 +53,7 @@ public class TestLucene40PostingsReader extends LuceneTestCase {
* depends heavily on term vectors cross-check at checkIndex
*/
public void testPostings() throws Exception {
Directory dir = newFSDirectory(TestUtil.getTempDir("postings"));
Directory dir = newFSDirectory(TestUtil.createTempDir("postings"));
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
iwc.setCodec(Codec.forName("Lucene40"));
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);

View File

@ -43,7 +43,7 @@ public class TestBlockPostingsFormat2 extends LuceneTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
dir = newFSDirectory(TestUtil.getTempDir("testDFBlockSize"));
dir = newFSDirectory(TestUtil.createTempDir("testDFBlockSize"));
iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
iwc.setCodec(TestUtil.alwaysPostingsFormat(new Lucene41PostingsFormat()));
iw = new RandomIndexWriter(random(), dir, iwc.clone());

View File

@ -38,7 +38,7 @@ public class Test2BBinaryDocValues extends LuceneTestCase {
// indexes Integer.MAX_VALUE docs with a fixed binary field
public void testFixedBinary() throws Exception {
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BFixedBinary"));
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BFixedBinary"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
@ -98,7 +98,7 @@ public class Test2BBinaryDocValues extends LuceneTestCase {
// indexes Integer.MAX_VALUE docs with a variable binary field
public void testVariableBinary() throws Exception {
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BVariableBinary"));
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BVariableBinary"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}

View File

@ -31,7 +31,7 @@ public class Test2BDocs extends LuceneTestCase {
@BeforeClass
public static void beforeClass() throws Exception {
dir = newFSDirectory(TestUtil.getTempDir("2Bdocs"));
dir = newFSDirectory(TestUtil.createTempDir("2Bdocs"));
IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
Document doc = new Document();
for (int i = 0; i < 262144; i++) {
@ -61,7 +61,7 @@ public class Test2BDocs extends LuceneTestCase {
}
public void testExactlyAtLimit() throws Exception {
Directory dir2 = newFSDirectory(TestUtil.getTempDir("2BDocs2"));
Directory dir2 = newFSDirectory(TestUtil.createTempDir("2BDocs2"));
IndexWriter iw = new IndexWriter(dir2, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
Document doc = new Document();
for (int i = 0; i < 262143; i++) {

View File

@ -35,7 +35,7 @@ public class Test2BNumericDocValues extends LuceneTestCase {
// indexes Integer.MAX_VALUE docs with an increasing dv field
public void testNumerics() throws Exception {
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BNumerics"));
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BNumerics"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}

View File

@ -47,7 +47,7 @@ public class Test2BPositions extends LuceneTestCase {
// uses lots of space and takes a few minutes
@Ignore("Very slow. Enable manually by removing @Ignore.")
public void test() throws Exception {
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BPositions"));
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BPositions"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}

View File

@ -45,7 +45,7 @@ public class Test2BPostings extends LuceneTestCase {
@Nightly
public void test() throws Exception {
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BPostings"));
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BPostings"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}

View File

@ -50,7 +50,7 @@ public class Test2BPostingsBytes extends LuceneTestCase {
// with some codecs needs more heap space as well.
@Ignore("Very slow. Enable manually by removing @Ignore.")
public void test() throws Exception {
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BPostingsBytes1"));
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BPostingsBytes1"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
@ -93,7 +93,7 @@ public class Test2BPostingsBytes extends LuceneTestCase {
IndexReader subReaders[] = new IndexReader[1000];
Arrays.fill(subReaders, oneThousand);
MultiReader mr = new MultiReader(subReaders);
BaseDirectoryWrapper dir2 = newFSDirectory(TestUtil.getTempDir("2BPostingsBytes2"));
BaseDirectoryWrapper dir2 = newFSDirectory(TestUtil.createTempDir("2BPostingsBytes2"));
if (dir2 instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir2).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
@ -108,7 +108,7 @@ public class Test2BPostingsBytes extends LuceneTestCase {
subReaders = new IndexReader[2000];
Arrays.fill(subReaders, oneMillion);
mr = new MultiReader(subReaders);
BaseDirectoryWrapper dir3 = newFSDirectory(TestUtil.getTempDir("2BPostingsBytes3"));
BaseDirectoryWrapper dir3 = newFSDirectory(TestUtil.createTempDir("2BPostingsBytes3"));
if (dir3 instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir3).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}

View File

@ -38,7 +38,7 @@ public class Test2BSortedDocValues extends LuceneTestCase {
// indexes Integer.MAX_VALUE docs with a fixed binary field
public void testFixedSorted() throws Exception {
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BFixedSorted"));
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BFixedSorted"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
@ -95,7 +95,7 @@ public class Test2BSortedDocValues extends LuceneTestCase {
// indexes Integer.MAX_VALUE docs with a fixed binary field
// TODO: must use random.nextBytes (like Test2BTerms) to avoid BytesRefHash probing issues
public void test2BOrds() throws Exception {
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BOrds"));
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BOrds"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}

View File

@ -148,7 +148,7 @@ public class Test2BTerms extends LuceneTestCase {
List<BytesRef> savedTerms = null;
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("2BTerms"));
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BTerms"));
//MockDirectoryWrapper dir = newFSDirectory(new File("/p/lucene/indices/2bindex"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);

View File

@ -42,7 +42,7 @@ public class Test4GBStoredFields extends LuceneTestCase {
@Nightly
public void test() throws Exception {
MockDirectoryWrapper dir = new MockDirectoryWrapper(random(), new MMapDirectory(TestUtil.getTempDir("4GBStoredFields")));
MockDirectoryWrapper dir = new MockDirectoryWrapper(random(), new MMapDirectory(TestUtil.createTempDir("4GBStoredFields")));
dir.setThrottling(MockDirectoryWrapper.Throttling.NEVER);
IndexWriter w = new IndexWriter(dir,

View File

@ -175,7 +175,7 @@ public class TestAtomicUpdate extends LuceneTestCase {
directory.close();
// Second in an FSDirectory:
File dirPath = TestUtil.getTempDir("lucene.test.atomic");
File dirPath = TestUtil.createTempDir("lucene.test.atomic");
directory = newFSDirectory(dirPath);
runTest(directory);
directory.close();

View File

@ -227,7 +227,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
names.addAll(Arrays.asList(oldSingleSegmentNames));
oldIndexDirs = new HashMap<>();
for (String name : names) {
File dir = TestUtil.getTempDir(name);
File dir = TestUtil.createTempDir(name);
File dataFile = new File(TestBackwardsCompatibility.class.getResource("index." + name + ".zip").toURI());
TestUtil.unzip(dataFile, dir);
oldIndexDirs.put(name, newFSDirectory(dir));
@ -248,7 +248,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
if (VERBOSE) {
System.out.println("TEST: index " + unsupportedNames[i]);
}
File oldIndxeDir = TestUtil.getTempDir(unsupportedNames[i]);
File oldIndxeDir = TestUtil.createTempDir(unsupportedNames[i]);
TestUtil.unzip(getDataFile("unsupported." + unsupportedNames[i] + ".zip"), oldIndxeDir);
BaseDirectoryWrapper dir = newFSDirectory(oldIndxeDir);
// don't checkindex, these are intentionally not supported
@ -645,7 +645,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
public void testExactFileNames() throws IOException {
String outputDirName = "lucene.backwardscompat0.index";
File outputDir = TestUtil.getTempDir(outputDirName);
File outputDir = TestUtil.createTempDir(outputDirName);
TestUtil.rmDir(outputDir);
try {
@ -955,7 +955,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
public void testCommandLineArgs() throws Exception {
for (String name : oldIndexDirs.keySet()) {
File dir = TestUtil.getTempDir(name);
File dir = TestUtil.createTempDir(name);
File dataFile = new File(TestBackwardsCompatibility.class.getResource("index." + name + ".zip").toURI());
TestUtil.unzip(dataFile, dir);
@ -1048,7 +1048,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
public static final String moreTermsIndex = "moreterms.40.zip";
public void testMoreTerms() throws Exception {
File oldIndexDir = TestUtil.getTempDir("moreterms");
File oldIndexDir = TestUtil.createTempDir("moreterms");
TestUtil.unzip(getDataFile(moreTermsIndex), oldIndexDir);
Directory dir = newFSDirectory(oldIndexDir);
// TODO: more tests

View File

@ -68,7 +68,7 @@ public class TestBagOfPositions extends LuceneTestCase {
final ConcurrentLinkedQueue<String> postings = new ConcurrentLinkedQueue<>(postingsList);
Directory dir = newFSDirectory(TestUtil.getTempDir("bagofpositions"));
Directory dir = newFSDirectory(TestUtil.createTempDir("bagofpositions"));
final RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);

View File

@ -70,7 +70,7 @@ public class TestBagOfPostings extends LuceneTestCase {
final ConcurrentLinkedQueue<String> postings = new ConcurrentLinkedQueue<>(postingsList);
Directory dir = newFSDirectory(TestUtil.getTempDir("bagofpostings"));
Directory dir = newFSDirectory(TestUtil.createTempDir("bagofpostings"));
final RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
int threadCount = TestUtil.nextInt(random(), 1, 5);

View File

@ -42,7 +42,7 @@ public class TestCompoundFile extends LuceneTestCase
@Override
public void setUp() throws Exception {
super.setUp();
File file = TestUtil.getTempDir("testIndex");
File file = TestUtil.createTempDir("testIndex");
// use a simple FSDir here, to be sure to have SimpleFSInputs
dir = new SimpleFSDirectory(file,null);
}
@ -769,7 +769,7 @@ public class TestCompoundFile extends LuceneTestCase
// when reading a CFS with many subs:
public void testManySubFiles() throws IOException {
final Directory d = newFSDirectory(TestUtil.getTempDir("CFSManySubFiles"));
final Directory d = newFSDirectory(TestUtil.createTempDir("CFSManySubFiles"));
final int FILE_COUNT = atLeast(500);
for(int fileIdx=0;fileIdx<FILE_COUNT;fileIdx++) {

View File

@ -42,7 +42,7 @@ public class TestCrashCausesCorruptIndex extends LuceneTestCase {
* LUCENE-3627: This test fails.
*/
public void testCrashCorruptsIndexing() throws Exception {
path = TestUtil.getTempDir("testCrashCorruptsIndexing");
path = TestUtil.createTempDir("testCrashCorruptsIndexing");
indexAndCrashOnCreateOutputSegments2();

View File

@ -438,7 +438,7 @@ void assertTermDocsCount(String msg,
public void testFilesOpenClose() throws IOException {
// Create initial data set
File dirFile = TestUtil.getTempDir("TestIndexReader.testFilesOpenClose");
File dirFile = TestUtil.createTempDir("TestIndexReader.testFilesOpenClose");
Directory dir = newFSDirectory(dirFile);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
addDoc(writer, "test");
@ -467,7 +467,7 @@ public void testFilesOpenClose() throws IOException {
}
public void testOpenReaderAfterDelete() throws IOException {
File dirFile = TestUtil.getTempDir("deletetest");
File dirFile = TestUtil.createTempDir("deletetest");
Directory dir = newFSDirectory(dirFile);
try {
DirectoryReader.open(dir);
@ -715,7 +715,7 @@ public void testFilesOpenClose() throws IOException {
// DirectoryReader on a non-existent directory, you get a
// good exception
public void testNoDir() throws Throwable {
File tempDir = TestUtil.getTempDir("doesnotexist");
File tempDir = TestUtil.createTempDir("doesnotexist");
TestUtil.rmDir(tempDir);
Directory dir = newFSDirectory(tempDir);
try {
@ -1090,7 +1090,7 @@ public void testFilesOpenClose() throws IOException {
}
public void testIndexExistsOnNonExistentDirectory() throws Exception {
File tempDir = TestUtil.getTempDir("testIndexExistsOnNonExistentDirectory");
File tempDir = TestUtil.createTempDir("testIndexExistsOnNonExistentDirectory");
tempDir.delete();
Directory dir = newFSDirectory(tempDir);
assertFalse(DirectoryReader.indexExists(dir));

View File

@ -62,10 +62,10 @@ public class TestDoc extends LuceneTestCase {
if (VERBOSE) {
System.out.println("TEST: setUp");
}
workDir = TestUtil.getTempDir("TestDoc");
workDir = TestUtil.createTempDir("TestDoc");
workDir.mkdirs();
indexDir = TestUtil.getTempDir("testIndex");
indexDir = TestUtil.createTempDir("testIndex");
indexDir.mkdirs();
Directory directory = newFSDirectory(indexDir);

View File

@ -187,7 +187,7 @@ public class TestFieldsReader extends LuceneTestCase {
// LUCENE-1262
public void testExceptions() throws Throwable {
File indexDir = TestUtil.getTempDir("testfieldswriterexceptions");
File indexDir = TestUtil.createTempDir("testfieldswriterexceptions");
try {
Directory dir = new FaultyFSDirectory(indexDir);

View File

@ -1476,7 +1476,7 @@ public class TestIndexWriter extends LuceneTestCase {
// Tests that if FSDir is opened w/ a NoLockFactory (or SingleInstanceLF),
// then IndexWriter ctor succeeds. Previously (LUCENE-2386) it failed
// when listAll() was called in IndexFileDeleter.
Directory dir = newFSDirectory(TestUtil.getTempDir("emptyFSDirNoLock"), NoLockFactory.getNoLockFactory());
Directory dir = newFSDirectory(TestUtil.createTempDir("emptyFSDirNoLock"), NoLockFactory.getNoLockFactory());
new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))).close();
dir.close();
}
@ -1783,7 +1783,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testWhetherDeleteAllDeletesWriteLock() throws Exception {
Directory d = newFSDirectory(TestUtil.getTempDir("TestIndexWriter.testWhetherDeleteAllDeletesWriteLock"));
Directory d = newFSDirectory(TestUtil.createTempDir("TestIndexWriter.testWhetherDeleteAllDeletesWriteLock"));
// Must use SimpleFSLockFactory... NativeFSLockFactory
// somehow "knows" a lock is held against write.lock
// even if you remove that file:
@ -2032,7 +2032,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-4398
public void testRotatingFieldNames() throws Exception {
Directory dir = newFSDirectory(TestUtil.getTempDir("TestIndexWriter.testChangingFields"));
Directory dir = newFSDirectory(TestUtil.createTempDir("TestIndexWriter.testChangingFields"));
IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
iwc.setRAMBufferSizeMB(0.2);
iwc.setMaxBufferedDocs(-1);

View File

@ -36,7 +36,7 @@ import org.apache.lucene.util.TestUtil;
public class TestIndexWriterLockRelease extends LuceneTestCase {
public void testIndexWriterLockRelease() throws IOException {
Directory dir = newFSDirectory(TestUtil.getTempDir("testLockRelease"));
Directory dir = newFSDirectory(TestUtil.createTempDir("testLockRelease"));
try {
new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
} catch (FileNotFoundException | NoSuchFileException e) {

View File

@ -43,7 +43,7 @@ public class TestIndexWriterOnJRECrash extends TestNRTThreads {
@Override
public void setUp() throws Exception {
super.setUp();
tempDir = TestUtil.getTempDir("jrecrash");
tempDir = TestUtil.createTempDir("jrecrash");
tempDir.delete();
tempDir.mkdir();
}

View File

@ -32,7 +32,7 @@ import org.apache.lucene.util.TestUtil;
public class TestIndexWriterOutOfFileDescriptors extends LuceneTestCase {
public void test() throws Exception {
MockDirectoryWrapper dir = newMockFSDirectory(TestUtil.getTempDir("TestIndexWriterOutOfFileDescriptors"));
MockDirectoryWrapper dir = newMockFSDirectory(TestUtil.createTempDir("TestIndexWriterOutOfFileDescriptors"));
dir.setPreventDoubleWrite(false);
double rate = random().nextDouble()*0.01;
//System.out.println("rate=" + rate);
@ -132,7 +132,7 @@ public class TestIndexWriterOutOfFileDescriptors extends LuceneTestCase {
// it to addIndexes later:
dir.setRandomIOExceptionRateOnOpen(0.0);
r = DirectoryReader.open(dir);
dirCopy = newMockFSDirectory(TestUtil.getTempDir("TestIndexWriterOutOfFileDescriptors.copy"));
dirCopy = newMockFSDirectory(TestUtil.createTempDir("TestIndexWriterOutOfFileDescriptors.copy"));
Set<String> files = new HashSet<>();
for (String file : dir.listAll()) {
dir.copy(dirCopy, file, file, IOContext.DEFAULT);

View File

@ -78,7 +78,7 @@ public class TestLongPostings extends LuceneTestCase {
public void testLongPostings() throws Exception {
// Don't use _TestUtil.getTempDir so that we own the
// randomness (ie same seed will point to same dir):
Directory dir = newFSDirectory(TestUtil.getTempDir("longpostings" + "." + random().nextLong()));
Directory dir = newFSDirectory(TestUtil.createTempDir("longpostings" + "." + random().nextLong()));
final int NUM_DOCS = atLeast(2000);
@ -275,7 +275,7 @@ public class TestLongPostings extends LuceneTestCase {
public void doTestLongPostingsNoPositions(IndexOptions options) throws Exception {
// Don't use _TestUtil.getTempDir so that we own the
// randomness (ie same seed will point to same dir):
Directory dir = newFSDirectory(TestUtil.getTempDir("longpostings" + "." + random().nextLong()));
Directory dir = newFSDirectory(TestUtil.createTempDir("longpostings" + "." + random().nextLong()));
final int NUM_DOCS = atLeast(2000);

View File

@ -35,7 +35,7 @@ import org.apache.lucene.util.TestUtil;
public class TestNeverDelete extends LuceneTestCase {
public void testIndexing() throws Exception {
final File tmpDir = TestUtil.getTempDir("TestNeverDelete");
final File tmpDir = TestUtil.createTempDir("TestNeverDelete");
final BaseDirectoryWrapper d = newFSDirectory(tmpDir);
// We want to "see" files removed if Lucene removed

View File

@ -110,7 +110,7 @@ public class TestNorms extends LuceneTestCase {
}
public void testMaxByteNorms() throws IOException {
Directory dir = newFSDirectory(TestUtil.getTempDir("TestNorms.testMaxByteNorms"));
Directory dir = newFSDirectory(TestUtil.createTempDir("TestNorms.testMaxByteNorms"));
buildIndex(dir);
AtomicReader open = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir));
NumericDocValues normValues = open.getNormValues(byteTestField);

View File

@ -473,7 +473,7 @@ public class TestControlledRealTimeReopenThread extends ThreadedIndexingAndSearc
String content = builder.toString();
final SnapshotDeletionPolicy sdp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
final Directory dir = new NRTCachingDirectory(newFSDirectory(TestUtil.getTempDir("nrt")), 5, 128);
final Directory dir = new NRTCachingDirectory(newFSDirectory(TestUtil.createTempDir("nrt")), 5, 128);
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_46,
new MockAnalyzer(random()));
config.setIndexDeletionPolicy(sdp);

View File

@ -44,7 +44,7 @@ import org.apache.lucene.util.TestUtil;
public class TestLiveFieldValues extends LuceneTestCase {
public void test() throws Exception {
Directory dir = newFSDirectory(TestUtil.getTempDir("livefieldupdates"));
Directory dir = newFSDirectory(TestUtil.createTempDir("livefieldupdates"));
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
final IndexWriter w = new IndexWriter(dir, iwc);

View File

@ -222,7 +222,7 @@ public class TestBufferedIndexInput extends LuceneTestCase {
}
public void testSetBufferSize() throws IOException {
File indexDir = TestUtil.getTempDir("testSetBufferSize");
File indexDir = TestUtil.createTempDir("testSetBufferSize");
MockFSDirectory dir = new MockFSDirectory(indexDir, random());
try {
IndexWriter writer = new IndexWriter(

View File

@ -29,10 +29,11 @@ import org.apache.lucene.util.TestUtil;
public class TestDirectory extends LuceneTestCase {
public void testDetectClose() throws Throwable {
File tempDir = TestUtil.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) {
@ -134,7 +135,7 @@ public class TestDirectory extends LuceneTestCase {
// 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 = TestUtil.createTempDir("testDirectInstantiation");
final byte[] largeBuffer = new byte[random().nextInt(256*1024)], largeReadBuffer = new byte[largeBuffer.length];
for (int i = 0; i < largeBuffer.length; i++) {
@ -222,7 +223,7 @@ public class TestDirectory extends LuceneTestCase {
// LUCENE-1464
public void testDontCreate() throws Throwable {
File path = new File(TEMP_DIR, "doesnotexist");
File path = new File(TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()), "doesnotexist");
try {
assertTrue(!path.exists());
Directory dir = new SimpleFSDirectory(path, null);
@ -240,7 +241,7 @@ public class TestDirectory extends LuceneTestCase {
// LUCENE-1468
public void testFSDirectoryFilter() throws IOException {
checkDirectoryFilter(newFSDirectory(TestUtil.getTempDir("test")));
checkDirectoryFilter(newFSDirectory(TestUtil.createTempDir("test")));
}
// LUCENE-1468
@ -257,7 +258,7 @@ public class TestDirectory extends LuceneTestCase {
// LUCENE-1468
public void testCopySubdir() throws Throwable {
File path = TestUtil.getTempDir("testsubdir");
File path = TestUtil.createTempDir("testsubdir");
try {
path.mkdirs();
new File(path, "subdir").mkdirs();
@ -270,7 +271,7 @@ public class TestDirectory extends LuceneTestCase {
// LUCENE-1468
public void testNotDirectory() throws Throwable {
File path = TestUtil.getTempDir("testnotdir");
File path = TestUtil.createTempDir("testnotdir");
Directory fsDir = new SimpleFSDirectory(path, null);
try {
IndexOutput out = fsDir.createOutput("afile", newIOContext(random()));

View File

@ -88,8 +88,8 @@ public class TestFileSwitchDirectory extends LuceneTestCase {
}
private Directory newFSSwitchDirectory(Set<String> primaryExtensions) throws IOException {
File primDir = TestUtil.getTempDir("foo");
File secondDir = TestUtil.getTempDir("bar");
File primDir = TestUtil.createTempDir("foo");
File secondDir = TestUtil.createTempDir("bar");
return newFSSwitchDirectory(primDir, secondDir, primaryExtensions);
}
@ -102,8 +102,8 @@ public class TestFileSwitchDirectory extends LuceneTestCase {
// 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");
File primDir = TestUtil.createTempDir("foo");
File secondDir = TestUtil.createTempDir("bar");
TestUtil.rmDir(primDir);
TestUtil.rmDir(secondDir);
Directory dir = newFSSwitchDirectory(primDir, secondDir, Collections.<String>emptySet());

View File

@ -136,7 +136,7 @@ public class TestLockFactory extends LuceneTestCase {
// no unexpected exceptions are raised:
@Nightly
public void testStressLocks() throws Exception {
_testStressLocks(null, TestUtil.getTempDir("index.TestLockFactory6"));
_testStressLocks(null, TestUtil.createTempDir("index.TestLockFactory6"));
}
// Verify: do stress test, by opening IndexReaders and
@ -145,7 +145,7 @@ public class TestLockFactory extends LuceneTestCase {
// NativeFSLockFactory:
@Nightly
public void testStressLocksNativeFSLockFactory() throws Exception {
File dir = TestUtil.getTempDir("index.TestLockFactory7");
File dir = TestUtil.createTempDir("index.TestLockFactory7");
_testStressLocks(new NativeFSLockFactory(dir), dir);
}
@ -176,8 +176,7 @@ public class TestLockFactory extends LuceneTestCase {
// Verify: NativeFSLockFactory works correctly
public void testNativeFSLockFactory() throws IOException {
NativeFSLockFactory f = new NativeFSLockFactory(TEMP_DIR);
NativeFSLockFactory f = new NativeFSLockFactory(TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()));
f.setLockPrefix("test");
Lock l = f.makeLock("commit");
@ -202,11 +201,11 @@ public class TestLockFactory extends LuceneTestCase {
// Verify: NativeFSLockFactory works correctly if the lock file exists
public void testNativeFSLockFactoryLockExists() throws IOException {
File lockFile = new File(TEMP_DIR, "test.lock");
File tempDir = TestUtil.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 LuceneTestCase {
}
public void testNativeFSLockReleaseByOtherLock() throws IOException {
NativeFSLockFactory f = new NativeFSLockFactory(TEMP_DIR);
NativeFSLockFactory f = new NativeFSLockFactory(TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()));
f.setLockPrefix("test");
Lock l = f.makeLock("commit");
@ -238,8 +236,8 @@ public class TestLockFactory extends LuceneTestCase {
// 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 = TestUtil.createTempDir("TestLockFactory.8");
File fdir2 = TestUtil.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));
@ -261,7 +259,7 @@ public class TestLockFactory extends LuceneTestCase {
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 = TestUtil.createTempDir("TestLockFactory.10");
Directory dir = new SimpleFSDirectory(dirName);
assertNull("Default lock prefix should be null", dir.getLockFactory().getLockPrefix());

View File

@ -44,12 +44,12 @@ public class TestMultiMMap extends LuceneTestCase {
public void setUp() throws Exception {
super.setUp();
assumeTrue("test requires a jre that supports unmapping", MMapDirectory.UNMAP_SUPPORTED);
workDir = TestUtil.getTempDir("TestMultiMMap");
workDir = TestUtil.createTempDir("TestMultiMMap");
workDir.mkdirs();
}
public void testCloneSafety() throws Exception {
MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testCloneSafety"));
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testCloneSafety"));
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
io.writeVInt(5);
io.close();
@ -83,7 +83,7 @@ public class TestMultiMMap extends LuceneTestCase {
}
public void testCloneClose() throws Exception {
MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testCloneClose"));
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testCloneClose"));
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
io.writeVInt(5);
io.close();
@ -105,7 +105,7 @@ public class TestMultiMMap extends LuceneTestCase {
}
public void testCloneSliceSafety() throws Exception {
MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testCloneSliceSafety"));
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testCloneSliceSafety"));
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
io.writeInt(1);
io.writeInt(2);
@ -150,7 +150,7 @@ public class TestMultiMMap extends LuceneTestCase {
}
public void testCloneSliceClose() throws Exception {
MMapDirectory mmapDir = new MMapDirectory(TestUtil.getTempDir("testCloneSliceClose"));
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testCloneSliceClose"));
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
io.writeInt(1);
io.writeInt(2);
@ -177,7 +177,7 @@ public class TestMultiMMap extends LuceneTestCase {
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(TestUtil.createTempDir("testSeekZero"), null, 1<<i);
IndexOutput io = mmapDir.createOutput("zeroBytes", newIOContext(random()));
io.close();
IndexInput ii = mmapDir.openInput("zeroBytes", newIOContext(random()));
@ -189,7 +189,7 @@ public class TestMultiMMap extends LuceneTestCase {
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(TestUtil.createTempDir("testSeekSliceZero"), null, 1<<i);
IndexOutput io = mmapDir.createOutput("zeroBytes", newIOContext(random()));
io.close();
IndexInputSlicer slicer = mmapDir.createSlicer("zeroBytes", newIOContext(random()));
@ -203,7 +203,7 @@ public class TestMultiMMap extends LuceneTestCase {
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(TestUtil.createTempDir("testSeekEnd"), null, 1<<i);
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
byte bytes[] = new byte[1<<i];
random().nextBytes(bytes);
@ -221,7 +221,7 @@ public class TestMultiMMap extends LuceneTestCase {
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(TestUtil.createTempDir("testSeekSliceEnd"), null, 1<<i);
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
byte bytes[] = new byte[1<<i];
random().nextBytes(bytes);
@ -241,7 +241,7 @@ public class TestMultiMMap extends LuceneTestCase {
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(TestUtil.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 +268,7 @@ public class TestMultiMMap extends LuceneTestCase {
// 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(TestUtil.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);

View File

@ -123,7 +123,7 @@ public class TestNRTCachingDirectory extends LuceneTestCase {
// LUCENE-3382 -- make sure we get exception if the directory really does not exist.
public void testNoDir() throws Throwable {
File tempDir = TestUtil.getTempDir("doesnotexist");
File tempDir = TestUtil.createTempDir("doesnotexist");
TestUtil.rmDir(tempDir);
Directory dir = new NRTCachingDirectory(newFSDirectory(tempDir), 2.0, 25.0);
try {
@ -137,7 +137,7 @@ public class TestNRTCachingDirectory extends LuceneTestCase {
// 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(TestUtil.createTempDir("foo")), 2.0, 25.0);
String name = "file";
try {
dir.createOutput(name, newIOContext(random())).close();

View File

@ -50,7 +50,7 @@ public class TestRAMDirectory extends LuceneTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
indexDir = TestUtil.getTempDir("RAMDirIndex");
indexDir = TestUtil.createTempDir("RAMDirIndex");
Directory dir = newFSDirectory(indexDir);
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(

View File

@ -65,7 +65,7 @@ public class TestWindowsMMap extends LuceneTestCase {
// 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 = TestUtil.createTempDir("testLuceneMmap");
rmDir(dirPath);
MMapDirectory dir = new MMapDirectory(dirPath, null);

View File

@ -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(TestUtil.createTempDir("test2BPagedBytes"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}

View File

@ -42,7 +42,7 @@ public class TestOfflineSorter extends LuceneTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
tempDir = TestUtil.getTempDir("mergesort");
tempDir = TestUtil.createTempDir("mergesort");
TestUtil.rmDir(tempDir);
tempDir.mkdirs();
}

View File

@ -37,7 +37,7 @@ public class TestPagedBytes extends LuceneTestCase {
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(TestUtil.createTempDir("testOverflow"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}
@ -150,7 +150,7 @@ public class TestPagedBytes extends LuceneTestCase {
@Ignore // memory hole
public void testOverflow() throws IOException {
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.getTempDir("testOverflow"));
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("testOverflow"));
if (dir instanceof MockDirectoryWrapper) {
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
}

View File

@ -45,7 +45,7 @@ public class Test2BFST extends LuceneTestCase {
IntsRef input = new IntsRef(ints, 0, ints.length);
long seed = random().nextLong();
Directory dir = new MMapDirectory(TestUtil.getTempDir("2BFST"));
Directory dir = new MMapDirectory(TestUtil.createTempDir("2BFST"));
for(int doPackIter=0;doPackIter<2;doPackIter++) {
boolean doPack = doPackIter == 1;

View File

@ -309,7 +309,7 @@ public class TestFSTs extends LuceneTestCase {
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 = TestUtil.createTempDir("fstlines");
final Directory dir = newFSDirectory(tempDir);
final IndexWriter writer = new IndexWriter(dir, conf);
final long stopTime = System.currentTimeMillis() + RUN_TIME_MSEC;

View File

@ -33,7 +33,7 @@ public class TestLeaveFilesIfTestFails extends WithNestedTests {
public static class Nested1 extends WithNestedTests.AbstractNestedTest {
static File file;
public void testDummy() {
file = TestUtil.getTempDir("leftover");
file = TestUtil.createTempDir("leftover");
file.mkdirs();
fail();
}

View File

@ -44,7 +44,7 @@ public class TestDemo extends LuceneTestCase {
public void testIndexSearch() throws Exception {
File dir = getDataFile("test-files/docs");
File indexDir = TestUtil.getTempDir("ContribDemoTest");
File indexDir = TestUtil.createTempDir("ContribDemoTest");
IndexFiles.main(new String[] { "-create", "-docs", dir.getPath(), "-index", indexDir.getPath()});
testOneSearch(indexDir, "apache", 3);
testOneSearch(indexDir, "patent", 8);

View File

@ -941,10 +941,12 @@ public class DirectoryTaxonomyWriter implements TaxonomyWriter {
map[origordinal] = newordinal;
}
in.close();
// Delete the temporary file, which is no longer needed.
if (!tmpfile.delete()) {
tmpfile.deleteOnExit();
}
return map;
}
}

View File

@ -74,7 +74,7 @@ public class TestAddTaxonomy extends FacetTestCase {
private OrdinalMap randomOrdinalMap() throws IOException {
if (random().nextBoolean()) {
return new DiskOrdinalMap(TestUtil.createTempFile("taxoMap", "", TEMP_DIR));
return new DiskOrdinalMap(TestUtil.createTempFile("taxoMap", ""));
} else {
return new MemoryOrdinalMap();
}

View File

@ -85,7 +85,7 @@ public class TestCharBlockArray extends FacetTestCase {
assertEqualsInternal("GrowingCharArray<->StringBuilder mismatch.", builder, array);
File tempDir = TestUtil.getTempDir("growingchararray");
File tempDir = TestUtil.createTempDir("growingchararray");
File f = new File(tempDir, "GrowingCharArrayTest.tmp");
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));
array.flush(out);

View File

@ -68,7 +68,7 @@ public class TestCompactLabelToOrdinal extends FacetTestCase {
}
}
File tmpDir = TestUtil.getTempDir("testLableToOrdinal");
File tmpDir = TestUtil.createTempDir("testLableToOrdinal");
File f = new File(tmpDir, "CompactLabelToOrdinalTest.tmp");
int flushInterval = 10;

View File

@ -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 = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File destDir = TestUtil.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 LuceneTestCase {
fsDirDest.close();
// now test cmdline
File destDir2 = new File(TEMP_DIR, "testfilesplitterdest2");
TestUtil.rmDir(destDir2);
destDir2.mkdirs();
File destDir2 = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
IndexSplitter.main(new String[] {dir.getAbsolutePath(), destDir2.getAbsolutePath(), splitSegName});
assertEquals(5, destDir2.listFiles().length);
Directory fsDirDest2 = newFSDirectory(destDir2);

View File

@ -191,7 +191,7 @@ public class IndexAndTaxonomyReplicationClientTest extends ReplicatorTestCase {
publishTaxoDir = newDirectory();
handlerIndexDir = newMockDirectory();
handlerTaxoDir = newMockDirectory();
clientWorkDir = TestUtil.getTempDir("replicationClientTest");
clientWorkDir = TestUtil.createTempDir("replicationClientTest");
sourceDirFactory = new PerSessionDirectoryFactory(clientWorkDir);
replicator = new LocalReplicator();
callback = new IndexAndTaxonomyReadyCallback(handlerIndexDir, handlerTaxoDir);

View File

@ -136,7 +136,7 @@ public class IndexReplicationClientTest extends ReplicatorTestCase {
super.setUp();
publishDir = newMockDirectory();
handlerDir = newMockDirectory();
sourceDirFactory = new PerSessionDirectoryFactory(TestUtil.getTempDir("replicationClientTest"));
sourceDirFactory = new PerSessionDirectoryFactory(TestUtil.createTempDir("replicationClientTest"));
replicator = new LocalReplicator();
callback = new IndexReadyCallback(handlerDir);
handler = new IndexReplicationHandler(handlerDir, callback);

View File

@ -68,7 +68,7 @@ public class HttpReplicatorTest extends ReplicatorTestCase {
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 = TestUtil.createTempDir("httpReplicatorTest");
handlerIndexDir = newDirectory();
serverIndexDir = newDirectory();
serverReplicator = new LocalReplicator();

View File

@ -162,7 +162,7 @@ public class LookupBenchmarkTest extends LuceneTestCase {
} 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(TestUtil.createTempDir("LookupBenchmarkTest")), a);
} else {
Constructor<? extends Lookup> ctor = cls.getConstructor(Analyzer.class);
lookup = ctor.newInstance(a);

View File

@ -70,7 +70,7 @@ public class PersistenceTest extends LuceneTestCase {
lookup.build(new InputArrayIterator(keys));
// Store the suggester.
File storeDir = TEMP_DIR;
File storeDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
lookup.store(new FileOutputStream(new File(storeDir, "lookup.dat")));
// Re-read it from disk.

View File

@ -94,7 +94,7 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz")),
};
File tempDir = TestUtil.getTempDir("AnalyzingInfixSuggesterTest");
File tempDir = TestUtil.createTempDir("AnalyzingInfixSuggesterTest");
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, newFSDirectory(tempDir), a, a, 3);
@ -213,7 +213,7 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
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 = TestUtil.createTempDir("AnalyzingInfixSuggesterTest");
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
int minPrefixLength = random().nextInt(10);
@ -474,7 +474,7 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
}
public void testRandomNRT() throws Exception {
final File tempDir = TestUtil.getTempDir("AnalyzingInfixSuggesterTest");
final File tempDir = TestUtil.createTempDir("AnalyzingInfixSuggesterTest");
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
int minPrefixChars = random().nextInt(7);
if (VERBOSE) {
@ -809,7 +809,7 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz"), asSet("foo", "baz"))
};
File tempDir = TestUtil.getTempDir("analyzingInfixContext");
File tempDir = TestUtil.createTempDir("analyzingInfixContext");
for(int iter=0;iter<2;iter++) {
AnalyzingInfixSuggester suggester;

View File

@ -921,7 +921,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase {
assertEquals(3, results.get(2).value);
// Try again after save/load:
File tmpDir = TestUtil.getTempDir("AnalyzingSuggesterTest");
File tmpDir = TestUtil.createTempDir("AnalyzingSuggesterTest");
tmpDir.mkdir();
File path = new File(tmpDir, "suggester");
@ -983,7 +983,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase {
assertEquals(5, results.get(1).value);
// Try again after save/load:
File tmpDir = TestUtil.getTempDir("AnalyzingSuggesterTest");
File tmpDir = TestUtil.createTempDir("AnalyzingSuggesterTest");
tmpDir.mkdir();
File path = new File(tmpDir, "suggester");
@ -1053,7 +1053,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase {
assertEquals(5, results.get(1).value);
// Try again after save/load:
File tmpDir = TestUtil.getTempDir("AnalyzingSuggesterTest");
File tmpDir = TestUtil.createTempDir("AnalyzingSuggesterTest");
tmpDir.mkdir();
File path = new File(tmpDir, "suggester");

View File

@ -45,7 +45,7 @@ public class BlendedInfixSuggesterTest extends LuceneTestCase {
new Input("star wars: episode v - the empire strikes back", 8, payload)
};
File tempDir = TestUtil.getTempDir("BlendedInfixSuggesterTest");
File tempDir = TestUtil.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 +84,7 @@ public class BlendedInfixSuggesterTest extends LuceneTestCase {
new Input("top of the lake", w, pl)
};
File tempDir = TestUtil.getTempDir("BlendedInfixSuggesterTest");
File tempDir = TestUtil.createTempDir("BlendedInfixSuggesterTest");
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
// BlenderType.LINEAR is used by default (remove position*10%)
@ -125,7 +125,7 @@ public class BlendedInfixSuggesterTest extends LuceneTestCase {
new Input("the returned", 10, ret),
};
File tempDir = TestUtil.getTempDir("BlendedInfixSuggesterTest");
File tempDir = TestUtil.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 +175,7 @@ public class BlendedInfixSuggesterTest extends LuceneTestCase {
new Input("the returned", 10, ret),
};
File tempDir = TestUtil.getTempDir("BlendedInfixSuggesterTest");
File tempDir = TestUtil.createTempDir("BlendedInfixSuggesterTest");
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
// if factor is small, we don't get the expected element

View File

@ -82,7 +82,7 @@ public class TestFreeTextSuggester extends LuceneTestCase {
toString(sug.lookup("b", 10)));
// Try again after save/load:
File tmpDir = TestUtil.getTempDir("FreeTextSuggesterTest");
File tmpDir = TestUtil.createTempDir("FreeTextSuggesterTest");
tmpDir.mkdir();
File path = new File(tmpDir, "suggester");

View File

@ -502,7 +502,7 @@ public abstract class BaseTokenStreamTestCase extends LuceneTestCase {
!(postingsFormat.equals("Memory") ||
postingsFormat.equals("SimpleText"));
if (rarely(random) && codecOk) {
dir = newFSDirectory(TestUtil.getTempDir("bttc"));
dir = newFSDirectory(TestUtil.createTempDir("bttc"));
iw = new RandomIndexWriter(new Random(seed), dir, a);
}
boolean success = false;

View File

@ -2615,7 +2615,7 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase {
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(TestUtil.createTempDir("hugeBinaryValues"));
boolean doFixed = random().nextBoolean();
int numDocs;
int fixedLength = 0;
@ -2713,7 +2713,7 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase {
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(TestUtil.createTempDir("hugeBinaryValues"));
boolean doFixed = random().nextBoolean();
int numDocs;
int fixedLength = 0;

View File

@ -1211,7 +1211,7 @@ public abstract class BasePostingsFormatTestCase extends LuceneTestCase {
/** 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 = TestUtil.createTempDir("testPostingsFormat.testExact");
Directory dir = newFSDirectory(path);
// TODO test thread safety of buildIndex too
@ -1264,7 +1264,7 @@ public abstract class BasePostingsFormatTestCase extends LuceneTestCase {
int iters = 5;
for(int iter=0;iter<iters;iter++) {
File path = TestUtil.getTempDir("testPostingsFormat");
File path = TestUtil.createTempDir("testPostingsFormat");
Directory dir = newFSDirectory(path);
boolean indexPayloads = random().nextBoolean();

View File

@ -598,7 +598,7 @@ public abstract class BaseStoredFieldsFormatTestCase extends LuceneTestCase {
// 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(TestUtil.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);

View File

@ -435,7 +435,7 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
Random random = new Random(random().nextLong());
final LineFileDocs docs = new LineFileDocs(random, true);
final File tempDir = TestUtil.getTempDir(testName);
final File tempDir = TestUtil.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.

View File

@ -447,7 +447,7 @@ public abstract class ShardSearchingTestBase extends LuceneTestCase {
public NodeState(Random random, int nodeID, int numNodes) throws IOException {
myNodeID = nodeID;
dir = newFSDirectory(TestUtil.getTempDir("ShardSearchingTestBase"));
dir = newFSDirectory(TestUtil.createTempDir("ShardSearchingTestBase"));
// TODO: set warmer
MockAnalyzer analyzer = new MockAnalyzer(random());
analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));

View File

@ -1,6 +1,8 @@
package org.apache.lucene.util;
import java.io.*;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -25,10 +27,17 @@ import java.io.*;
final class CloseableFile implements Closeable {
private final File file;
private final TestRuleMarkFailure failureMarker;
private final String creationStack;
public CloseableFile(File file, TestRuleMarkFailure failureMarker) {
this.file = file;
this.failureMarker = failureMarker;
StringBuilder b = new StringBuilder();
for (StackTraceElement e : Thread.currentThread().getStackTrace()) {
b.append('\t').append(e.toString()).append('\n');
}
creationStack = b.toString();
}
@Override
@ -36,6 +45,10 @@ final class CloseableFile implements Closeable {
// only if there were no other test failures.
if (failureMarker.wasSuccessful()) {
if (file.exists()) {
if (file.listFiles().length > 0) {
// throw new IOException("Temporary folder not clean: " + file.getAbsolutePath() + ". Created at stack trace:\n" + creationStack);
}
try {
TestUtil.rmDir(file);
} catch (IOException e) {
@ -45,9 +58,9 @@ final class CloseableFile implements Closeable {
// Re-check.
if (file.exists()) {
throw new IOException(
"Could not remove: " + file.getAbsolutePath());
"Could not remove temporary folder: " + file.getAbsolutePath() + ". Created at stack trace:\n" + creationStack);
}
}
}
}
}
}

View File

@ -290,16 +290,6 @@ public abstract class LuceneTestCase extends Assert {
/** 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;
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();
}
/**
* These property keys will be ignored in verification of altered properties.
* @see SystemPropertiesInvariantRule
@ -1164,7 +1154,7 @@ public abstract class LuceneTestCase extends Assert {
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 = TestUtil.createTempDir("index");
dir.mkdirs(); // ensure it's created so we 'have' it.
return newFSDirectoryImpl(clazz.asSubclass(FSDirectory.class), dir);
}

View File

@ -102,34 +102,6 @@ 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.
*/
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.");
}
LuceneTestCase.closeAfterSuite(new CloseableFile(f, LuceneTestCase.suiteFailureMarker));
return f;
}
/**
* Deletes a directory and everything underneath it.
*/
@ -809,9 +781,45 @@ public final class TestUtil {
Assert.assertEquals("Reflection does not produce same map", reflectedValues, map);
}
/**
* Returns a new, empty temporary folder, based on the given name. The folder will be
* deleted at the end of the suite. Failure to delete the temporary folder will cause
* an exception (typically on Windows).
*/
public static File createTempDir(String name) {
if (name.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;
String tmpDir = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
File f;
do {
f = genTempFile(random, name + "_", "", new File(tmpDir));
} 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.");
}
LuceneTestCase.closeAfterSuite(new CloseableFile(f, LuceneTestCase.suiteFailureMarker));
return f;
}
public static File createTempFile(String prefix, String suffix) throws IOException {
String tmpDir = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
return createTempFile(prefix, suffix, new File(tmpDir));
}
/**
* insecure, fast version of File.createTempFile
* uses Random instead of SecureRandom.
* Insecure, fast version of {@link File#createTempFile(String, String)}, uses
* Random instead of SecureRandom.
*/
public static File createTempFile(String prefix, String suffix, File directory)
throws IOException {
@ -828,6 +836,7 @@ public final class TestUtil {
do {
result = genTempFile(random, prefix, newSuffix, directory);
} while (!result.createNewFile());
LuceneTestCase.closeAfterSuite(new CloseableFile(result, LuceneTestCase.suiteFailureMarker));
return result;
}

View File

@ -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.solr.SolrTestCaseJ4;
import org.junit.BeforeClass;
@ -62,7 +64,7 @@ public class TestICUCollationField extends SolrTestCaseJ4 {
*/
public static String setupSolrHome() throws Exception {
// make a solr home underneath the test's TEMP_DIR
File tmpFile = File.createTempFile("test", "tmp", TEMP_DIR);
File tmpFile = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
tmpFile.delete();
tmpFile.mkdir();

View File

@ -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;
@ -64,7 +66,7 @@ public class TestICUCollationFieldDocValues extends SolrTestCaseJ4 {
*/
public static String setupSolrHome() throws Exception {
// make a solr home underneath the test's TEMP_DIR
File tmpFile = File.createTempFile("test", "tmp", TEMP_DIR);
File tmpFile = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
tmpFile.delete();
tmpFile.mkdir();

View File

@ -16,6 +16,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.junit.After;
import org.junit.Before;
@ -54,9 +56,7 @@ public abstract class AbstractSqlEntityProcessorTestCase extends
@Before
public void beforeSqlEntitiyProcessorTestCase() throws Exception {
File tmpdir = File.createTempFile("test", "tmp", TEMP_DIR);
tmpdir.delete();
tmpdir.mkdir();
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
fileLocation = tmpdir.getPath();
fileName = "the.properties";
}

View File

@ -16,7 +16,12 @@
*/
package org.apache.solr.handler.dataimport;
import java.io.File;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.DirectXmlRequest;
@ -25,14 +30,10 @@ import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.UpdateParams;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.util.List;
/**
* Test for ContentStreamDataSource
*
@ -150,10 +151,7 @@ public class TestContentStreamDataSource extends AbstractDataImportHandlerTestCa
public void setUp() throws Exception {
File home = new File(TEMP_DIR,
getClass().getName() + "-" + System.currentTimeMillis());
File home = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
homeDir = new File(home, "inst");
dataDir = new File(homeDir + "/collection1", "data");

View File

@ -20,6 +20,8 @@ import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.request.LocalSolrQueryRequest;
import java.util.ArrayList;
@ -240,10 +242,7 @@ public class TestDocBuilder2 extends AbstractDataImportHandlerTestCase {
@Test
@Ignore("Fix Me. See SOLR-4103.")
public void testFileListEntityProcessor_lastIndexTime() throws Exception {
File tmpdir = File.createTempFile("test", "tmp", TEMP_DIR);
tmpdir.delete();
tmpdir.mkdir();
tmpdir.deleteOnExit();
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
Map<String, String> params = createMap("baseDir", tmpdir.getAbsolutePath());

View File

@ -16,6 +16,8 @@ package org.apache.solr.handler.dataimport;
* limitations under the License.
*/
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.junit.Ignore;
import org.junit.Test;
@ -37,10 +39,7 @@ public class TestFileListEntityProcessor extends AbstractDataImportHandlerTestCa
@Test
@SuppressWarnings("unchecked")
public void testSimple() throws IOException {
File tmpdir = File.createTempFile("test", "tmp", TEMP_DIR);
tmpdir.delete();
tmpdir.mkdir();
tmpdir.deleteOnExit();
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
createFile(tmpdir, "a.xml", "a.xml".getBytes("UTF-8"), false);
createFile(tmpdir, "b.xml", "b.xml".getBytes("UTF-8"), false);
createFile(tmpdir, "c.props", "c.props".getBytes("UTF-8"), false);
@ -63,10 +62,7 @@ public class TestFileListEntityProcessor extends AbstractDataImportHandlerTestCa
@Test
public void testBiggerSmallerFiles() throws IOException {
File tmpdir = File.createTempFile("test", "tmp", TEMP_DIR);
tmpdir.delete();
tmpdir.mkdir();
tmpdir.deleteOnExit();
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
long minLength = Long.MAX_VALUE;
String smallestFile = "";
byte[] content = "abcdefgij".getBytes("UTF-8");
@ -133,10 +129,7 @@ public class TestFileListEntityProcessor extends AbstractDataImportHandlerTestCa
@Test
public void testNTOT() throws IOException {
File tmpdir = File.createTempFile("test", "tmp", TEMP_DIR);
tmpdir.delete();
tmpdir.mkdir();
tmpdir.deleteOnExit();
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
createFile(tmpdir, "a.xml", "a.xml".getBytes("UTF-8"), true);
createFile(tmpdir, "b.xml", "b.xml".getBytes("UTF-8"), true);
createFile(tmpdir, "c.props", "c.props".getBytes("UTF-8"), true);
@ -169,13 +162,8 @@ public class TestFileListEntityProcessor extends AbstractDataImportHandlerTestCa
@Test
public void testRECURSION() throws IOException {
File tmpdir = File.createTempFile("test", "tmp", TEMP_DIR);
tmpdir.delete();
tmpdir.mkdir();
tmpdir.deleteOnExit();
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File childdir = new File(tmpdir + "/child" );
childdir.mkdirs();
childdir.deleteOnExit();
createFile(childdir, "a.xml", "a.xml".getBytes("UTF-8"), true);
createFile(childdir, "b.xml", "b.xml".getBytes("UTF-8"), true);
createFile(childdir, "c.props", "c.props".getBytes("UTF-8"), true);

View File

@ -2,6 +2,8 @@ package org.apache.solr.handler.dataimport;
import java.io.File;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.junit.BeforeClass;
@ -29,10 +31,7 @@ public class TestFileListWithLineEntityProcessor extends AbstractDataImportHandl
}
public void test() throws Exception {
File tmpdir = File.createTempFile("test", "tmp", TEMP_DIR);
tmpdir.delete();
tmpdir.mkdir();
tmpdir.deleteOnExit();
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
createFile(tmpdir, "a.txt", "a line one\na line two\na line three".getBytes("UTF-8"), false);
createFile(tmpdir, "b.txt", "b line one\nb line two".getBytes("UTF-8"), false);
createFile(tmpdir, "c.txt", "c line one\nc line two\nc line three\nc line four".getBytes("UTF-8"), false);

View File

@ -17,6 +17,8 @@
package org.apache.solr.handler.dataimport;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -53,7 +55,7 @@ public class TestNonWritablePersistFile extends AbstractDataImportHandlerTestCas
@BeforeClass
public static void createTempSolrHomeAndCore() throws Exception {
createTempDir();
tmpSolrHome = TEMP_DIR + File.separator + TestNonWritablePersistFile.class.getSimpleName() + System.currentTimeMillis();
tmpSolrHome = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
FileUtils.copyDirectory(getFile("dih/solr"), new File(tmpSolrHome).getAbsoluteFile());
initCore("dataimport-solrconfig.xml", "dataimport-schema.xml",
new File(tmpSolrHome).getAbsolutePath());

View File

@ -14,6 +14,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@ -46,9 +48,7 @@ public class TestSimplePropertiesWriter extends AbstractDIHJdbcTestCase {
@Before
public void spwBefore() throws Exception {
File tmpdir = File.createTempFile("test", "tmp", TEMP_DIR);
tmpdir.delete();
tmpdir.mkdir();
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
fileLocation = tmpdir.getPath();
fileName = "the.properties";
}

View File

@ -26,6 +26,8 @@ import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
@ -316,9 +318,7 @@ public class TestSolrEntityProcessorEndToEnd extends AbstractDataImportHandlerTe
}
public void setUp() throws Exception {
File home = new File(TEMP_DIR, getClass().getName() + "-"
+ System.currentTimeMillis());
File home = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
homeDir = new File(home + "inst");
dataDir = new File(homeDir + "/collection1", "data");

View File

@ -16,6 +16,8 @@
*/
package org.apache.solr.handler.dataimport;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.junit.Test;
import java.io.File;
@ -42,10 +44,7 @@ public class TestXPathEntityProcessor extends AbstractDataImportHandlerTestCase
@Test
public void withFieldsAndXpath() throws Exception {
File tmpdir = File.createTempFile("test", "tmp", TEMP_DIR);
tmpdir.delete();
tmpdir.mkdir();
tmpdir.deleteOnExit();
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
createFile(tmpdir, "x.xsl", xsl.getBytes("UTF-8"), false);
Map entityAttrs = createMap("name", "e", "url", "cd.xml",
XPathEntityProcessor.FOR_EACH, "/catalog/cd");
@ -333,12 +332,8 @@ public class TestXPathEntityProcessor extends AbstractDataImportHandlerTestCase
@Test
public void withDefaultSolrAndXsl() throws Exception {
File tmpdir = File.createTempFile("test", "tmp", TEMP_DIR);
tmpdir.delete();
tmpdir.mkdir();
tmpdir.deleteOnExit();
AbstractDataImportHandlerTestCase.createFile(tmpdir, "x.xsl", xsl.getBytes("UTF-8"),
false);
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
AbstractDataImportHandlerTestCase.createFile(tmpdir, "x.xsl", xsl.getBytes("UTF-8"), false);
Map entityAttrs = createMap("name", "e",
XPathEntityProcessor.USE_SOLR_ADD_SCHEMA, "true", "xsl", ""
+ new File(tmpdir, "x.xsl").toURI(), "url", "cd.xml");

View File

@ -21,6 +21,8 @@ import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.hadoop.morphline.MorphlineMapRunner;
import org.apache.solr.morphlines.solr.AbstractSolrMorphlineTestBase;
@ -45,11 +47,9 @@ public abstract class MRUnitBase extends SolrTestCaseJ4 {
}
protected void setupHadoopConfig(Configuration config) throws IOException {
String tempDir = TEMP_DIR + "/test-morphlines-" + System.currentTimeMillis();
new File(tempDir).mkdirs();
String tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
FileUtils.copyFile(new File(RESOURCES_DIR + "/custom-mimetypes.xml"), new File(tempDir + "/custom-mimetypes.xml"));
AbstractSolrMorphlineTestBase.setupMorphline(tempDir, "test-morphlines/solrCellDocumentTypes", true);
config.set(MorphlineMapRunner.MORPHLINE_FILE_PARAM, tempDir + "/test-morphlines/solrCellDocumentTypes.conf");

View File

@ -27,6 +27,8 @@ import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.lucene.util.Constants;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.cloud.AbstractZkTestCase;
import org.apache.solr.hadoop.dedup.NoChangeUpdateConflictResolver;
@ -55,11 +57,12 @@ public class MapReduceIndexerToolArgumentParserTest extends SolrTestCaseJ4 {
private static final Logger LOG = LoggerFactory.getLogger(MapReduceIndexerToolArgumentParserTest.class);
private static final File solrHomeDirectory = new File(TEMP_DIR, MorphlineGoLiveMiniMRTest.class.getName());
private static File solrHomeDirectory;
@BeforeClass
public static void beforeClass() {
assumeFalse("Does not work on Windows, because it uses UNIX shell commands or POSIX paths", Constants.WINDOWS);
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
}
@Before

View File

@ -38,6 +38,8 @@ import org.apache.hadoop.util.JarFinder;
import org.apache.hadoop.util.ToolRunner;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.lucene.util.Constants;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.cloud.AbstractZkTestCase;
@ -79,7 +81,7 @@ public class MorphlineBasicMiniMRTest extends SolrTestCaseJ4 {
private static String tempDir;
private static final File solrHomeDirectory = new File(TEMP_DIR, MorphlineBasicMiniMRTest.class.getName());
private static File solrHomeDirectory;
protected MapReduceIndexerTool createTool() {
return new MapReduceIndexerTool();
@ -108,6 +110,8 @@ public class MorphlineBasicMiniMRTest extends SolrTestCaseJ4 {
@BeforeClass
public static void setupClass() throws Exception {
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
assumeTrue(
"Currently this test can only be run without the lucene test security policy in place",
System.getProperty("java.security.manager", "").equals(""));
@ -121,8 +125,8 @@ public class MorphlineBasicMiniMRTest extends SolrTestCaseJ4 {
AbstractZkTestCase.SOLRHOME = solrHomeDirectory;
FileUtils.copyDirectory(MINIMR_CONF_DIR, solrHomeDirectory);
tempDir = TEMP_DIR + "/test-morphlines-" + System.currentTimeMillis();
tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
new File(tempDir).mkdirs();
FileUtils.copyFile(new File(RESOURCES_DIR + "/custom-mimetypes.xml"), new File(tempDir + "/custom-mimetypes.xml"));

View File

@ -43,6 +43,8 @@ import org.apache.hadoop.util.JarFinder;
import org.apache.hadoop.util.ToolRunner;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.lucene.util.Constants;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
@ -108,8 +110,8 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
private final String inputAvroFile2;
private final String inputAvroFile3;
private static final File solrHomeDirectory = new File(TEMP_DIR, MorphlineGoLiveMiniMRTest.class.getName());
private static File solrHomeDirectory;
@Override
public String getSolrHome() {
return solrHomeDirectory.getPath();
@ -138,11 +140,11 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
assumeFalse("FIXME: This test fails under Java 8 due to the Saxon dependency - see SOLR-1301", Constants.JRE_IS_MINIMUM_JAVA8);
assumeFalse("FIXME: This test fails under J9 due to the Saxon dependency - see SOLR-1301", System.getProperty("java.vm.info", "<?>").contains("IBM J9"));
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
AbstractZkTestCase.SOLRHOME = solrHomeDirectory;
FileUtils.copyDirectory(MINIMR_INSTANCE_DIR, solrHomeDirectory);
FileUtils.copyDirectory(MINIMR_INSTANCE_DIR, AbstractZkTestCase.SOLRHOME);
tempDir = TEMP_DIR + "/test-morphlines-" + System.currentTimeMillis();
new File(tempDir).mkdirs();
tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
FileUtils.copyFile(new File(RESOURCES_DIR + "/custom-mimetypes.xml"), new File(tempDir + "/custom-mimetypes.xml"));
AbstractSolrMorphlineTestBase.setupMorphline(tempDir, "test-morphlines/solrCellDocumentTypes", true);

View File

@ -32,6 +32,8 @@ import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
@ -118,8 +120,7 @@ public class AbstractSolrMorphlineTestBase extends SolrTestCaseJ4 {
testServer = new SolrServerDocumentLoader(solrServer, batchSize);
deleteAllDocuments();
tempDir = new File(TEMP_DIR + "/test-morphlines-" + System.currentTimeMillis()).getAbsolutePath();
new File(tempDir).mkdirs();
tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
}
@After

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.Iterator;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
@ -47,8 +48,8 @@ import com.google.common.collect.ListMultimap;
import com.typesafe.config.Config;
public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistribZkTestBase {
private static final File solrHomeDirectory = new File(TEMP_DIR, AbstractSolrMorphlineZkTestBase.class.getName());
private static File solrHomeDirectory;
protected static final String RESOURCES_DIR = getFile("morphlines-core.marker").getParent();
private static final File SOLR_INSTANCE_DIR = new File(RESOURCES_DIR + "/solr");
private static final File SOLR_CONF_DIR = new File(RESOURCES_DIR + "/solr/collection1");
@ -69,6 +70,7 @@ public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistri
@BeforeClass
public static void setupClass() throws Exception {
solrHomeDirectory = TestUtil.createTempDir(AbstractSolrMorphlineZkTestBase.class.getName());
AbstractZkTestCase.SOLRHOME = solrHomeDirectory;
FileUtils.copyDirectory(SOLR_INSTANCE_DIR, solrHomeDirectory);
createTempDir();

View File

@ -18,6 +18,7 @@ package org.apache.solr;
*/
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
@ -43,7 +44,7 @@ public class AnalysisAfterCoreReloadTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
createTempDir();
tmpSolrHome = TEMP_DIR + File.separator + AnalysisAfterCoreReloadTest.class.getSimpleName() + System.currentTimeMillis();
tmpSolrHome = TestUtil.createTempDir(AnalysisAfterCoreReloadTest.class.getSimpleName()).getAbsolutePath();
FileUtils.copyDirectory(new File(TEST_HOME()), new File(tmpSolrHome).getAbsoluteFile());
initCore("solrconfig.xml", "schema.xml", new File(tmpSolrHome).getAbsolutePath());
}

View File

@ -18,6 +18,8 @@ package org.apache.solr;
*/
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -31,11 +33,10 @@ public class SolrTestCaseJ4Test extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
// Create a temporary directory that holds a core NOT named "collection1". Use the smallest configuration sets
// we can so we don't copy that much junk around.
createTempDir();
tmpSolrHome = TEMP_DIR + File.separator + SolrTestCaseJ4Test.class.getSimpleName() + System.currentTimeMillis();
tmpSolrHome = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath();
File subHome = new File(new File(tmpSolrHome, "core0"), "conf");
assertTrue("Failed to make subdirectory ", subHome.mkdirs());

View File

@ -17,6 +17,7 @@
package org.apache.solr;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.TestUtil;
//import org.apache.lucene.util.LuceneTestCase;
//import org.apache.solr.util.AbstractSolrTestCase;
//import org.apache.solr.client.solrj.embedded.JettySolrRunner;
@ -45,8 +46,7 @@ public class TestSolrCoreProperties extends SolrJettyTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
File homeDir = new File(TEMP_DIR,
"solrtest-TestSolrCoreProperties-" + System.currentTimeMillis());
File homeDir = TestUtil.createTempDir(TestSolrCoreProperties.class.getSimpleName());
File collDir = new File(homeDir, "collection1");
File dataDir = new File(collDir, "data");
File confDir = new File(collDir, "conf");

View File

@ -26,6 +26,8 @@ import java.util.regex.Pattern;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
@ -415,15 +417,15 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/replication");
params.set("command", "backup");
File location = new File(TEMP_DIR, BasicDistributedZk2Test.class.getName() + "-backupdir-" + System.currentTimeMillis());
File location = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName() + "-backupdir");
params.set("location", location.getAbsolutePath());
QueryRequest request = new QueryRequest(params);
NamedList<Object> results = client.request(request );
checkForBackupSuccess(client, location);
}
private void checkForBackupSuccess(final HttpSolrServer client, File location)
throws InterruptedException, IOException {
class CheckStatus extends Thread {

View File

@ -18,6 +18,7 @@ package org.apache.solr.cloud;
*/
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.ClusterState;
@ -67,11 +68,11 @@ public class ClusterStateUpdateTest extends SolrTestCaseJ4 {
private File dataDir4;
private static final File solrHomeDirectory = new File(TEMP_DIR, "ZkControllerTest");
private static File solrHomeDirectory;
@BeforeClass
public static void beforeClass() throws IOException {
solrHomeDirectory = TestUtil.createTempDir(ClusterStateUpdateTest.class.getSimpleName());
System.setProperty("solrcloud.skip.autorecovery", "true");
System.setProperty("genericCoreNodeNames", "false");
if (solrHomeDirectory.exists()) {

View File

@ -17,10 +17,13 @@
package org.apache.solr.cloud;
import java.io.File;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.ExternalPaths;
import org.junit.After;
import org.junit.Before;
@ -28,8 +31,6 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
public class TestMultiCoreConfBootstrap extends SolrTestCaseJ4 {
protected static Logger log = LoggerFactory.getLogger(TestMultiCoreConfBootstrap.class);
protected CoreContainer cores = null;
@ -45,9 +46,7 @@ public class TestMultiCoreConfBootstrap extends SolrTestCaseJ4 {
super.setUp();
createTempDir();
dataDir2 = new File(TEMP_DIR, getSimpleClassName() + "-core1-"
+ System.currentTimeMillis());
dataDir2.mkdirs();
dataDir2 = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
home = ExternalPaths.EXAMPLE_MULTICORE_HOME;
System.setProperty("solr.solr.home", home);

View File

@ -28,6 +28,8 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.RegexFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.cloud.SolrZkClient;
@ -231,11 +233,9 @@ public class ZkCLITest extends SolrTestCaseJ4 {
assertEquals(confsetname, collectionProps.getStr("configName"));
// test down config
File confDir = new File(TEMP_DIR,
"solrtest-confdropspot-" + this.getClass().getName() + "-" + System.currentTimeMillis());
File confDir = new File(TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()), "solrtest-confdropspot");
assertFalse(confDir.exists());
args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
"downconfig", "-confdir", confDir.getAbsolutePath(), "-confname", confsetname};
ZkCLI.main(args);
@ -281,8 +281,7 @@ public class ZkCLITest extends SolrTestCaseJ4 {
byte [] data = new String("getFileNode-data").getBytes("UTF-8");
this.zkClient.create(getNode, data, CreateMode.PERSISTENT, true);
File file = new File(TEMP_DIR,
"solrtest-getfile-" + this.getClass().getName() + "-" + System.currentTimeMillis());
File file = TestUtil.createTempFile("solrtest-getfile", "");
String[] args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
"getfile", getNode, file.getAbsolutePath()};
ZkCLI.main(args);
@ -295,8 +294,7 @@ public class ZkCLITest extends SolrTestCaseJ4 {
public void testGetFileNotExists() throws Exception {
String getNode = "/getFileNotExistsNode";
File file = new File(TEMP_DIR,
"solrtest-getfilenotexists-" + this.getClass().getName() + "-" + System.currentTimeMillis());
File file = TestUtil.createTempFile("solrtest-getfilenotexists", "");
String[] args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
"getfile", getNode, file.getAbsolutePath()};
try {

View File

@ -17,11 +17,11 @@ package org.apache.solr.cloud.hdfs;
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.cloud.BasicDistributedZk2Test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@ -38,9 +38,7 @@ public class HdfsBasicDistributedZk2Test extends BasicDistributedZk2Test {
@BeforeClass
public static void setupClass() throws Exception {
dfsCluster = HdfsTestUtil.setupClass(new File(TEMP_DIR,
HdfsBasicDistributedZk2Test.class.getName() + "_"
+ System.currentTimeMillis()).getAbsolutePath());
dfsCluster = HdfsTestUtil.setupClass();
}
@AfterClass

Some files were not shown because too many files have changed in this diff Show More