diff --git a/.hgignore b/.hgignore
new file mode 100644
index 00000000000..3cb9afd9fae
--- /dev/null
+++ b/.hgignore
@@ -0,0 +1,2 @@
+syntax: glob
+*/build/*
diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index 711a0c1e48a..98106f124ad 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -60,6 +60,7 @@
+
@@ -444,6 +445,8 @@
+
+
diff --git a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java
index a5d9243987c..e1968e2353a 100644
--- a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java
+++ b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterPhraseTest.java
@@ -35,7 +35,6 @@ import org.apache.lucene.document.Field.TermVector;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermPositionVector;
import org.apache.lucene.search.Collector;
@@ -49,7 +48,6 @@ import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.OpenBitSet;
diff --git a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
index 0c734e38cb4..bf69b807a2f 100644
--- a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
+++ b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
@@ -78,7 +78,6 @@ import org.apache.lucene.search.spans.SpanOrQuery;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.automaton.BasicAutomata;
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
import org.apache.lucene.util.automaton.RegExp;
@@ -95,7 +94,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
static final String FIELD_NAME = "contents";
private static final String NUMERIC_FIELD_NAME = "nfield";
private Query query;
- MockRAMDirectory ramDir;
+ Directory ramDir;
public IndexSearcher searcher = null;
int numHighlights = 0;
final Analyzer analyzer = new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true);
@@ -1323,7 +1322,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
public void testMultiSearcher() throws Exception {
// setup index 1
- MockRAMDirectory ramDir1 = newDirectory(random);
+ Directory ramDir1 = newDirectory(random);
IndexWriter writer1 = new IndexWriter(ramDir1, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true)));
Document d = new Document();
@@ -1335,7 +1334,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
IndexReader reader1 = IndexReader.open(ramDir1, true);
// setup index 2
- MockRAMDirectory ramDir2 = newDirectory(random);
+ Directory ramDir2 = newDirectory(random);
IndexWriter writer2 = new IndexWriter(ramDir2, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true)));
d = new Document();
diff --git a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java
index c66796c0d74..da79a066a8d 100644
--- a/lucene/contrib/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java
+++ b/lucene/contrib/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java
@@ -44,7 +44,6 @@ import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public abstract class AbstractTestCase extends LuceneTestCase {
diff --git a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java
index 89ecfdb0309..e4b037d1135 100644
--- a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java
+++ b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java
@@ -23,14 +23,12 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public class TestEmptyIndex extends LuceneTestCase {
diff --git a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
index 70408184787..d8716d5d97a 100644
--- a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
+++ b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
@@ -41,7 +41,6 @@ import org.apache.lucene.index.FieldsEnum;
import org.apache.lucene.index.TermFreqVector;
import org.apache.lucene.index.TermPositionVector;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.AttributeImpl;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
@@ -63,7 +62,7 @@ public class TestIndicesEquals extends LuceneTestCase {
public void testLoadIndexReader() throws Exception {
Random random = newRandom();
- MockRAMDirectory dir = newDirectory(random);
+ Directory dir = newDirectory(random);
// create dir data
IndexWriter indexWriter = new IndexWriter(dir, newIndexWriterConfig(random,
@@ -88,7 +87,7 @@ public class TestIndicesEquals extends LuceneTestCase {
public void testInstantiatedIndexWriter() throws Exception {
Random random = newRandom();
- MockRAMDirectory dir = newDirectory(random);
+ Directory dir = newDirectory(random);
InstantiatedIndex ii = new InstantiatedIndex();
// create dir data
diff --git a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestUnoptimizedReaderOnConstructor.java b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestUnoptimizedReaderOnConstructor.java
index 6fc55c922c9..7f07840ec84 100644
--- a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestUnoptimizedReaderOnConstructor.java
+++ b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestUnoptimizedReaderOnConstructor.java
@@ -22,7 +22,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.analysis.MockAnalyzer;
diff --git a/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java b/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
index a948d659606..503048a750c 100644
--- a/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
+++ b/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
@@ -37,7 +37,7 @@ import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TopDocs;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util._TestUtil;
/**
@@ -106,7 +106,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
termField.append(randomTerm());
}
- MockRAMDirectory ramdir = newDirectory(random);
+ Directory ramdir = newDirectory(random);
Analyzer analyzer = randomAnalyzer();
IndexWriter writer = new IndexWriter(ramdir,
new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
@@ -128,7 +128,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
/**
* Run all queries against both the RAMDirectory and MemoryIndex, ensuring they are the same.
*/
- public void assertAllQueries(MemoryIndex memory, MockRAMDirectory ramdir, Analyzer analyzer) throws Exception {
+ public void assertAllQueries(MemoryIndex memory, Directory ramdir, Analyzer analyzer) throws Exception {
IndexSearcher ram = new IndexSearcher(ramdir);
IndexSearcher mem = memory.createSearcher();
QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "foo", analyzer);
diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java
index 6eaaa2b1b4d..0b98350c1bd 100644
--- a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java
+++ b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java
@@ -31,7 +31,6 @@ import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**
diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
index 18f2749cf02..d38b34de4c6 100644
--- a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
+++ b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
@@ -22,7 +22,6 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
@@ -30,7 +29,7 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase {
IndexReader input;
int NUM_DOCS = 11;
private Random random;
- MockRAMDirectory dir;
+ Directory dir;
@Override
protected void setUp() throws Exception {
diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java
index 59dc97e1e86..8858e1cc1ad 100644
--- a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java
+++ b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java
@@ -4,10 +4,8 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
-import java.util.Collections;
import java.util.Random;
/*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java b/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java
index e0a09fa3d4f..3e161547139 100644
--- a/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java
+++ b/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java
@@ -42,7 +42,8 @@ import org.apache.lucene.index.codecs.SegmentInfosReader;
import org.apache.lucene.index.codecs.SegmentInfosWriter;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IndexOutput;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.Version;
@@ -118,7 +119,11 @@ public class TestAppendingCodec extends LuceneTestCase {
}
@SuppressWarnings("serial")
- private static class AppendingRAMDirectory extends MockRAMDirectory {
+ private static class AppendingRAMDirectory extends MockDirectoryWrapper {
+
+ public AppendingRAMDirectory(Directory delegate) {
+ super(delegate);
+ }
@Override
public IndexOutput createOutput(String name) throws IOException {
@@ -130,7 +135,7 @@ public class TestAppendingCodec extends LuceneTestCase {
private static final String text = "the quick brown fox jumped over the lazy dog";
public void testCodec() throws Exception {
- Directory dir = new AppendingRAMDirectory();
+ Directory dir = new AppendingRAMDirectory(new RAMDirectory());
IndexWriterConfig cfg = new IndexWriterConfig(Version.LUCENE_40, new MockAnalyzer());
cfg.setCodecProvider(new AppendingCodecProvider());
diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java
index dafc0559238..ad35de38b29 100644
--- a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java
+++ b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java
@@ -21,10 +21,9 @@ import java.util.Random;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
@@ -33,7 +32,7 @@ import org.apache.lucene.document.Field;
public class TestHighFreqTerms extends LuceneTestCase {
private static IndexWriter writer =null;
- private static MockRAMDirectory dir = null;
+ private static Directory dir = null;
private static IndexReader reader =null;
public void setUp() throws Exception {
diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java
index 0470a90de37..a4fa6992754 100644
--- a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java
+++ b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java
@@ -35,7 +35,6 @@ import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java
index 6720e568dfb..1101fdc5270 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java
@@ -28,11 +28,11 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.SlowMultiReaderWrapper;
import org.apache.lucene.index.Term;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
public class BooleanFilterTest extends LuceneTestCase {
- private MockRAMDirectory directory;
+ private Directory directory;
private IndexReader mainReader;
private IndexReader reader;
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java
index 6bd31084448..c2b895f22f7 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java
@@ -39,13 +39,12 @@ import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeFilter;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public class ChainedFilterTest extends LuceneTestCase {
public static final int MAX = 500;
- private MockRAMDirectory directory;
+ private Directory directory;
private IndexSearcher searcher;
private IndexReader reader;
private Query query;
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
index 11f918b24dd..dfa998255b6 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
@@ -28,13 +28,13 @@ import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.DocsEnum;
import org.apache.lucene.index.MultiFields;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
public class DuplicateFilterTest extends LuceneTestCase {
private static final String KEY_FIELD = "url";
- private MockRAMDirectory directory;
+ private Directory directory;
private IndexReader reader;
TermQuery tq=new TermQuery(new Term("text","lucene"));
private IndexSearcher searcher;
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java
index b23bedda473..bf8c564503a 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java
@@ -28,11 +28,11 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
public class FuzzyLikeThisQueryTest extends LuceneTestCase {
- private MockRAMDirectory directory;
+ private Directory directory;
private IndexSearcher searcher;
private IndexReader reader;
private Analyzer analyzer=new MockAnalyzer();
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java
index dc2edf16cf5..2e22de95954 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java
@@ -25,7 +25,7 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.index.SlowMultiReaderWrapper;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.OpenBitSet;
@@ -53,7 +53,7 @@ public class TermsFilterTest extends LuceneTestCase {
public void testMissingTerms() throws Exception {
String fieldName="field1";
Random random = newRandom();
- MockRAMDirectory rd=newDirectory(random);
+ Directory rd=newDirectory(random);
RandomIndexWriter w = new RandomIndexWriter(random, rd);
for (int i = 0; i < 100; i++) {
Document doc=new Document();
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
index daacf506aba..e41e2a4e772 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
@@ -20,7 +20,6 @@ package org.apache.lucene.search.regex;
import java.util.Random;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
index 99998228c4f..f35f8bb13e1 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
@@ -35,7 +35,6 @@ import org.apache.lucene.search.spans.SpanNearQuery;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public class TestSpanRegexQuery extends LuceneTestCase {
@@ -60,7 +59,7 @@ public class TestSpanRegexQuery extends LuceneTestCase {
}
public void testSpanRegex() throws Exception {
- MockRAMDirectory directory = newDirectory(random);
+ Directory directory = newDirectory(random);
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
index 2d7f6b7ee0e..3a71dd52de9 100644
--- a/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
+++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
@@ -34,11 +34,11 @@ import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
public class TestMoreLikeThis extends LuceneTestCase {
- private MockRAMDirectory directory;
+ private Directory directory;
private IndexReader reader;
private IndexSearcher searcher;
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
index d12b2cd2d39..ab5a66ed233 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
@@ -25,17 +25,16 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
public class TestComplexPhraseQuery extends LuceneTestCase {
- MockRAMDirectory rd;
+ Directory rd;
Analyzer analyzer = new MockAnalyzer();
DocData docsContent[] = { new DocData("john smith", "1"),
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
index 4d6a8f46eb7..fb3e01002e2 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
@@ -28,7 +28,6 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.queryParser.core.QueryNodeException;
import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute.Operator;
import org.apache.lucene.search.BooleanClause;
@@ -37,7 +36,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
index 2196a770b62..7d82aaae5ca 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
@@ -36,7 +36,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
index 43643436cd8..4f19708f509 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
@@ -48,7 +48,6 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.messages.MessageImpl;
import org.apache.lucene.queryParser.core.QueryNodeException;
@@ -73,8 +72,7 @@ import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeQuery;
import org.apache.lucene.search.WildcardQuery;
-import org.apache.lucene.store.MockRAMDirectory;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LocalizedTestCase;
import org.apache.lucene.util.automaton.BasicAutomata;
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
@@ -655,7 +653,7 @@ public class TestQPHelper extends LocalizedTestCase {
public void testFarsiRangeCollating() throws Exception {
Random random = newRandom();
- MockRAMDirectory ramDir = newDirectory(random);
+ Directory ramDir = newDirectory(random);
IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
Document doc = new Document();
doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES,
@@ -1079,7 +1077,7 @@ public class TestQPHelper extends LocalizedTestCase {
public void testLocalDateFormat() throws IOException, QueryNodeException {
Random random = newRandom();
- MockRAMDirectory ramDir = newDirectory(random);
+ Directory ramDir = newDirectory(random);
IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
addDateDoc("a", 2005, 12, 2, 10, 15, 33, iw);
addDateDoc("b", 2005, 12, 4, 22, 15, 00, iw);
@@ -1279,7 +1277,7 @@ public class TestQPHelper extends LocalizedTestCase {
public void testMultiPhraseQuery() throws Exception {
Random random = newRandom();
- MockRAMDirectory dir = newDirectory(random);
+ Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new CannedAnalyzer()));
Document doc = new Document();
doc.add(new Field("field", "", Field.Store.NO, Field.Index.ANALYZED));
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
index 725a3e93bfb..3747bb3e55e 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
@@ -67,7 +67,7 @@ import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeQuery;
import org.apache.lucene.search.WildcardQuery;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LocalizedTestCase;
import org.apache.lucene.util.automaton.BasicAutomata;
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
@@ -654,7 +654,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
public void testFarsiRangeCollating() throws Exception {
- MockRAMDirectory ramDir = newDirectory(newRandom());
+ Directory ramDir = newDirectory(newRandom());
IndexWriter iw = new IndexWriter(ramDir, new MockAnalyzer(MockTokenizer.WHITESPACE, false), true,
IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
@@ -1063,7 +1063,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
public void testLocalDateFormat() throws IOException, ParseException {
- MockRAMDirectory ramDir = newDirectory(newRandom());
+ Directory ramDir = newDirectory(newRandom());
IndexWriter iw = new IndexWriter(ramDir, new MockAnalyzer(MockTokenizer.WHITESPACE, false), true,
IndexWriter.MaxFieldLength.LIMITED);
addDateDoc("a", 2005, 12, 2, 10, 15, 33, iw);
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/surround/query/SingleFieldTestDb.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/surround/query/SingleFieldTestDb.java
index 1f6700165a4..ae6f9d74199 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/surround/query/SingleFieldTestDb.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/surround/query/SingleFieldTestDb.java
@@ -18,7 +18,8 @@ package org.apache.lucene.queryParser.surround.query;
*/
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.Version;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -33,7 +34,7 @@ public class SingleFieldTestDb {
public SingleFieldTestDb(String[] documents, String fName) {
try {
- db = new MockRAMDirectory();
+ db = new MockDirectoryWrapper(new RAMDirectory());
docs = documents;
fieldName = fName;
IndexWriter writer = new IndexWriter(db, new IndexWriterConfig(
diff --git a/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java b/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java
index fa9893cc658..efb7701909a 100644
--- a/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java
+++ b/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java
@@ -24,7 +24,7 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -35,7 +35,7 @@ import static org.junit.Assert.*;
* Tests that the index is cached on the searcher side of things.
*/
public class TestRemoteCachingWrapperFilter extends RemoteTestCaseJ4 {
- private static MockRAMDirectory indexStore;
+ private static Directory indexStore;
private static Searchable local;
@BeforeClass
diff --git a/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSearchable.java b/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSearchable.java
index 18eda716291..69ce657c258 100644
--- a/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSearchable.java
+++ b/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSearchable.java
@@ -21,7 +21,7 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.*;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -34,7 +34,7 @@ import java.util.Set;
import java.util.HashSet;
public class TestRemoteSearchable extends RemoteTestCaseJ4 {
- private static MockRAMDirectory indexStore;
+ private static Directory indexStore;
private static Searchable local;
@BeforeClass
diff --git a/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java b/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java
index fc3a4cc2111..cf21369ecd2 100644
--- a/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java
+++ b/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java
@@ -30,10 +30,9 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LogMergePolicy;
import org.apache.lucene.index.Term;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.junit.AfterClass;
import org.junit.Before;
@@ -49,7 +48,7 @@ import org.junit.Test;
public class TestRemoteSort extends RemoteTestCaseJ4 {
private static IndexSearcher full;
- private static MockRAMDirectory indexStore;
+ private static Directory indexStore;
private Query queryX;
private Query queryY;
private Query queryA;
diff --git a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java
index 6703aaf9e45..46e5d8266d2 100644
--- a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java
+++ b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java
@@ -29,11 +29,11 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.QueryWrapperFilter;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
public class TestDistance extends LuceneTestCase {
- private MockRAMDirectory directory;
+ private Directory directory;
// reston va
private double lat = 38.969398;
private double lng= -77.386398;
diff --git a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
index 05058116aa8..65c78cd40d0 100644
--- a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
+++ b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
@@ -23,14 +23,11 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
-import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**
diff --git a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestPlainTextDictionary.java b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestPlainTextDictionary.java
index 259e91b65af..f99ab3b0048 100644
--- a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestPlainTextDictionary.java
+++ b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestPlainTextDictionary.java
@@ -20,7 +20,7 @@ package org.apache.lucene.search.spell;
import java.io.IOException;
import java.io.StringReader;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
/**
@@ -33,7 +33,7 @@ public class TestPlainTextDictionary extends LuceneTestCase {
final String LF = System.getProperty("line.separator");
String input = "oneword" + LF + "twoword" + LF + "threeword";
PlainTextDictionary ptd = new PlainTextDictionary(new StringReader(input));
- MockRAMDirectory ramDir = newDirectory(newRandom());
+ Directory ramDir = newDirectory(newRandom());
SpellChecker spellChecker = new SpellChecker(ramDir);
spellChecker.indexDictionary(ptd);
String[] similar = spellChecker.suggestSimilar("treeword", 2);
diff --git a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
index 27fbab73815..35b06221dc8 100644
--- a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
+++ b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
@@ -14,13 +14,11 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.Version;
import org.apache.lucene.util.LuceneTestCase;
/**
diff --git a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java
index 0cc03346f18..e5fd77db82a 100644
--- a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java
+++ b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java
@@ -12,10 +12,9 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -45,7 +44,7 @@ public class TestQueryTemplateManager extends LuceneTestCase {
CoreParser builder;
Analyzer analyzer=new MockAnalyzer();
private IndexSearcher searcher;
- private MockRAMDirectory dir;
+ private Directory dir;
//A collection of documents' field values for use in our tests
String docFieldValues []=
diff --git a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/builders/TestNumericRangeFilterBuilder.java b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/builders/TestNumericRangeFilterBuilder.java
index 0dba08bf690..b2e76c52d87 100644
--- a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/builders/TestNumericRangeFilterBuilder.java
+++ b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/builders/TestNumericRangeFilterBuilder.java
@@ -30,11 +30,10 @@ import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.NumericRangeFilter;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.xmlparser.ParserException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -63,7 +62,7 @@ public class TestNumericRangeFilterBuilder extends LuceneTestCase {
Document doc = getDocumentFromString(xml);
Filter filter = filterBuilder.getFilter(doc.getDocumentElement());
Random random = newRandom();
- MockRAMDirectory ramDir = newDirectory(random);
+ Directory ramDir = newDirectory(random);
IndexWriter writer = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, null));
writer.commit();
try
diff --git a/lucene/src/java/org/apache/lucene/index/FieldsWriter.java b/lucene/src/java/org/apache/lucene/index/FieldsWriter.java
index 2b29270f73d..47425740a4f 100644
--- a/lucene/src/java/org/apache/lucene/index/FieldsWriter.java
+++ b/lucene/src/java/org/apache/lucene/index/FieldsWriter.java
@@ -135,7 +135,6 @@ final class FieldsWriter
final void close() throws IOException {
if (doClose) {
-
try {
if (fieldsStream != null) {
try {
diff --git a/lucene/src/test/org/apache/lucene/TestDemo.java b/lucene/src/test/org/apache/lucene/TestDemo.java
index 130783544e2..2e2c137dc11 100644
--- a/lucene/src/test/org/apache/lucene/TestDemo.java
+++ b/lucene/src/test/org/apache/lucene/TestDemo.java
@@ -33,7 +33,7 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**
@@ -49,7 +49,7 @@ public class TestDemo extends LuceneTestCase {
Analyzer analyzer = new MockAnalyzer();
// Store the index in memory:
- Directory directory = new MockRAMDirectory();
+ Directory directory = newDirectory(newRandom());
// To store an index on disk, use this instead:
//Directory directory = FSDirectory.open("/tmp/testindex");
IndexWriter iwriter = new IndexWriter(directory, new IndexWriterConfig(
diff --git a/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java b/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
index bd52d9743da..df73e027f78 100644
--- a/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
+++ b/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
@@ -20,7 +20,7 @@ import java.io.IOException;
import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LogMergePolicy;
@@ -71,9 +71,9 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
}
}
- private static class FailOnlyOnMerge extends MockRAMDirectory.Failure {
+ private static class FailOnlyOnMerge extends MockDirectoryWrapper.Failure {
@Override
- public void eval(MockRAMDirectory dir) throws IOException {
+ public void eval(MockDirectoryWrapper dir) throws IOException {
StackTraceElement[] trace = new Exception().getStackTrace();
for (int i = 0; i < trace.length; i++) {
if ("doMerge".equals(trace[i].getMethodName()))
@@ -84,7 +84,7 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
public void testSubclassConcurrentMergeScheduler() throws IOException {
Random random = newRandom();
- MockRAMDirectory dir = newDirectory(random);
+ MockDirectoryWrapper dir = newDirectory(random);
dir.failOn(new FailOnlyOnMerge());
Document doc = new Document();
diff --git a/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java b/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java
index 8588f612c04..19dca4e1580 100644
--- a/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java
+++ b/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java
@@ -6,7 +6,7 @@ import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -58,7 +58,7 @@ public class TestBinaryDocument extends LuceneTestCase {
/** add the doc to a ram index */
Random random = newRandom();
- MockRAMDirectory dir = newDirectory(random);
+ Directory dir = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(doc);
@@ -98,7 +98,7 @@ public class TestBinaryDocument extends LuceneTestCase {
/** add the doc to a ram index */
Random random = newRandom();
- MockRAMDirectory dir = newDirectory(random);
+ Directory dir = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(doc);
diff --git a/lucene/src/test/org/apache/lucene/document/TestDocument.java b/lucene/src/test/org/apache/lucene/document/TestDocument.java
index d9e7632fb72..bfd0b165589 100644
--- a/lucene/src/test/org/apache/lucene/document/TestDocument.java
+++ b/lucene/src/test/org/apache/lucene/document/TestDocument.java
@@ -10,7 +10,7 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
/**
@@ -155,7 +155,7 @@ public class TestDocument extends LuceneTestCase {
*/
public void testGetValuesForIndexedDocument() throws Exception {
Random random = newRandom();
- MockRAMDirectory dir = newDirectory(random);
+ Directory dir = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(makeDocumentWithFields());
IndexReader reader = writer.getReader();
@@ -234,7 +234,7 @@ public class TestDocument extends LuceneTestCase {
Field.Index.NOT_ANALYZED));
Random random = newRandom();
- MockRAMDirectory dir = newDirectory(random);
+ Directory dir = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(doc);
field.setValue("id2");
diff --git a/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java b/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java
index c476232cff3..bc98bebe303 100755
--- a/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java
+++ b/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java
@@ -26,8 +26,8 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.search.DocIdSetIterator;
@@ -368,7 +368,7 @@ public class TestAddIndexes extends LuceneTestCase {
.setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(10));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
- writer.addIndexes(new Directory[] { aux, new MockRAMDirectory(aux) });
+ writer.addIndexes(new Directory[] { aux, new MockDirectoryWrapper(new RAMDirectory(aux)) });
assertEquals(1060, writer.maxDoc());
assertEquals(1000, writer.getDocCount(0));
writer.close();
@@ -400,7 +400,7 @@ public class TestAddIndexes extends LuceneTestCase {
.setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(4));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
- writer.addIndexes(new Directory[] { aux, new MockRAMDirectory(aux) });
+ writer.addIndexes(new Directory[] { aux, new MockDirectoryWrapper(new RAMDirectory(aux)) });
assertEquals(1060, writer.maxDoc());
assertEquals(1000, writer.getDocCount(0));
writer.close();
diff --git a/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java b/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java
index e5f33bbab36..3ff926ed4bd 100644
--- a/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java
+++ b/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java
@@ -189,7 +189,7 @@ public class TestAtomicUpdate extends LuceneTestCase {
Directory directory;
// First in a RAM directory:
- directory = new MockRAMDirectory();
+ directory = new MockDirectoryWrapper(new RAMDirectory());
runTest(directory);
directory.close();
diff --git a/lucene/src/test/org/apache/lucene/index/TestCheckIndex.java b/lucene/src/test/org/apache/lucene/index/TestCheckIndex.java
index 9e41074d51c..5493ca4936d 100644
--- a/lucene/src/test/org/apache/lucene/index/TestCheckIndex.java
+++ b/lucene/src/test/org/apache/lucene/index/TestCheckIndex.java
@@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -35,7 +35,7 @@ public class TestCheckIndex extends LuceneTestCase {
public void testDeletedDocs() throws IOException {
Random random = newRandom();
- MockRAMDirectory dir = newDirectory(random);
+ Directory dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
Document doc = new Document();
doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
diff --git a/lucene/src/test/org/apache/lucene/index/TestCodecs.java b/lucene/src/test/org/apache/lucene/index/TestCodecs.java
index 426e8939805..b4da93330af 100644
--- a/lucene/src/test/org/apache/lucene/index/TestCodecs.java
+++ b/lucene/src/test/org/apache/lucene/index/TestCodecs.java
@@ -39,8 +39,6 @@ import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.MultiCodecTestCase;
import org.apache.lucene.util.Version;
diff --git a/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java b/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
index f07a494dbbf..1e45008598c 100644
--- a/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
+++ b/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
@@ -17,8 +17,7 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import org.apache.lucene.store.MockRAMDirectory;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -30,7 +29,7 @@ import java.util.Random;
public class TestConcurrentMergeScheduler extends LuceneTestCase {
- private static class FailOnlyOnFlush extends MockRAMDirectory.Failure {
+ private static class FailOnlyOnFlush extends MockDirectoryWrapper.Failure {
boolean doFail;
boolean hitExc;
@@ -45,7 +44,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
}
@Override
- public void eval(MockRAMDirectory dir) throws IOException {
+ public void eval(MockDirectoryWrapper dir) throws IOException {
if (doFail && Thread.currentThread().getName().equals("main")) {
StackTraceElement[] trace = new Exception().getStackTrace();
for (int i = 0; i < trace.length; i++) {
@@ -62,7 +61,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
// we are hitting exceptions during flushing.
public void testFlushExceptions() throws IOException {
Random random = newRandom();
- MockRAMDirectory directory = newDirectory(random);
+ MockDirectoryWrapper directory = newDirectory(random);
FailOnlyOnFlush failure = new FailOnlyOnFlush();
directory.failOn(failure);
@@ -108,7 +107,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
// before it finishes, are correctly merged back:
public void testDeleteMerging() throws IOException {
Random random = newRandom();
- MockRAMDirectory directory = newDirectory(random);
+ MockDirectoryWrapper directory = newDirectory(random);
LogDocMergePolicy mp = new LogDocMergePolicy();
// Force degenerate merging so we can get a mix of
@@ -147,7 +146,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
public void testNoExtraFiles() throws IOException {
Random random = newRandom();
- MockRAMDirectory directory = newDirectory(random);
+ MockDirectoryWrapper directory = newDirectory(random);
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2));
@@ -176,7 +175,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
public void testNoWaitClose() throws IOException {
Random random = newRandom();
- MockRAMDirectory directory = newDirectory(random);
+ MockDirectoryWrapper directory = newDirectory(random);
Document doc = new Document();
Field idField = new Field("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
doc.add(idField);
diff --git a/lucene/src/test/org/apache/lucene/index/TestCrash.java b/lucene/src/test/org/apache/lucene/index/TestCrash.java
index 654267435d9..dae95603459 100644
--- a/lucene/src/test/org/apache/lucene/index/TestCrash.java
+++ b/lucene/src/test/org/apache/lucene/index/TestCrash.java
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.NoLockFactory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -33,7 +33,7 @@ public class TestCrash extends LuceneTestCase {
return initIndex(random, newDirectory(random), initialCommit);
}
- private IndexWriter initIndex(Random random, MockRAMDirectory dir, boolean initialCommit) throws IOException {
+ private IndexWriter initIndex(Random random, MockDirectoryWrapper dir, boolean initialCommit) throws IOException {
dir.setLockFactory(NoLockFactory.getNoLockFactory());
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
@@ -53,7 +53,7 @@ public class TestCrash extends LuceneTestCase {
}
private void crash(final IndexWriter writer) throws IOException {
- final MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
+ final MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
ConcurrentMergeScheduler cms = (ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler();
cms.sync();
dir.crash();
@@ -66,7 +66,7 @@ public class TestCrash extends LuceneTestCase {
// happened, so we must create an initial commit just to allow that, but
// before any documents were added.
IndexWriter writer = initIndex(newRandom(), true);
- MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
+ MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
crash(writer);
IndexReader reader = IndexReader.open(dir, false);
assertTrue(reader.numDocs() < 157);
@@ -80,7 +80,7 @@ public class TestCrash extends LuceneTestCase {
// before any documents were added.
Random random = newRandom();
IndexWriter writer = initIndex(random, true);
- MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
+ MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
dir.setPreventDoubleWrite(false);
crash(writer);
writer = initIndex(random, dir, false);
@@ -95,7 +95,7 @@ public class TestCrash extends LuceneTestCase {
public void testCrashAfterReopen() throws IOException {
Random random = newRandom();
IndexWriter writer = initIndex(random, false);
- MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
+ MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
writer.close();
writer = initIndex(random, dir, false);
assertEquals(314, writer.maxDoc());
@@ -119,7 +119,7 @@ public class TestCrash extends LuceneTestCase {
public void testCrashAfterClose() throws IOException {
IndexWriter writer = initIndex(newRandom(), false);
- MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
+ MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
writer.close();
dir.crash();
@@ -140,7 +140,7 @@ public class TestCrash extends LuceneTestCase {
public void testCrashAfterCloseNoWait() throws IOException {
IndexWriter writer = initIndex(newRandom(), false);
- MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
+ MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
writer.close(false);
@@ -161,7 +161,7 @@ public class TestCrash extends LuceneTestCase {
public void testCrashReaderDeletes() throws IOException {
IndexWriter writer = initIndex(newRandom(), false);
- MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
+ MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
writer.close(false);
IndexReader reader = IndexReader.open(dir, false);
@@ -184,7 +184,7 @@ public class TestCrash extends LuceneTestCase {
public void testCrashReaderDeletesAfterClose() throws IOException {
IndexWriter writer = initIndex(newRandom(), false);
- MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
+ MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
writer.close(false);
IndexReader reader = IndexReader.open(dir, false);
diff --git a/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java b/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java
index a614c5cb0ea..749dbb37576 100644
--- a/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java
+++ b/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java
@@ -33,8 +33,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/*
diff --git a/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java b/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java
index a5d49f81029..c7958c7fe9b 100644
--- a/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java
@@ -24,7 +24,6 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.BytesRef;
import java.io.IOException;
@@ -137,9 +136,9 @@ public class TestDirectoryReader extends LuceneTestCase {
}
public void testIsCurrent() throws IOException {
- MockRAMDirectory ramDir1=newDirectory(random);
+ Directory ramDir1=newDirectory(random);
addDoc(random, ramDir1, "test foo", true);
- MockRAMDirectory ramDir2=newDirectory(random);
+ Directory ramDir2=newDirectory(random);
addDoc(random, ramDir2, "test blah", true);
IndexReader[] readers = new IndexReader[]{IndexReader.open(ramDir1, false), IndexReader.open(ramDir2, false)};
MultiReader mr = new MultiReader(readers);
@@ -160,11 +159,11 @@ public class TestDirectoryReader extends LuceneTestCase {
}
public void testMultiTermDocs() throws IOException {
- MockRAMDirectory ramDir1=newDirectory(random);
+ Directory ramDir1=newDirectory(random);
addDoc(random, ramDir1, "test foo", true);
- MockRAMDirectory ramDir2=newDirectory(random);
+ Directory ramDir2=newDirectory(random);
addDoc(random, ramDir2, "test blah", true);
- MockRAMDirectory ramDir3=newDirectory(random);
+ Directory ramDir3=newDirectory(random);
addDoc(random, ramDir3, "test wow", true);
IndexReader[] readers1 = new IndexReader[]{IndexReader.open(ramDir1, false), IndexReader.open(ramDir3, false)};
@@ -204,7 +203,7 @@ public class TestDirectoryReader extends LuceneTestCase {
ramDir3.close();
}
- private void addDoc(Random random, MockRAMDirectory ramDir1, String s, boolean create) throws IOException {
+ private void addDoc(Random random, Directory ramDir1, String s, boolean create) throws IOException {
IndexWriter iw = new IndexWriter(ramDir1, newIndexWriterConfig(random,
TEST_VERSION_CURRENT,
new MockAnalyzer()).setOpenMode(
diff --git a/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java b/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java
index b5d8b330d07..8dc6955c95d 100644
--- a/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java
+++ b/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java
@@ -35,14 +35,14 @@ import org.apache.lucene.document.Fieldable;
import org.apache.lucene.document.Field.Index;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.Field.TermVector;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.AttributeSource;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.util.BytesRef;
public class TestDocumentWriter extends LuceneTestCase {
- private MockRAMDirectory dir;
+ private Directory dir;
private Random random;
public TestDocumentWriter(String s) {
diff --git a/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java b/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java
index 7b6e5e40b22..d9389292a3a 100644
--- a/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java
+++ b/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java
@@ -19,7 +19,7 @@ package org.apache.lucene.index;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.document.Document;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IndexOutput;
import java.io.IOException;
@@ -47,16 +47,15 @@ public class TestFieldInfos extends LuceneTestCase {
fieldInfos.add(testDoc);
//Since the complement is stored as well in the fields map
assertTrue(fieldInfos.size() == DocHelper.all.size()); //this is all b/c we are using the no-arg constructor
- MockRAMDirectory dir = newDirectory(newRandom());
+ Directory dir = newDirectory(newRandom());
String name = "testFile";
IndexOutput output = dir.createOutput(name);
assertTrue(output != null);
//Use a RAMOutputStream
- try {
fieldInfos.write(output);
output.close();
- assertTrue(output.length() > 0);
+ assertTrue(dir.fileLength(name) > 0);
FieldInfos readIn = new FieldInfos(dir, name);
assertTrue(fieldInfos.size() == readIn.size());
FieldInfo info = readIn.fieldInfo("textField1");
@@ -80,10 +79,5 @@ public class TestFieldInfos extends LuceneTestCase {
assertTrue(info.omitNorms == true);
dir.close();
-
- } catch (IOException e) {
- assertTrue(false);
- }
-
}
}
diff --git a/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java b/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java
index dfd7635d611..ffaeb6b2c69 100644
--- a/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java
@@ -40,12 +40,11 @@ import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
public class TestFieldsReader extends LuceneTestCase {
- private MockRAMDirectory dir;
+ private Directory dir;
private Document testDoc = new Document();
private FieldInfos fieldInfos = null;
private Random random;
diff --git a/lucene/src/test/org/apache/lucene/index/TestFilterIndexReader.java b/lucene/src/test/org/apache/lucene/index/TestFilterIndexReader.java
index 9f8b67edb33..d33ca69baa1 100644
--- a/lucene/src/test/org/apache/lucene/index/TestFilterIndexReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestFilterIndexReader.java
@@ -22,8 +22,7 @@ import org.apache.lucene.util.LuceneTestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
-import org.apache.lucene.store.MockRAMDirectory;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -132,7 +131,7 @@ public class TestFilterIndexReader extends LuceneTestCase {
*/
public void testFilterIndexReader() throws Exception {
Random random = newRandom();
- MockRAMDirectory directory = newDirectory(random);
+ Directory directory = newDirectory(random);
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document d1 = new Document();
@@ -150,7 +149,7 @@ public class TestFilterIndexReader extends LuceneTestCase {
writer.close();
//IndexReader reader = new TestReader(IndexReader.open(directory, true));
- MockRAMDirectory target = newDirectory(random);
+ Directory target = newDirectory(random);
writer = new IndexWriter(target, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
IndexReader reader = new TestReader(IndexReader.open(directory, true));
writer.addIndexes(reader);
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java b/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
index 31474b42e8c..d3fc0d75456 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
@@ -21,7 +21,7 @@ import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -39,7 +39,7 @@ public class TestIndexFileDeleter extends LuceneTestCase {
public void testDeleteLeftoverFiles() throws IOException {
Random random = newRandom();
- MockRAMDirectory dir = newDirectory(random);
+ MockDirectoryWrapper dir = newDirectory(random);
dir.setPreventDoubleWrite(false);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer())
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexReader.java b/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
index ff8abe3e8e9..30255184c03 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
@@ -51,8 +51,10 @@ import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.LockObtainFailedException;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.NoSuchDirectoryException;
+import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.store.LockReleaseFailedException;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.util.BytesRef;
@@ -82,7 +84,7 @@ public class TestIndexReader extends LuceneTestCase
}
public void testCommitUserData() throws Exception {
- MockRAMDirectory d = newDirectory(random);
+ Directory d = newDirectory(random);
Map commitUserData = new HashMap();
commitUserData.put("foo", "fighters");
@@ -137,7 +139,7 @@ public class TestIndexReader extends LuceneTestCase
}
public void testIsCurrent() throws Exception {
- MockRAMDirectory d = newDirectory(random);
+ Directory d = newDirectory(random);
IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
@@ -166,7 +168,7 @@ public class TestIndexReader extends LuceneTestCase
* @throws Exception on error
*/
public void testGetFieldNames() throws Exception {
- MockRAMDirectory d = newDirectory(random);
+ Directory d = newDirectory(random);
// set up writer
IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
@@ -258,7 +260,7 @@ public class TestIndexReader extends LuceneTestCase
}
public void testTermVectors() throws Exception {
- MockRAMDirectory d = newDirectory(random);
+ Directory d = newDirectory(random);
// set up writer
IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
@@ -794,7 +796,7 @@ public class TestIndexReader extends LuceneTestCase
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
writer.close();
- writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
+ writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
IndexReader reader = IndexReader.open(dir, false);
try {
reader.deleteDocument(0);
@@ -802,7 +804,11 @@ public class TestIndexReader extends LuceneTestCase
} catch(IOException e) {
// expected exception
}
- IndexWriter.unlock(dir); // this should not be done in the real world!
+ try {
+ IndexWriter.unlock(dir); // this should not be done in the real world!
+ } catch (LockReleaseFailedException lrfe) {
+ writer.close();
+ }
reader.deleteDocument(0);
reader.close();
writer.close();
@@ -881,7 +887,7 @@ public class TestIndexReader extends LuceneTestCase
int END_COUNT = 144;
// First build up a starting index:
- MockRAMDirectory startDir = newDirectory(random);
+ MockDirectoryWrapper startDir = newDirectory(random);
IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
for(int i=0;i<157;i++) {
Document d = new Document();
@@ -893,7 +899,7 @@ public class TestIndexReader extends LuceneTestCase
}
writer.close();
- long diskUsage = ((MockRAMDirectory) startDir).getRecomputedActualSizeInBytes();
+ long diskUsage = startDir.getRecomputedActualSizeInBytes();
long diskFree = diskUsage+100;
IOException err = null;
@@ -903,7 +909,7 @@ public class TestIndexReader extends LuceneTestCase
// Iterate w/ ever increasing free disk space:
while(!done) {
- MockRAMDirectory dir = new MockRAMDirectory(startDir);
+ MockDirectoryWrapper dir = new MockDirectoryWrapper(new RAMDirectory(startDir));
// If IndexReader hits disk full, it can write to
// the same files again.
@@ -1150,7 +1156,7 @@ public class TestIndexReader extends LuceneTestCase
}
public void testMultiReaderDeletes() throws Exception {
- Directory dir = new MockRAMDirectory();
+ Directory dir = newDirectory(random);
RandomIndexWriter w = new RandomIndexWriter(random, dir);
Document doc = new Document();
doc.add(new Field("f", "doctor", Field.Store.NO, Field.Index.NOT_ANALYZED));
@@ -1417,7 +1423,7 @@ public class TestIndexReader extends LuceneTestCase
public void testGetIndexCommit() throws IOException {
- MockRAMDirectory d = newDirectory(random);
+ Directory d = newDirectory(random);
// set up writer
IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
@@ -1466,7 +1472,7 @@ public class TestIndexReader extends LuceneTestCase
}
public void testReadOnly() throws Throwable {
- MockRAMDirectory d = newDirectory(random);
+ Directory d = newDirectory(random);
IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
@@ -1553,7 +1559,7 @@ public class TestIndexReader extends LuceneTestCase
// LUCENE-1647
public void testIndexReaderUnDeleteAll() throws Exception {
- MockRAMDirectory dir = newDirectory(random);
+ MockDirectoryWrapper dir = newDirectory(random);
dir.setPreventDoubleWrite(false);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
index 816600c666d..aaa7787e3f8 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -68,9 +68,9 @@ import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.Lock;
import org.apache.lucene.store.LockFactory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.NoLockFactory;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.SingleInstanceLockFactory;
import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util._TestUtil;
@@ -203,7 +203,7 @@ public class TestIndexWriter extends LuceneTestCase {
// Now, build a starting index that has START_COUNT docs. We
// will then try to addIndexesNoOptimize into a copy of this:
- MockRAMDirectory startDir = newDirectory(random);
+ MockDirectoryWrapper startDir = newDirectory(random);
IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
for(int j=0;j termsSet = new HashSet();
diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java b/lucene/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
index be1658ba5d5..4ea1ecb815d 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
@@ -22,11 +22,9 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import java.io.IOException;
import java.util.Random;
diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java b/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
index ee66c4100da..20f62b4e269 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
@@ -25,7 +25,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import java.io.IOException;
import java.text.Collator;
import java.util.Locale;
@@ -609,7 +608,7 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter {
public void testFarsi() throws Exception {
/* build an index */
- MockRAMDirectory farsiIndex = newDirectory(rand);
+ Directory farsiIndex = newDirectory(rand);
RandomIndexWriter writer = new RandomIndexWriter(rand, farsiIndex, new MockAnalyzer(MockTokenizer.SIMPLE, true));
Document doc = new Document();
doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES,
@@ -649,7 +648,7 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter {
public void testDanish() throws Exception {
/* build an index */
- MockRAMDirectory danishIndex = newDirectory(rand);
+ Directory danishIndex = newDirectory(rand);
RandomIndexWriter writer = new RandomIndexWriter(rand, danishIndex, new MockAnalyzer(MockTokenizer.SIMPLE, true));
// Danish collation orders the words below in the given order
diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java b/lucene/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java
index faea2f40220..cabde91122c 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java
@@ -24,14 +24,14 @@ import org.apache.lucene.document.*;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.TermFreqVector;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.English;
import java.io.IOException;
import java.util.Random;
public class TestMultiThreadTermVectors extends LuceneTestCase {
- private MockRAMDirectory directory;
+ private Directory directory;
public int numDocs = 100;
public int numThreads = 3;
diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java b/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
index c5cbb898d8d..c2185b0240e 100644
--- a/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
@@ -27,7 +27,7 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
public class TestMultiValuedNumericRangeQuery extends LuceneTestCase {
@@ -40,7 +40,7 @@ public class TestMultiValuedNumericRangeQuery extends LuceneTestCase {
public void testMultiValuedNRQ() throws Exception {
final Random rnd = newRandom();
- MockRAMDirectory directory = newDirectory(rnd);
+ Directory directory = newDirectory(rnd);
RandomIndexWriter writer = new RandomIndexWriter(rnd, directory);
DecimalFormat format = new DecimalFormat("00000000000", new DecimalFormatSymbols(Locale.US));
diff --git a/lucene/src/test/org/apache/lucene/search/TestNot.java b/lucene/src/test/org/apache/lucene/search/TestNot.java
index 9f56a40b14c..26b7f252bf3 100644
--- a/lucene/src/test/org/apache/lucene/search/TestNot.java
+++ b/lucene/src/test/org/apache/lucene/search/TestNot.java
@@ -24,7 +24,7 @@ import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -41,7 +41,7 @@ public class TestNot extends LuceneTestCase {
public void testNot() throws Exception {
Random random = newRandom();
- MockRAMDirectory store = newDirectory(random);
+ Directory store = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, store);
Document d1 = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
index 4e14de0331c..762fcbaa6ea 100644
--- a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
+++ b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
@@ -28,7 +28,7 @@ import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCaseJ4;
import org.apache.lucene.util.NumericUtils;
@@ -46,7 +46,7 @@ public class TestNumericRangeQuery32 extends LuceneTestCaseJ4 {
// number of docs to generate for testing
private static final int noDocs = 10000 * RANDOM_MULTIPLIER;
- private static MockRAMDirectory directory = null;
+ private static Directory directory = null;
private static IndexReader reader = null;
private static IndexSearcher searcher = null;
private static Random random = null;
@@ -281,7 +281,7 @@ public class TestNumericRangeQuery32 extends LuceneTestCaseJ4 {
@Test
public void testInfiniteValues() throws Exception {
- MockRAMDirectory dir = newDirectory(random);
+ Directory dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new NumericField("float").setFloatValue(Float.NEGATIVE_INFINITY));
diff --git a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
index d7c83e38186..a5464078d48 100644
--- a/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
+++ b/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
@@ -27,7 +27,7 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCaseJ4;
import org.apache.lucene.util.NumericUtils;
@@ -45,7 +45,7 @@ public class TestNumericRangeQuery64 extends LuceneTestCaseJ4 {
// number of docs to generate for testing
private static final int noDocs = 10000 * RANDOM_MULTIPLIER;
- private static MockRAMDirectory directory = null;
+ private static Directory directory = null;
private static IndexReader reader = null;
private static IndexSearcher searcher = null;
private static Random random = null;
@@ -299,7 +299,7 @@ public class TestNumericRangeQuery64 extends LuceneTestCaseJ4 {
@Test
public void testInfiniteValues() throws Exception {
- MockRAMDirectory dir = newDirectory(random);
+ Directory dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java b/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
index 37823d2b2cf..3ad3d2f684b 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
@@ -26,7 +26,7 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import java.io.IOException;
import java.util.LinkedList;
@@ -45,7 +45,7 @@ public class TestPhrasePrefixQuery extends LuceneTestCase {
*/
public void testPhrasePrefix() throws IOException {
Random random = newRandom();
- MockRAMDirectory indexStore = newDirectory(random);
+ Directory indexStore = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, indexStore);
Document doc1 = new Document();
Document doc2 = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java b/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
index c3da70c9766..9ff91630df6 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
@@ -48,7 +48,7 @@ public class TestPhraseQuery extends LuceneTestCase {
private IndexSearcher searcher;
private IndexReader reader;
private PhraseQuery query;
- private MockRAMDirectory directory;
+ private Directory directory;
private Random random;
@Override
@@ -213,7 +213,7 @@ public class TestPhraseQuery extends LuceneTestCase {
}
public void testPhraseQueryWithStopAnalyzer() throws Exception {
- MockRAMDirectory directory = newDirectory(random);
+ Directory directory = newDirectory(random);
Analyzer stopAnalyzer = new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, false);
RandomIndexWriter writer = new RandomIndexWriter(random, directory,
newIndexWriterConfig(random, Version.LUCENE_24, stopAnalyzer));
@@ -249,7 +249,7 @@ public class TestPhraseQuery extends LuceneTestCase {
}
public void testPhraseQueryInConjunctionScorer() throws Exception {
- MockRAMDirectory directory = newDirectory(random);
+ Directory directory = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, directory);
Document doc = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java b/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
index bd0c0890f9c..35437d310ae 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
@@ -40,7 +40,6 @@ import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.SlowMultiReaderWrapper;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.index.Payload;
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java b/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
index 4368c5cdaf0..a4f092cf084 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
@@ -20,7 +20,7 @@ package org.apache.lucene.search;
import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
@@ -34,7 +34,7 @@ import org.apache.lucene.document.Field;
public class TestPrefixFilter extends LuceneTestCase {
public void testPrefixFilter() throws Exception {
Random random = newRandom();
- MockRAMDirectory directory = newDirectory(random);
+ Directory directory = newDirectory(random);
String[] categories = new String[] {"/Computers/Linux",
"/Computers/Mac/One",
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java b/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
index 0bd4214f7b4..8e1b3e62f9b 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
@@ -25,7 +25,7 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
/**
* https://issues.apache.org/jira/browse/LUCENE-1974
@@ -40,7 +40,7 @@ import org.apache.lucene.store.MockRAMDirectory;
public class TestPrefixInBooleanQuery extends LuceneTestCase {
private static final String FIELD = "name";
- private MockRAMDirectory directory;
+ private Directory directory;
private IndexReader reader;
private IndexSearcher searcher;
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java b/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
index 67228ce1cf2..d0e5d21bd38 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
@@ -19,8 +19,8 @@ package org.apache.lucene.search;
import java.util.Random;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
@@ -34,7 +34,7 @@ import org.apache.lucene.document.Field;
public class TestPrefixQuery extends LuceneTestCase {
public void testPrefixQuery() throws Exception {
Random random = newRandom();
- MockRAMDirectory directory = newDirectory(random);
+ Directory directory = newDirectory(random);
String[] categories = new String[] {"/Computers",
"/Computers/Mac",
diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java b/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java
index 6dfd43947e2..4505e69504a 100644
--- a/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java
+++ b/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java
@@ -29,7 +29,6 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
index 75fc6884fa7..ccf045ce085 100644
--- a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
+++ b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
@@ -29,7 +29,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**
diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
index cea476eb1d1..d1487938082 100644
--- a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
+++ b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
@@ -32,7 +32,6 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.UnicodeUtil;
diff --git a/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java b/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java
index cb87b4861e4..77eba4ac652 100755
--- a/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java
+++ b/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java
@@ -9,10 +9,8 @@ import java.io.IOException;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
diff --git a/lucene/src/test/org/apache/lucene/search/TestSetNorm.java b/lucene/src/test/org/apache/lucene/search/TestSetNorm.java
index 3581342274e..165f2851349 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSetNorm.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSetNorm.java
@@ -25,9 +25,8 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.*;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
/** Document boost unit test.
*
@@ -41,7 +40,7 @@ public class TestSetNorm extends LuceneTestCase {
public void testSetNorm() throws Exception {
Random random = newRandom();
- MockRAMDirectory store = newDirectory(random);
+ Directory store = newDirectory(random);
IndexWriter writer = new IndexWriter(store, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
// add the same document four times
diff --git a/lucene/src/test/org/apache/lucene/search/TestSimilarity.java b/lucene/src/test/org/apache/lucene/search/TestSimilarity.java
index cfa18285972..9aee8db5d95 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSimilarity.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSimilarity.java
@@ -23,11 +23,9 @@ import java.util.Collection;
import java.util.Random;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -66,7 +64,7 @@ public class TestSimilarity extends LuceneTestCase {
public void testSimilarity() throws Exception {
Random random = newRandom();
- MockRAMDirectory store = newDirectory(random);
+ Directory store = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, store,
newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
.setSimilarity(new SimpleSimilarity()));
diff --git a/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java b/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java
index ab08f89b93a..60dc170297b 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSimpleExplanations.java
@@ -17,20 +17,16 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import java.util.Random;
-
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.spans.SpanNearQuery;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
/**
diff --git a/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java b/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java
index 33c0c982bf0..f975a8acabb 100755
--- a/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java
@@ -29,7 +29,7 @@ import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.PhraseQuery;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
public class TestSloppyPhraseQuery extends LuceneTestCase {
@@ -125,7 +125,7 @@ public class TestSloppyPhraseQuery extends LuceneTestCase {
private float checkPhraseQuery(Document doc, PhraseQuery query, int slop, int expectedNumResults) throws Exception {
query.setSlop(slop);
- MockRAMDirectory ramDir = newDirectory(random);
+ Directory ramDir = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, ramDir, new MockAnalyzer(MockTokenizer.WHITESPACE, false));
writer.addDocument(doc);
diff --git a/lucene/src/test/org/apache/lucene/search/TestSort.java b/lucene/src/test/org/apache/lucene/search/TestSort.java
index 9503a396716..2e4b315162a 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSort.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSort.java
@@ -44,7 +44,6 @@ import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.FieldValueHitQueue.Entry;
import org.apache.lucene.store.LockObtainFailedException;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.DocIdBitSet;
import org.apache.lucene.util.LuceneTestCase;
@@ -110,7 +109,7 @@ public class TestSort extends LuceneTestCase implements Serializable {
// create an index of all the documents, or just the x, or just the y documents
private IndexSearcher getIndex (boolean even, boolean odd)
throws IOException {
- MockRAMDirectory indexStore = newDirectory(random);
+ Directory indexStore = newDirectory(random);
dirs.add(indexStore);
RandomIndexWriter writer = new RandomIndexWriter(random, indexStore);
@@ -146,7 +145,7 @@ public class TestSort extends LuceneTestCase implements Serializable {
}
private IndexSearcher getFullStrings() throws CorruptIndexException, LockObtainFailedException, IOException {
- MockRAMDirectory indexStore = newDirectory (random);
+ Directory indexStore = newDirectory (random);
dirs.add(indexStore);
IndexWriter writer = new IndexWriter(indexStore, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(4));
@@ -1057,7 +1056,7 @@ public class TestSort extends LuceneTestCase implements Serializable {
}
public void testLUCENE2142() throws IOException {
- MockRAMDirectory indexStore = newDirectory (random);
+ Directory indexStore = newDirectory (random);
IndexWriter writer = new IndexWriter(indexStore, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i=0; i<5; i++) {
diff --git a/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java b/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
index ebbcf375d83..2fbc9fcc01e 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
@@ -26,7 +26,7 @@ import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
/**
* A basic 'positive' Unit test class for the TermRangeFilter class.
@@ -398,7 +398,7 @@ public class TestTermRangeFilter extends BaseTestRangeFilter {
public void testFarsi() throws Exception {
/* build an index */
- MockRAMDirectory farsiIndex = newDirectory(rand);
+ Directory farsiIndex = newDirectory(rand);
RandomIndexWriter writer = new RandomIndexWriter(rand, farsiIndex);
Document doc = new Document();
doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES,
@@ -438,7 +438,7 @@ public class TestTermRangeFilter extends BaseTestRangeFilter {
public void testDanish() throws Exception {
/* build an index */
- MockRAMDirectory danishIndex = newDirectory(rand);
+ Directory danishIndex = newDirectory(rand);
RandomIndexWriter writer = new RandomIndexWriter(rand, danishIndex);
// Danish collation orders the words below in the given order
// (example taken from TestSort.testInternationalSort() ).
diff --git a/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java b/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
index 0afbe66a91a..e8d880dc9de 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTermRangeQuery.java
@@ -21,7 +21,7 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -43,7 +43,7 @@ import java.text.Collator;
public class TestTermRangeQuery extends LuceneTestCase {
private int docCount = 0;
- private MockRAMDirectory dir;
+ private Directory dir;
private Random random;
@Override
diff --git a/lucene/src/test/org/apache/lucene/search/TestTermScorer.java b/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
index fbcf58cbe75..0780f35a610 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
@@ -29,10 +29,10 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.SlowMultiReaderWrapper;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
public class TestTermScorer extends LuceneTestCase {
- protected MockRAMDirectory directory;
+ protected Directory directory;
private static final String FIELD = "field";
protected String[] values = new String[] {"all", "dogs dogs", "like",
diff --git a/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java b/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
index be29841d866..2609e4bf600 100644
--- a/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
+++ b/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
@@ -29,7 +29,6 @@ import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.TimeLimitingCollector.TimeExceededException;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.ThreadInterruptedException;
diff --git a/lucene/src/test/org/apache/lucene/search/TestWildcard.java b/lucene/src/test/org/apache/lucene/search/TestWildcard.java
index 99e08b1634f..526c99528d6 100644
--- a/lucene/src/test/org/apache/lucene/search/TestWildcard.java
+++ b/lucene/src/test/org/apache/lucene/search/TestWildcard.java
@@ -17,6 +17,7 @@ package org.apache.lucene.search;
* limitations under the License.
*/
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -26,7 +27,6 @@ import org.apache.lucene.document.Field.Index;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.store.MockRAMDirectory;
import java.io.IOException;
import java.util.Random;
@@ -70,7 +70,7 @@ public class TestWildcard
* a ConstantScoreQuery if the WildcardQuery had a ConstantScore rewriteMethod.
*/
public void testTermWithoutWildcard() throws IOException {
- MockRAMDirectory indexStore = getIndexStore("field", new String[]{"nowildcard", "nowildcardx"});
+ Directory indexStore = getIndexStore("field", new String[]{"nowildcard", "nowildcardx"});
IndexSearcher searcher = new IndexSearcher(indexStore, true);
MultiTermQuery wq = new WildcardQuery(new Term("field", "nowildcard"));
@@ -107,7 +107,7 @@ public class TestWildcard
* Tests if a WildcardQuery with an empty term is rewritten to an empty BooleanQuery
*/
public void testEmptyTerm() throws IOException {
- MockRAMDirectory indexStore = getIndexStore("field", new String[]{"nowildcard", "nowildcardx"});
+ Directory indexStore = getIndexStore("field", new String[]{"nowildcard", "nowildcardx"});
IndexSearcher searcher = new IndexSearcher(indexStore, true);
MultiTermQuery wq = new WildcardQuery(new Term("field", ""));
@@ -126,7 +126,7 @@ public class TestWildcard
* preserved.
*/
public void testPrefixTerm() throws IOException {
- MockRAMDirectory indexStore = getIndexStore("field", new String[]{"prefix", "prefixx"});
+ Directory indexStore = getIndexStore("field", new String[]{"prefix", "prefixx"});
IndexSearcher searcher = new IndexSearcher(indexStore, true);
MultiTermQuery wq = new WildcardQuery(new Term("field", "prefix*"));
@@ -147,7 +147,7 @@ public class TestWildcard
*/
public void testAsterisk()
throws IOException {
- MockRAMDirectory indexStore = getIndexStore("body", new String[]
+ Directory indexStore = getIndexStore("body", new String[]
{"metal", "metals"});
IndexSearcher searcher = new IndexSearcher(indexStore, true);
Query query1 = new TermQuery(new Term("body", "metal"));
@@ -188,7 +188,7 @@ public class TestWildcard
*/
public void testQuestionmark()
throws IOException {
- MockRAMDirectory indexStore = getIndexStore("body", new String[]
+ Directory indexStore = getIndexStore("body", new String[]
{"metal", "metals", "mXtals", "mXtXls"});
IndexSearcher searcher = new IndexSearcher(indexStore, true);
Query query1 = new WildcardQuery(new Term("body", "m?tal"));
@@ -208,9 +208,9 @@ public class TestWildcard
indexStore.close();
}
- private MockRAMDirectory getIndexStore(String field, String[] contents)
+ private Directory getIndexStore(String field, String[] contents)
throws IOException {
- MockRAMDirectory indexStore = newDirectory(random);
+ Directory indexStore = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, indexStore);
for (int i = 0; i < contents.length; ++i) {
Document doc = new Document();
@@ -266,7 +266,7 @@ public class TestWildcard
};
// prepare the index
- MockRAMDirectory dir = newDirectory(random);
+ Directory dir = newDirectory(random);
RandomIndexWriter iw = new RandomIndexWriter(random, dir);
for (int i = 0; i < docs.length; i++) {
Document doc = new Document();
diff --git a/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java b/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java
index 09e08deebba..a6ac1573292 100644
--- a/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java
+++ b/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java
@@ -29,7 +29,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**
diff --git a/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java b/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
index 2705fa6a26f..e2c655ed8d8 100644
--- a/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
+++ b/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
@@ -22,7 +22,6 @@ import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Payload;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.util.English;
@@ -30,6 +29,10 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.SlowMultiReaderWrapper;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Similarity;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.store.RAMDirectory;
+
import static org.apache.lucene.util.LuceneTestCaseJ4.TEST_VERSION_CURRENT;
import java.io.Reader;
@@ -109,7 +112,7 @@ public class PayloadHelper {
*/
// TODO: randomize
public IndexSearcher setUp(Similarity similarity, int numDocs) throws IOException {
- MockRAMDirectory directory = new MockRAMDirectory();
+ Directory directory = new MockDirectoryWrapper(new RAMDirectory());
PayloadAnalyzer analyzer = new PayloadAnalyzer();
// TODO randomize this
diff --git a/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java b/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
index f6b8b3d5faf..bb1d4ac37a8 100644
--- a/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
@@ -39,7 +39,7 @@ import org.apache.lucene.index.Payload;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.SlowMultiReaderWrapper;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -59,7 +59,7 @@ public class TestPayloadTermQuery extends LuceneTestCase {
private byte[] payloadField = new byte[]{1};
private byte[] payloadMultiField1 = new byte[]{2};
private byte[] payloadMultiField2 = new byte[]{4};
- protected MockRAMDirectory directory;
+ protected Directory directory;
public TestPayloadTermQuery(String s) {
super(s);
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java b/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java
index ee20850ecbe..c51c00dc970 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java
@@ -37,7 +37,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryUtils;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.English;
import org.apache.lucene.util.LuceneTestCase;
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java b/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
index 355dbddd1b0..57f5905bd12 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
@@ -48,7 +48,6 @@ import org.apache.lucene.search.payloads.PayloadHelper;
import org.apache.lucene.search.payloads.PayloadSpanUtil;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
-import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public class TestPayloadSpans extends LuceneTestCase {
@@ -117,7 +116,7 @@ public class TestPayloadSpans extends LuceneTestCase {
- MockRAMDirectory directory = newDirectory(rand);
+ Directory directory = newDirectory(rand);
RandomIndexWriter writer = new RandomIndexWriter(rand, directory,
newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new PayloadAnalyzer()).setSimilarity(similarity));
@@ -261,7 +260,7 @@ public class TestPayloadSpans extends LuceneTestCase {
public void testShrinkToAfterShortestMatch() throws CorruptIndexException,
LockObtainFailedException, IOException {
- MockRAMDirectory directory = newDirectory(rand);
+ Directory directory = newDirectory(rand);
RandomIndexWriter writer = new RandomIndexWriter(rand, directory,
newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new TestPayloadAnalyzer()));
@@ -299,7 +298,7 @@ public class TestPayloadSpans extends LuceneTestCase {
public void testShrinkToAfterShortestMatch2() throws CorruptIndexException,
LockObtainFailedException, IOException {
- MockRAMDirectory directory = newDirectory(rand);
+ Directory directory = newDirectory(rand);
RandomIndexWriter writer = new RandomIndexWriter(rand, directory,
newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new TestPayloadAnalyzer()));
@@ -335,7 +334,7 @@ public class TestPayloadSpans extends LuceneTestCase {
public void testShrinkToAfterShortestMatch3() throws CorruptIndexException,
LockObtainFailedException, IOException {
- MockRAMDirectory directory = newDirectory(rand);
+ Directory directory = newDirectory(rand);
RandomIndexWriter writer = new RandomIndexWriter(rand, directory,
newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new TestPayloadAnalyzer()));
@@ -376,7 +375,7 @@ public class TestPayloadSpans extends LuceneTestCase {
}
public void testPayloadSpanUtil() throws Exception {
- MockRAMDirectory directory = newDirectory(rand);
+ Directory directory = newDirectory(rand);
RandomIndexWriter writer = new RandomIndexWriter(rand, directory,
newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new PayloadAnalyzer()).setSimilarity(similarity));
diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java b/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
index 21cac58aa69..cd658988535 100644
--- a/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
+++ b/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
@@ -32,7 +32,6 @@ import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.*;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
/*******************************************************************************
* Tests the span query bug in Lucene. It demonstrates that SpanTermQuerys don't
diff --git a/lucene/src/test/org/apache/lucene/store/MockRAMDirectory.java b/lucene/src/test/org/apache/lucene/store/MockDirectoryWrapper.java
similarity index 62%
rename from lucene/src/test/org/apache/lucene/store/MockRAMDirectory.java
rename to lucene/src/test/org/apache/lucene/store/MockDirectoryWrapper.java
index 1853caba44c..918ea315af9 100644
--- a/lucene/src/test/org/apache/lucene/store/MockRAMDirectory.java
+++ b/lucene/src/test/org/apache/lucene/store/MockDirectoryWrapper.java
@@ -31,11 +31,12 @@ import java.util.ArrayList;
import java.util.Arrays;
/**
- * This is a subclass of RAMDirectory that adds methods
+ * This is a Directory Wrapper that adds methods
* intended to be used only by unit tests.
*/
-public class MockRAMDirectory extends RAMDirectory {
+public class MockDirectoryWrapper extends Directory {
+ final Directory delegate;
long maxSize;
// Max actual bytes used. This is set by MockRAMOutputStream:
@@ -63,12 +64,8 @@ public class MockRAMDirectory extends RAMDirectory {
unSyncedFiles = new HashSet();
}
- public MockRAMDirectory() {
- super();
- init();
- }
- public MockRAMDirectory(Directory dir) throws IOException {
- super(dir);
+ public MockDirectoryWrapper(Directory delegate) {
+ this.delegate = delegate;
init();
}
@@ -81,7 +78,11 @@ public class MockRAMDirectory extends RAMDirectory {
@Deprecated
@Override
public void sync(String name) throws IOException {
- sync(Collections.singleton(name));
+ maybeThrowDeterministicException();
+ if (crashed)
+ throw new IOException("cannot sync after crash");
+ unSyncedFiles.remove(name);
+ delegate.sync(name);
}
@Override
@@ -91,6 +92,19 @@ public class MockRAMDirectory extends RAMDirectory {
if (crashed)
throw new IOException("cannot sync after crash");
unSyncedFiles.removeAll(names);
+ delegate.sync(names);
+ }
+
+ public synchronized final long sizeInBytes() throws IOException {
+ if (delegate instanceof RAMDirectory)
+ return ((RAMDirectory) delegate).sizeInBytes();
+ else {
+ // hack
+ long size = 0;
+ for (String file : delegate.listAll())
+ size += delegate.fileLength(file);
+ return size;
+ }
}
/** Simulates a crash of OS or machine by overwriting
@@ -101,23 +115,52 @@ public class MockRAMDirectory extends RAMDirectory {
Iterator it = unSyncedFiles.iterator();
unSyncedFiles = new HashSet();
int count = 0;
- while(it.hasNext()) {
- String name = it.next();
- RAMFile file = fileMap.get(name);
- if (count % 3 == 0) {
- deleteFile(name, true);
- } else if (count % 3 == 1) {
- // Zero out file entirely
- final int numBuffers = file.numBuffers();
- for(int i=0;i();
}
@@ -282,6 +333,7 @@ public class MockRAMDirectory extends RAMDirectory {
throw new RuntimeException("MockRAMDirectory: cannot close: there are still open files: " + openFiles);
}
open = false;
+ delegate.close();
}
boolean open = true;
@@ -300,7 +352,7 @@ public class MockRAMDirectory extends RAMDirectory {
/**
* eval is called on the first write of every new file.
*/
- public void eval(MockRAMDirectory dir) throws IOException { }
+ public void eval(MockDirectoryWrapper dir) throws IOException { }
/**
* reset should set the state of the failure to its default
@@ -353,5 +405,58 @@ public class MockRAMDirectory extends RAMDirectory {
}
}
+ @Override
+ public synchronized String[] listAll() throws IOException {
+ return delegate.listAll();
+ }
+ @Override
+ public synchronized boolean fileExists(String name) throws IOException {
+ return delegate.fileExists(name);
+ }
+
+ @Override
+ public synchronized long fileModified(String name) throws IOException {
+ return delegate.fileModified(name);
+ }
+
+ @Override
+ public synchronized void touchFile(String name) throws IOException {
+ delegate.touchFile(name);
+ }
+
+ @Override
+ public synchronized long fileLength(String name) throws IOException {
+ return delegate.fileLength(name);
+ }
+
+ @Override
+ public synchronized Lock makeLock(String name) {
+ return delegate.makeLock(name);
+ }
+
+ @Override
+ public synchronized void clearLock(String name) throws IOException {
+ delegate.clearLock(name);
+ }
+
+ @Override
+ public synchronized void setLockFactory(LockFactory lockFactory) {
+ delegate.setLockFactory(lockFactory);
+ }
+
+ @Override
+ public synchronized LockFactory getLockFactory() {
+ return delegate.getLockFactory();
+ }
+
+ @Override
+ public synchronized String getLockID() {
+ return delegate.getLockID();
+ }
+
+ @Override
+ public synchronized void copy(Directory to, String src, String dest) throws IOException {
+ delegate.copy(to, src, dest);
+ }
}
diff --git a/lucene/src/test/org/apache/lucene/store/MockRAMInputStream.java b/lucene/src/test/org/apache/lucene/store/MockIndexInputWrapper.java
similarity index 52%
rename from lucene/src/test/org/apache/lucene/store/MockRAMInputStream.java
rename to lucene/src/test/org/apache/lucene/store/MockIndexInputWrapper.java
index b7606c94f15..b81c8ac432f 100644
--- a/lucene/src/test/org/apache/lucene/store/MockRAMInputStream.java
+++ b/lucene/src/test/org/apache/lucene/store/MockIndexInputWrapper.java
@@ -1,6 +1,7 @@
package org.apache.lucene.store;
import java.io.IOException;
+import java.util.Map;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,26 +21,27 @@ import java.io.IOException;
*/
/**
- * Used by MockRAMDirectory to create an input stream that
+ * Used by MockDirectoryWrapper to create an input stream that
* keeps track of when it's been closed.
*/
-public class MockRAMInputStream extends RAMInputStream {
- private MockRAMDirectory dir;
+public class MockIndexInputWrapper extends IndexInput {
+ private MockDirectoryWrapper dir;
private String name;
+ private IndexInput delegate;
private boolean isClone;
/** Construct an empty output buffer.
* @throws IOException */
- public MockRAMInputStream(MockRAMDirectory dir, String name, RAMFile f) throws IOException {
- super(f);
+ public MockIndexInputWrapper(MockDirectoryWrapper dir, String name, IndexInput delegate) {
this.name = name;
this.dir = dir;
+ this.delegate = delegate;
}
@Override
- public void close() {
- super.close();
+ public void close() throws IOException {
+ delegate.close();
// Pending resolution on LUCENE-686 we may want to
// remove the conditional check so we also track that
// all clones get closed:
@@ -61,7 +63,8 @@ public class MockRAMInputStream extends RAMInputStream {
@Override
public Object clone() {
- MockRAMInputStream clone = (MockRAMInputStream) super.clone();
+ IndexInput iiclone = (IndexInput) delegate.clone();
+ MockIndexInputWrapper clone = new MockIndexInputWrapper(dir, name, iiclone);
clone.isClone = true;
// Pending resolution on LUCENE-686 we may want to
// uncomment this code so that we also track that all
@@ -79,4 +82,75 @@ public class MockRAMInputStream extends RAMInputStream {
*/
return clone;
}
+
+ @Override
+ public long getFilePointer() {
+ return delegate.getFilePointer();
+ }
+
+ @Override
+ public void seek(long pos) throws IOException {
+ delegate.seek(pos);
+ }
+
+ @Override
+ public long length() {
+ return delegate.length();
+ }
+
+ @Override
+ public byte readByte() throws IOException {
+ return delegate.readByte();
+ }
+
+ @Override
+ public void readBytes(byte[] b, int offset, int len) throws IOException {
+ delegate.readBytes(b, offset, len);
+ }
+
+ @Override
+ public void copyBytes(IndexOutput out, long numBytes) throws IOException {
+ delegate.copyBytes(out, numBytes);
+ }
+
+ @Override
+ public void readBytes(byte[] b, int offset, int len, boolean useBuffer)
+ throws IOException {
+ delegate.readBytes(b, offset, len, useBuffer);
+ }
+
+ @Override
+ public short readShort() throws IOException {
+ return delegate.readShort();
+ }
+
+ @Override
+ public int readInt() throws IOException {
+ return delegate.readInt();
+ }
+
+ @Override
+ public int readVInt() throws IOException {
+ return delegate.readVInt();
+ }
+
+ @Override
+ public long readLong() throws IOException {
+ return delegate.readLong();
+ }
+
+ @Override
+ public long readVLong() throws IOException {
+ return delegate.readVLong();
+ }
+
+ @Override
+ public String readString() throws IOException {
+ return delegate.readString();
+ }
+
+ @Override
+ public Map readStringStringMap() throws IOException {
+ return delegate.readStringStringMap();
+ }
}
diff --git a/lucene/src/test/org/apache/lucene/store/MockRAMOutputStream.java b/lucene/src/test/org/apache/lucene/store/MockIndexOutputWrapper.java
similarity index 56%
rename from lucene/src/test/org/apache/lucene/store/MockRAMOutputStream.java
rename to lucene/src/test/org/apache/lucene/store/MockIndexOutputWrapper.java
index 74ac8a7b422..ef99801d574 100644
--- a/lucene/src/test/org/apache/lucene/store/MockRAMOutputStream.java
+++ b/lucene/src/test/org/apache/lucene/store/MockIndexOutputWrapper.java
@@ -18,6 +18,7 @@ package org.apache.lucene.store;
*/
import java.io.IOException;
+import java.util.Map;
/**
* Used by MockRAMDirectory to create an output stream that
@@ -26,26 +27,27 @@ import java.io.IOException;
* IOExceptions.
*/
-public class MockRAMOutputStream extends RAMOutputStream {
- private MockRAMDirectory dir;
+public class MockIndexOutputWrapper extends IndexOutput {
+ private MockDirectoryWrapper dir;
+ private final IndexOutput delegate;
private boolean first=true;
private final String name;
byte[] singleByte = new byte[1];
/** Construct an empty output buffer. */
- public MockRAMOutputStream(MockRAMDirectory dir, RAMFile f, String name) {
- super(f);
+ public MockIndexOutputWrapper(MockDirectoryWrapper dir, IndexOutput delegate, String name) {
this.dir = dir;
this.name = name;
+ this.delegate = delegate;
}
@Override
public void close() throws IOException {
- super.close();
-
+ dir.maybeThrowDeterministicException();
+ delegate.close();
// Now compute actual disk usage & track the maxUsedSize
- // in the MockRAMDirectory:
+ // in the MockDirectoryWrapper:
long size = dir.getRecomputedActualSizeInBytes();
if (size > dir.maxUsedSize) {
dir.maxUsedSize = size;
@@ -55,7 +57,7 @@ public class MockRAMOutputStream extends RAMOutputStream {
@Override
public void flush() throws IOException {
dir.maybeThrowDeterministicException();
- super.flush();
+ delegate.flush();
}
@Override
@@ -66,7 +68,7 @@ public class MockRAMOutputStream extends RAMOutputStream {
@Override
public void writeBytes(byte[] b, int offset, int len) throws IOException {
- long freeSpace = dir.maxSize - dir.sizeInBytes();
+ long freeSpace = dir.maxSize == 0 ? 0 : dir.maxSize - dir.sizeInBytes();
long realUsage = 0;
// If MockRAMDir crashed since we were opened, then
@@ -85,14 +87,14 @@ public class MockRAMOutputStream extends RAMOutputStream {
if (dir.maxSize != 0 && freeSpace <= len) {
if (freeSpace > 0 && freeSpace < len) {
realUsage += freeSpace;
- super.writeBytes(b, offset, (int) freeSpace);
+ delegate.writeBytes(b, offset, (int) freeSpace);
}
if (realUsage > dir.maxUsedSize) {
dir.maxUsedSize = realUsage;
}
throw new IOException("fake disk full at " + dir.getRecomputedActualSizeInBytes() + " bytes when writing " + name);
} else {
- super.writeBytes(b, offset, len);
+ delegate.writeBytes(b, offset, len);
}
dir.maybeThrowDeterministicException();
@@ -104,4 +106,78 @@ public class MockRAMOutputStream extends RAMOutputStream {
dir.maybeThrowIOException();
}
}
+
+ @Override
+ public long getFilePointer() {
+ return delegate.getFilePointer();
+ }
+
+ @Override
+ public void seek(long pos) throws IOException {
+ delegate.seek(pos);
+ }
+
+ @Override
+ public long length() throws IOException {
+ return delegate.length();
+ }
+
+ @Override
+ public void setLength(long length) throws IOException {
+ delegate.setLength(length);
+ }
+
+ /*
+ @Override
+ public void writeBytes(byte[] b, int length) throws IOException {
+ delegate.writeBytes(b, length);
+ }
+
+ @Override
+ public void writeInt(int i) throws IOException {
+ delegate.writeInt(i);
+ }
+
+ @Override
+ public void writeVInt(int i) throws IOException {
+ delegate.writeVInt(i);
+ }
+
+ @Override
+ public void writeLong(long i) throws IOException {
+ delegate.writeLong(i);
+ }
+
+ @Override
+ public void writeVLong(long i) throws IOException {
+ delegate.writeVLong(i);
+ }
+
+ @Override
+ public void writeString(String s) throws IOException {
+ delegate.writeString(s);
+ }
+
+ @Override
+ public void writeChars(String s, int start, int length) throws IOException {
+ delegate.writeChars(s, start, length);
+ }
+
+ @Override
+ public void writeChars(char[] s, int start, int length) throws IOException {
+ delegate.writeChars(s, start, length);
+ }
+
+ @Override
+ public void writeStringStringMap(Map map) throws IOException {
+ delegate.writeStringStringMap(map);
+ }
+ */
+
+ @Override
+ public void copyBytes(DataInput input, long numBytes) throws IOException {
+ delegate.copyBytes(input, numBytes);
+ // TODO: we may need to check disk full here as well
+ dir.maybeThrowDeterministicException();
+ }
}
diff --git a/lucene/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java b/lucene/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
index 61752677298..ce21cc36726 100644
--- a/lucene/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
+++ b/lucene/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
@@ -40,8 +40,8 @@ public class TestFileSwitchDirectory extends LuceneTestCase {
fileExtensions.add(IndexFileNames.FIELDS_EXTENSION);
fileExtensions.add(IndexFileNames.FIELDS_INDEX_EXTENSION);
- Directory primaryDir = new MockRAMDirectory();
- RAMDirectory secondaryDir = new MockRAMDirectory();
+ Directory primaryDir = new MockDirectoryWrapper(new RAMDirectory());
+ Directory secondaryDir = new MockDirectoryWrapper(new RAMDirectory());
FileSwitchDirectory fsd = new FileSwitchDirectory(fileExtensions, primaryDir, secondaryDir, true);
IndexWriter writer = new IndexWriter(fsd, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
diff --git a/lucene/src/test/org/apache/lucene/store/TestLockFactory.java b/lucene/src/test/org/apache/lucene/store/TestLockFactory.java
index 58afe52a3ee..e3a341808ed 100755
--- a/lucene/src/test/org/apache/lucene/store/TestLockFactory.java
+++ b/lucene/src/test/org/apache/lucene/store/TestLockFactory.java
@@ -42,7 +42,7 @@ public class TestLockFactory extends LuceneTestCase {
// methods are called at the right time, locks are created, etc.
public void testCustomLockFactory() throws IOException {
- Directory dir = new MockRAMDirectory();
+ Directory dir = new MockDirectoryWrapper(new RAMDirectory());
MockLockFactory lf = new MockLockFactory();
dir.setLockFactory(lf);
@@ -75,7 +75,7 @@ public class TestLockFactory extends LuceneTestCase {
// exceptions raised:
// Verify: NoLockFactory allows two IndexWriters
public void testRAMDirectoryNoLocking() throws IOException {
- Directory dir = new MockRAMDirectory();
+ Directory dir = new MockDirectoryWrapper(new RAMDirectory());
dir.setLockFactory(NoLockFactory.getNoLockFactory());
assertTrue("RAMDirectory.setLockFactory did not take",
@@ -102,7 +102,7 @@ public class TestLockFactory extends LuceneTestCase {
// Verify: SingleInstanceLockFactory is the default lock for RAMDirectory
// Verify: RAMDirectory does basic locking correctly (can't create two IndexWriters)
public void testDefaultRAMDirectory() throws IOException {
- Directory dir = new MockRAMDirectory();
+ Directory dir = new RAMDirectory();
assertTrue("RAMDirectory did not use correct LockFactory: got " + dir.getLockFactory(),
SingleInstanceLockFactory.class.isInstance(dir.getLockFactory()));
diff --git a/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java b/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java
index 86a2966c8ef..85ebb5c3775 100644
--- a/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java
+++ b/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java
@@ -69,7 +69,7 @@ public class TestRAMDirectory extends LuceneTestCase {
public void testRAMDirectory () throws IOException {
Directory dir = FSDirectory.open(indexDir);
- MockRAMDirectory ramDir = new MockRAMDirectory(dir);
+ MockDirectoryWrapper ramDir = new MockDirectoryWrapper(new RAMDirectory(dir));
// close the underlaying directory
dir.close();
@@ -101,7 +101,7 @@ public class TestRAMDirectory extends LuceneTestCase {
public void testRAMDirectorySize() throws IOException, InterruptedException {
Directory dir = FSDirectory.open(indexDir);
- final MockRAMDirectory ramDir = new MockRAMDirectory(dir);
+ final MockDirectoryWrapper ramDir = new MockDirectoryWrapper(new RAMDirectory(dir));
dir.close();
final IndexWriter writer = new IndexWriter(ramDir, new IndexWriterConfig(
diff --git a/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java b/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
index 6b6eeacea37..ec6f2c8c8e5 100644
--- a/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
+++ b/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
@@ -42,7 +42,9 @@ import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.FieldCache.CacheEntry;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
/**
@@ -84,6 +86,8 @@ public abstract class LuceneTestCase extends TestCase {
static final String TEST_LOCALE = LuceneTestCaseJ4.TEST_LOCALE;
/** Gets the timezone to run tests with */
static final String TEST_TIMEZONE = LuceneTestCaseJ4.TEST_TIMEZONE;
+ /** Gets the directory to run tests with */
+ static final String TEST_DIRECTORY = LuceneTestCaseJ4.TEST_DIRECTORY;
/**
* A random multiplier which you should use when writing random tests:
@@ -102,7 +106,7 @@ public abstract class LuceneTestCase extends TestCase {
private TimeZone timeZone;
private TimeZone savedTimeZone;
- private Map stores;
+ private Map stores;
/** Used to track if setUp and tearDown are called correctly from subclasses */
private boolean setup;
@@ -131,7 +135,7 @@ public abstract class LuceneTestCase extends TestCase {
super.setUp();
assertFalse("ensure your tearDown() calls super.tearDown()!!!", setup);
setup = true;
- stores = new IdentityHashMap();
+ stores = new IdentityHashMap();
savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
@@ -211,7 +215,7 @@ public abstract class LuceneTestCase extends TestCase {
}
// now look for unclosed resources
- for (MockRAMDirectory d : stores.keySet()) {
+ for (MockDirectoryWrapper d : stores.keySet()) {
if (d.isOpen()) {
StackTraceElement elements[] = stores.get(d);
StackTraceElement element = (elements.length > 1) ? elements[1] : null;
@@ -329,16 +333,17 @@ public abstract class LuceneTestCase extends TestCase {
return LuceneTestCaseJ4.newIndexWriterConfig(r, v, a);
}
- public MockRAMDirectory newDirectory(Random r) throws IOException {
+ public MockDirectoryWrapper newDirectory(Random r) throws IOException {
StackTraceElement[] stack = new Exception().getStackTrace();
- MockRAMDirectory dir = new MockRAMDirectory();
+ Directory impl = LuceneTestCaseJ4.newDirectoryImpl(TEST_DIRECTORY);
+ MockDirectoryWrapper dir = new MockDirectoryWrapper(impl);
stores.put(dir, stack);
return dir;
}
- public MockRAMDirectory newDirectory(Random r, Directory d) throws IOException {
+ public MockDirectoryWrapper newDirectory(Random r, Directory d) throws IOException {
StackTraceElement[] stack = new Exception().getStackTrace();
- MockRAMDirectory dir = new MockRAMDirectory(d);
+ MockDirectoryWrapper dir = new MockDirectoryWrapper(new RAMDirectory(d));
stores.put(dir, stack);
return dir;
}
diff --git a/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java b/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
index 891807c21ef..4d797c4a903 100644
--- a/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
+++ b/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
@@ -27,7 +27,8 @@ import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.FieldCache.CacheEntry;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.index.codecs.Codec;
@@ -70,6 +71,7 @@ import java.util.WeakHashMap;
import java.util.Collections;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import static org.junit.Assert.assertEquals;
@@ -149,6 +151,8 @@ public class LuceneTestCaseJ4 {
static final String TEST_LOCALE = System.getProperty("tests.locale", "random");
/** Gets the timezone to run tests with */
static final String TEST_TIMEZONE = System.getProperty("tests.timezone", "random");
+ /** Gets the directory to run tests with */
+ static final String TEST_DIRECTORY = System.getProperty("tests.directory", "RAMDirectory");
private static final Pattern codecWithParam = Pattern.compile("(.*)\\(\\s*(\\d+)\\s*\\)");
@@ -190,7 +194,7 @@ public class LuceneTestCaseJ4 {
private static TimeZone timeZone;
private static TimeZone savedTimeZone;
- private static Map stores;
+ private static Map stores;
private static final String[] TEST_CODECS = new String[] {"MockSep", "MockFixedIntBlock", "MockVariableIntBlock"};
@@ -279,7 +283,7 @@ public class LuceneTestCaseJ4 {
@BeforeClass
public static void beforeClassLuceneTestCaseJ4() {
- stores = Collections.synchronizedMap(new IdentityHashMap());
+ stores = Collections.synchronizedMap(new IdentityHashMap());
codec = installTestCodecs();
savedLocale = Locale.getDefault();
locale = TEST_LOCALE.equals("random") ? randomLocale(seedRnd) : localeForName(TEST_LOCALE);
@@ -295,7 +299,7 @@ public class LuceneTestCaseJ4 {
Locale.setDefault(savedLocale);
TimeZone.setDefault(savedTimeZone);
// now look for unclosed resources
- for (MockRAMDirectory d : stores.keySet()) {
+ for (MockDirectoryWrapper d : stores.keySet()) {
if (d.isOpen()) {
StackTraceElement elements[] = stores.get(d);
StackTraceElement element = (elements.length > 1) ? elements[1] : null;
@@ -582,16 +586,17 @@ public class LuceneTestCaseJ4 {
return c;
}
- public static MockRAMDirectory newDirectory(Random r) throws IOException {
+ public static MockDirectoryWrapper newDirectory(Random r) throws IOException {
StackTraceElement[] stack = new Exception().getStackTrace();
- MockRAMDirectory dir = new MockRAMDirectory();
+ Directory impl = newDirectoryImpl(TEST_DIRECTORY);
+ MockDirectoryWrapper dir = new MockDirectoryWrapper(impl);
stores.put(dir, stack);
return dir;
}
- public static MockRAMDirectory newDirectory(Random r, Directory d) throws IOException {
+ public static MockDirectoryWrapper newDirectory(Random r, Directory d) throws IOException {
StackTraceElement[] stack = new Exception().getStackTrace();
- MockRAMDirectory dir = new MockRAMDirectory(d);
+ MockDirectoryWrapper dir = new MockDirectoryWrapper(new RAMDirectory(d));
stores.put(dir, stack);
return dir;
}
@@ -619,6 +624,32 @@ public class LuceneTestCaseJ4 {
}
}
+ static Directory newDirectoryImpl(String clazzName) {
+ if (clazzName.indexOf(".") == -1) // if not fully qualified, assume .store
+ clazzName = "org.apache.lucene.store." + clazzName;
+ try {
+ final Class extends Directory> clazz = Class.forName(clazzName).asSubclass(Directory.class);
+ try {
+ // try empty ctor
+ return clazz.newInstance();
+ } catch (Exception e) {
+ final File tmpFile = File.createTempFile("test", "tmp", TEMP_DIR);
+ tmpFile.delete();
+ tmpFile.mkdir();
+ try {
+ Constructor extends Directory> ctor = clazz.getConstructor(File.class);
+ return ctor.newInstance(tmpFile);
+ } catch (Exception e2) {
+ // try .open(File)
+ Method method = clazz.getMethod("open", new Class[] { File.class });
+ return (Directory) method.invoke(null, tmpFile);
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
public String getName() {
return this.name;
}
diff --git a/lucene/src/test/org/apache/lucene/util/TestBitVector.java b/lucene/src/test/org/apache/lucene/util/TestBitVector.java
index deeb7347569..3516ed87395 100644
--- a/lucene/src/test/org/apache/lucene/util/TestBitVector.java
+++ b/lucene/src/test/org/apache/lucene/util/TestBitVector.java
@@ -20,8 +20,8 @@ package org.apache.lucene.util;
import java.io.IOException;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.store.RAMDirectory;
/**
* TestBitVector
tests the BitVector
, obviously.
@@ -140,7 +140,7 @@ public class TestBitVector extends LuceneTestCase
}
private void doTestWriteRead(int n) throws Exception {
- MockRAMDirectory d = new MockRAMDirectory();
+ MockDirectoryWrapper d = new MockDirectoryWrapper(new RAMDirectory());
d.setPreventDoubleWrite(false);
BitVector bv = new BitVector(n);
// test count when incrementally setting bits
@@ -171,7 +171,7 @@ public class TestBitVector extends LuceneTestCase
}
private void doTestDgaps(int size, int count1, int count2) throws IOException {
- MockRAMDirectory d = new MockRAMDirectory();
+ MockDirectoryWrapper d = new MockDirectoryWrapper(new RAMDirectory());
d.setPreventDoubleWrite(false);
BitVector bv = new BitVector(size);
for (int i=0; i