mirror of https://github.com/apache/lucene.git
Moved createTemp* to LuceneTestCase, removing it from SolrTestCaseJ4. Created common infrastructure that creates temporary files and folders under the suite's master folder. Created a rule that cleans up afterwards (or provides an explicit message if something fails to clean up).:
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/solr5914@1584832 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c0bdf68730
commit
bfecbc9274
|
@ -62,7 +62,7 @@ public class TestFilesystemResourceLoader extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBaseDir() throws Exception {
|
public void testBaseDir() throws Exception {
|
||||||
final File base = TestUtil.createTempDir("fsResourceLoaderBase").getAbsoluteFile();
|
final File base = createTempDir("fsResourceLoaderBase").getAbsoluteFile();
|
||||||
try {
|
try {
|
||||||
base.mkdirs();
|
base.mkdirs();
|
||||||
Writer os = new OutputStreamWriter(new FileOutputStream(new File(base, "template.txt")), StandardCharsets.UTF_8);
|
Writer os = new OutputStreamWriter(new FileOutputStream(new File(base, "template.txt")), StandardCharsets.UTF_8);
|
||||||
|
|
|
@ -75,7 +75,7 @@ import org.apache.lucene.util.TestUtil;
|
||||||
public class TestCompile extends LuceneTestCase {
|
public class TestCompile extends LuceneTestCase {
|
||||||
|
|
||||||
public void testCompile() throws Exception {
|
public void testCompile() throws Exception {
|
||||||
File dir = TestUtil.createTempDir("testCompile");
|
File dir = createTempDir("testCompile");
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
InputStream input = getClass().getResourceAsStream("testRules.txt");
|
InputStream input = getClass().getResourceAsStream("testRules.txt");
|
||||||
File output = new File(dir, "testRules.txt");
|
File output = new File(dir, "testRules.txt");
|
||||||
|
@ -91,7 +91,7 @@ public class TestCompile extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCompileBackwards() throws Exception {
|
public void testCompileBackwards() throws Exception {
|
||||||
File dir = TestUtil.createTempDir("testCompile");
|
File dir = createTempDir("testCompile");
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
InputStream input = getClass().getResourceAsStream("testRules.txt");
|
InputStream input = getClass().getResourceAsStream("testRules.txt");
|
||||||
File output = new File(dir, "testRules.txt");
|
File output = new File(dir, "testRules.txt");
|
||||||
|
@ -107,7 +107,7 @@ public class TestCompile extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCompileMulti() throws Exception {
|
public void testCompileMulti() throws Exception {
|
||||||
File dir = TestUtil.createTempDir("testCompile");
|
File dir = createTempDir("testCompile");
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
InputStream input = getClass().getResourceAsStream("testRules.txt");
|
InputStream input = getClass().getResourceAsStream("testRules.txt");
|
||||||
File output = new File(dir, "testRules.txt");
|
File output = new File(dir, "testRules.txt");
|
||||||
|
|
|
@ -36,7 +36,7 @@ public abstract class BenchmarkTestCase extends LuceneTestCase {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClassBenchmarkTestCase() {
|
public static void beforeClassBenchmarkTestCase() {
|
||||||
WORKDIR = TestUtil.createTempDir("benchmark");
|
WORKDIR = createTempDir("benchmark");
|
||||||
WORKDIR.delete();
|
WORKDIR.delete();
|
||||||
WORKDIR.mkdirs();
|
WORKDIR.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,7 +387,7 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
|
||||||
* Test WriteLineDoc and LineDocSource.
|
* Test WriteLineDoc and LineDocSource.
|
||||||
*/
|
*/
|
||||||
public void testLineDocFile() throws Exception {
|
public void testLineDocFile() throws Exception {
|
||||||
File lineFile = TestUtil.createTempFile("test.reuters.lines", ".txt");
|
File lineFile = createTempFile("test.reuters.lines", ".txt");
|
||||||
|
|
||||||
// We will call WriteLineDocs this many times
|
// We will call WriteLineDocs this many times
|
||||||
final int NUM_TRY_DOCS = 50;
|
final int NUM_TRY_DOCS = 50;
|
||||||
|
|
|
@ -125,13 +125,13 @@ public class TestPerfTasksParse extends LuceneTestCase {
|
||||||
Config config = new Config(new InputStreamReader(new FileInputStream(algFile), StandardCharsets.UTF_8));
|
Config config = new Config(new InputStreamReader(new FileInputStream(algFile), StandardCharsets.UTF_8));
|
||||||
String contentSource = config.get("content.source", null);
|
String contentSource = config.get("content.source", null);
|
||||||
if (contentSource != null) { Class.forName(contentSource); }
|
if (contentSource != null) { Class.forName(contentSource); }
|
||||||
config.set("work.dir", TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath());
|
config.set("work.dir", createTempDir(LuceneTestCase.getTestClass().getSimpleName()).getAbsolutePath());
|
||||||
config.set("content.source", MockContentSource.class.getName());
|
config.set("content.source", MockContentSource.class.getName());
|
||||||
String dir = config.get("content.source", null);
|
String dir = config.get("content.source", null);
|
||||||
if (dir != null) { Class.forName(dir); }
|
if (dir != null) { Class.forName(dir); }
|
||||||
config.set("directory", RAMDirectory.class.getName());
|
config.set("directory", RAMDirectory.class.getName());
|
||||||
if (config.get("line.file.out", null) != null) {
|
if (config.get("line.file.out", null) != null) {
|
||||||
config.set("line.file.out", TestUtil.createTempFile("linefile", ".txt").getAbsolutePath());
|
config.set("line.file.out", createTempFile("linefile", ".txt").getAbsolutePath());
|
||||||
}
|
}
|
||||||
if (config.get("query.maker", null) != null) {
|
if (config.get("query.maker", null) != null) {
|
||||||
Class.forName(config.get("query.maker", null));
|
Class.forName(config.get("query.maker", null));
|
||||||
|
|
|
@ -344,7 +344,7 @@ public class TrecContentSourceTest extends LuceneTestCase {
|
||||||
* supported formats - bzip, gzip, txt.
|
* supported formats - bzip, gzip, txt.
|
||||||
*/
|
*/
|
||||||
public void testTrecFeedDirAllTypes() throws Exception {
|
public void testTrecFeedDirAllTypes() throws Exception {
|
||||||
File dataDir = TestUtil.createTempDir("trecFeedAllTypes");
|
File dataDir = createTempDir("trecFeedAllTypes");
|
||||||
TestUtil.unzip(getDataFile("trecdocs.zip"), dataDir);
|
TestUtil.unzip(getDataFile("trecdocs.zip"), dataDir);
|
||||||
TrecContentSource tcs = new TrecContentSource();
|
TrecContentSource tcs = new TrecContentSource();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class AddIndexesTaskTest extends BenchmarkTestCase {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClassAddIndexesTaskTest() throws Exception {
|
public static void beforeClassAddIndexesTaskTest() throws Exception {
|
||||||
testDir = TestUtil.createTempDir("addIndexesTask");
|
testDir = createTempDir("addIndexesTask");
|
||||||
|
|
||||||
// create a dummy index under inputDir
|
// create a dummy index under inputDir
|
||||||
inputDir = new File(testDir, "input");
|
inputDir = new File(testDir, "input");
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class Test10KPulsings extends LuceneTestCase {
|
||||||
// we always run this test with pulsing codec.
|
// we always run this test with pulsing codec.
|
||||||
Codec cp = TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat(1));
|
Codec cp = TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat(1));
|
||||||
|
|
||||||
File f = TestUtil.createTempDir("10kpulsed");
|
File f = createTempDir("10kpulsed");
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(f);
|
BaseDirectoryWrapper dir = newFSDirectory(f);
|
||||||
dir.setCheckIndexOnClose(false); // we do this ourselves explicitly
|
dir.setCheckIndexOnClose(false); // we do this ourselves explicitly
|
||||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir,
|
RandomIndexWriter iw = new RandomIndexWriter(random(), dir,
|
||||||
|
@ -103,7 +103,7 @@ public class Test10KPulsings extends LuceneTestCase {
|
||||||
int freqCutoff = TestUtil.nextInt(random(), 1, 10);
|
int freqCutoff = TestUtil.nextInt(random(), 1, 10);
|
||||||
Codec cp = TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat(freqCutoff));
|
Codec cp = TestUtil.alwaysPostingsFormat(new Pulsing41PostingsFormat(freqCutoff));
|
||||||
|
|
||||||
File f = TestUtil.createTempDir("10knotpulsed");
|
File f = createTempDir("10knotpulsed");
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(f);
|
BaseDirectoryWrapper dir = newFSDirectory(f);
|
||||||
dir.setCheckIndexOnClose(false); // we do this ourselves explicitly
|
dir.setCheckIndexOnClose(false); // we do this ourselves explicitly
|
||||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir,
|
RandomIndexWriter iw = new RandomIndexWriter(random(), dir,
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class TestLucene40PostingsReader extends LuceneTestCase {
|
||||||
* depends heavily on term vectors cross-check at checkIndex
|
* depends heavily on term vectors cross-check at checkIndex
|
||||||
*/
|
*/
|
||||||
public void testPostings() throws Exception {
|
public void testPostings() throws Exception {
|
||||||
Directory dir = newFSDirectory(TestUtil.createTempDir("postings"));
|
Directory dir = newFSDirectory(createTempDir("postings"));
|
||||||
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||||
iwc.setCodec(Codec.forName("Lucene40"));
|
iwc.setCodec(Codec.forName("Lucene40"));
|
||||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
|
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class TestBlockPostingsFormat2 extends LuceneTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
dir = newFSDirectory(TestUtil.createTempDir("testDFBlockSize"));
|
dir = newFSDirectory(createTempDir("testDFBlockSize"));
|
||||||
iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||||
iwc.setCodec(TestUtil.alwaysPostingsFormat(new Lucene41PostingsFormat()));
|
iwc.setCodec(TestUtil.alwaysPostingsFormat(new Lucene41PostingsFormat()));
|
||||||
iw = new RandomIndexWriter(random(), dir, iwc.clone());
|
iw = new RandomIndexWriter(random(), dir, iwc.clone());
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class Test2BBinaryDocValues extends LuceneTestCase {
|
||||||
|
|
||||||
// indexes Integer.MAX_VALUE docs with a fixed binary field
|
// indexes Integer.MAX_VALUE docs with a fixed binary field
|
||||||
public void testFixedBinary() throws Exception {
|
public void testFixedBinary() throws Exception {
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BFixedBinary"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("2BFixedBinary"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((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
|
// indexes Integer.MAX_VALUE docs with a variable binary field
|
||||||
public void testVariableBinary() throws Exception {
|
public void testVariableBinary() throws Exception {
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BVariableBinary"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("2BVariableBinary"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class Test2BDocs extends LuceneTestCase {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
dir = newFSDirectory(TestUtil.createTempDir("2Bdocs"));
|
dir = newFSDirectory(createTempDir("2Bdocs"));
|
||||||
IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
|
IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
for (int i = 0; i < 262144; i++) {
|
for (int i = 0; i < 262144; i++) {
|
||||||
|
@ -61,7 +61,7 @@ public class Test2BDocs extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExactlyAtLimit() throws Exception {
|
public void testExactlyAtLimit() throws Exception {
|
||||||
Directory dir2 = newFSDirectory(TestUtil.createTempDir("2BDocs2"));
|
Directory dir2 = newFSDirectory(createTempDir("2BDocs2"));
|
||||||
IndexWriter iw = new IndexWriter(dir2, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
|
IndexWriter iw = new IndexWriter(dir2, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
for (int i = 0; i < 262143; i++) {
|
for (int i = 0; i < 262143; i++) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class Test2BNumericDocValues extends LuceneTestCase {
|
||||||
|
|
||||||
// indexes Integer.MAX_VALUE docs with an increasing dv field
|
// indexes Integer.MAX_VALUE docs with an increasing dv field
|
||||||
public void testNumerics() throws Exception {
|
public void testNumerics() throws Exception {
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BNumerics"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("2BNumerics"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class Test2BPositions extends LuceneTestCase {
|
||||||
// uses lots of space and takes a few minutes
|
// uses lots of space and takes a few minutes
|
||||||
@Ignore("Very slow. Enable manually by removing @Ignore.")
|
@Ignore("Very slow. Enable manually by removing @Ignore.")
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BPositions"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("2BPositions"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class Test2BPostings extends LuceneTestCase {
|
||||||
|
|
||||||
@Nightly
|
@Nightly
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BPostings"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("2BPostings"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class Test2BPostingsBytes extends LuceneTestCase {
|
||||||
// with some codecs needs more heap space as well.
|
// with some codecs needs more heap space as well.
|
||||||
@Ignore("Very slow. Enable manually by removing @Ignore.")
|
@Ignore("Very slow. Enable manually by removing @Ignore.")
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BPostingsBytes1"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("2BPostingsBytes1"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class Test2BPostingsBytes extends LuceneTestCase {
|
||||||
IndexReader subReaders[] = new IndexReader[1000];
|
IndexReader subReaders[] = new IndexReader[1000];
|
||||||
Arrays.fill(subReaders, oneThousand);
|
Arrays.fill(subReaders, oneThousand);
|
||||||
MultiReader mr = new MultiReader(subReaders);
|
MultiReader mr = new MultiReader(subReaders);
|
||||||
BaseDirectoryWrapper dir2 = newFSDirectory(TestUtil.createTempDir("2BPostingsBytes2"));
|
BaseDirectoryWrapper dir2 = newFSDirectory(createTempDir("2BPostingsBytes2"));
|
||||||
if (dir2 instanceof MockDirectoryWrapper) {
|
if (dir2 instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir2).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir2).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class Test2BPostingsBytes extends LuceneTestCase {
|
||||||
subReaders = new IndexReader[2000];
|
subReaders = new IndexReader[2000];
|
||||||
Arrays.fill(subReaders, oneMillion);
|
Arrays.fill(subReaders, oneMillion);
|
||||||
mr = new MultiReader(subReaders);
|
mr = new MultiReader(subReaders);
|
||||||
BaseDirectoryWrapper dir3 = newFSDirectory(TestUtil.createTempDir("2BPostingsBytes3"));
|
BaseDirectoryWrapper dir3 = newFSDirectory(createTempDir("2BPostingsBytes3"));
|
||||||
if (dir3 instanceof MockDirectoryWrapper) {
|
if (dir3 instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir3).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir3).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class Test2BSortedDocValues extends LuceneTestCase {
|
||||||
|
|
||||||
// indexes Integer.MAX_VALUE docs with a fixed binary field
|
// indexes Integer.MAX_VALUE docs with a fixed binary field
|
||||||
public void testFixedSorted() throws Exception {
|
public void testFixedSorted() throws Exception {
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BFixedSorted"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("2BFixedSorted"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((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
|
// indexes Integer.MAX_VALUE docs with a fixed binary field
|
||||||
// TODO: must use random.nextBytes (like Test2BTerms) to avoid BytesRefHash probing issues
|
// TODO: must use random.nextBytes (like Test2BTerms) to avoid BytesRefHash probing issues
|
||||||
public void test2BOrds() throws Exception {
|
public void test2BOrds() throws Exception {
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BOrds"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("2BOrds"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ public class Test2BTerms extends LuceneTestCase {
|
||||||
|
|
||||||
List<BytesRef> savedTerms = null;
|
List<BytesRef> savedTerms = null;
|
||||||
|
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("2BTerms"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("2BTerms"));
|
||||||
//MockDirectoryWrapper dir = newFSDirectory(new File("/p/lucene/indices/2bindex"));
|
//MockDirectoryWrapper dir = newFSDirectory(new File("/p/lucene/indices/2bindex"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class Test4GBStoredFields extends LuceneTestCase {
|
||||||
|
|
||||||
@Nightly
|
@Nightly
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
MockDirectoryWrapper dir = new MockDirectoryWrapper(random(), new MMapDirectory(TestUtil.createTempDir("4GBStoredFields")));
|
MockDirectoryWrapper dir = new MockDirectoryWrapper(random(), new MMapDirectory(createTempDir("4GBStoredFields")));
|
||||||
dir.setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
dir.setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
|
|
||||||
IndexWriter w = new IndexWriter(dir,
|
IndexWriter w = new IndexWriter(dir,
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class TestAtomicUpdate extends LuceneTestCase {
|
||||||
directory.close();
|
directory.close();
|
||||||
|
|
||||||
// Second in an FSDirectory:
|
// Second in an FSDirectory:
|
||||||
File dirPath = TestUtil.createTempDir("lucene.test.atomic");
|
File dirPath = createTempDir("lucene.test.atomic");
|
||||||
directory = newFSDirectory(dirPath);
|
directory = newFSDirectory(dirPath);
|
||||||
runTest(directory);
|
runTest(directory);
|
||||||
directory.close();
|
directory.close();
|
||||||
|
|
|
@ -228,7 +228,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
|
||||||
names.addAll(Arrays.asList(oldSingleSegmentNames));
|
names.addAll(Arrays.asList(oldSingleSegmentNames));
|
||||||
oldIndexDirs = new HashMap<>();
|
oldIndexDirs = new HashMap<>();
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
File dir = TestUtil.createTempDir(name);
|
File dir = createTempDir(name);
|
||||||
File dataFile = new File(TestBackwardsCompatibility.class.getResource("index." + name + ".zip").toURI());
|
File dataFile = new File(TestBackwardsCompatibility.class.getResource("index." + name + ".zip").toURI());
|
||||||
TestUtil.unzip(dataFile, dir);
|
TestUtil.unzip(dataFile, dir);
|
||||||
oldIndexDirs.put(name, newFSDirectory(dir));
|
oldIndexDirs.put(name, newFSDirectory(dir));
|
||||||
|
@ -249,7 +249,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
|
||||||
if (VERBOSE) {
|
if (VERBOSE) {
|
||||||
System.out.println("TEST: index " + unsupportedNames[i]);
|
System.out.println("TEST: index " + unsupportedNames[i]);
|
||||||
}
|
}
|
||||||
File oldIndxeDir = TestUtil.createTempDir(unsupportedNames[i]);
|
File oldIndxeDir = createTempDir(unsupportedNames[i]);
|
||||||
TestUtil.unzip(getDataFile("unsupported." + unsupportedNames[i] + ".zip"), oldIndxeDir);
|
TestUtil.unzip(getDataFile("unsupported." + unsupportedNames[i] + ".zip"), oldIndxeDir);
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(oldIndxeDir);
|
BaseDirectoryWrapper dir = newFSDirectory(oldIndxeDir);
|
||||||
// don't checkindex, these are intentionally not supported
|
// don't checkindex, these are intentionally not supported
|
||||||
|
@ -646,7 +646,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
|
||||||
public void testExactFileNames() throws IOException {
|
public void testExactFileNames() throws IOException {
|
||||||
|
|
||||||
String outputDirName = "lucene.backwardscompat0.index";
|
String outputDirName = "lucene.backwardscompat0.index";
|
||||||
File outputDir = TestUtil.createTempDir(outputDirName);
|
File outputDir = createTempDir(outputDirName);
|
||||||
TestUtil.rm(outputDir);
|
TestUtil.rm(outputDir);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -956,7 +956,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
|
||||||
public void testCommandLineArgs() throws Exception {
|
public void testCommandLineArgs() throws Exception {
|
||||||
|
|
||||||
for (String name : oldIndexDirs.keySet()) {
|
for (String name : oldIndexDirs.keySet()) {
|
||||||
File dir = TestUtil.createTempDir(name);
|
File dir = createTempDir(name);
|
||||||
File dataFile = new File(TestBackwardsCompatibility.class.getResource("index." + name + ".zip").toURI());
|
File dataFile = new File(TestBackwardsCompatibility.class.getResource("index." + name + ".zip").toURI());
|
||||||
TestUtil.unzip(dataFile, dir);
|
TestUtil.unzip(dataFile, dir);
|
||||||
|
|
||||||
|
@ -1049,7 +1049,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
|
||||||
public static final String moreTermsIndex = "moreterms.40.zip";
|
public static final String moreTermsIndex = "moreterms.40.zip";
|
||||||
|
|
||||||
public void testMoreTerms() throws Exception {
|
public void testMoreTerms() throws Exception {
|
||||||
File oldIndexDir = TestUtil.createTempDir("moreterms");
|
File oldIndexDir = createTempDir("moreterms");
|
||||||
TestUtil.unzip(getDataFile(moreTermsIndex), oldIndexDir);
|
TestUtil.unzip(getDataFile(moreTermsIndex), oldIndexDir);
|
||||||
Directory dir = newFSDirectory(oldIndexDir);
|
Directory dir = newFSDirectory(oldIndexDir);
|
||||||
// TODO: more tests
|
// TODO: more tests
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class TestBagOfPositions extends LuceneTestCase {
|
||||||
|
|
||||||
final ConcurrentLinkedQueue<String> postings = new ConcurrentLinkedQueue<>(postingsList);
|
final ConcurrentLinkedQueue<String> postings = new ConcurrentLinkedQueue<>(postingsList);
|
||||||
|
|
||||||
Directory dir = newFSDirectory(TestUtil.createTempDir("bagofpositions"));
|
Directory dir = newFSDirectory(createTempDir("bagofpositions"));
|
||||||
|
|
||||||
final RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
|
final RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class TestBagOfPostings extends LuceneTestCase {
|
||||||
|
|
||||||
final ConcurrentLinkedQueue<String> postings = new ConcurrentLinkedQueue<>(postingsList);
|
final ConcurrentLinkedQueue<String> postings = new ConcurrentLinkedQueue<>(postingsList);
|
||||||
|
|
||||||
Directory dir = newFSDirectory(TestUtil.createTempDir("bagofpostings"));
|
Directory dir = newFSDirectory(createTempDir("bagofpostings"));
|
||||||
final RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
|
final RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
|
||||||
|
|
||||||
int threadCount = TestUtil.nextInt(random(), 1, 5);
|
int threadCount = TestUtil.nextInt(random(), 1, 5);
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class TestCompoundFile extends LuceneTestCase
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
File file = TestUtil.createTempDir("testIndex");
|
File file = createTempDir("testIndex");
|
||||||
// use a simple FSDir here, to be sure to have SimpleFSInputs
|
// use a simple FSDir here, to be sure to have SimpleFSInputs
|
||||||
dir = new SimpleFSDirectory(file,null);
|
dir = new SimpleFSDirectory(file,null);
|
||||||
}
|
}
|
||||||
|
@ -769,7 +769,7 @@ public class TestCompoundFile extends LuceneTestCase
|
||||||
// when reading a CFS with many subs:
|
// when reading a CFS with many subs:
|
||||||
public void testManySubFiles() throws IOException {
|
public void testManySubFiles() throws IOException {
|
||||||
|
|
||||||
final Directory d = newFSDirectory(TestUtil.createTempDir("CFSManySubFiles"));
|
final Directory d = newFSDirectory(createTempDir("CFSManySubFiles"));
|
||||||
final int FILE_COUNT = atLeast(500);
|
final int FILE_COUNT = atLeast(500);
|
||||||
|
|
||||||
for(int fileIdx=0;fileIdx<FILE_COUNT;fileIdx++) {
|
for(int fileIdx=0;fileIdx<FILE_COUNT;fileIdx++) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class TestCrashCausesCorruptIndex extends LuceneTestCase {
|
||||||
* LUCENE-3627: This test fails.
|
* LUCENE-3627: This test fails.
|
||||||
*/
|
*/
|
||||||
public void testCrashCorruptsIndexing() throws Exception {
|
public void testCrashCorruptsIndexing() throws Exception {
|
||||||
path = TestUtil.createTempDir("testCrashCorruptsIndexing");
|
path = createTempDir("testCrashCorruptsIndexing");
|
||||||
|
|
||||||
indexAndCrashOnCreateOutputSegments2();
|
indexAndCrashOnCreateOutputSegments2();
|
||||||
|
|
||||||
|
|
|
@ -438,7 +438,7 @@ void assertTermDocsCount(String msg,
|
||||||
|
|
||||||
public void testFilesOpenClose() throws IOException {
|
public void testFilesOpenClose() throws IOException {
|
||||||
// Create initial data set
|
// Create initial data set
|
||||||
File dirFile = TestUtil.createTempDir("TestIndexReader.testFilesOpenClose");
|
File dirFile = createTempDir("TestIndexReader.testFilesOpenClose");
|
||||||
Directory dir = newFSDirectory(dirFile);
|
Directory dir = newFSDirectory(dirFile);
|
||||||
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
|
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
|
||||||
addDoc(writer, "test");
|
addDoc(writer, "test");
|
||||||
|
@ -467,7 +467,7 @@ public void testFilesOpenClose() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOpenReaderAfterDelete() throws IOException {
|
public void testOpenReaderAfterDelete() throws IOException {
|
||||||
File dirFile = TestUtil.createTempDir("deletetest");
|
File dirFile = createTempDir("deletetest");
|
||||||
Directory dir = newFSDirectory(dirFile);
|
Directory dir = newFSDirectory(dirFile);
|
||||||
try {
|
try {
|
||||||
DirectoryReader.open(dir);
|
DirectoryReader.open(dir);
|
||||||
|
@ -715,7 +715,7 @@ public void testFilesOpenClose() throws IOException {
|
||||||
// DirectoryReader on a non-existent directory, you get a
|
// DirectoryReader on a non-existent directory, you get a
|
||||||
// good exception
|
// good exception
|
||||||
public void testNoDir() throws Throwable {
|
public void testNoDir() throws Throwable {
|
||||||
File tempDir = TestUtil.createTempDir("doesnotexist");
|
File tempDir = createTempDir("doesnotexist");
|
||||||
TestUtil.rm(tempDir);
|
TestUtil.rm(tempDir);
|
||||||
Directory dir = newFSDirectory(tempDir);
|
Directory dir = newFSDirectory(tempDir);
|
||||||
try {
|
try {
|
||||||
|
@ -1090,7 +1090,7 @@ public void testFilesOpenClose() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIndexExistsOnNonExistentDirectory() throws Exception {
|
public void testIndexExistsOnNonExistentDirectory() throws Exception {
|
||||||
File tempDir = TestUtil.createTempDir("testIndexExistsOnNonExistentDirectory");
|
File tempDir = createTempDir("testIndexExistsOnNonExistentDirectory");
|
||||||
tempDir.delete();
|
tempDir.delete();
|
||||||
Directory dir = newFSDirectory(tempDir);
|
Directory dir = newFSDirectory(tempDir);
|
||||||
assertFalse(DirectoryReader.indexExists(dir));
|
assertFalse(DirectoryReader.indexExists(dir));
|
||||||
|
|
|
@ -63,10 +63,10 @@ public class TestDoc extends LuceneTestCase {
|
||||||
if (VERBOSE) {
|
if (VERBOSE) {
|
||||||
System.out.println("TEST: setUp");
|
System.out.println("TEST: setUp");
|
||||||
}
|
}
|
||||||
workDir = TestUtil.createTempDir("TestDoc");
|
workDir = createTempDir("TestDoc");
|
||||||
workDir.mkdirs();
|
workDir.mkdirs();
|
||||||
|
|
||||||
indexDir = TestUtil.createTempDir("testIndex");
|
indexDir = createTempDir("testIndex");
|
||||||
indexDir.mkdirs();
|
indexDir.mkdirs();
|
||||||
|
|
||||||
Directory directory = newFSDirectory(indexDir);
|
Directory directory = newFSDirectory(indexDir);
|
||||||
|
|
|
@ -187,7 +187,7 @@ public class TestFieldsReader extends LuceneTestCase {
|
||||||
|
|
||||||
// LUCENE-1262
|
// LUCENE-1262
|
||||||
public void testExceptions() throws Throwable {
|
public void testExceptions() throws Throwable {
|
||||||
File indexDir = TestUtil.createTempDir("testfieldswriterexceptions");
|
File indexDir = createTempDir("testfieldswriterexceptions");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Directory dir = new FaultyFSDirectory(indexDir);
|
Directory dir = new FaultyFSDirectory(indexDir);
|
||||||
|
|
|
@ -1476,7 +1476,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
||||||
// Tests that if FSDir is opened w/ a NoLockFactory (or SingleInstanceLF),
|
// Tests that if FSDir is opened w/ a NoLockFactory (or SingleInstanceLF),
|
||||||
// then IndexWriter ctor succeeds. Previously (LUCENE-2386) it failed
|
// then IndexWriter ctor succeeds. Previously (LUCENE-2386) it failed
|
||||||
// when listAll() was called in IndexFileDeleter.
|
// when listAll() was called in IndexFileDeleter.
|
||||||
Directory dir = newFSDirectory(TestUtil.createTempDir("emptyFSDirNoLock"), NoLockFactory.getNoLockFactory());
|
Directory dir = newFSDirectory(createTempDir("emptyFSDirNoLock"), NoLockFactory.getNoLockFactory());
|
||||||
new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))).close();
|
new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))).close();
|
||||||
dir.close();
|
dir.close();
|
||||||
}
|
}
|
||||||
|
@ -1783,7 +1783,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWhetherDeleteAllDeletesWriteLock() throws Exception {
|
public void testWhetherDeleteAllDeletesWriteLock() throws Exception {
|
||||||
Directory d = newFSDirectory(TestUtil.createTempDir("TestIndexWriter.testWhetherDeleteAllDeletesWriteLock"));
|
Directory d = newFSDirectory(createTempDir("TestIndexWriter.testWhetherDeleteAllDeletesWriteLock"));
|
||||||
// Must use SimpleFSLockFactory... NativeFSLockFactory
|
// Must use SimpleFSLockFactory... NativeFSLockFactory
|
||||||
// somehow "knows" a lock is held against write.lock
|
// somehow "knows" a lock is held against write.lock
|
||||||
// even if you remove that file:
|
// even if you remove that file:
|
||||||
|
@ -2032,7 +2032,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
||||||
|
|
||||||
// LUCENE-4398
|
// LUCENE-4398
|
||||||
public void testRotatingFieldNames() throws Exception {
|
public void testRotatingFieldNames() throws Exception {
|
||||||
Directory dir = newFSDirectory(TestUtil.createTempDir("TestIndexWriter.testChangingFields"));
|
Directory dir = newFSDirectory(createTempDir("TestIndexWriter.testChangingFields"));
|
||||||
IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||||
iwc.setRAMBufferSizeMB(0.2);
|
iwc.setRAMBufferSizeMB(0.2);
|
||||||
iwc.setMaxBufferedDocs(-1);
|
iwc.setMaxBufferedDocs(-1);
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.lucene.util.TestUtil;
|
||||||
public class TestIndexWriterLockRelease extends LuceneTestCase {
|
public class TestIndexWriterLockRelease extends LuceneTestCase {
|
||||||
|
|
||||||
public void testIndexWriterLockRelease() throws IOException {
|
public void testIndexWriterLockRelease() throws IOException {
|
||||||
Directory dir = newFSDirectory(TestUtil.createTempDir("testLockRelease"));
|
Directory dir = newFSDirectory(createTempDir("testLockRelease"));
|
||||||
try {
|
try {
|
||||||
new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
|
new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
|
||||||
} catch (FileNotFoundException | NoSuchFileException e) {
|
} catch (FileNotFoundException | NoSuchFileException e) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class TestIndexWriterOnJRECrash extends TestNRTThreads {
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
tempDir = TestUtil.createTempDir("jrecrash");
|
tempDir = createTempDir("jrecrash");
|
||||||
tempDir.delete();
|
tempDir.delete();
|
||||||
tempDir.mkdir();
|
tempDir.mkdir();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.lucene.util.TestUtil;
|
||||||
|
|
||||||
public class TestIndexWriterOutOfFileDescriptors extends LuceneTestCase {
|
public class TestIndexWriterOutOfFileDescriptors extends LuceneTestCase {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
MockDirectoryWrapper dir = newMockFSDirectory(TestUtil.createTempDir("TestIndexWriterOutOfFileDescriptors"));
|
MockDirectoryWrapper dir = newMockFSDirectory(createTempDir("TestIndexWriterOutOfFileDescriptors"));
|
||||||
dir.setPreventDoubleWrite(false);
|
dir.setPreventDoubleWrite(false);
|
||||||
double rate = random().nextDouble()*0.01;
|
double rate = random().nextDouble()*0.01;
|
||||||
//System.out.println("rate=" + rate);
|
//System.out.println("rate=" + rate);
|
||||||
|
@ -132,7 +132,7 @@ public class TestIndexWriterOutOfFileDescriptors extends LuceneTestCase {
|
||||||
// it to addIndexes later:
|
// it to addIndexes later:
|
||||||
dir.setRandomIOExceptionRateOnOpen(0.0);
|
dir.setRandomIOExceptionRateOnOpen(0.0);
|
||||||
r = DirectoryReader.open(dir);
|
r = DirectoryReader.open(dir);
|
||||||
dirCopy = newMockFSDirectory(TestUtil.createTempDir("TestIndexWriterOutOfFileDescriptors.copy"));
|
dirCopy = newMockFSDirectory(createTempDir("TestIndexWriterOutOfFileDescriptors.copy"));
|
||||||
Set<String> files = new HashSet<>();
|
Set<String> files = new HashSet<>();
|
||||||
for (String file : dir.listAll()) {
|
for (String file : dir.listAll()) {
|
||||||
dir.copy(dirCopy, file, file, IOContext.DEFAULT);
|
dir.copy(dirCopy, file, file, IOContext.DEFAULT);
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class TestLongPostings extends LuceneTestCase {
|
||||||
public void testLongPostings() throws Exception {
|
public void testLongPostings() throws Exception {
|
||||||
// Don't use _TestUtil.getTempDir so that we own the
|
// Don't use _TestUtil.getTempDir so that we own the
|
||||||
// randomness (ie same seed will point to same dir):
|
// randomness (ie same seed will point to same dir):
|
||||||
Directory dir = newFSDirectory(TestUtil.createTempDir("longpostings" + "." + random().nextLong()));
|
Directory dir = newFSDirectory(createTempDir("longpostings" + "." + random().nextLong()));
|
||||||
|
|
||||||
final int NUM_DOCS = atLeast(2000);
|
final int NUM_DOCS = atLeast(2000);
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ public class TestLongPostings extends LuceneTestCase {
|
||||||
public void doTestLongPostingsNoPositions(IndexOptions options) throws Exception {
|
public void doTestLongPostingsNoPositions(IndexOptions options) throws Exception {
|
||||||
// Don't use _TestUtil.getTempDir so that we own the
|
// Don't use _TestUtil.getTempDir so that we own the
|
||||||
// randomness (ie same seed will point to same dir):
|
// randomness (ie same seed will point to same dir):
|
||||||
Directory dir = newFSDirectory(TestUtil.createTempDir("longpostings" + "." + random().nextLong()));
|
Directory dir = newFSDirectory(createTempDir("longpostings" + "." + random().nextLong()));
|
||||||
|
|
||||||
final int NUM_DOCS = atLeast(2000);
|
final int NUM_DOCS = atLeast(2000);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.lucene.util.TestUtil;
|
||||||
public class TestNeverDelete extends LuceneTestCase {
|
public class TestNeverDelete extends LuceneTestCase {
|
||||||
|
|
||||||
public void testIndexing() throws Exception {
|
public void testIndexing() throws Exception {
|
||||||
final File tmpDir = TestUtil.createTempDir("TestNeverDelete");
|
final File tmpDir = createTempDir("TestNeverDelete");
|
||||||
final BaseDirectoryWrapper d = newFSDirectory(tmpDir);
|
final BaseDirectoryWrapper d = newFSDirectory(tmpDir);
|
||||||
|
|
||||||
// We want to "see" files removed if Lucene removed
|
// We want to "see" files removed if Lucene removed
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class TestNorms extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMaxByteNorms() throws IOException {
|
public void testMaxByteNorms() throws IOException {
|
||||||
Directory dir = newFSDirectory(TestUtil.createTempDir("TestNorms.testMaxByteNorms"));
|
Directory dir = newFSDirectory(createTempDir("TestNorms.testMaxByteNorms"));
|
||||||
buildIndex(dir);
|
buildIndex(dir);
|
||||||
AtomicReader open = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir));
|
AtomicReader open = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir));
|
||||||
NumericDocValues normValues = open.getNormValues(byteTestField);
|
NumericDocValues normValues = open.getNormValues(byteTestField);
|
||||||
|
|
|
@ -473,7 +473,7 @@ public class TestControlledRealTimeReopenThread extends ThreadedIndexingAndSearc
|
||||||
String content = builder.toString();
|
String content = builder.toString();
|
||||||
|
|
||||||
final SnapshotDeletionPolicy sdp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
|
final SnapshotDeletionPolicy sdp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
|
||||||
final Directory dir = new NRTCachingDirectory(newFSDirectory(TestUtil.createTempDir("nrt")), 5, 128);
|
final Directory dir = new NRTCachingDirectory(newFSDirectory(createTempDir("nrt")), 5, 128);
|
||||||
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_46,
|
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_46,
|
||||||
new MockAnalyzer(random()));
|
new MockAnalyzer(random()));
|
||||||
config.setIndexDeletionPolicy(sdp);
|
config.setIndexDeletionPolicy(sdp);
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.lucene.util.TestUtil;
|
||||||
public class TestLiveFieldValues extends LuceneTestCase {
|
public class TestLiveFieldValues extends LuceneTestCase {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
|
|
||||||
Directory dir = newFSDirectory(TestUtil.createTempDir("livefieldupdates"));
|
Directory dir = newFSDirectory(createTempDir("livefieldupdates"));
|
||||||
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||||
|
|
||||||
final IndexWriter w = new IndexWriter(dir, iwc);
|
final IndexWriter w = new IndexWriter(dir, iwc);
|
||||||
|
|
|
@ -222,7 +222,7 @@ public class TestBufferedIndexInput extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetBufferSize() throws IOException {
|
public void testSetBufferSize() throws IOException {
|
||||||
File indexDir = TestUtil.createTempDir("testSetBufferSize");
|
File indexDir = createTempDir("testSetBufferSize");
|
||||||
MockFSDirectory dir = new MockFSDirectory(indexDir, random());
|
MockFSDirectory dir = new MockFSDirectory(indexDir, random());
|
||||||
try {
|
try {
|
||||||
IndexWriter writer = new IndexWriter(
|
IndexWriter writer = new IndexWriter(
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.lucene.util.TestUtil;
|
||||||
|
|
||||||
public class TestDirectory extends LuceneTestCase {
|
public class TestDirectory extends LuceneTestCase {
|
||||||
public void testDetectClose() throws Throwable {
|
public void testDetectClose() throws Throwable {
|
||||||
File tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
File tempDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
||||||
Directory[] dirs = new Directory[] {
|
Directory[] dirs = new Directory[] {
|
||||||
new RAMDirectory(),
|
new RAMDirectory(),
|
||||||
new SimpleFSDirectory(tempDir),
|
new SimpleFSDirectory(tempDir),
|
||||||
|
@ -135,7 +135,7 @@ public class TestDirectory extends LuceneTestCase {
|
||||||
// Test that different instances of FSDirectory can coexist on the same
|
// Test that different instances of FSDirectory can coexist on the same
|
||||||
// path, can read, write, and lock files.
|
// path, can read, write, and lock files.
|
||||||
public void testDirectInstantiation() throws Exception {
|
public void testDirectInstantiation() throws Exception {
|
||||||
final File path = TestUtil.createTempDir("testDirectInstantiation");
|
final File path = createTempDir("testDirectInstantiation");
|
||||||
|
|
||||||
final byte[] largeBuffer = new byte[random().nextInt(256*1024)], largeReadBuffer = new byte[largeBuffer.length];
|
final byte[] largeBuffer = new byte[random().nextInt(256*1024)], largeReadBuffer = new byte[largeBuffer.length];
|
||||||
for (int i = 0; i < largeBuffer.length; i++) {
|
for (int i = 0; i < largeBuffer.length; i++) {
|
||||||
|
@ -223,7 +223,7 @@ public class TestDirectory extends LuceneTestCase {
|
||||||
|
|
||||||
// LUCENE-1464
|
// LUCENE-1464
|
||||||
public void testDontCreate() throws Throwable {
|
public void testDontCreate() throws Throwable {
|
||||||
File path = new File(TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()), "doesnotexist");
|
File path = new File(createTempDir(LuceneTestCase.getTestClass().getSimpleName()), "doesnotexist");
|
||||||
try {
|
try {
|
||||||
assertTrue(!path.exists());
|
assertTrue(!path.exists());
|
||||||
Directory dir = new SimpleFSDirectory(path, null);
|
Directory dir = new SimpleFSDirectory(path, null);
|
||||||
|
@ -241,7 +241,7 @@ public class TestDirectory extends LuceneTestCase {
|
||||||
|
|
||||||
// LUCENE-1468
|
// LUCENE-1468
|
||||||
public void testFSDirectoryFilter() throws IOException {
|
public void testFSDirectoryFilter() throws IOException {
|
||||||
checkDirectoryFilter(newFSDirectory(TestUtil.createTempDir("test")));
|
checkDirectoryFilter(newFSDirectory(createTempDir("test")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// LUCENE-1468
|
// LUCENE-1468
|
||||||
|
@ -258,7 +258,7 @@ public class TestDirectory extends LuceneTestCase {
|
||||||
|
|
||||||
// LUCENE-1468
|
// LUCENE-1468
|
||||||
public void testCopySubdir() throws Throwable {
|
public void testCopySubdir() throws Throwable {
|
||||||
File path = TestUtil.createTempDir("testsubdir");
|
File path = createTempDir("testsubdir");
|
||||||
try {
|
try {
|
||||||
path.mkdirs();
|
path.mkdirs();
|
||||||
new File(path, "subdir").mkdirs();
|
new File(path, "subdir").mkdirs();
|
||||||
|
@ -271,7 +271,7 @@ public class TestDirectory extends LuceneTestCase {
|
||||||
|
|
||||||
// LUCENE-1468
|
// LUCENE-1468
|
||||||
public void testNotDirectory() throws Throwable {
|
public void testNotDirectory() throws Throwable {
|
||||||
File path = TestUtil.createTempDir("testnotdir");
|
File path = createTempDir("testnotdir");
|
||||||
Directory fsDir = new SimpleFSDirectory(path, null);
|
Directory fsDir = new SimpleFSDirectory(path, null);
|
||||||
try {
|
try {
|
||||||
IndexOutput out = fsDir.createOutput("afile", newIOContext(random()));
|
IndexOutput out = fsDir.createOutput("afile", newIOContext(random()));
|
||||||
|
|
|
@ -88,8 +88,8 @@ public class TestFileSwitchDirectory extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Directory newFSSwitchDirectory(Set<String> primaryExtensions) throws IOException {
|
private Directory newFSSwitchDirectory(Set<String> primaryExtensions) throws IOException {
|
||||||
File primDir = TestUtil.createTempDir("foo");
|
File primDir = createTempDir("foo");
|
||||||
File secondDir = TestUtil.createTempDir("bar");
|
File secondDir = createTempDir("bar");
|
||||||
return newFSSwitchDirectory(primDir, secondDir, primaryExtensions);
|
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.
|
// LUCENE-3380 -- make sure we get exception if the directory really does not exist.
|
||||||
public void testNoDir() throws Throwable {
|
public void testNoDir() throws Throwable {
|
||||||
File primDir = TestUtil.createTempDir("foo");
|
File primDir = createTempDir("foo");
|
||||||
File secondDir = TestUtil.createTempDir("bar");
|
File secondDir = createTempDir("bar");
|
||||||
TestUtil.rm(primDir);
|
TestUtil.rm(primDir);
|
||||||
TestUtil.rm(secondDir);
|
TestUtil.rm(secondDir);
|
||||||
Directory dir = newFSSwitchDirectory(primDir, secondDir, Collections.<String>emptySet());
|
Directory dir = newFSSwitchDirectory(primDir, secondDir, Collections.<String>emptySet());
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class TestLockFactory extends LuceneTestCase {
|
||||||
// no unexpected exceptions are raised:
|
// no unexpected exceptions are raised:
|
||||||
@Nightly
|
@Nightly
|
||||||
public void testStressLocks() throws Exception {
|
public void testStressLocks() throws Exception {
|
||||||
_testStressLocks(null, TestUtil.createTempDir("index.TestLockFactory6"));
|
_testStressLocks(null, createTempDir("index.TestLockFactory6"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify: do stress test, by opening IndexReaders and
|
// Verify: do stress test, by opening IndexReaders and
|
||||||
|
@ -145,7 +145,7 @@ public class TestLockFactory extends LuceneTestCase {
|
||||||
// NativeFSLockFactory:
|
// NativeFSLockFactory:
|
||||||
@Nightly
|
@Nightly
|
||||||
public void testStressLocksNativeFSLockFactory() throws Exception {
|
public void testStressLocksNativeFSLockFactory() throws Exception {
|
||||||
File dir = TestUtil.createTempDir("index.TestLockFactory7");
|
File dir = createTempDir("index.TestLockFactory7");
|
||||||
_testStressLocks(new NativeFSLockFactory(dir), dir);
|
_testStressLocks(new NativeFSLockFactory(dir), dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public class TestLockFactory extends LuceneTestCase {
|
||||||
|
|
||||||
// Verify: NativeFSLockFactory works correctly
|
// Verify: NativeFSLockFactory works correctly
|
||||||
public void testNativeFSLockFactory() throws IOException {
|
public void testNativeFSLockFactory() throws IOException {
|
||||||
NativeFSLockFactory f = new NativeFSLockFactory(TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()));
|
NativeFSLockFactory f = new NativeFSLockFactory(createTempDir(LuceneTestCase.getTestClass().getSimpleName()));
|
||||||
|
|
||||||
f.setLockPrefix("test");
|
f.setLockPrefix("test");
|
||||||
Lock l = f.makeLock("commit");
|
Lock l = f.makeLock("commit");
|
||||||
|
@ -201,7 +201,7 @@ public class TestLockFactory extends LuceneTestCase {
|
||||||
|
|
||||||
// Verify: NativeFSLockFactory works correctly if the lock file exists
|
// Verify: NativeFSLockFactory works correctly if the lock file exists
|
||||||
public void testNativeFSLockFactoryLockExists() throws IOException {
|
public void testNativeFSLockFactoryLockExists() throws IOException {
|
||||||
File tempDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
File tempDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
||||||
File lockFile = new File(tempDir, "test.lock");
|
File lockFile = new File(tempDir, "test.lock");
|
||||||
lockFile.createNewFile();
|
lockFile.createNewFile();
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ public class TestLockFactory extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNativeFSLockReleaseByOtherLock() throws IOException {
|
public void testNativeFSLockReleaseByOtherLock() throws IOException {
|
||||||
NativeFSLockFactory f = new NativeFSLockFactory(TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName()));
|
NativeFSLockFactory f = new NativeFSLockFactory(createTempDir(LuceneTestCase.getTestClass().getSimpleName()));
|
||||||
|
|
||||||
f.setLockPrefix("test");
|
f.setLockPrefix("test");
|
||||||
Lock l = f.makeLock("commit");
|
Lock l = f.makeLock("commit");
|
||||||
|
@ -236,8 +236,8 @@ public class TestLockFactory extends LuceneTestCase {
|
||||||
// Verify: NativeFSLockFactory assigns null as lockPrefix if the lockDir is inside directory
|
// Verify: NativeFSLockFactory assigns null as lockPrefix if the lockDir is inside directory
|
||||||
public void testNativeFSLockFactoryPrefix() throws IOException {
|
public void testNativeFSLockFactoryPrefix() throws IOException {
|
||||||
|
|
||||||
File fdir1 = TestUtil.createTempDir("TestLockFactory.8");
|
File fdir1 = createTempDir("TestLockFactory.8");
|
||||||
File fdir2 = TestUtil.createTempDir("TestLockFactory.8.Lockdir");
|
File fdir2 = createTempDir("TestLockFactory.8.Lockdir");
|
||||||
Directory dir1 = newFSDirectory(fdir1, new NativeFSLockFactory(fdir1));
|
Directory dir1 = newFSDirectory(fdir1, new NativeFSLockFactory(fdir1));
|
||||||
// same directory, but locks are stored somewhere else. The prefix of the lock factory should != null
|
// same directory, but locks are stored somewhere else. The prefix of the lock factory should != null
|
||||||
Directory dir2 = newFSDirectory(fdir1, new NativeFSLockFactory(fdir2));
|
Directory dir2 = newFSDirectory(fdir1, new NativeFSLockFactory(fdir2));
|
||||||
|
@ -259,7 +259,7 @@ public class TestLockFactory extends LuceneTestCase {
|
||||||
public void testDefaultFSLockFactoryPrefix() throws IOException {
|
public void testDefaultFSLockFactoryPrefix() throws IOException {
|
||||||
|
|
||||||
// Make sure we get null prefix, which wont happen if setLockFactory is ever called.
|
// Make sure we get null prefix, which wont happen if setLockFactory is ever called.
|
||||||
File dirName = TestUtil.createTempDir("TestLockFactory.10");
|
File dirName = createTempDir("TestLockFactory.10");
|
||||||
|
|
||||||
Directory dir = new SimpleFSDirectory(dirName);
|
Directory dir = new SimpleFSDirectory(dirName);
|
||||||
assertNull("Default lock prefix should be null", dir.getLockFactory().getLockPrefix());
|
assertNull("Default lock prefix should be null", dir.getLockFactory().getLockPrefix());
|
||||||
|
|
|
@ -38,18 +38,15 @@ import org.apache.lucene.util.TestUtil;
|
||||||
* Integer.MAX_VALUE in size using multiple byte buffers.
|
* Integer.MAX_VALUE in size using multiple byte buffers.
|
||||||
*/
|
*/
|
||||||
public class TestMultiMMap extends LuceneTestCase {
|
public class TestMultiMMap extends LuceneTestCase {
|
||||||
File workDir;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
assumeTrue("test requires a jre that supports unmapping", MMapDirectory.UNMAP_SUPPORTED);
|
assumeTrue("test requires a jre that supports unmapping", MMapDirectory.UNMAP_SUPPORTED);
|
||||||
workDir = TestUtil.createTempDir("TestMultiMMap");
|
|
||||||
workDir.mkdirs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCloneSafety() throws Exception {
|
public void testCloneSafety() throws Exception {
|
||||||
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testCloneSafety"));
|
MMapDirectory mmapDir = new MMapDirectory(createTempDir("testCloneSafety"));
|
||||||
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
||||||
io.writeVInt(5);
|
io.writeVInt(5);
|
||||||
io.close();
|
io.close();
|
||||||
|
@ -83,7 +80,7 @@ public class TestMultiMMap extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCloneClose() throws Exception {
|
public void testCloneClose() throws Exception {
|
||||||
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testCloneClose"));
|
MMapDirectory mmapDir = new MMapDirectory(createTempDir("testCloneClose"));
|
||||||
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
||||||
io.writeVInt(5);
|
io.writeVInt(5);
|
||||||
io.close();
|
io.close();
|
||||||
|
@ -105,7 +102,7 @@ public class TestMultiMMap extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCloneSliceSafety() throws Exception {
|
public void testCloneSliceSafety() throws Exception {
|
||||||
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testCloneSliceSafety"));
|
MMapDirectory mmapDir = new MMapDirectory(createTempDir("testCloneSliceSafety"));
|
||||||
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
||||||
io.writeInt(1);
|
io.writeInt(1);
|
||||||
io.writeInt(2);
|
io.writeInt(2);
|
||||||
|
@ -150,7 +147,7 @@ public class TestMultiMMap extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCloneSliceClose() throws Exception {
|
public void testCloneSliceClose() throws Exception {
|
||||||
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testCloneSliceClose"));
|
MMapDirectory mmapDir = new MMapDirectory(createTempDir("testCloneSliceClose"));
|
||||||
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
||||||
io.writeInt(1);
|
io.writeInt(1);
|
||||||
io.writeInt(2);
|
io.writeInt(2);
|
||||||
|
@ -177,7 +174,7 @@ public class TestMultiMMap extends LuceneTestCase {
|
||||||
|
|
||||||
public void testSeekZero() throws Exception {
|
public void testSeekZero() throws Exception {
|
||||||
for (int i = 0; i < 31; i++) {
|
for (int i = 0; i < 31; i++) {
|
||||||
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testSeekZero"), null, 1<<i);
|
MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSeekZero"), null, 1<<i);
|
||||||
IndexOutput io = mmapDir.createOutput("zeroBytes", newIOContext(random()));
|
IndexOutput io = mmapDir.createOutput("zeroBytes", newIOContext(random()));
|
||||||
io.close();
|
io.close();
|
||||||
IndexInput ii = mmapDir.openInput("zeroBytes", newIOContext(random()));
|
IndexInput ii = mmapDir.openInput("zeroBytes", newIOContext(random()));
|
||||||
|
@ -189,7 +186,7 @@ public class TestMultiMMap extends LuceneTestCase {
|
||||||
|
|
||||||
public void testSeekSliceZero() throws Exception {
|
public void testSeekSliceZero() throws Exception {
|
||||||
for (int i = 0; i < 31; i++) {
|
for (int i = 0; i < 31; i++) {
|
||||||
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testSeekSliceZero"), null, 1<<i);
|
MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSeekSliceZero"), null, 1<<i);
|
||||||
IndexOutput io = mmapDir.createOutput("zeroBytes", newIOContext(random()));
|
IndexOutput io = mmapDir.createOutput("zeroBytes", newIOContext(random()));
|
||||||
io.close();
|
io.close();
|
||||||
IndexInputSlicer slicer = mmapDir.createSlicer("zeroBytes", newIOContext(random()));
|
IndexInputSlicer slicer = mmapDir.createSlicer("zeroBytes", newIOContext(random()));
|
||||||
|
@ -203,7 +200,7 @@ public class TestMultiMMap extends LuceneTestCase {
|
||||||
|
|
||||||
public void testSeekEnd() throws Exception {
|
public void testSeekEnd() throws Exception {
|
||||||
for (int i = 0; i < 17; i++) {
|
for (int i = 0; i < 17; i++) {
|
||||||
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testSeekEnd"), null, 1<<i);
|
MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSeekEnd"), null, 1<<i);
|
||||||
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
||||||
byte bytes[] = new byte[1<<i];
|
byte bytes[] = new byte[1<<i];
|
||||||
random().nextBytes(bytes);
|
random().nextBytes(bytes);
|
||||||
|
@ -221,7 +218,7 @@ public class TestMultiMMap extends LuceneTestCase {
|
||||||
|
|
||||||
public void testSeekSliceEnd() throws Exception {
|
public void testSeekSliceEnd() throws Exception {
|
||||||
for (int i = 0; i < 17; i++) {
|
for (int i = 0; i < 17; i++) {
|
||||||
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testSeekSliceEnd"), null, 1<<i);
|
MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSeekSliceEnd"), null, 1<<i);
|
||||||
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
||||||
byte bytes[] = new byte[1<<i];
|
byte bytes[] = new byte[1<<i];
|
||||||
random().nextBytes(bytes);
|
random().nextBytes(bytes);
|
||||||
|
@ -241,7 +238,7 @@ public class TestMultiMMap extends LuceneTestCase {
|
||||||
|
|
||||||
public void testSeeking() throws Exception {
|
public void testSeeking() throws Exception {
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testSeeking"), null, 1<<i);
|
MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSeeking"), null, 1<<i);
|
||||||
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
||||||
byte bytes[] = new byte[1<<(i+1)]; // make sure we switch buffers
|
byte bytes[] = new byte[1<<(i+1)]; // make sure we switch buffers
|
||||||
random().nextBytes(bytes);
|
random().nextBytes(bytes);
|
||||||
|
@ -268,7 +265,7 @@ public class TestMultiMMap extends LuceneTestCase {
|
||||||
// the various offset+length and just does readBytes.
|
// the various offset+length and just does readBytes.
|
||||||
public void testSlicedSeeking() throws Exception {
|
public void testSlicedSeeking() throws Exception {
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
MMapDirectory mmapDir = new MMapDirectory(TestUtil.createTempDir("testSlicedSeeking"), null, 1<<i);
|
MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSlicedSeeking"), null, 1<<i);
|
||||||
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
IndexOutput io = mmapDir.createOutput("bytes", newIOContext(random()));
|
||||||
byte bytes[] = new byte[1<<(i+1)]; // make sure we switch buffers
|
byte bytes[] = new byte[1<<(i+1)]; // make sure we switch buffers
|
||||||
random().nextBytes(bytes);
|
random().nextBytes(bytes);
|
||||||
|
@ -301,9 +298,7 @@ public class TestMultiMMap extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertChunking(Random random, int chunkSize) throws Exception {
|
private void assertChunking(Random random, int chunkSize) throws Exception {
|
||||||
File path = TestUtil.createTempFile("mmap" + chunkSize, "tmp", workDir);
|
File path = createTempDir("mmap" + chunkSize);
|
||||||
path.delete();
|
|
||||||
path.mkdirs();
|
|
||||||
MMapDirectory mmapDir = new MMapDirectory(path, null, chunkSize);
|
MMapDirectory mmapDir = new MMapDirectory(path, null, chunkSize);
|
||||||
// we will map a lot, try to turn on the unmap hack
|
// we will map a lot, try to turn on the unmap hack
|
||||||
if (MMapDirectory.UNMAP_SUPPORTED)
|
if (MMapDirectory.UNMAP_SUPPORTED)
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class TestNRTCachingDirectory extends LuceneTestCase {
|
||||||
|
|
||||||
// LUCENE-3382 -- make sure we get exception if the directory really does not exist.
|
// LUCENE-3382 -- make sure we get exception if the directory really does not exist.
|
||||||
public void testNoDir() throws Throwable {
|
public void testNoDir() throws Throwable {
|
||||||
File tempDir = TestUtil.createTempDir("doesnotexist");
|
File tempDir = createTempDir("doesnotexist");
|
||||||
TestUtil.rm(tempDir);
|
TestUtil.rm(tempDir);
|
||||||
Directory dir = new NRTCachingDirectory(newFSDirectory(tempDir), 2.0, 25.0);
|
Directory dir = new NRTCachingDirectory(newFSDirectory(tempDir), 2.0, 25.0);
|
||||||
try {
|
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
|
// LUCENE-3382 test that we can add a file, and then when we call list() we get it back
|
||||||
public void testDirectoryFilter() throws IOException {
|
public void testDirectoryFilter() throws IOException {
|
||||||
Directory dir = new NRTCachingDirectory(newFSDirectory(TestUtil.createTempDir("foo")), 2.0, 25.0);
|
Directory dir = new NRTCachingDirectory(newFSDirectory(createTempDir("foo")), 2.0, 25.0);
|
||||||
String name = "file";
|
String name = "file";
|
||||||
try {
|
try {
|
||||||
dir.createOutput(name, newIOContext(random())).close();
|
dir.createOutput(name, newIOContext(random())).close();
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class TestRAMDirectory extends LuceneTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
indexDir = TestUtil.createTempDir("RAMDirIndex");
|
indexDir = createTempDir("RAMDirIndex");
|
||||||
|
|
||||||
Directory dir = newFSDirectory(indexDir);
|
Directory dir = newFSDirectory(indexDir);
|
||||||
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
|
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class TestWindowsMMap extends LuceneTestCase {
|
||||||
// sometimes the directory is not cleaned by rmDir, because on Windows it
|
// 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
|
// may take some time until the files are finally dereferenced. So clean the
|
||||||
// directory up front, or otherwise new IndexWriter will fail.
|
// directory up front, or otherwise new IndexWriter will fail.
|
||||||
File dirPath = TestUtil.createTempDir("testLuceneMmap");
|
File dirPath = createTempDir("testLuceneMmap");
|
||||||
rmDir(dirPath);
|
rmDir(dirPath);
|
||||||
MMapDirectory dir = new MMapDirectory(dirPath, null);
|
MMapDirectory dir = new MMapDirectory(dirPath, null);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.junit.Ignore;
|
||||||
public class Test2BPagedBytes extends LuceneTestCase {
|
public class Test2BPagedBytes extends LuceneTestCase {
|
||||||
|
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("test2BPagedBytes"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("test2BPagedBytes"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class TestOfflineSorter extends LuceneTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
tempDir = TestUtil.createTempDir("mergesort");
|
tempDir = createTempDir("mergesort");
|
||||||
TestUtil.rm(tempDir);
|
TestUtil.rm(tempDir);
|
||||||
tempDir.mkdirs();
|
tempDir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class TestPagedBytes extends LuceneTestCase {
|
||||||
public void testDataInputOutput() throws Exception {
|
public void testDataInputOutput() throws Exception {
|
||||||
Random random = random();
|
Random random = random();
|
||||||
for(int iter=0;iter<5*RANDOM_MULTIPLIER;iter++) {
|
for(int iter=0;iter<5*RANDOM_MULTIPLIER;iter++) {
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("testOverflow"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("testOverflow"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ public class TestPagedBytes extends LuceneTestCase {
|
||||||
|
|
||||||
@Ignore // memory hole
|
@Ignore // memory hole
|
||||||
public void testOverflow() throws IOException {
|
public void testOverflow() throws IOException {
|
||||||
BaseDirectoryWrapper dir = newFSDirectory(TestUtil.createTempDir("testOverflow"));
|
BaseDirectoryWrapper dir = newFSDirectory(createTempDir("testOverflow"));
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
if (dir instanceof MockDirectoryWrapper) {
|
||||||
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
((MockDirectoryWrapper)dir).setThrottling(MockDirectoryWrapper.Throttling.NEVER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class Test2BFST extends LuceneTestCase {
|
||||||
IntsRef input = new IntsRef(ints, 0, ints.length);
|
IntsRef input = new IntsRef(ints, 0, ints.length);
|
||||||
long seed = random().nextLong();
|
long seed = random().nextLong();
|
||||||
|
|
||||||
Directory dir = new MMapDirectory(TestUtil.createTempDir("2BFST"));
|
Directory dir = new MMapDirectory(createTempDir("2BFST"));
|
||||||
|
|
||||||
for(int doPackIter=0;doPackIter<2;doPackIter++) {
|
for(int doPackIter=0;doPackIter<2;doPackIter++) {
|
||||||
boolean doPack = doPackIter == 1;
|
boolean doPack = doPackIter == 1;
|
||||||
|
|
|
@ -310,7 +310,7 @@ public class TestFSTs extends LuceneTestCase {
|
||||||
analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));
|
analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));
|
||||||
|
|
||||||
final IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(-1).setRAMBufferSizeMB(64);
|
final IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(-1).setRAMBufferSizeMB(64);
|
||||||
final File tempDir = TestUtil.createTempDir("fstlines");
|
final File tempDir = createTempDir("fstlines");
|
||||||
final Directory dir = newFSDirectory(tempDir);
|
final Directory dir = newFSDirectory(tempDir);
|
||||||
final IndexWriter writer = new IndexWriter(dir, conf);
|
final IndexWriter writer = new IndexWriter(dir, conf);
|
||||||
final long stopTime = System.currentTimeMillis() + RUN_TIME_MSEC;
|
final long stopTime = System.currentTimeMillis() + RUN_TIME_MSEC;
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class TestLeaveFilesIfTestFails extends WithNestedTests {
|
||||||
public static class Nested1 extends WithNestedTests.AbstractNestedTest {
|
public static class Nested1 extends WithNestedTests.AbstractNestedTest {
|
||||||
static File file;
|
static File file;
|
||||||
public void testDummy() {
|
public void testDummy() {
|
||||||
file = TestUtil.createTempDir("leftover");
|
file = createTempDir("leftover");
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class TestDemo extends LuceneTestCase {
|
||||||
|
|
||||||
public void testIndexSearch() throws Exception {
|
public void testIndexSearch() throws Exception {
|
||||||
File dir = getDataFile("test-files/docs");
|
File dir = getDataFile("test-files/docs");
|
||||||
File indexDir = TestUtil.createTempDir("ContribDemoTest");
|
File indexDir = createTempDir("ContribDemoTest");
|
||||||
IndexFiles.main(new String[] { "-create", "-docs", dir.getPath(), "-index", indexDir.getPath()});
|
IndexFiles.main(new String[] { "-create", "-docs", dir.getPath(), "-index", indexDir.getPath()});
|
||||||
testOneSearch(indexDir, "apache", 3);
|
testOneSearch(indexDir, "apache", 3);
|
||||||
testOneSearch(indexDir, "patent", 8);
|
testOneSearch(indexDir, "patent", 8);
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class TestAddTaxonomy extends FacetTestCase {
|
||||||
|
|
||||||
private OrdinalMap randomOrdinalMap() throws IOException {
|
private OrdinalMap randomOrdinalMap() throws IOException {
|
||||||
if (random().nextBoolean()) {
|
if (random().nextBoolean()) {
|
||||||
return new DiskOrdinalMap(TestUtil.createTempFile("taxoMap", ""));
|
return new DiskOrdinalMap(createTempFile("taxoMap", ""));
|
||||||
} else {
|
} else {
|
||||||
return new MemoryOrdinalMap();
|
return new MemoryOrdinalMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class TestCharBlockArray extends FacetTestCase {
|
||||||
|
|
||||||
assertEqualsInternal("GrowingCharArray<->StringBuilder mismatch.", builder, array);
|
assertEqualsInternal("GrowingCharArray<->StringBuilder mismatch.", builder, array);
|
||||||
|
|
||||||
File tempDir = TestUtil.createTempDir("growingchararray");
|
File tempDir = createTempDir("growingchararray");
|
||||||
File f = new File(tempDir, "GrowingCharArrayTest.tmp");
|
File f = new File(tempDir, "GrowingCharArrayTest.tmp");
|
||||||
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));
|
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));
|
||||||
array.flush(out);
|
array.flush(out);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class TestCompactLabelToOrdinal extends FacetTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File tmpDir = TestUtil.createTempDir("testLableToOrdinal");
|
File tmpDir = createTempDir("testLableToOrdinal");
|
||||||
File f = new File(tmpDir, "CompactLabelToOrdinalTest.tmp");
|
File f = new File(tmpDir, "CompactLabelToOrdinalTest.tmp");
|
||||||
int flushInterval = 10;
|
int flushInterval = 10;
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ import org.apache.lucene.util.TestUtil;
|
||||||
|
|
||||||
public class TestIndexSplitter extends LuceneTestCase {
|
public class TestIndexSplitter extends LuceneTestCase {
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
File dir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
File dir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
||||||
File destDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
File destDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
||||||
Directory fsDir = newFSDirectory(dir);
|
Directory fsDir = newFSDirectory(dir);
|
||||||
// IndexSplitter.split makes its own commit directly with SIPC/SegmentInfos,
|
// IndexSplitter.split makes its own commit directly with SIPC/SegmentInfos,
|
||||||
// so the unreferenced files are expected.
|
// so the unreferenced files are expected.
|
||||||
|
@ -76,7 +76,7 @@ public class TestIndexSplitter extends LuceneTestCase {
|
||||||
fsDirDest.close();
|
fsDirDest.close();
|
||||||
|
|
||||||
// now test cmdline
|
// now test cmdline
|
||||||
File destDir2 = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
File destDir2 = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
||||||
IndexSplitter.main(new String[] {dir.getAbsolutePath(), destDir2.getAbsolutePath(), splitSegName});
|
IndexSplitter.main(new String[] {dir.getAbsolutePath(), destDir2.getAbsolutePath(), splitSegName});
|
||||||
assertEquals(5, destDir2.listFiles().length);
|
assertEquals(5, destDir2.listFiles().length);
|
||||||
Directory fsDirDest2 = newFSDirectory(destDir2);
|
Directory fsDirDest2 = newFSDirectory(destDir2);
|
||||||
|
|
|
@ -191,7 +191,7 @@ public class IndexAndTaxonomyReplicationClientTest extends ReplicatorTestCase {
|
||||||
publishTaxoDir = newDirectory();
|
publishTaxoDir = newDirectory();
|
||||||
handlerIndexDir = newMockDirectory();
|
handlerIndexDir = newMockDirectory();
|
||||||
handlerTaxoDir = newMockDirectory();
|
handlerTaxoDir = newMockDirectory();
|
||||||
clientWorkDir = TestUtil.createTempDir("replicationClientTest");
|
clientWorkDir = createTempDir("replicationClientTest");
|
||||||
sourceDirFactory = new PerSessionDirectoryFactory(clientWorkDir);
|
sourceDirFactory = new PerSessionDirectoryFactory(clientWorkDir);
|
||||||
replicator = new LocalReplicator();
|
replicator = new LocalReplicator();
|
||||||
callback = new IndexAndTaxonomyReadyCallback(handlerIndexDir, handlerTaxoDir);
|
callback = new IndexAndTaxonomyReadyCallback(handlerIndexDir, handlerTaxoDir);
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class IndexReplicationClientTest extends ReplicatorTestCase {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
publishDir = newMockDirectory();
|
publishDir = newMockDirectory();
|
||||||
handlerDir = newMockDirectory();
|
handlerDir = newMockDirectory();
|
||||||
sourceDirFactory = new PerSessionDirectoryFactory(TestUtil.createTempDir("replicationClientTest"));
|
sourceDirFactory = new PerSessionDirectoryFactory(createTempDir("replicationClientTest"));
|
||||||
replicator = new LocalReplicator();
|
replicator = new LocalReplicator();
|
||||||
callback = new IndexReadyCallback(handlerDir);
|
callback = new IndexReadyCallback(handlerDir);
|
||||||
handler = new IndexReplicationHandler(handlerDir, callback);
|
handler = new IndexReplicationHandler(handlerDir, callback);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class HttpReplicatorTest extends ReplicatorTestCase {
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
System.setProperty("org.eclipse.jetty.LEVEL", "DEBUG"); // sets stderr logging to DEBUG level
|
System.setProperty("org.eclipse.jetty.LEVEL", "DEBUG"); // sets stderr logging to DEBUG level
|
||||||
clientWorkDir = TestUtil.createTempDir("httpReplicatorTest");
|
clientWorkDir = createTempDir("httpReplicatorTest");
|
||||||
handlerIndexDir = newDirectory();
|
handlerIndexDir = newDirectory();
|
||||||
serverIndexDir = newDirectory();
|
serverIndexDir = newDirectory();
|
||||||
serverReplicator = new LocalReplicator();
|
serverReplicator = new LocalReplicator();
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class LookupBenchmarkTest extends LuceneTestCase {
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
Analyzer a = new MockAnalyzer(random, MockTokenizer.KEYWORD, false);
|
Analyzer a = new MockAnalyzer(random, MockTokenizer.KEYWORD, false);
|
||||||
if (cls == AnalyzingInfixSuggester.class) {
|
if (cls == AnalyzingInfixSuggester.class) {
|
||||||
lookup = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, FSDirectory.open(TestUtil.createTempDir("LookupBenchmarkTest")), a);
|
lookup = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, FSDirectory.open(createTempDir("LookupBenchmarkTest")), a);
|
||||||
} else {
|
} else {
|
||||||
Constructor<? extends Lookup> ctor = cls.getConstructor(Analyzer.class);
|
Constructor<? extends Lookup> ctor = cls.getConstructor(Analyzer.class);
|
||||||
lookup = ctor.newInstance(a);
|
lookup = ctor.newInstance(a);
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class PersistenceTest extends LuceneTestCase {
|
||||||
lookup.build(new InputArrayIterator(keys));
|
lookup.build(new InputArrayIterator(keys));
|
||||||
|
|
||||||
// Store the suggester.
|
// Store the suggester.
|
||||||
File storeDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
File storeDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
||||||
lookup.store(new FileOutputStream(new File(storeDir, "lookup.dat")));
|
lookup.store(new FileOutputStream(new File(storeDir, "lookup.dat")));
|
||||||
|
|
||||||
// Re-read it from disk.
|
// Re-read it from disk.
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
|
||||||
new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz")),
|
new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz")),
|
||||||
};
|
};
|
||||||
|
|
||||||
File tempDir = TestUtil.createTempDir("AnalyzingInfixSuggesterTest");
|
File tempDir = createTempDir("AnalyzingInfixSuggesterTest");
|
||||||
|
|
||||||
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
|
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
|
||||||
AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, newFSDirectory(tempDir), a, a, 3);
|
AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(TEST_VERSION_CURRENT, newFSDirectory(tempDir), a, a, 3);
|
||||||
|
@ -210,7 +210,7 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
|
||||||
new Input("lend me your ear", 8, new BytesRef("foobar")),
|
new Input("lend me your ear", 8, new BytesRef("foobar")),
|
||||||
new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz")),
|
new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz")),
|
||||||
};
|
};
|
||||||
File tempDir = TestUtil.createTempDir("AnalyzingInfixSuggesterTest");
|
File tempDir = createTempDir("AnalyzingInfixSuggesterTest");
|
||||||
|
|
||||||
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
|
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
|
||||||
int minPrefixLength = random().nextInt(10);
|
int minPrefixLength = random().nextInt(10);
|
||||||
|
@ -471,7 +471,7 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRandomNRT() throws Exception {
|
public void testRandomNRT() throws Exception {
|
||||||
final File tempDir = TestUtil.createTempDir("AnalyzingInfixSuggesterTest");
|
final File tempDir = createTempDir("AnalyzingInfixSuggesterTest");
|
||||||
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
|
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
|
||||||
int minPrefixChars = random().nextInt(7);
|
int minPrefixChars = random().nextInt(7);
|
||||||
if (VERBOSE) {
|
if (VERBOSE) {
|
||||||
|
@ -806,7 +806,7 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
|
||||||
new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz"), asSet("foo", "baz"))
|
new Input("a penny saved is a penny earned", 10, new BytesRef("foobaz"), asSet("foo", "baz"))
|
||||||
};
|
};
|
||||||
|
|
||||||
File tempDir = TestUtil.createTempDir("analyzingInfixContext");
|
File tempDir = createTempDir("analyzingInfixContext");
|
||||||
|
|
||||||
for(int iter=0;iter<2;iter++) {
|
for(int iter=0;iter<2;iter++) {
|
||||||
AnalyzingInfixSuggester suggester;
|
AnalyzingInfixSuggester suggester;
|
||||||
|
|
|
@ -921,7 +921,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase {
|
||||||
assertEquals(3, results.get(2).value);
|
assertEquals(3, results.get(2).value);
|
||||||
|
|
||||||
// Try again after save/load:
|
// Try again after save/load:
|
||||||
File tmpDir = TestUtil.createTempDir("AnalyzingSuggesterTest");
|
File tmpDir = createTempDir("AnalyzingSuggesterTest");
|
||||||
tmpDir.mkdir();
|
tmpDir.mkdir();
|
||||||
|
|
||||||
File path = new File(tmpDir, "suggester");
|
File path = new File(tmpDir, "suggester");
|
||||||
|
@ -983,7 +983,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase {
|
||||||
assertEquals(5, results.get(1).value);
|
assertEquals(5, results.get(1).value);
|
||||||
|
|
||||||
// Try again after save/load:
|
// Try again after save/load:
|
||||||
File tmpDir = TestUtil.createTempDir("AnalyzingSuggesterTest");
|
File tmpDir = createTempDir("AnalyzingSuggesterTest");
|
||||||
tmpDir.mkdir();
|
tmpDir.mkdir();
|
||||||
|
|
||||||
File path = new File(tmpDir, "suggester");
|
File path = new File(tmpDir, "suggester");
|
||||||
|
@ -1053,7 +1053,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase {
|
||||||
assertEquals(5, results.get(1).value);
|
assertEquals(5, results.get(1).value);
|
||||||
|
|
||||||
// Try again after save/load:
|
// Try again after save/load:
|
||||||
File tmpDir = TestUtil.createTempDir("AnalyzingSuggesterTest");
|
File tmpDir = createTempDir("AnalyzingSuggesterTest");
|
||||||
tmpDir.mkdir();
|
tmpDir.mkdir();
|
||||||
|
|
||||||
File path = new File(tmpDir, "suggester");
|
File path = new File(tmpDir, "suggester");
|
||||||
|
|
|
@ -17,6 +17,10 @@ package org.apache.lucene.search.suggest.analyzing;
|
||||||
* limitations under the License.
|
* 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.Analyzer;
|
||||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||||
import org.apache.lucene.analysis.util.CharArraySet;
|
import org.apache.lucene.analysis.util.CharArraySet;
|
||||||
|
@ -25,11 +29,6 @@ import org.apache.lucene.search.suggest.InputArrayIterator;
|
||||||
import org.apache.lucene.search.suggest.Lookup;
|
import org.apache.lucene.search.suggest.Lookup;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
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 {
|
public class BlendedInfixSuggesterTest extends LuceneTestCase {
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ public class BlendedInfixSuggesterTest extends LuceneTestCase {
|
||||||
new Input("star wars: episode v - the empire strikes back", 8, payload)
|
new Input("star wars: episode v - the empire strikes back", 8, payload)
|
||||||
};
|
};
|
||||||
|
|
||||||
File tempDir = TestUtil.createTempDir("BlendedInfixSuggesterTest");
|
File tempDir = createTempDir("BlendedInfixSuggesterTest");
|
||||||
|
|
||||||
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
|
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
|
||||||
BlendedInfixSuggester suggester = new BlendedInfixSuggester(TEST_VERSION_CURRENT, newFSDirectory(tempDir), a, a,
|
BlendedInfixSuggester suggester = new BlendedInfixSuggester(TEST_VERSION_CURRENT, newFSDirectory(tempDir), a, a,
|
||||||
|
@ -84,7 +83,7 @@ public class BlendedInfixSuggesterTest extends LuceneTestCase {
|
||||||
new Input("top of the lake", w, pl)
|
new Input("top of the lake", w, pl)
|
||||||
};
|
};
|
||||||
|
|
||||||
File tempDir = TestUtil.createTempDir("BlendedInfixSuggesterTest");
|
File tempDir = createTempDir("BlendedInfixSuggesterTest");
|
||||||
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
|
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
|
||||||
|
|
||||||
// BlenderType.LINEAR is used by default (remove position*10%)
|
// BlenderType.LINEAR is used by default (remove position*10%)
|
||||||
|
@ -125,7 +124,7 @@ public class BlendedInfixSuggesterTest extends LuceneTestCase {
|
||||||
new Input("the returned", 10, ret),
|
new Input("the returned", 10, ret),
|
||||||
};
|
};
|
||||||
|
|
||||||
File tempDir = TestUtil.createTempDir("BlendedInfixSuggesterTest");
|
File tempDir = createTempDir("BlendedInfixSuggesterTest");
|
||||||
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
|
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
|
||||||
|
|
||||||
// if factor is small, we don't get the expected element
|
// if factor is small, we don't get the expected element
|
||||||
|
@ -175,7 +174,7 @@ public class BlendedInfixSuggesterTest extends LuceneTestCase {
|
||||||
new Input("the returned", 10, ret),
|
new Input("the returned", 10, ret),
|
||||||
};
|
};
|
||||||
|
|
||||||
File tempDir = TestUtil.createTempDir("BlendedInfixSuggesterTest");
|
File tempDir = createTempDir("BlendedInfixSuggesterTest");
|
||||||
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
|
Analyzer a = new StandardAnalyzer(TEST_VERSION_CURRENT, CharArraySet.EMPTY_SET);
|
||||||
|
|
||||||
// if factor is small, we don't get the expected element
|
// if factor is small, we don't get the expected element
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class TestFreeTextSuggester extends LuceneTestCase {
|
||||||
toString(sug.lookup("b", 10)));
|
toString(sug.lookup("b", 10)));
|
||||||
|
|
||||||
// Try again after save/load:
|
// Try again after save/load:
|
||||||
File tmpDir = TestUtil.createTempDir("FreeTextSuggesterTest");
|
File tmpDir = createTempDir("FreeTextSuggesterTest");
|
||||||
tmpDir.mkdir();
|
tmpDir.mkdir();
|
||||||
|
|
||||||
File path = new File(tmpDir, "suggester");
|
File path = new File(tmpDir, "suggester");
|
||||||
|
|
|
@ -503,7 +503,7 @@ public abstract class BaseTokenStreamTestCase extends LuceneTestCase {
|
||||||
!(postingsFormat.equals("Memory") ||
|
!(postingsFormat.equals("Memory") ||
|
||||||
postingsFormat.equals("SimpleText"));
|
postingsFormat.equals("SimpleText"));
|
||||||
if (rarely(random) && codecOk) {
|
if (rarely(random) && codecOk) {
|
||||||
dir = newFSDirectory(TestUtil.createTempDir("bttc"));
|
dir = newFSDirectory(createTempDir("bttc"));
|
||||||
iw = new RandomIndexWriter(new Random(seed), dir, a);
|
iw = new RandomIndexWriter(new Random(seed), dir, a);
|
||||||
}
|
}
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
|
@ -2615,7 +2615,7 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase {
|
||||||
Analyzer analyzer = new MockAnalyzer(random());
|
Analyzer analyzer = new MockAnalyzer(random());
|
||||||
// FSDirectory because SimpleText will consume gobbs of
|
// FSDirectory because SimpleText will consume gobbs of
|
||||||
// space when storing big binary values:
|
// space when storing big binary values:
|
||||||
Directory d = newFSDirectory(TestUtil.createTempDir("hugeBinaryValues"));
|
Directory d = newFSDirectory(createTempDir("hugeBinaryValues"));
|
||||||
boolean doFixed = random().nextBoolean();
|
boolean doFixed = random().nextBoolean();
|
||||||
int numDocs;
|
int numDocs;
|
||||||
int fixedLength = 0;
|
int fixedLength = 0;
|
||||||
|
@ -2713,7 +2713,7 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase {
|
||||||
Analyzer analyzer = new MockAnalyzer(random());
|
Analyzer analyzer = new MockAnalyzer(random());
|
||||||
// FSDirectory because SimpleText will consume gobbs of
|
// FSDirectory because SimpleText will consume gobbs of
|
||||||
// space when storing big binary values:
|
// space when storing big binary values:
|
||||||
Directory d = newFSDirectory(TestUtil.createTempDir("hugeBinaryValues"));
|
Directory d = newFSDirectory(createTempDir("hugeBinaryValues"));
|
||||||
boolean doFixed = random().nextBoolean();
|
boolean doFixed = random().nextBoolean();
|
||||||
int numDocs;
|
int numDocs;
|
||||||
int fixedLength = 0;
|
int fixedLength = 0;
|
||||||
|
|
|
@ -1203,7 +1203,7 @@ public abstract class BasePostingsFormatTestCase extends LuceneTestCase {
|
||||||
/** Indexes all fields/terms at the specified
|
/** Indexes all fields/terms at the specified
|
||||||
* IndexOptions, and fully tests at that IndexOptions. */
|
* IndexOptions, and fully tests at that IndexOptions. */
|
||||||
private void testFull(IndexOptions options, boolean withPayloads) throws Exception {
|
private void testFull(IndexOptions options, boolean withPayloads) throws Exception {
|
||||||
File path = TestUtil.createTempDir("testPostingsFormat.testExact");
|
File path = createTempDir("testPostingsFormat.testExact");
|
||||||
Directory dir = newFSDirectory(path);
|
Directory dir = newFSDirectory(path);
|
||||||
|
|
||||||
// TODO test thread safety of buildIndex too
|
// TODO test thread safety of buildIndex too
|
||||||
|
@ -1256,7 +1256,7 @@ public abstract class BasePostingsFormatTestCase extends LuceneTestCase {
|
||||||
int iters = 5;
|
int iters = 5;
|
||||||
|
|
||||||
for(int iter=0;iter<iters;iter++) {
|
for(int iter=0;iter<iters;iter++) {
|
||||||
File path = TestUtil.createTempDir("testPostingsFormat");
|
File path = createTempDir("testPostingsFormat");
|
||||||
Directory dir = newFSDirectory(path);
|
Directory dir = newFSDirectory(path);
|
||||||
|
|
||||||
boolean indexPayloads = random().nextBoolean();
|
boolean indexPayloads = random().nextBoolean();
|
||||||
|
|
|
@ -599,7 +599,7 @@ public abstract class BaseStoredFieldsFormatTestCase extends LuceneTestCase {
|
||||||
// for this test we force a FS dir
|
// for this test we force a FS dir
|
||||||
// we can't just use newFSDirectory, because this test doesn't really index anything.
|
// 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)
|
// so if we get NRTCachingDir+SimpleText, we make massive stored fields and OOM (LUCENE-4484)
|
||||||
Directory dir = new MockDirectoryWrapper(random(), new MMapDirectory(TestUtil.createTempDir("testBigDocuments")));
|
Directory dir = new MockDirectoryWrapper(random(), new MMapDirectory(createTempDir("testBigDocuments")));
|
||||||
IndexWriterConfig iwConf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
IndexWriterConfig iwConf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||||
iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
|
iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
|
||||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConf);
|
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConf);
|
||||||
|
|
|
@ -435,7 +435,7 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
|
||||||
|
|
||||||
Random random = new Random(random().nextLong());
|
Random random = new Random(random().nextLong());
|
||||||
final LineFileDocs docs = new LineFileDocs(random, true);
|
final LineFileDocs docs = new LineFileDocs(random, true);
|
||||||
final File tempDir = TestUtil.createTempDir(testName);
|
final File tempDir = createTempDir(testName);
|
||||||
dir = getDirectory(newMockFSDirectory(tempDir)); // some subclasses rely on this being MDW
|
dir = getDirectory(newMockFSDirectory(tempDir)); // some subclasses rely on this being MDW
|
||||||
if (dir instanceof BaseDirectoryWrapper) {
|
if (dir instanceof BaseDirectoryWrapper) {
|
||||||
((BaseDirectoryWrapper) dir).setCheckIndexOnClose(false); // don't double-checkIndex, we do it ourselves.
|
((BaseDirectoryWrapper) dir).setCheckIndexOnClose(false); // don't double-checkIndex, we do it ourselves.
|
||||||
|
|
|
@ -447,7 +447,7 @@ public abstract class ShardSearchingTestBase extends LuceneTestCase {
|
||||||
|
|
||||||
public NodeState(Random random, int nodeID, int numNodes) throws IOException {
|
public NodeState(Random random, int nodeID, int numNodes) throws IOException {
|
||||||
myNodeID = nodeID;
|
myNodeID = nodeID;
|
||||||
dir = newFSDirectory(TestUtil.createTempDir("ShardSearchingTestBase"));
|
dir = newFSDirectory(createTempDir("ShardSearchingTestBase"));
|
||||||
// TODO: set warmer
|
// TODO: set warmer
|
||||||
MockAnalyzer analyzer = new MockAnalyzer(random());
|
MockAnalyzer analyzer = new MockAnalyzer(random());
|
||||||
analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));
|
analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));
|
||||||
|
|
|
@ -17,55 +17,153 @@ package org.apache.lucene.util;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.*;
|
import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
|
||||||
import java.nio.file.NoSuchFileException;
|
import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsInt;
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
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.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.nio.file.NoSuchFileException;
|
||||||
import java.util.concurrent.*;
|
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.concurrent.atomic.AtomicReference;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.Analyzer;
|
import org.apache.lucene.analysis.Analyzer;
|
||||||
import org.apache.lucene.codecs.Codec;
|
import org.apache.lucene.codecs.Codec;
|
||||||
import org.apache.lucene.document.Field.Store;
|
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
|
import org.apache.lucene.document.Field.Store;
|
||||||
import org.apache.lucene.document.FieldType;
|
import org.apache.lucene.document.FieldType;
|
||||||
import org.apache.lucene.document.StringField;
|
import org.apache.lucene.document.StringField;
|
||||||
import org.apache.lucene.document.TextField;
|
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.IndexReader.ReaderClosedListener;
|
||||||
|
import org.apache.lucene.index.IndexWriterConfig;
|
||||||
|
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.StorableField;
|
||||||
|
import org.apache.lucene.index.StoredDocument;
|
||||||
|
import org.apache.lucene.index.Terms;
|
||||||
|
import org.apache.lucene.index.TermsEnum;
|
||||||
import org.apache.lucene.index.TermsEnum.SeekStatus;
|
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.FieldCache.CacheEntry;
|
||||||
|
import org.apache.lucene.search.IndexSearcher;
|
||||||
import org.apache.lucene.search.QueryUtils.FCInvisibleMultiReader;
|
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.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.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.FieldCacheSanityChecker.Insanity;
|
||||||
import org.apache.lucene.util.automaton.AutomatonTestUtil;
|
import org.apache.lucene.util.automaton.AutomatonTestUtil;
|
||||||
import org.apache.lucene.util.automaton.CompiledAutomaton;
|
import org.apache.lucene.util.automaton.CompiledAutomaton;
|
||||||
import org.apache.lucene.util.automaton.RegExp;
|
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.RuleChain;
|
||||||
import org.junit.rules.TestRule;
|
import org.junit.rules.TestRule;
|
||||||
import org.junit.runner.RunWith;
|
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.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.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.ThreadLeakScope.Scope;
|
||||||
|
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;
|
||||||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;
|
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;
|
||||||
|
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
|
||||||
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
|
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
|
||||||
import com.carrotsearch.randomizedtesting.rules.NoClassHooksShadowingRule;
|
import com.carrotsearch.randomizedtesting.rules.NoClassHooksShadowingRule;
|
||||||
import com.carrotsearch.randomizedtesting.rules.NoInstanceHooksOverridesRule;
|
import com.carrotsearch.randomizedtesting.rules.NoInstanceHooksOverridesRule;
|
||||||
import com.carrotsearch.randomizedtesting.rules.StaticFieldsInvariantRule;
|
import com.carrotsearch.randomizedtesting.rules.StaticFieldsInvariantRule;
|
||||||
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule;
|
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule;
|
||||||
|
import com.carrotsearch.randomizedtesting.rules.TestRuleAdapter;
|
||||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
|
|
||||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsInt;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all Lucene unit tests, Junit3 or Junit4 variant.
|
* Base class for all Lucene unit tests, Junit3 or Junit4 variant.
|
||||||
|
@ -112,13 +210,6 @@ import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAs
|
||||||
* context ({@link RandomizedContext#current()}) and then calling
|
* context ({@link RandomizedContext#current()}) and then calling
|
||||||
* {@link RandomizedContext#getRunnerSeedAsString()}.</li>
|
* {@link RandomizedContext#getRunnerSeedAsString()}.</li>
|
||||||
* </ul>
|
* </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)
|
@RunWith(RandomizedRunner.class)
|
||||||
@TestMethodProviders({
|
@TestMethodProviders({
|
||||||
|
@ -233,8 +324,8 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
* files. This may prevent temp. files and folders from being cleaned
|
* files. This may prevent temp. files and folders from being cleaned
|
||||||
* up after the suite is completed.
|
* up after the suite is completed.
|
||||||
*
|
*
|
||||||
* @see TestUtil#createTempDir()
|
* @see LuceneTestCase#createTempDir()
|
||||||
* @see TestUtil#createTempFile(String, String)
|
* @see LuceneTestCase#createTempFile(String, String)
|
||||||
*/
|
*/
|
||||||
@Documented
|
@Documented
|
||||||
@Inherited
|
@Inherited
|
||||||
|
@ -444,6 +535,7 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
.around(ignoreAfterMaxFailures)
|
.around(ignoreAfterMaxFailures)
|
||||||
.around(suiteFailureMarker = new TestRuleMarkFailure())
|
.around(suiteFailureMarker = new TestRuleMarkFailure())
|
||||||
.around(new TestRuleAssertionsRequired())
|
.around(new TestRuleAssertionsRequired())
|
||||||
|
.around(new TemporaryFilesCleanupRule())
|
||||||
.around(new StaticFieldsInvariantRule(STATIC_LEAK_THRESHOLD, true) {
|
.around(new StaticFieldsInvariantRule(STATIC_LEAK_THRESHOLD, true) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean accept(java.lang.reflect.Field field) {
|
protected boolean accept(java.lang.reflect.Field field) {
|
||||||
|
@ -1178,7 +1270,7 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
final Class<? extends Directory> clazz = CommandLineUtil.loadDirectoryClass(clazzName);
|
final Class<? extends Directory> clazz = CommandLineUtil.loadDirectoryClass(clazzName);
|
||||||
// If it is a FSDirectory type, try its ctor(File)
|
// If it is a FSDirectory type, try its ctor(File)
|
||||||
if (FSDirectory.class.isAssignableFrom(clazz)) {
|
if (FSDirectory.class.isAssignableFrom(clazz)) {
|
||||||
final File dir = new File(TestUtil.createTempDir(), "index");
|
final File dir = createTempDir("index-" + clazzName);
|
||||||
dir.mkdirs(); // ensure it's created so we 'have' it.
|
dir.mkdirs(); // ensure it's created so we 'have' it.
|
||||||
return newFSDirectoryImpl(clazz.asSubclass(FSDirectory.class), dir);
|
return newFSDirectoryImpl(clazz.asSubclass(FSDirectory.class), dir);
|
||||||
}
|
}
|
||||||
|
@ -2091,4 +2183,148 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
return false;
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private static File getTempDirBase() {
|
||||||
|
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.", "oa.lucene.");
|
||||||
|
prefix = prefix.replaceFirst("^org.apache.solr.", "oa.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, "%3d", attempt));
|
||||||
|
} while (!f.mkdirs());
|
||||||
|
|
||||||
|
tempDirBase = f;
|
||||||
|
registerToRemoveAfterSuite(tempDirBase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tempDirBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected static File createTempDir(String prefix) {
|
||||||
|
File base = getTempDirBase();
|
||||||
|
|
||||||
|
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, "%3d", attempt));
|
||||||
|
} while (!f.mkdirs());
|
||||||
|
|
||||||
|
registerToRemoveAfterSuite(f);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected static File createTempFile(String prefix, String suffix) throws IOException {
|
||||||
|
File base = getTempDirBase();
|
||||||
|
|
||||||
|
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, "%3d", attempt) + suffix);
|
||||||
|
} while (!f.createNewFile());
|
||||||
|
|
||||||
|
registerToRemoveAfterSuite(f);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected static File createTempDir() {
|
||||||
|
return createTempDir("tempDir");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
protected 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Class<?> suiteClass = RandomizedContext.current().getTargetClass();
|
||||||
|
if (suiteClass.isAnnotationPresent(SuppressTempFileChecks.class)) {
|
||||||
|
System.err.println("WARNING: Will leave temporary files (bugUrl: "
|
||||||
|
+ suiteClass.getAnnotation(SuppressTempFileChecks.class).bugUrl() + "): "
|
||||||
|
+ f.getAbsolutePath());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (cleanupQueue) {
|
||||||
|
cleanupQueue.addLast(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class TemporaryFilesCleanupRule extends TestRuleAdapter {
|
||||||
|
@Override
|
||||||
|
protected void afterIfSuccessful() throws Throwable {
|
||||||
|
synchronized (cleanupQueue) {
|
||||||
|
File [] everything = new File [cleanupQueue.size()];
|
||||||
|
for (int i = 0; !cleanupQueue.isEmpty(); i++) {
|
||||||
|
everything[i] = cleanupQueue.removeFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Will throw an IOException on un-removable files.
|
||||||
|
TestUtil.rm(everything);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
@ -87,10 +86,8 @@ import org.apache.lucene.search.FilteredQuery.FilterStrategy;
|
||||||
import org.apache.lucene.search.ScoreDoc;
|
import org.apache.lucene.search.ScoreDoc;
|
||||||
import org.apache.lucene.search.TopDocs;
|
import org.apache.lucene.search.TopDocs;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.util.LuceneTestCase.SuppressTempFileChecks;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.RandomizedContext;
|
|
||||||
import com.carrotsearch.randomizedtesting.generators.RandomInts;
|
import com.carrotsearch.randomizedtesting.generators.RandomInts;
|
||||||
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
|
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
|
||||||
|
|
||||||
|
@ -102,14 +99,14 @@ 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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a file or a directory (and everything underneath it).
|
* 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 void rm(File location) throws IOException {
|
public static void rm(File... locations) throws IOException {
|
||||||
ArrayList<File> unremoved = rm(location, new ArrayList<File>());
|
ArrayList<File> unremoved = rm(new ArrayList<File>(), locations);
|
||||||
if (!unremoved.isEmpty()) {
|
if (!unremoved.isEmpty()) {
|
||||||
StringBuilder b = new StringBuilder("Could not remove the following files (in the order of attempts):\n");
|
StringBuilder b = new StringBuilder("Could not remove the following files (in the order of attempts):\n");
|
||||||
for (File f : unremoved) {
|
for (File f : unremoved) {
|
||||||
|
@ -121,16 +118,16 @@ public final class TestUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<File> rm(File location, ArrayList<File> unremoved) {
|
private static ArrayList<File> rm(ArrayList<File> unremoved, File... locations) {
|
||||||
if (location.exists()) {
|
for (File location : locations) {
|
||||||
if (location.isDirectory()) {
|
if (location.exists()) {
|
||||||
for (File f : location.listFiles()) {
|
if (location.isDirectory()) {
|
||||||
rm(f, unremoved);
|
rm(unremoved, location.listFiles());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!location.delete()) {
|
||||||
|
unremoved.add(location);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!location.delete()) {
|
|
||||||
unremoved.add(location);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return unremoved;
|
return unremoved;
|
||||||
|
@ -789,131 +786,6 @@ public final class TestUtil {
|
||||||
});
|
});
|
||||||
Assert.assertEquals("Reflection does not produce same map", reflectedValues, map);
|
Assert.assertEquals("Reflection does not produce same map", reflectedValues, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a new, empty temporary folder, based on the current test class's name.
|
|
||||||
*
|
|
||||||
* @see #createTempDir(String, File)
|
|
||||||
*/
|
|
||||||
public static File createTempDir() {
|
|
||||||
Class<?> clazz = RandomizedContext.current().getTargetClass();
|
|
||||||
String prefix = clazz.getName();
|
|
||||||
prefix = prefix.replaceFirst("^org.apache.lucene.", "lucene-");
|
|
||||||
prefix = prefix.replaceFirst("^org.apache.solr.", "solr-");
|
|
||||||
return createTempDir(prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see #createTempDir(String, File)
|
|
||||||
*/
|
|
||||||
public static File createTempDir(String prefix) {
|
|
||||||
return createTempDir(prefix, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a new and empty temporary folder, based on the given name. The folder will be
|
|
||||||
* deleted at the end of the test suite. Failure to delete the temporary folder will cause
|
|
||||||
* an exception (typically happens on Windows on unclosed file handles).
|
|
||||||
*/
|
|
||||||
public static File createTempDir(String prefix, File parent) {
|
|
||||||
if (prefix.length() < 3) {
|
|
||||||
throw new IllegalArgumentException("The prefix must be at least 3 characters: " + prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parent == null) {
|
|
||||||
parent = tempDirectory();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parent.exists()) {
|
|
||||||
throw new RuntimeException("Parent location does not exist: " + parent.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parent.isDirectory()) {
|
|
||||||
throw new RuntimeException("Parent location is not a folder: " + parent.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parent.canWrite()) {
|
|
||||||
throw new RuntimeException("Parent folder not writeable: " + parent.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
int attempt = 0;
|
|
||||||
File f;
|
|
||||||
do {
|
|
||||||
f = genTempFile(prefix + "_", "", parent);
|
|
||||||
} 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: "
|
|
||||||
+ parent.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
return maybeRemoveAfterSuite(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static File maybeRemoveAfterSuite(File f) {
|
|
||||||
if (LuceneTestCase.LEAVE_TEMPORARY) {
|
|
||||||
System.err.println("INFO: Will leave temporary file: " + f.getAbsolutePath());
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
Class<?> suiteClass = RandomizedContext.current().getTargetClass();
|
|
||||||
if (suiteClass.isAnnotationPresent(SuppressTempFileChecks.class)) {
|
|
||||||
System.err.println("WARNING: Will leave temporary files (bugUrl: "
|
|
||||||
+ suiteClass.getAnnotation(SuppressTempFileChecks.class).bugUrl() + "): "
|
|
||||||
+ f.getAbsolutePath());
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
LuceneTestCase.closeAfterSuite(new RemoveUponClose(f, LuceneTestCase.suiteFailureMarker));
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File createTempFile(String prefix, String suffix) throws IOException {
|
|
||||||
return createTempFile(prefix, suffix, tempDirectory());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Do NOT expose this method public. Use {@link #createTempDir()} instead.
|
|
||||||
*/
|
|
||||||
private static File tempDirectory() {
|
|
||||||
File directory = new File(System.getProperty("tempDir", System.getProperty("java.io.tmpdir")));
|
|
||||||
assert directory.exists() &&
|
|
||||||
directory.isDirectory() &&
|
|
||||||
directory.canWrite();
|
|
||||||
return directory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 {
|
|
||||||
if (prefix.length() < 3) {
|
|
||||||
throw new IllegalArgumentException("prefix must be at least 3 characters");
|
|
||||||
}
|
|
||||||
String newSuffix = suffix == null ? ".tmp" : suffix;
|
|
||||||
File result;
|
|
||||||
do {
|
|
||||||
result = genTempFile(prefix, newSuffix, directory);
|
|
||||||
} while (!result.createNewFile());
|
|
||||||
return maybeRemoveAfterSuite(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Temp file counter */
|
|
||||||
private static final AtomicInteger counter = new AtomicInteger();
|
|
||||||
|
|
||||||
private static File genTempFile(String prefix, String suffix, File directory) {
|
|
||||||
return new File(directory,
|
|
||||||
prefix
|
|
||||||
+ RandomizedContext.current().getRunnerSeedAsString()
|
|
||||||
+ "-" + counter.incrementAndGet()
|
|
||||||
+ suffix);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void assertEquals(TopDocs expected, TopDocs actual) {
|
public static void assertEquals(TopDocs expected, TopDocs actual) {
|
||||||
Assert.assertEquals("wrong total hits", expected.totalHits, actual.totalHits);
|
Assert.assertEquals("wrong total hits", expected.totalHits, actual.totalHits);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class TestFileListWithLineEntityProcessor extends AbstractDataImportHandl
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
File tmpdir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
File tmpdir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
||||||
createFile(tmpdir, "a.txt", "a line one\na line two\na line three".getBytes(StandardCharsets.UTF_8), false);
|
createFile(tmpdir, "a.txt", "a line one\na line two\na line three".getBytes(StandardCharsets.UTF_8), false);
|
||||||
createFile(tmpdir, "b.txt", "b line one\nb line two".getBytes(StandardCharsets.UTF_8), false);
|
createFile(tmpdir, "b.txt", "b line one\nb line two".getBytes(StandardCharsets.UTF_8), false);
|
||||||
createFile(tmpdir, "c.txt", "c line one\nc line two\nc line three\nc line four".getBytes(StandardCharsets.UTF_8), false);
|
createFile(tmpdir, "c.txt", "c line one\nc line two\nc line three\nc line four".getBytes(StandardCharsets.UTF_8), false);
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class ResourceLoaderTest extends SolrTestCaseJ4
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEscapeInstanceDir() throws Exception {
|
public void testEscapeInstanceDir() throws Exception {
|
||||||
File temp = TestUtil.createTempDir("testEscapeInstanceDir");
|
File temp = createTempDir("testEscapeInstanceDir");
|
||||||
try {
|
try {
|
||||||
temp.mkdirs();
|
temp.mkdirs();
|
||||||
new File(temp, "dummy.txt").createNewFile();
|
new File(temp, "dummy.txt").createNewFile();
|
||||||
|
@ -170,7 +170,7 @@ public class ResourceLoaderTest extends SolrTestCaseJ4
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClassLoaderLibs() throws Exception {
|
public void testClassLoaderLibs() throws Exception {
|
||||||
File tmpRoot = TestUtil.createTempDir("testClassLoaderLibs");
|
File tmpRoot = createTempDir("testClassLoaderLibs");
|
||||||
|
|
||||||
File lib = new File(tmpRoot, "lib");
|
File lib = new File(tmpRoot, "lib");
|
||||||
lib.mkdirs();
|
lib.mkdirs();
|
||||||
|
|
|
@ -233,7 +233,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSharedLib() throws Exception {
|
public void testSharedLib() throws Exception {
|
||||||
File tmpRoot = TestUtil.createTempDir("testSharedLib");
|
File tmpRoot = createTempDir("testSharedLib");
|
||||||
|
|
||||||
File lib = new File(tmpRoot, "lib");
|
File lib = new File(tmpRoot, "lib");
|
||||||
lib.mkdirs();
|
lib.mkdirs();
|
||||||
|
|
|
@ -81,12 +81,10 @@ public class TestSolrXMLSerializer extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertResults(w.toString().getBytes(StandardCharsets.UTF_8));
|
assertResults(w.toString().getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
// again with default file
|
|
||||||
File tmpFile = TestUtil.createTempFile("solr.xml", null, createTempDir());
|
|
||||||
|
|
||||||
serializer.persistFile(tmpFile, solrXMLDef);
|
|
||||||
|
|
||||||
|
// again with default file
|
||||||
|
File tmpFile = new File(createTempDir(), "solr.xml");
|
||||||
|
serializer.persistFile(tmpFile, solrXMLDef);
|
||||||
assertResults(FileUtils.readFileToByteArray(tmpFile));
|
assertResults(FileUtils.readFileToByteArray(tmpFile));
|
||||||
tmpFile.delete();
|
tmpFile.delete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setupTest() {
|
public void setupTest() {
|
||||||
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
solrHomeDirectory = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private CoreContainer init(String solrXmlString, String... subDirs) throws Exception {
|
private CoreContainer init(String solrXmlString, String... subDirs) throws Exception {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 {
|
||||||
// if you override setUp or tearDown, you better call
|
// if you override setUp or tearDown, you better call
|
||||||
// the super classes version
|
// the super classes version
|
||||||
super.setUp();
|
super.setUp();
|
||||||
File tempDir = TestUtil.createTempDir("TestCSVLoader");
|
File tempDir = createTempDir("TestCSVLoader");
|
||||||
file = new File(tempDir, "solr_tmp.csv");
|
file = new File(tempDir, "solr_tmp.csv");
|
||||||
filename = file.getPath();
|
filename = file.getPath();
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class TestRemoteStreaming extends SolrJettyTestBase {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeTest() throws Exception {
|
public static void beforeTest() throws Exception {
|
||||||
//this one has handleSelect=true which a test here needs
|
//this one has handleSelect=true which a test here needs
|
||||||
solrHomeDirectory = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
solrHomeDirectory = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
||||||
setupJettyTestHome(solrHomeDirectory, "collection1");
|
setupJettyTestHome(solrHomeDirectory, "collection1");
|
||||||
createJetty(solrHomeDirectory.getAbsolutePath(), null, null);
|
createJetty(solrHomeDirectory.getAbsolutePath(), null, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class TestCollationField extends SolrTestCaseJ4 {
|
||||||
*/
|
*/
|
||||||
public static String setupSolrHome() throws Exception {
|
public static String setupSolrHome() throws Exception {
|
||||||
// make a solr home underneath the test's TEMP_DIR
|
// make a solr home underneath the test's TEMP_DIR
|
||||||
File tmpFile = TestUtil.createTempDir("collation1");
|
File tmpFile = createTempDir("collation1");
|
||||||
tmpFile.delete();
|
tmpFile.delete();
|
||||||
tmpFile.mkdir();
|
tmpFile.mkdir();
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class TestCollationFieldDocValues extends SolrTestCaseJ4 {
|
||||||
*/
|
*/
|
||||||
public static String setupSolrHome() throws Exception {
|
public static String setupSolrHome() throws Exception {
|
||||||
// make a solr home underneath the test's TEMP_DIR
|
// make a solr home underneath the test's TEMP_DIR
|
||||||
File tmpFile = TestUtil.createTempDir("collation1");
|
File tmpFile = createTempDir("collation1");
|
||||||
tmpFile.delete();
|
tmpFile.delete();
|
||||||
tmpFile.mkdir();
|
tmpFile.mkdir();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.apache.http.Header;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.methods.HttpRequestBase;
|
import org.apache.http.client.methods.HttpRequestBase;
|
||||||
import org.apache.http.impl.cookie.DateUtils;
|
import org.apache.http.impl.cookie.DateUtils;
|
||||||
import org.apache.lucene.util.TestUtil;
|
|
||||||
import org.apache.solr.common.params.CommonParams;
|
import org.apache.solr.common.params.CommonParams;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -255,7 +254,7 @@ public class CacheHeaderTest extends CacheHeaderTestBase {
|
||||||
|
|
||||||
protected File makeFile(String contents, String charset) {
|
protected File makeFile(String contents, String charset) {
|
||||||
try {
|
try {
|
||||||
File f = TestUtil.createTempFile("cachetest_csv", null, initCoreDataDir);
|
File f = new File(initCoreDataDir, "cachetest_csv");
|
||||||
Writer out = new OutputStreamWriter(new FileOutputStream(f), charset);
|
Writer out = new OutputStreamWriter(new FileOutputStream(f), charset);
|
||||||
out.write(contents);
|
out.write(contents);
|
||||||
out.close();
|
out.close();
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
|
||||||
spellchecker.add(AbstractLuceneSpellChecker.LOCATION, "spellings.txt");
|
spellchecker.add(AbstractLuceneSpellChecker.LOCATION, "spellings.txt");
|
||||||
spellchecker.add(AbstractLuceneSpellChecker.FIELD, "teststop");
|
spellchecker.add(AbstractLuceneSpellChecker.FIELD, "teststop");
|
||||||
spellchecker.add(FileBasedSpellChecker.SOURCE_FILE_CHAR_ENCODING, "UTF-8");
|
spellchecker.add(FileBasedSpellChecker.SOURCE_FILE_CHAR_ENCODING, "UTF-8");
|
||||||
File indexDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
File indexDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
||||||
spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
|
spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
|
||||||
SolrCore core = h.getCore();
|
SolrCore core = h.getCore();
|
||||||
String dictName = checker.init(spellchecker, core);
|
String dictName = checker.init(spellchecker, core);
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {
|
||||||
public void testConfigSet() throws Exception {
|
public void testConfigSet() throws Exception {
|
||||||
|
|
||||||
SolrServer server = getSolrAdmin();
|
SolrServer server = getSolrAdmin();
|
||||||
File testDir = TestUtil.createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
File testDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
|
||||||
|
|
||||||
File newCoreInstanceDir = new File(testDir, "newcore");
|
File newCoreInstanceDir = new File(testDir, "newcore");
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class ContentStreamTest extends SolrTestCaseJ4
|
||||||
{
|
{
|
||||||
InputStream is = new SolrResourceLoader(null, null).openResource( "solrj/README" );
|
InputStream is = new SolrResourceLoader(null, null).openResource( "solrj/README" );
|
||||||
assertNotNull( is );
|
assertNotNull( is );
|
||||||
File file = TestUtil.createTempFile("README", "", createTempDir());
|
File file = new File(createTempDir(), "README");
|
||||||
FileOutputStream os = new FileOutputStream(file);
|
FileOutputStream os = new FileOutputStream(file);
|
||||||
IOUtils.copy(is, os);
|
IOUtils.copy(is, os);
|
||||||
os.close();
|
os.close();
|
||||||
|
|
|
@ -150,10 +150,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static void beforeClass() {
|
private static void beforeClass() {
|
||||||
// Create the root parent folder for all other temporary solr files.
|
initCoreDataDir = createTempDir("init-core-data");
|
||||||
rootTmpDir = TestUtil.createTempDir();
|
|
||||||
|
|
||||||
initCoreDataDir = TestUtil.createTempDir("init-core-data", rootTmpDir);
|
|
||||||
|
|
||||||
System.err.println("Creating dataDir: " + initCoreDataDir.getAbsolutePath());
|
System.err.println("Creating dataDir: " + initCoreDataDir.getAbsolutePath());
|
||||||
|
|
||||||
|
@ -465,14 +462,6 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
SolrException.ignorePatterns.remove(pattern);
|
SolrException.ignorePatterns.remove(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File createTempDir() {
|
|
||||||
return createTempDir(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File createTempDir(String prefix) {
|
|
||||||
return TestUtil.createTempDir(prefix == null ? "temp" : prefix, rootTmpDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void resetExceptionIgnores() {
|
public static void resetExceptionIgnores() {
|
||||||
SolrException.ignorePatterns = null;
|
SolrException.ignorePatterns = null;
|
||||||
ignoreException("ignore_exception"); // always ignore "ignore_exception"
|
ignoreException("ignore_exception"); // always ignore "ignore_exception"
|
||||||
|
@ -533,8 +522,6 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
*/
|
*/
|
||||||
protected static volatile File initCoreDataDir;
|
protected static volatile File initCoreDataDir;
|
||||||
|
|
||||||
protected static volatile File rootTmpDir;
|
|
||||||
|
|
||||||
// hack due to File dataDir
|
// hack due to File dataDir
|
||||||
protected static String hdfsDataDir;
|
protected static String hdfsDataDir;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue