From d2165cf08e07d751522f56f2f2d2af4664f9d722 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Tue, 10 Aug 2010 22:03:54 +0000 Subject: [PATCH] LUCENE-2595: switch tests to use MockRAMDirectory instead of RAMDirectory git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@984232 13f79535-47bb-0310-9956-ffa450edef68 --- .../highlight/HighlighterPhraseTest.java | 12 ++-- .../search/highlight/HighlighterTest.java | 12 ++-- .../vectorhighlight/AbstractTestCase.java | 4 +- .../store/instantiated/TestEmptyIndex.java | 6 +- .../store/instantiated/TestIndicesEquals.java | 6 +- .../store/instantiated/TestSerialization.java | 4 +- .../TestUnoptimizedReaderOnConstructor.java | 4 +- .../lucene/index/memory/MemoryIndexTest.java | 6 +- .../lucene/index/TestFieldNormModifier.java | 4 +- .../index/TestMultiPassIndexSplitter.java | 16 ++--- .../lucene/index/TestTermVectorAccessor.java | 4 +- .../codecs/appending/TestAppendingCodec.java | 4 +- .../lucene/misc/TestLengthNormModifier.java | 4 +- .../lucene/search/BooleanFilterTest.java | 6 +- .../lucene/search/ChainedFilterTest.java | 8 +-- .../lucene/search/DuplicateFilterTest.java | 6 +- .../lucene/search/FuzzyLikeThisQueryTest.java | 6 +- .../apache/lucene/search/TermsFilterTest.java | 4 +- .../lucene/search/regex/TestRegexQuery.java | 4 +- .../search/regex/TestSpanRegexQuery.java | 8 +-- .../search/similar/TestMoreLikeThis.java | 6 +- .../complexPhrase/TestComplexPhraseQuery.java | 4 +- .../standard/TestMultiFieldQPHelper.java | 4 +- .../TestMultiFieldQueryParserWrapper.java | 4 +- .../queryParser/standard/TestQPHelper.java | 6 +- .../standard/TestQueryParserWrapper.java | 6 +- .../surround/query/SingleFieldTestDb.java | 4 +- .../TestRemoteCachingWrapperFilter.java | 4 +- .../lucene/search/TestRemoteSearchable.java | 4 +- .../apache/lucene/search/TestRemoteSort.java | 4 +- .../lucene/spatial/tier/TestCartesian.java | 4 +- .../lucene/spatial/tier/TestDistance.java | 6 +- .../search/spell/TestLuceneDictionary.java | 6 +- .../search/spell/TestPlainTextDictionary.java | 4 +- .../lucene/search/spell/TestSpellChecker.java | 6 +- .../apache/lucene/xmlparser/TestParser.java | 4 +- .../xmlparser/TestQueryTemplateManager.java | 4 +- .../TestNumericRangeFilterBuilder.java | 4 +- .../src/test/org/apache/lucene/TestDemo.java | 4 +- .../test/org/apache/lucene/TestSearch.java | 2 +- .../lucene/TestSearchForDuplicates.java | 2 +- .../analysis/TestCachingTokenFilter.java | 4 +- .../apache/lucene/document/TestDocument.java | 6 +- .../apache/lucene/index/TestAddIndexes.java | 50 ++++++++-------- .../index/TestBackwardsCompatibility.java | 6 +- .../org/apache/lucene/index/TestCodecs.java | 4 +- .../index/TestConcurrentMergeScheduler.java | 8 +-- .../lucene/index/TestDeletionPolicy.java | 17 +++--- .../lucene/index/TestDirectoryReader.java | 16 ++--- .../lucene/index/TestDocumentWriter.java | 6 +- .../apache/lucene/index/TestFieldInfos.java | 4 +- .../apache/lucene/index/TestFieldsReader.java | 4 +- .../lucene/index/TestFilterIndexReader.java | 6 +- .../apache/lucene/index/TestIndexCommit.java | 4 +- .../lucene/index/TestIndexFileDeleter.java | 10 ++-- .../apache/lucene/index/TestIndexReader.java | 24 ++++---- .../apache/lucene/index/TestIndexWriter.java | 58 ++++++++++--------- .../lucene/index/TestIndexWriterConfig.java | 4 +- .../index/TestIndexWriterMergePolicy.java | 14 ++--- .../org/apache/lucene/index/TestLazyBug.java | 4 +- .../lucene/index/TestLazyProxSkipping.java | 6 +- .../lucene/index/TestNewestSegment.java | 4 +- .../lucene/index/TestNoDeletionPolicy.java | 4 +- .../org/apache/lucene/index/TestNorms.java | 8 +-- .../lucene/index/TestParallelReader.java | 4 +- .../index/TestParallelReaderEmptyIndex.java | 14 ++--- .../lucene/index/TestParallelTermEnum.java | 6 +- .../lucene/index/TestSegmentMerger.java | 8 +-- .../lucene/index/TestSegmentReader.java | 4 +- .../lucene/index/TestSegmentTermDocs.java | 6 +- .../lucene/index/TestSegmentTermEnum.java | 4 +- .../apache/lucene/index/TestTermdocPerf.java | 4 +- .../TestMultiFieldQueryParser.java | 4 +- .../lucene/queryParser/TestQueryParser.java | 6 +- .../lucene/search/BaseTestRangeFilter.java | 4 +- .../org/apache/lucene/search/QueryUtils.java | 6 +- .../lucene/search/TestAutomatonQuery.java | 4 +- .../search/TestAutomatonQueryUnicode.java | 4 +- .../apache/lucene/search/TestBoolean2.java | 6 +- .../search/TestBooleanMinShouldMatch.java | 4 +- .../apache/lucene/search/TestBooleanOr.java | 4 +- .../lucene/search/TestBooleanPrefixQuery.java | 4 +- .../lucene/search/TestBooleanScorer.java | 4 +- .../search/TestCachingWrapperFilter.java | 10 ++-- .../lucene/search/TestCustomSearcherSort.java | 4 +- .../apache/lucene/search/TestDateFilter.java | 6 +- .../apache/lucene/search/TestDateSort.java | 4 +- .../search/TestDisjunctionMaxQuery.java | 4 +- .../apache/lucene/search/TestDocBoost.java | 4 +- .../apache/lucene/search/TestDocIdSet.java | 4 +- .../lucene/search/TestExplanations.java | 4 +- .../apache/lucene/search/TestFieldCache.java | 4 +- .../search/TestFieldCacheRangeFilter.java | 4 +- .../lucene/search/TestFilteredQuery.java | 6 +- .../lucene/search/TestFilteredSearch.java | 4 +- .../apache/lucene/search/TestFuzzyQuery.java | 10 ++-- .../apache/lucene/search/TestFuzzyQuery2.java | 4 +- .../lucene/search/TestMatchAllDocsQuery.java | 4 +- .../lucene/search/TestMultiSearcher.java | 22 +++---- .../search/TestMultiSearcherRanking.java | 8 +-- .../search/TestMultiTermConstantScore.java | 8 +-- .../search/TestMultiThreadTermVectors.java | 4 +- .../TestMultiValuedNumericRangeQuery.java | 4 +- .../org/apache/lucene/search/TestNot.java | 4 +- .../search/TestNumericRangeQuery32.java | 8 +-- .../search/TestNumericRangeQuery64.java | 8 +-- .../lucene/search/TestPhrasePrefixQuery.java | 4 +- .../apache/lucene/search/TestPhraseQuery.java | 10 ++-- .../lucene/search/TestPrefixFilter.java | 4 +- .../search/TestPrefixInBooleanQuery.java | 4 +- .../apache/lucene/search/TestPrefixQuery.java | 4 +- .../lucene/search/TestQueryWrapperFilter.java | 4 +- .../apache/lucene/search/TestRegexpQuery.java | 4 +- .../lucene/search/TestRegexpRandom.java | 4 +- .../apache/lucene/search/TestScorerPerf.java | 4 +- .../org/apache/lucene/search/TestSetNorm.java | 4 +- .../apache/lucene/search/TestSimilarity.java | 4 +- .../lucene/search/TestSloppyPhraseQuery.java | 4 +- .../org/apache/lucene/search/TestSort.java | 8 +-- .../lucene/search/TestSpanQueryFilter.java | 4 +- .../lucene/search/TestTermRangeFilter.java | 6 +- .../lucene/search/TestTermRangeQuery.java | 6 +- .../apache/lucene/search/TestTermScorer.java | 6 +- .../apache/lucene/search/TestThreadSafe.java | 4 +- .../search/TestTimeLimitingCollector.java | 4 +- .../lucene/search/TestTopDocsCollector.java | 4 +- .../search/TestTopScoreDocCollector.java | 4 +- .../apache/lucene/search/TestWildcard.java | 18 +++--- .../lucene/search/TestWildcardRandom.java | 8 ++- .../search/function/FunctionTestSetup.java | 4 +- .../lucene/search/payloads/PayloadHelper.java | 4 +- .../search/payloads/TestPayloadNearQuery.java | 4 +- .../search/payloads/TestPayloadTermQuery.java | 7 ++- .../lucene/search/spans/TestBasics.java | 4 +- .../spans/TestFieldMaskingSpanQuery.java | 4 +- .../search/spans/TestNearSpansOrdered.java | 4 +- .../lucene/search/spans/TestPayloadSpans.java | 14 ++--- .../apache/lucene/search/spans/TestSpans.java | 4 +- .../search/spans/TestSpansAdvanced.java | 4 +- .../apache/lucene/store/TestLockFactory.java | 6 +- .../org/apache/lucene/util/TestBitVector.java | 9 +-- .../util/TestFieldCacheSanityChecker.java | 6 +- .../test/org/apache/solr/search/TestSort.java | 4 +- 143 files changed, 471 insertions(+), 466 deletions(-) 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 40166fcd531..8269bfe284a 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 @@ -48,7 +48,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.OpenBitSet; @@ -58,7 +58,7 @@ public class HighlighterPhraseTest extends LuceneTestCase { public void testConcurrentPhrase() throws CorruptIndexException, LockObtainFailedException, IOException, InvalidTokenOffsetsException { final String TEXT = "the fox jumped"; - final Directory directory = new RAMDirectory(); + final Directory directory = new MockRAMDirectory(); final IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false))); try { @@ -101,7 +101,7 @@ public class HighlighterPhraseTest extends LuceneTestCase { public void testConcurrentSpan() throws CorruptIndexException, LockObtainFailedException, IOException, InvalidTokenOffsetsException { final String TEXT = "the fox jumped"; - final Directory directory = new RAMDirectory(); + final Directory directory = new MockRAMDirectory(); final IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false))); try { @@ -170,7 +170,7 @@ public class HighlighterPhraseTest extends LuceneTestCase { public void testSparsePhrase() throws CorruptIndexException, LockObtainFailedException, IOException, InvalidTokenOffsetsException { final String TEXT = "the fox did not jump"; - final Directory directory = new RAMDirectory(); + final Directory directory = new MockRAMDirectory(); final IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false))); try { @@ -212,7 +212,7 @@ public class HighlighterPhraseTest extends LuceneTestCase { public void testSparsePhraseWithNoPositions() throws CorruptIndexException, LockObtainFailedException, IOException, InvalidTokenOffsetsException { final String TEXT = "the fox did not jump"; - final Directory directory = new RAMDirectory(); + final Directory directory = new MockRAMDirectory(); final IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false))); try { @@ -252,7 +252,7 @@ public class HighlighterPhraseTest extends LuceneTestCase { public void testSparseSpan() throws CorruptIndexException, LockObtainFailedException, IOException, InvalidTokenOffsetsException { final String TEXT = "the fox did not jump"; - final Directory directory = new RAMDirectory(); + final Directory directory = new MockRAMDirectory(); final IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false))); try { 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 1b786a3a41c..bd8400b58f1 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 @@ -77,7 +77,7 @@ 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.RAMDirectory; +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; @@ -94,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; - RAMDirectory ramDir; + MockRAMDirectory ramDir; public IndexSearcher searcher = null; int numHighlights = 0; final Analyzer analyzer = new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true); @@ -1319,7 +1319,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte public void testMultiSearcher() throws Exception { // setup index 1 - RAMDirectory ramDir1 = new RAMDirectory(); + MockRAMDirectory ramDir1 = new MockRAMDirectory(); IndexWriter writer1 = new IndexWriter(ramDir1, new IndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true))); Document d = new Document(); @@ -1331,7 +1331,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte IndexReader reader1 = IndexReader.open(ramDir1, true); // setup index 2 - RAMDirectory ramDir2 = new RAMDirectory(); + MockRAMDirectory ramDir2 = new MockRAMDirectory(); IndexWriter writer2 = new IndexWriter(ramDir2, new IndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true))); d = new Document(); @@ -1587,7 +1587,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte helper.start(); } - private Directory dir = new RAMDirectory(); + private Directory dir = new MockRAMDirectory(); private Analyzer a = new MockAnalyzer(MockTokenizer.WHITESPACE, false); public void testWeightedTermsWithDeletes() throws IOException, ParseException, InvalidTokenOffsetsException { @@ -1714,7 +1714,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte @Override protected void setUp() throws Exception { super.setUp(); - ramDir = new RAMDirectory(); + ramDir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(ramDir, new IndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true))); for (int i = 0; i < texts.length; i++) { 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 b0926087144..efd946ffe05 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,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public abstract class AbstractTestCase extends LuceneTestCase { @@ -91,7 +91,7 @@ public abstract class AbstractTestCase extends LuceneTestCase { analyzerK = new MockAnalyzer(MockTokenizer.KEYWORD, false); paW = new QueryParser(TEST_VERSION_CURRENT, F, analyzerW ); paB = new QueryParser(TEST_VERSION_CURRENT, F, analyzerB ); - dir = new RAMDirectory(); + dir = new MockRAMDirectory(); } @Override 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 c103c66423a..65faaf1bcd7 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 @@ -29,7 +29,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestEmptyIndex extends LuceneTestCase { @@ -61,7 +61,7 @@ public class TestEmptyIndex extends LuceneTestCase { // make sure a Directory acts the same - Directory d = new RAMDirectory(); + Directory d = new MockRAMDirectory(); new IndexWriter(d, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())).close(); r = IndexReader.open(d, false); testNorms(r); @@ -94,7 +94,7 @@ public class TestEmptyIndex extends LuceneTestCase { // make sure a Directory acts the same - Directory d = new RAMDirectory(); + Directory d = new MockRAMDirectory(); new IndexWriter(d, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())).close(); r = IndexReader.open(d, false); termsEnumTest(r); 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 10a4fba0209..230f2ac0c73 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,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.AttributeImpl; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.BytesRef; @@ -61,7 +61,7 @@ public class TestIndicesEquals extends LuceneTestCase { public void testLoadIndexReader() throws Exception { - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); // create dir data IndexWriter indexWriter = new IndexWriter(dir, new IndexWriterConfig( @@ -85,7 +85,7 @@ public class TestIndicesEquals extends LuceneTestCase { public void testInstantiatedIndexWriter() throws Exception { - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); InstantiatedIndex ii = new InstantiatedIndex(); // create dir data diff --git a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestSerialization.java b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestSerialization.java index a9a8c1255fa..cdf8f10e550 100644 --- a/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestSerialization.java +++ b/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestSerialization.java @@ -17,7 +17,7 @@ package org.apache.lucene.store.instantiated; */ -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.index.IndexWriter; @@ -34,7 +34,7 @@ public class TestSerialization extends LuceneTestCase { public void test() throws Exception { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); Document doc = new Document(); 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 1fa4d5325be..7f388d20352 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 @@ -20,7 +20,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.analysis.MockAnalyzer; @@ -33,7 +33,7 @@ import org.apache.lucene.document.Field; public class TestUnoptimizedReaderOnConstructor extends LuceneTestCase { public void test() throws Exception { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); addDocument(iw, "Hello, world!"); addDocument(iw, "All work and no play makes jack a dull boy"); 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 7b587abfc5f..23b2de979ce 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util._TestUtil; /** @@ -106,7 +106,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase { termField.append(randomTerm()); } - RAMDirectory ramdir = new RAMDirectory(); + MockRAMDirectory ramdir = new MockRAMDirectory(); Analyzer analyzer = randomAnalyzer(); IndexWriter writer = new IndexWriter(ramdir, new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer).setCodecProvider(_TestUtil.alwaysCodec("Standard"))); @@ -127,7 +127,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, RAMDirectory ramdir, Analyzer analyzer) throws Exception { + public void assertAllQueries(MemoryIndex memory, MockRAMDirectory 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 5ed0824e6e1..6bc8048ad82 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 @@ -30,7 +30,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -44,7 +44,7 @@ public class TestFieldNormModifier extends LuceneTestCase { public static int NUM_DOCS = 5; - public Directory store = new RAMDirectory(); + public Directory store = new MockRAMDirectory(); /** inverts the normal notion of lengthNorm */ public static Similarity s = new DefaultSimilarity() { 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 e9bc8027996..a05e37bf898 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 @@ -20,7 +20,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.BytesRef; @@ -31,7 +31,7 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); Document doc; for (int i = 0; i < NUM_DOCS; i++) { @@ -53,9 +53,9 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase { public void testSplitRR() throws Exception { MultiPassIndexSplitter splitter = new MultiPassIndexSplitter(); Directory[] dirs = new Directory[]{ - new RAMDirectory(), - new RAMDirectory(), - new RAMDirectory() + new MockRAMDirectory(), + new MockRAMDirectory(), + new MockRAMDirectory() }; splitter.split(input, dirs, false); IndexReader ir; @@ -95,9 +95,9 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase { public void testSplitSeq() throws Exception { MultiPassIndexSplitter splitter = new MultiPassIndexSplitter(); Directory[] dirs = new Directory[]{ - new RAMDirectory(), - new RAMDirectory(), - new RAMDirectory() + new MockRAMDirectory(), + new MockRAMDirectory(), + new MockRAMDirectory() }; splitter.split(input, dirs, true); IndexReader ir; 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 452af1f6004..39b6349cb92 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,7 +4,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import java.util.Collections; @@ -27,7 +27,7 @@ public class TestTermVectorAccessor extends LuceneTestCase { public void test() throws Exception { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); Document doc; 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 cef9ece0b54..e0a09fa3d4f 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,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.Version; @@ -118,7 +118,7 @@ public class TestAppendingCodec extends LuceneTestCase { } @SuppressWarnings("serial") - private static class AppendingRAMDirectory extends RAMDirectory { + private static class AppendingRAMDirectory extends MockRAMDirectory { @Override public IndexOutput createOutput(String name) throws IOException { 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 7dd9b410c99..121492199a6 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 @@ -34,7 +34,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -48,7 +48,7 @@ public class TestLengthNormModifier extends LuceneTestCase { public static int NUM_DOCS = 5; - public Directory store = new RAMDirectory(); + public Directory store = new MockRAMDirectory(); /** inverts the normal notion of lengthNorm */ public static Similarity s = new DefaultSimilarity() { 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 aec2481c41f..3192f2afc25 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 @@ -27,17 +27,17 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class BooleanFilterTest extends LuceneTestCase { - private RAMDirectory directory; + private MockRAMDirectory directory; private IndexReader reader; @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory, new MockAnalyzer(MockTokenizer.WHITESPACE, false)); //Add series of docs with filterable fields : acces rights, prices, dates and "in-stock" flags 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 2e4bb29cb87..0de905e20a2 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,13 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class ChainedFilterTest extends LuceneTestCase { public static final int MAX = 500; - private RAMDirectory directory; + private MockRAMDirectory directory; private IndexSearcher searcher; private IndexReader reader; private Query query; @@ -60,7 +60,7 @@ public class ChainedFilterTest extends LuceneTestCase { protected void setUp() throws Exception { super.setUp(); random = newRandom(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, directory); Calendar cal = new GregorianCalendar(); cal.clear(); @@ -195,7 +195,7 @@ public class ChainedFilterTest extends LuceneTestCase { */ public void testWithCachingFilter() throws Exception { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, dir); IndexReader reader = writer.getReader(); writer.close(); 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 e41ebd7282b..2b6b85ae9ae 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 @@ -27,13 +27,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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; 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 RAMDirectory directory; + private MockRAMDirectory directory; private IndexReader reader; TermQuery tq=new TermQuery(new Term("text","lucene")); private IndexSearcher searcher; @@ -41,7 +41,7 @@ public class DuplicateFilterTest extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory); //Add series of docs with filterable fields : url, text and dates flags 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 96fa522b78b..c64a1161076 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 @@ -27,11 +27,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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class FuzzyLikeThisQueryTest extends LuceneTestCase { - private RAMDirectory directory; + private MockRAMDirectory directory; private IndexSearcher searcher; private IndexReader reader; private Analyzer analyzer=new MockAnalyzer(); @@ -39,7 +39,7 @@ public class FuzzyLikeThisQueryTest extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory); //Add series of docs with misspelt names 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 9ac12257d18..9cc19ebf168 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 @@ -24,7 +24,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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.OpenBitSet; @@ -50,7 +50,7 @@ public class TermsFilterTest extends LuceneTestCase { public void testMissingTerms() throws Exception { String fieldName="field1"; - RAMDirectory rd=new RAMDirectory(); + MockRAMDirectory rd=new MockRAMDirectory(); RandomIndexWriter w = new RandomIndexWriter(newRandom(), 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 9dad9d98edd..a0e0dc67972 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 @@ -18,7 +18,7 @@ package org.apache.lucene.search.regex; */ import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; @@ -41,7 +41,7 @@ public class TestRegexQuery extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory); Document doc = new Document(); doc.add(new Field(FN, "the quick brown fox jumps over the lazy dog", Field.Store.NO, Field.Index.ANALYZED)); 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 6e036717dbf..9b0ccb8ce43 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 @@ -34,17 +34,17 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestSpanRegexQuery extends LuceneTestCase { - Directory indexStoreA = new RAMDirectory(); + Directory indexStoreA = new MockRAMDirectory(); - Directory indexStoreB = new RAMDirectory(); + Directory indexStoreB = new MockRAMDirectory(); public void testSpanRegex() throws Exception { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig( 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 d36893a8cb7..233a1898f30 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 @@ -33,18 +33,18 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestMoreLikeThis extends LuceneTestCase { - private RAMDirectory directory; + private MockRAMDirectory directory; private IndexReader reader; private IndexSearcher searcher; @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory); // Add series of docs with specific information for MoreLikeThis 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 e613411a015..28024e2d837 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 @@ -30,7 +30,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestComplexPhraseQuery extends LuceneTestCase { @@ -112,7 +112,7 @@ public class TestComplexPhraseQuery extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - RAMDirectory rd = new RAMDirectory(); + MockRAMDirectory rd = new MockRAMDirectory(); IndexWriter w = new IndexWriter(rd, new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer)); for (int i = 0; i < docsContent.length; i++) { Document doc = new Document(); 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 99269505151..0265551fa75 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 @@ -36,7 +36,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -319,7 +319,7 @@ public class TestMultiFieldQPHelper extends LuceneTestCase { public void testStopWordSearching() throws Exception { Analyzer analyzer = new MockAnalyzer(); - Directory ramDir = new RAMDirectory(); + Directory ramDir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(ramDir, new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer)); Document doc = new Document(); doc.add(new Field("body", "blah the footest blah", Field.Store.NO, 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 fe3ab1db290..8c7891567c2 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,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -321,7 +321,7 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase { public void testStopWordSearching() throws Exception { Analyzer analyzer = new MockAnalyzer(); - Directory ramDir = new RAMDirectory(); + Directory ramDir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(ramDir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED); Document doc = new Document(); 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 3a8156f8b4a..b1e54eb3967 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 @@ -72,7 +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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LocalizedTestCase; import org.apache.lucene.util.automaton.BasicAutomata; @@ -654,7 +654,7 @@ public class TestQPHelper extends LocalizedTestCase { public void testFarsiRangeCollating() throws Exception { - RAMDirectory ramDir = new RAMDirectory(); + MockRAMDirectory ramDir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(ramDir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false))); Document doc = new Document(); doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES, @@ -1077,7 +1077,7 @@ public class TestQPHelper extends LocalizedTestCase { public void testLocalDateFormat() throws IOException, QueryNodeException { - RAMDirectory ramDir = new RAMDirectory(); + MockRAMDirectory ramDir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(ramDir, new IndexWriterConfig(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); 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 d6f74d3f50e..34ee1998983 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; 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 { - RAMDirectory ramDir = new RAMDirectory(); + MockRAMDirectory ramDir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(ramDir, new MockAnalyzer(MockTokenizer.WHITESPACE, false), true, IndexWriter.MaxFieldLength.LIMITED); Document doc = new Document(); @@ -1062,7 +1062,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase { public void testLocalDateFormat() throws IOException, ParseException { - RAMDirectory ramDir = new RAMDirectory(); + MockRAMDirectory ramDir = new MockRAMDirectory(); 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 ae14630ea9c..1f6700165a4 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,7 @@ package org.apache.lucene.queryParser.surround.query; */ import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.Version; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; @@ -33,7 +33,7 @@ public class SingleFieldTestDb { public SingleFieldTestDb(String[] documents, String fName) { try { - db = new RAMDirectory(); + db = new MockRAMDirectory(); 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 f07ea67542c..ff75cd18d48 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 @@ -23,7 +23,7 @@ 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.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.junit.BeforeClass; import org.junit.Test; @@ -36,7 +36,7 @@ public class TestRemoteCachingWrapperFilter extends RemoteTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { // construct an index - RAMDirectory indexStore = new RAMDirectory(); + MockRAMDirectory indexStore = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(indexStore, new IndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); Document doc = new Document(); 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 5422b032c4e..fd302840e02 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 @@ -22,7 +22,7 @@ import org.apache.lucene.document.*; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.Term; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.junit.BeforeClass; import org.junit.Test; @@ -37,7 +37,7 @@ public class TestRemoteSearchable extends RemoteTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { // construct an index - RAMDirectory indexStore = new RAMDirectory(); + MockRAMDirectory indexStore = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(indexStore, new IndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); Document doc = new Document(); 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 272f4934c7e..02791ae6e86 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 @@ -33,7 +33,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.BytesRef; import org.junit.Before; import org.junit.BeforeClass; @@ -82,7 +82,7 @@ public class TestRemoteSort extends RemoteTestCaseJ4 { // create an index of all the documents, or just the x, or just the y documents @BeforeClass public static void beforeClass() throws Exception { - RAMDirectory indexStore = new RAMDirectory (); + MockRAMDirectory indexStore = new MockRAMDirectory (); IndexWriter writer = new IndexWriter(indexStore, new IndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()) .setMaxBufferedDocs(2)); diff --git a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java index c42149f6820..f69c10ec7a1 100644 --- a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java +++ b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java @@ -49,7 +49,7 @@ import org.apache.lucene.spatial.tier.projections.CartesianTierPlotter; import org.apache.lucene.spatial.tier.projections.IProjector; import org.apache.lucene.spatial.tier.projections.SinusoidalProjector; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestCartesian extends LuceneTestCase { @@ -71,7 +71,7 @@ public class TestCartesian extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); 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 779d1891dda..a6dfeb27a3e 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; public class TestDistance extends LuceneTestCase { - private RAMDirectory directory; + private MockRAMDirectory directory; // reston va private double lat = 38.969398; private double lng= -77.386398; @@ -44,7 +44,7 @@ public class TestDistance extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); writer = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); addData(writer); 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 7c68947e964..d5af6db3b69 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 @@ -29,7 +29,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -39,7 +39,7 @@ import org.apache.lucene.util.LuceneTestCase; */ public class TestLuceneDictionary extends LuceneTestCase { - private Directory store = new RAMDirectory(); + private Directory store = new MockRAMDirectory(); private IndexReader indexReader = null; @@ -187,7 +187,7 @@ public class TestLuceneDictionary extends LuceneTestCase { } public void testSpellchecker() throws IOException { - SpellChecker sc = new SpellChecker(new RAMDirectory()); + SpellChecker sc = new SpellChecker(new MockRAMDirectory()); indexReader = IndexReader.open(store, true); sc.indexDictionary(new LuceneDictionary(indexReader, "contents")); String[] suggestions = sc.suggestSimilar("Tam", 1); 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 2a8d2a8b672..fb3b081ae7c 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; 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)); - RAMDirectory ramDir = new RAMDirectory(); + MockRAMDirectory ramDir = new MockRAMDirectory(); SpellChecker spellChecker = new SpellChecker(ramDir); spellChecker.indexDictionary(ptd); String[] similar = spellChecker.suggestSimilar("treeword", 2); diff --git a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java index 0378c1efefa..e03794c1999 100755 --- a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java +++ b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java @@ -36,7 +36,7 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.English; import org.apache.lucene.util.LuceneTestCase; @@ -54,7 +54,7 @@ public class TestSpellChecker extends LuceneTestCase { super.setUp(); //create a user index - userindex = new RAMDirectory(); + userindex = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(userindex, new IndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); @@ -67,7 +67,7 @@ public class TestSpellChecker extends LuceneTestCase { writer.close(); searchers = Collections.synchronizedList(new ArrayList()); // create the spellChecker - spellindex = new RAMDirectory(); + spellindex = new MockRAMDirectory(); spellChecker = new SpellCheckerMock(spellindex); } 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 260996e5d77..77ee3c043e3 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 @@ -19,7 +19,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.Version; import org.apache.lucene.util.LuceneTestCase; /** @@ -62,7 +62,7 @@ public class TestParser extends LuceneTestCase { if(dir==null) { BufferedReader d = new BufferedReader(new InputStreamReader(TestParser.class.getResourceAsStream("reuters21578.txt"))); - dir=new RAMDirectory(); + dir=new MockRAMDirectory(); IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Version.LUCENE_24, analyzer)); String line = d.readLine(); while(line!=null) 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 aefc78abe9c..d1c0c0bfe0f 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 @@ -14,7 +14,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -141,7 +141,7 @@ public class TestQueryTemplateManager extends LuceneTestCase { //Create an index - RAMDirectory dir=new RAMDirectory(); + MockRAMDirectory dir=new MockRAMDirectory(); IndexWriter w=new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer)); for (int i = 0; i < docFieldValues.length; i++) { 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 b5f4915f851..f3214533df3 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 @@ -33,7 +33,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.xmlparser.ParserException; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -62,7 +62,7 @@ public class TestNumericRangeFilterBuilder extends LuceneTestCase { Document doc = getDocumentFromString(xml); Filter filter = filterBuilder.getFilter(doc.getDocumentElement()); - RAMDirectory ramDir = new RAMDirectory(); + MockRAMDirectory ramDir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(ramDir, new IndexWriterConfig(TEST_VERSION_CURRENT, null)); writer.commit(); try diff --git a/lucene/src/test/org/apache/lucene/TestDemo.java b/lucene/src/test/org/apache/lucene/TestDemo.java index 3954d19d310..130783544e2 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; 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 RAMDirectory(); + Directory directory = new MockRAMDirectory(); // 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/TestSearch.java b/lucene/src/test/org/apache/lucene/TestSearch.java index 75d7ebeb642..30d0f278a95 100644 --- a/lucene/src/test/org/apache/lucene/TestSearch.java +++ b/lucene/src/test/org/apache/lucene/TestSearch.java @@ -71,7 +71,7 @@ public class TestSearch extends LuceneTestCase { private void doTestSearch(PrintWriter out, boolean useCompoundFile) throws Exception { - Directory directory = new RAMDirectory(); + Directory directory = new MockRAMDirectory(); Analyzer analyzer = new MockAnalyzer(); IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer); LogMergePolicy lmp = (LogMergePolicy) conf.getMergePolicy(); diff --git a/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java b/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java index 9f11ef0edd5..b57dcc659cb 100644 --- a/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java +++ b/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java @@ -76,7 +76,7 @@ public class TestSearchForDuplicates extends LuceneTestCase { private void doTest(PrintWriter out, boolean useCompoundFiles) throws Exception { - Directory directory = new RAMDirectory(); + Directory directory = new MockRAMDirectory(); Analyzer analyzer = new MockAnalyzer(); IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer); LogMergePolicy lmp = (LogMergePolicy) conf.getMergePolicy(); diff --git a/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java b/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java index c3edb4be1fc..b021f939b2f 100644 --- a/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java +++ b/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java @@ -31,14 +31,14 @@ import org.apache.lucene.index.MultiFields; import org.apache.lucene.index.DocsAndPositionsEnum; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.BytesRef; public class TestCachingTokenFilter extends BaseTokenStreamTestCase { private String[] tokens = new String[] {"term1", "term2", "term3", "term2"}; public void testCaching() throws IOException { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), dir); Document doc = new Document(); TokenStream stream = new TokenStream() { diff --git a/lucene/src/test/org/apache/lucene/document/TestDocument.java b/lucene/src/test/org/apache/lucene/document/TestDocument.java index fea8f7d0028..799e18ed135 100644 --- a/lucene/src/test/org/apache/lucene/document/TestDocument.java +++ b/lucene/src/test/org/apache/lucene/document/TestDocument.java @@ -8,7 +8,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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -152,7 +152,7 @@ public class TestDocument extends LuceneTestCase { * @throws Exception on error */ public void testGetValuesForIndexedDocument() throws Exception { - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), dir); writer.addDocument(makeDocumentWithFields()); IndexReader reader = writer.getReader(); @@ -230,7 +230,7 @@ public class TestDocument extends LuceneTestCase { doc.add(new Field("keyword", "test", Field.Store.YES, Field.Index.NOT_ANALYZED)); - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), 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 610fa692734..bc0e5ee7018 100755 --- a/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java +++ b/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java @@ -26,7 +26,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util._TestUtil; @@ -44,10 +44,10 @@ public class TestAddIndexes extends LuceneTestCase { public void testSimpleCase() throws IOException { // main directory - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); // two auxiliary directories - Directory aux = new RAMDirectory(); - Directory aux2 = new RAMDirectory(); + Directory aux = new MockRAMDirectory(); + Directory aux2 = new MockRAMDirectory(); IndexWriter writer = null; @@ -89,7 +89,7 @@ public class TestAddIndexes extends LuceneTestCase { verifyNumDocs(dir, 190); // now add another set in. - Directory aux3 = new RAMDirectory(); + Directory aux3 = new MockRAMDirectory(); writer = newWriter(aux3, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); // add 40 documents addDocs(writer, 40); @@ -123,7 +123,7 @@ public class TestAddIndexes extends LuceneTestCase { verifyTermDocs(dir, new Term("content", "bbb"), 50); // now add a single document - Directory aux4 = new RAMDirectory(); + Directory aux4 = new MockRAMDirectory(); writer = newWriter(aux4, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); addDocs2(writer, 1); writer.close(); @@ -178,9 +178,9 @@ public class TestAddIndexes extends LuceneTestCase { public void testWithPendingDeletes2() throws IOException { // main directory - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); // auxiliary directory - Directory aux = new RAMDirectory(); + Directory aux = new MockRAMDirectory(); setUpDirs(dir, aux); IndexWriter writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND)); @@ -216,9 +216,9 @@ public class TestAddIndexes extends LuceneTestCase { public void testWithPendingDeletes3() throws IOException { // main directory - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); // auxiliary directory - Directory aux = new RAMDirectory(); + Directory aux = new MockRAMDirectory(); setUpDirs(dir, aux); IndexWriter writer = newWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND)); @@ -256,9 +256,9 @@ public class TestAddIndexes extends LuceneTestCase { // case 0: add self or exceed maxMergeDocs, expect exception public void testAddSelf() throws IOException { // main directory - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); // auxiliary directory - Directory aux = new RAMDirectory(); + Directory aux = new MockRAMDirectory(); IndexWriter writer = null; @@ -300,9 +300,9 @@ public class TestAddIndexes extends LuceneTestCase { // case 1: no tail segments public void testNoTailSegments() throws IOException { // main directory - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); // auxiliary directory - Directory aux = new RAMDirectory(); + Directory aux = new MockRAMDirectory(); setUpDirs(dir, aux); @@ -324,9 +324,9 @@ public class TestAddIndexes extends LuceneTestCase { // case 2: tail segments, invariants hold, no copy public void testNoCopySegments() throws IOException { // main directory - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); // auxiliary directory - Directory aux = new RAMDirectory(); + Directory aux = new MockRAMDirectory(); setUpDirs(dir, aux); @@ -346,9 +346,9 @@ public class TestAddIndexes extends LuceneTestCase { // case 3: tail segments, invariants hold, copy, invariants hold public void testNoMergeAfterCopy() throws IOException { // main directory - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); // auxiliary directory - Directory aux = new RAMDirectory(); + Directory aux = new MockRAMDirectory(); setUpDirs(dir, aux); @@ -357,7 +357,7 @@ public class TestAddIndexes extends LuceneTestCase { .setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(10)); ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4); - writer.addIndexes(new Directory[] { aux, new RAMDirectory(aux) }); + writer.addIndexes(new Directory[] { aux, new MockRAMDirectory(aux) }); assertEquals(1060, writer.maxDoc()); assertEquals(1000, writer.getDocCount(0)); writer.close(); @@ -369,9 +369,9 @@ public class TestAddIndexes extends LuceneTestCase { // case 4: tail segments, invariants hold, copy, invariants not hold public void testMergeAfterCopy() throws IOException { // main directory - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); // auxiliary directory - Directory aux = new RAMDirectory(); + Directory aux = new MockRAMDirectory(); setUpDirs(dir, aux); @@ -387,7 +387,7 @@ public class TestAddIndexes extends LuceneTestCase { .setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(4)); ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4); - writer.addIndexes(new Directory[] { aux, new RAMDirectory(aux) }); + writer.addIndexes(new Directory[] { aux, new MockRAMDirectory(aux) }); assertEquals(1060, writer.maxDoc()); assertEquals(1000, writer.getDocCount(0)); writer.close(); @@ -396,10 +396,10 @@ public class TestAddIndexes extends LuceneTestCase { // case 5: tail segments, invariants not hold public void testMoreMerges() throws IOException { // main directory - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); // auxiliary directory - Directory aux = new RAMDirectory(); - Directory aux2 = new RAMDirectory(); + Directory aux = new MockRAMDirectory(); + Directory aux2 = new MockRAMDirectory(); setUpDirs(dir, aux); diff --git a/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java index d047597b968..72f396d2e25 100644 --- a/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java +++ b/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java @@ -46,7 +46,7 @@ import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.NumericRangeQuery; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util._TestUtil; import org.apache.lucene.util.BytesRef; @@ -226,7 +226,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase { String fullPath = fullDir(name); Directory dir = FSDirectory.open(new File(fullPath)); - Directory targetDir = new RAMDirectory(); + Directory targetDir = new MockRAMDirectory(); IndexWriter w = new IndexWriter(targetDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); w.addIndexes(new Directory[] { dir }); @@ -247,7 +247,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase { Directory dir = FSDirectory.open(new File(fullPath)); IndexReader reader = IndexReader.open(dir); - Directory targetDir = new RAMDirectory(); + Directory targetDir = new MockRAMDirectory(); IndexWriter w = new IndexWriter(targetDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); w.addIndexes(new IndexReader[] { reader }); diff --git a/lucene/src/test/org/apache/lucene/index/TestCodecs.java b/lucene/src/test/org/apache/lucene/index/TestCodecs.java index 038886f4e74..30a2270c9cc 100644 --- a/lucene/src/test/org/apache/lucene/index/TestCodecs.java +++ b/lucene/src/test/org/apache/lucene/index/TestCodecs.java @@ -40,7 +40,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.MultiCodecTestCase; import org.apache.lucene.util.Version; @@ -352,7 +352,7 @@ public class TestCodecs extends MultiCodecTestCase { } public void testSepPositionAfterMerge() throws IOException { - final Directory dir = new RAMDirectory(); + final Directory dir = new MockRAMDirectory(); final IndexWriterConfig config = newIndexWriterConfig(newRandom(), Version.LUCENE_31, new MockAnalyzer()); config.setCodecProvider(new MockSepCodecs()); diff --git a/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java b/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java index 7edce8a5938..8fbe81ecd09 100644 --- a/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java +++ b/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java @@ -18,7 +18,7 @@ package org.apache.lucene.index; */ import org.apache.lucene.store.MockRAMDirectory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -108,7 +108,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase { // before it finishes, are correctly merged back: public void testDeleteMerging() throws IOException { - RAMDirectory directory = new MockRAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); LogDocMergePolicy mp = new LogDocMergePolicy(); // Force degenerate merging so we can get a mix of @@ -147,7 +147,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase { public void testNoExtraFiles() throws IOException { - RAMDirectory directory = new MockRAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); Random random = newRandom(); IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()) @@ -176,7 +176,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase { } public void testNoWaitClose() throws IOException { - RAMDirectory directory = new MockRAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); Random random = newRandom(); Document doc = new Document(); Field idField = new Field("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED); diff --git a/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java b/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java index ea11b9d862c..b413e5c70dd 100644 --- a/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java +++ b/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java @@ -33,7 +33,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; @@ -202,7 +202,7 @@ public class TestDeletionPolicy extends LuceneTestCase { boolean useCompoundFile = true; Random random = newRandom(); - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); ExpirationTimeDeletionPolicy policy = new ExpirationTimeDeletionPolicy(dir, SECONDS); IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()) @@ -282,7 +282,7 @@ public class TestDeletionPolicy extends LuceneTestCase { // Never deletes a commit KeepAllDeletionPolicy policy = new KeepAllDeletionPolicy(); - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); policy.dir = dir; IndexWriterConfig conf = newIndexWriterConfig(random, @@ -474,7 +474,7 @@ public class TestDeletionPolicy extends LuceneTestCase { KeepNoneOnInitDeletionPolicy policy = new KeepNoneOnInitDeletionPolicy(); - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()) @@ -523,7 +523,7 @@ public class TestDeletionPolicy extends LuceneTestCase { boolean useCompoundFile = (pass % 2) != 0; - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); KeepLastNDeletionPolicy policy = new KeepLastNDeletionPolicy(N); @@ -588,7 +588,7 @@ public class TestDeletionPolicy extends LuceneTestCase { KeepLastNDeletionPolicy policy = new KeepLastNDeletionPolicy(N); - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()) .setOpenMode(OpenMode.CREATE).setIndexDeletionPolicy(policy); @@ -646,7 +646,7 @@ public class TestDeletionPolicy extends LuceneTestCase { dir.deleteFile(IndexFileNames.SEGMENTS_GEN); int expectedCount = 176; - + searcher.close(); for(int i=0;i 0); } - private void addDoc(Random random, RAMDirectory ramDir1, String s, boolean create) throws IOException { + private void addDoc(Random random, MockRAMDirectory 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 36975056821..c4eaa109555 100644 --- a/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java +++ b/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java @@ -34,14 +34,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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; 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 RAMDirectory dir; + private MockRAMDirectory dir; public TestDocumentWriter(String s) { super(s); @@ -50,7 +50,7 @@ public class TestDocumentWriter extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - dir = new RAMDirectory(); + dir = new MockRAMDirectory(); } public void test() { diff --git a/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java b/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java index ffc20f48b5b..088a8519777 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.IndexOutput; import java.io.IOException; @@ -47,7 +47,7 @@ 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 - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); String name = "testFile"; IndexOutput output = dir.createOutput(name); assertTrue(output != null); diff --git a/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java b/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java index e8d59e226b8..6f4ac43a44c 100644 --- a/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java +++ b/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java @@ -40,12 +40,12 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util._TestUtil; public class TestFieldsReader extends LuceneTestCase { - private RAMDirectory dir = new RAMDirectory(); + private MockRAMDirectory dir = new MockRAMDirectory(); 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 fbf5903e872..b6e597e101a 100644 --- a/lucene/src/test/org/apache/lucene/index/TestFilterIndexReader.java +++ b/lucene/src/test/org/apache/lucene/index/TestFilterIndexReader.java @@ -22,7 +22,7 @@ import org.apache.lucene.util.LuceneTestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; @@ -132,7 +132,7 @@ public class TestFilterIndexReader extends LuceneTestCase { */ public void testFilterIndexReader() throws Exception { Random random = newRandom(); - RAMDirectory directory = new MockRAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); Document d1 = new Document(); @@ -150,7 +150,7 @@ public class TestFilterIndexReader extends LuceneTestCase { writer.close(); //IndexReader reader = new TestReader(IndexReader.open(directory, true)); - RAMDirectory target = new MockRAMDirectory(); + MockRAMDirectory target = new MockRAMDirectory(); 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/TestIndexCommit.java b/lucene/src/test/org/apache/lucene/index/TestIndexCommit.java index 38ef6c9062f..c920e99f5e9 100644 --- a/lucene/src/test/org/apache/lucene/index/TestIndexCommit.java +++ b/lucene/src/test/org/apache/lucene/index/TestIndexCommit.java @@ -24,7 +24,7 @@ import java.util.Collection; import java.util.Map; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCaseJ4; import org.junit.Test; @@ -33,7 +33,7 @@ public class TestIndexCommit extends LuceneTestCaseJ4 { @Test public void testEqualsHashCode() throws Exception { // LUCENE-2417: equals and hashCode() impl was inconsistent - final Directory dir = new RAMDirectory(); + final Directory dir = new MockRAMDirectory(); IndexCommit ic1 = new IndexCommit() { @Override public String getSegmentsFileName() { return "a"; } diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java b/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java index 0a380344418..326f633028f 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -39,8 +39,8 @@ public class TestIndexFileDeleter extends LuceneTestCase { public void testDeleteLeftoverFiles() throws IOException { Random random = newRandom(); - Directory dir = new RAMDirectory(); - + MockRAMDirectory dir = new MockRAMDirectory(); + dir.setPreventDoubleWrite(false); IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()) .setMaxBufferedDocs(10)); @@ -135,14 +135,14 @@ public class TestIndexFileDeleter extends LuceneTestCase { // Create a bogus fnm file when the CFS already exists: copyFile(dir, "_0.cfs", "_0.fnm"); - + // Create some old segments file: copyFile(dir, "segments_2", "segments"); copyFile(dir, "segments_2", "segments_1"); // Create a bogus cfs file shadowing a non-cfs segment: copyFile(dir, "_1.cfs", "_2.cfs"); - + String[] filesPre = dir.listAll(); // Open & close a writer: it should delete the above 4 diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexReader.java b/lucene/src/test/org/apache/lucene/index/TestIndexReader.java index 3aff15dcec0..d5eb9837b78 100644 --- a/lucene/src/test/org/apache/lucene/index/TestIndexReader.java +++ b/lucene/src/test/org/apache/lucene/index/TestIndexReader.java @@ -53,7 +53,7 @@ import org.apache.lucene.store.FSDirectory; import org.apache.lucene.store.LockObtainFailedException; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.NoSuchDirectoryException; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util._TestUtil; import org.apache.lucene.util.BytesRef; @@ -83,7 +83,7 @@ public class TestIndexReader extends LuceneTestCase } public void testCommitUserData() throws Exception { - RAMDirectory d = new MockRAMDirectory(); + MockRAMDirectory d = new MockRAMDirectory(); Map commitUserData = new HashMap(); commitUserData.put("foo", "fighters"); @@ -138,7 +138,7 @@ public class TestIndexReader extends LuceneTestCase } public void testIsCurrent() throws Exception { - RAMDirectory d = new MockRAMDirectory(); + MockRAMDirectory d = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); addDocumentWithFields(writer); @@ -167,7 +167,7 @@ public class TestIndexReader extends LuceneTestCase * @throws Exception on error */ public void testGetFieldNames() throws Exception { - RAMDirectory d = new MockRAMDirectory(); + MockRAMDirectory d = new MockRAMDirectory(); // set up writer IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); @@ -259,7 +259,7 @@ public class TestIndexReader extends LuceneTestCase } public void testTermVectors() throws Exception { - RAMDirectory d = new MockRAMDirectory(); + MockRAMDirectory d = new MockRAMDirectory(); // set up writer IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); @@ -356,7 +356,7 @@ public class TestIndexReader extends LuceneTestCase } public void testBinaryFields() throws IOException { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); byte[] bin = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); @@ -426,7 +426,7 @@ public class TestIndexReader extends LuceneTestCase // Make sure attempts to make changes after reader is // closed throws IOException: public void testChangesAfterClose() throws IOException { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriter writer = null; IndexReader reader = null; @@ -469,7 +469,7 @@ public class TestIndexReader extends LuceneTestCase // Make sure we get lock obtain failed exception with 2 writers: public void testLockObtainFailed() throws IOException { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); Term searchTerm = new Term("content", "aaa"); @@ -878,7 +878,7 @@ public class TestIndexReader extends LuceneTestCase int END_COUNT = 144; // First build up a starting index: - RAMDirectory startDir = new MockRAMDirectory(); + MockRAMDirectory startDir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); for(int i=0;i<157;i++) { Document d = new Document(); @@ -1381,7 +1381,7 @@ public class TestIndexReader extends LuceneTestCase public void testGetIndexCommit() throws IOException { - RAMDirectory d = new MockRAMDirectory(); + MockRAMDirectory d = new MockRAMDirectory(); // set up writer IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random, @@ -1430,7 +1430,7 @@ public class TestIndexReader extends LuceneTestCase } public void testReadOnly() throws Throwable { - RAMDirectory d = new MockRAMDirectory(); + MockRAMDirectory d = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); addDocumentWithFields(writer); @@ -1498,7 +1498,7 @@ public class TestIndexReader extends LuceneTestCase // LUCENE-1474 public void testIndexReader() throws Exception { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); writer.addDocument(createDocument("a")); diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java index e89b3d276b7..a238ba376d0 100644 --- a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java +++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java @@ -70,7 +70,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.SingleInstanceLockFactory; import org.apache.lucene.util.UnicodeUtil; import org.apache.lucene.util._TestUtil; @@ -91,7 +91,7 @@ public class TestIndexWriter extends LuceneTestCase { } public void testDocCount() throws IOException { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriter writer = null; IndexReader reader = null; @@ -187,7 +187,7 @@ public class TestIndexWriter extends LuceneTestCase { Directory[] dirs = new Directory[NUM_DIR]; long inputDiskUsage = 0; for(int i=0;i(); modifiedNorms = new ArrayList(); @@ -93,13 +93,13 @@ public class TestNorms extends LuceneTestCase { modifiedNorms = new ArrayList(); numDocNorms = 0; - Directory dir2 = new RAMDirectory(); + Directory dir2 = new MockRAMDirectory(); createIndex(random, dir2); doTestNorms(random, dir2); // add index1 and index2 to a third index: index3 - Directory dir3 = new RAMDirectory(); + Directory dir3 = new MockRAMDirectory(); createIndex(random, dir3); IndexWriter iw = new IndexWriter(dir3, newIndexWriterConfig(random, diff --git a/lucene/src/test/org/apache/lucene/index/TestParallelReader.java b/lucene/src/test/org/apache/lucene/index/TestParallelReader.java index 4776e1aa1b4..f1c0f25b403 100644 --- a/lucene/src/test/org/apache/lucene/index/TestParallelReader.java +++ b/lucene/src/test/org/apache/lucene/index/TestParallelReader.java @@ -35,7 +35,7 @@ import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.store.Directory; import org.apache.lucene.store.MockRAMDirectory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestParallelReader extends LuceneTestCase { @@ -262,7 +262,7 @@ public class TestParallelReader extends LuceneTestCase { } private Directory getDir2(Random random) throws IOException { - Directory dir2 = new RAMDirectory(); + Directory dir2 = new MockRAMDirectory(); IndexWriter w2 = new IndexWriter(dir2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); Document d3 = new Document(); d3.add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED)); diff --git a/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java b/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java index c9108d2db54..55dddd3805c 100644 --- a/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java +++ b/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java @@ -31,7 +31,7 @@ import org.apache.lucene.document.Field.Store; import org.apache.lucene.document.Field.TermVector; import org.apache.lucene.index.IndexWriterConfig.OpenMode; import org.apache.lucene.store.MockRAMDirectory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; /** * Some tests for {@link ParallelReader}s with empty indexes @@ -48,13 +48,13 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase { */ public void testEmptyIndex() throws IOException { Random random = newRandom(); - RAMDirectory rd1 = new MockRAMDirectory(); + MockRAMDirectory rd1 = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(rd1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); iw.close(); - RAMDirectory rd2 = new MockRAMDirectory(rd1); + MockRAMDirectory rd2 = new MockRAMDirectory(rd1); - RAMDirectory rdOut = new MockRAMDirectory(); + MockRAMDirectory rdOut = new MockRAMDirectory(); IndexWriter iwOut = new IndexWriter(rdOut, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); ParallelReader pr = new ParallelReader(); @@ -78,7 +78,7 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase { * any exception. */ public void testEmptyIndexWithVectors() throws IOException { - RAMDirectory rd1 = new MockRAMDirectory(); + MockRAMDirectory rd1 = new MockRAMDirectory(); Random random = newRandom(); { IndexWriter iw = new IndexWriter(rd1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); @@ -100,7 +100,7 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase { iw.close(); } - RAMDirectory rd2 = new MockRAMDirectory(); + MockRAMDirectory rd2 = new MockRAMDirectory(); { IndexWriter iw = new IndexWriter(rd2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); Document doc = new Document(); @@ -108,7 +108,7 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase { iw.close(); } - RAMDirectory rdOut = new MockRAMDirectory(); + MockRAMDirectory rdOut = new MockRAMDirectory(); IndexWriter iwOut = new IndexWriter(rdOut, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); ParallelReader pr = new ParallelReader(); diff --git a/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java b/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java index eba370fde0a..d8fdb8b92aa 100755 --- a/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java +++ b/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java @@ -26,7 +26,7 @@ import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.Field.Index; import org.apache.lucene.document.Field.Store; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.Bits; public class TestParallelTermEnum extends LuceneTestCase { @@ -38,7 +38,7 @@ public class TestParallelTermEnum extends LuceneTestCase { super.setUp(); Document doc; Random random = newRandom(); - RAMDirectory rd1 = new RAMDirectory(); + MockRAMDirectory rd1 = new MockRAMDirectory(); IndexWriter iw1 = new IndexWriter(rd1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); doc = new Document(); @@ -50,7 +50,7 @@ public class TestParallelTermEnum extends LuceneTestCase { iw1.addDocument(doc); iw1.close(); - RAMDirectory rd2 = new RAMDirectory(); + MockRAMDirectory rd2 = new MockRAMDirectory(); IndexWriter iw2 = new IndexWriter(rd2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); doc = new Document(); diff --git a/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java b/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java index 29c9d611c5b..2f6a618120e 100644 --- a/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java +++ b/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java @@ -20,7 +20,7 @@ package org.apache.lucene.index; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.store.BufferedIndexInput; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.document.Document; import org.apache.lucene.index.codecs.CodecProvider; import org.apache.lucene.util.BytesRef; @@ -30,14 +30,14 @@ import java.util.Collection; public class TestSegmentMerger extends LuceneTestCase { //The variables for the new merged segment - private Directory mergedDir = new RAMDirectory(); + private Directory mergedDir = new MockRAMDirectory(); private String mergedSegment = "test"; //First segment to be merged - private Directory merge1Dir = new RAMDirectory(); + private Directory merge1Dir = new MockRAMDirectory(); private Document doc1 = new Document(); private SegmentReader reader1 = null; //Second Segment to be merged - private Directory merge2Dir = new RAMDirectory(); + private Directory merge2Dir = new MockRAMDirectory(); private Document doc2 = new Document(); private SegmentReader reader2 = null; diff --git a/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java b/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java index 21cbff36820..8db0a77a396 100644 --- a/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java +++ b/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java @@ -28,10 +28,10 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.document.Document; import org.apache.lucene.document.Fieldable; import org.apache.lucene.search.Similarity; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; public class TestSegmentReader extends LuceneTestCase { - private RAMDirectory dir = new RAMDirectory(); + private MockRAMDirectory dir = new MockRAMDirectory(); private Document testDoc = new Document(); private SegmentReader reader = null; diff --git a/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java b/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java index 9b641d38db1..370bab226ad 100644 --- a/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java +++ b/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java @@ -18,7 +18,7 @@ package org.apache.lucene.index; */ import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.analysis.MockAnalyzer; @@ -30,7 +30,7 @@ import java.io.IOException; public class TestSegmentTermDocs extends LuceneTestCase { private Document testDoc = new Document(); - private Directory dir = new RAMDirectory(); + private Directory dir = new MockRAMDirectory(); private SegmentInfo info; public TestSegmentTermDocs(String s) { @@ -103,7 +103,7 @@ public class TestSegmentTermDocs extends LuceneTestCase { } public void testSkipTo(int indexDivisor) throws IOException { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(newRandom(), TEST_VERSION_CURRENT, new MockAnalyzer())); Term ta = new Term("content","aaa"); diff --git a/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java b/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java index 6867350121c..e781e5acda9 100644 --- a/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java +++ b/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java @@ -28,13 +28,13 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.MockRAMDirectory; public class TestSegmentTermEnum extends LuceneTestCase { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); public void testTermEnum() throws IOException { Random random = newRandom(); diff --git a/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java b/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java index e70dbf81b37..0c3d9b28154 100644 --- a/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java +++ b/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java @@ -28,7 +28,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.BytesRef; @@ -87,7 +87,7 @@ public class TestTermdocPerf extends LuceneTestCase { public int doTest(int iter, int ndocs, int maxTF, float percentDocs) throws IOException { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); long start = System.currentTimeMillis(); addDocs(dir, ndocs, "foo", "val", maxTF, percentDocs); diff --git a/lucene/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java b/lucene/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java index 8a88074cc8f..ccc011d597f 100644 --- a/lucene/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java +++ b/lucene/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java @@ -35,7 +35,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -283,7 +283,7 @@ public class TestMultiFieldQueryParser extends LuceneTestCase { public void testStopWordSearching() throws Exception { Analyzer analyzer = new MockAnalyzer(); - Directory ramDir = new RAMDirectory(); + Directory ramDir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(ramDir, new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer)); Document doc = new Document(); doc.add(new Field("body", "blah the footest blah", Field.Store.NO, Field.Index.ANALYZED)); diff --git a/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java b/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java index c272a5f2350..e3d23fbc7ce 100644 --- a/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java +++ b/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java @@ -58,7 +58,7 @@ import org.apache.lucene.search.TermRangeQuery; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.WildcardQuery; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LocalizedTestCase; @@ -570,7 +570,7 @@ public class TestQueryParser extends LocalizedTestCase { public void testFarsiRangeCollating() throws Exception { - RAMDirectory ramDir = new RAMDirectory(); + MockRAMDirectory ramDir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(ramDir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false))); Document doc = new Document(); doc.add(new Field("content","\u0633\u0627\u0628", @@ -978,7 +978,7 @@ public class TestQueryParser extends LocalizedTestCase { } public void testLocalDateFormat() throws IOException, ParseException { - RAMDirectory ramDir = new RAMDirectory(); + MockRAMDirectory ramDir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(ramDir, new IndexWriterConfig(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); diff --git a/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java b/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java index 5da509a1c63..503d303c826 100644 --- a/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java +++ b/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java @@ -27,7 +27,7 @@ import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.IndexWriterConfig.OpenMode; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; public class BaseTestRangeFilter extends LuceneTestCase { @@ -46,7 +46,7 @@ public class BaseTestRangeFilter extends LuceneTestCase { int maxR; int minR; boolean allowNegativeRandomInts; - RAMDirectory index = new RAMDirectory(); + MockRAMDirectory index = new MockRAMDirectory(); TestIndex(int minR, int maxR, boolean allowNegativeRandomInts) { this.minR = minR; diff --git a/lucene/src/test/org/apache/lucene/search/QueryUtils.java b/lucene/src/test/org/apache/lucene/search/QueryUtils.java index 6063be2301d..8cdd8b2c820 100644 --- a/lucene/src/test/org/apache/lucene/search/QueryUtils.java +++ b/lucene/src/test/org/apache/lucene/search/QueryUtils.java @@ -14,7 +14,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.MultiReader; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import static org.apache.lucene.util.LuceneTestCaseJ4.TEST_VERSION_CURRENT; /** @@ -197,9 +197,9 @@ public class QueryUtils { return out; } - private static RAMDirectory makeEmptyIndex(final int numDeletedDocs) + private static MockRAMDirectory makeEmptyIndex(final int numDeletedDocs) throws IOException { - RAMDirectory d = new RAMDirectory(); + MockRAMDirectory d = new MockRAMDirectory(); IndexWriter w = new IndexWriter(d, new IndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); for (int i = 0; i < numDeletedDocs; i++) { diff --git a/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java b/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java index c2a323ed4dd..7df36f45dec 100644 --- a/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java @@ -27,7 +27,7 @@ import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.automaton.Automaton; import org.apache.lucene.util.automaton.BasicAutomata; @@ -43,7 +43,7 @@ public class TestAutomatonQuery extends LuceneTestCase { public void setUp() throws Exception { super.setUp(); Random random = newRandom(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, directory); Document doc = new Document(); Field titleField = new Field("title", "some title", Field.Store.NO, diff --git a/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java b/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java index cd604e8bad4..ebb031d9b1d 100644 --- a/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java +++ b/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java @@ -26,7 +26,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.automaton.Automaton; import org.apache.lucene.util.automaton.RegExp; @@ -46,7 +46,7 @@ public class TestAutomatonQueryUnicode extends LuceneTestCase { public void setUp() throws Exception { super.setUp(); Random random = newRandom(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, directory); Document doc = new Document(); Field titleField = new Field("title", "some title", Field.Store.NO, diff --git a/lucene/src/test/org/apache/lucene/search/TestBoolean2.java b/lucene/src/test/org/apache/lucene/search/TestBoolean2.java index c8f15a12dfe..952473fb4de 100644 --- a/lucene/src/test/org/apache/lucene/search/TestBoolean2.java +++ b/lucene/src/test/org/apache/lucene/search/TestBoolean2.java @@ -29,7 +29,7 @@ import org.apache.lucene.index.Term; import org.apache.lucene.index.IndexReader; import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.queryParser.QueryParser; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.util.LuceneTestCase; @@ -53,7 +53,7 @@ public class TestBoolean2 extends LuceneTestCase { protected void setUp() throws Exception { super.setUp(); rnd = newRandom(); - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); RandomIndexWriter writer= new RandomIndexWriter(rnd, directory); for (int i = 0; i < docFields.length; i++) { Document doc = new Document(); @@ -70,7 +70,7 @@ public class TestBoolean2 extends LuceneTestCase { mulFactor = 1; int docCount = 0; do { - final Directory copy = new RAMDirectory(dir2); + final Directory copy = new MockRAMDirectory(dir2); RandomIndexWriter w = new RandomIndexWriter(rnd, dir2); w.addIndexes(new Directory[] {copy}); docCount = w.maxDoc(); diff --git a/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java b/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java index 06f5d842678..c4b948e55b5 100644 --- a/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java +++ b/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java @@ -24,7 +24,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import java.text.DecimalFormat; import java.util.Random; @@ -55,7 +55,7 @@ public class TestBooleanMinShouldMatch extends LuceneTestCase { "X 4 5 6" }; - index = new RAMDirectory(); + index = new MockRAMDirectory(); RandomIndexWriter w = new RandomIndexWriter(rnd, index); for (int i = 0; i < data.length; i++) { diff --git a/lucene/src/test/org/apache/lucene/search/TestBooleanOr.java b/lucene/src/test/org/apache/lucene/search/TestBooleanOr.java index 6a244e57e80..f1dfaff604d 100644 --- a/lucene/src/test/org/apache/lucene/search/TestBooleanOr.java +++ b/lucene/src/test/org/apache/lucene/search/TestBooleanOr.java @@ -31,7 +31,7 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; public class TestBooleanOr extends LuceneTestCase { @@ -137,7 +137,7 @@ public class TestBooleanOr extends LuceneTestCase { super.setUp(); // - dir = new RAMDirectory(); + dir = new MockRAMDirectory(); Random random = newRandom(); // diff --git a/lucene/src/test/org/apache/lucene/search/TestBooleanPrefixQuery.java b/lucene/src/test/org/apache/lucene/search/TestBooleanPrefixQuery.java index 868f92056f9..f0647fa0fd6 100644 --- a/lucene/src/test/org/apache/lucene/search/TestBooleanPrefixQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestBooleanPrefixQuery.java @@ -21,7 +21,7 @@ import org.apache.lucene.util.LuceneTestCase; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.index.IndexReader; @@ -65,7 +65,7 @@ public class TestBooleanPrefixQuery extends LuceneTestCase { } public void testMethod() throws Exception { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); String[] categories = new String[]{"food", "foodanddrink", diff --git a/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.java b/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.java index 70062e12259..d6a3138197d 100644 --- a/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.java +++ b/lucene/src/test/org/apache/lucene/search/TestBooleanScorer.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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; @@ -39,7 +39,7 @@ public class TestBooleanScorer extends LuceneTestCase private static final String FIELD = "category"; public void testMethod() throws Exception { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); String[] values = new String[] { "1", "2", "3", "4" }; diff --git a/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java b/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java index 6489323ecf8..33355dd10a8 100644 --- a/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java +++ b/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java @@ -27,7 +27,7 @@ import org.apache.lucene.index.Term; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.OpenBitSet; @@ -35,7 +35,7 @@ import org.apache.lucene.util.OpenBitSetDISI; public class TestCachingWrapperFilter extends LuceneTestCase { public void testCachingWorks() throws Exception { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); writer.close(); @@ -61,7 +61,7 @@ public class TestCachingWrapperFilter extends LuceneTestCase { } public void testNullDocIdSet() throws Exception { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); writer.close(); @@ -83,7 +83,7 @@ public class TestCachingWrapperFilter extends LuceneTestCase { } public void testNullDocIdSetIterator() throws Exception { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); writer.close(); @@ -124,7 +124,7 @@ public class TestCachingWrapperFilter extends LuceneTestCase { } public void testIsCacheAble() throws Exception { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); writer.close(); diff --git a/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java b/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java index e8c51a910cb..627c971a2bd 100644 --- a/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java +++ b/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java @@ -31,7 +31,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** Unit test for sorting code. */ @@ -50,7 +50,7 @@ public class TestCustomSearcherSort extends LuceneTestCase implements Serializab protected void setUp() throws Exception { super.setUp(); Random rand = newRandom(); - index = new RAMDirectory(); + index = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(rand, index); RandomGen random = new RandomGen(rand); for (int i = 0; i < INDEX_SIZE; ++i) { // don't decrease; if to low the diff --git a/lucene/src/test/org/apache/lucene/search/TestDateFilter.java b/lucene/src/test/org/apache/lucene/search/TestDateFilter.java index ddd54c91662..16583a64966 100644 --- a/lucene/src/test/org/apache/lucene/search/TestDateFilter.java +++ b/lucene/src/test/org/apache/lucene/search/TestDateFilter.java @@ -24,7 +24,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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import java.io.IOException; @@ -44,7 +44,7 @@ public class TestDateFilter extends LuceneTestCase { */ public void testBefore() throws IOException { // create an index - RAMDirectory indexStore = new RAMDirectory(); + MockRAMDirectory indexStore = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), indexStore); long now = System.currentTimeMillis(); @@ -110,7 +110,7 @@ public class TestDateFilter extends LuceneTestCase { */ public void testAfter() throws IOException { // create an index - RAMDirectory indexStore = new RAMDirectory(); + MockRAMDirectory indexStore = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), indexStore); long now = System.currentTimeMillis(); diff --git a/lucene/src/test/org/apache/lucene/search/TestDateSort.java b/lucene/src/test/org/apache/lucene/search/TestDateSort.java index 084342e0002..7187658b9c2 100644 --- a/lucene/src/test/org/apache/lucene/search/TestDateSort.java +++ b/lucene/src/test/org/apache/lucene/search/TestDateSort.java @@ -33,7 +33,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.Sort; import org.apache.lucene.search.SortField; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; /** * Test date sorting, i.e. auto-sorting of fields with type "long". @@ -51,7 +51,7 @@ public class TestDateSort extends LuceneTestCase { protected void setUp() throws Exception { super.setUp(); // Create an index writer. - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory); // oldest doc: diff --git a/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java b/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java index 39df176dacb..36058776a37 100644 --- a/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java @@ -25,7 +25,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import java.text.DecimalFormat; import java.util.Random; @@ -79,7 +79,7 @@ public class TestDisjunctionMaxQuery extends LuceneTestCase { protected void setUp() throws Exception { super.setUp(); - index = new RAMDirectory(); + index = new MockRAMDirectory(); Random random = newRandom(); RandomIndexWriter writer = new RandomIndexWriter(random, index, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()) diff --git a/lucene/src/test/org/apache/lucene/search/TestDocBoost.java b/lucene/src/test/org/apache/lucene/search/TestDocBoost.java index c0727e91834..ca0ffce6b1c 100644 --- a/lucene/src/test/org/apache/lucene/search/TestDocBoost.java +++ b/lucene/src/test/org/apache/lucene/search/TestDocBoost.java @@ -24,7 +24,7 @@ import org.apache.lucene.document.*; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; /** Document boost unit test. * @@ -37,7 +37,7 @@ public class TestDocBoost extends LuceneTestCase { } public void testDocBoost() throws Exception { - RAMDirectory store = new RAMDirectory(); + MockRAMDirectory store = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), store); Fieldable f1 = new Field("field", "word", Field.Store.YES, Field.Index.ANALYZED); diff --git a/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java b/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java index 4792c176e51..11db91884c1 100644 --- a/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java +++ b/lucene/src/test/org/apache/lucene/search/TestDocIdSet.java @@ -31,7 +31,7 @@ import org.apache.lucene.document.Field.Store; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestDocIdSet extends LuceneTestCase { @@ -101,7 +101,7 @@ public class TestDocIdSet extends LuceneTestCase { public void testNullDocIdSet() throws Exception { // Tests that if a Filter produces a null DocIdSet, which is given to // IndexSearcher, everything works fine. This came up in LUCENE-1754. - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), dir); Document doc = new Document(); doc.add(new Field("c", "val", Store.NO, Index.NOT_ANALYZED_NO_NORMS)); diff --git a/lucene/src/test/org/apache/lucene/search/TestExplanations.java b/lucene/src/test/org/apache/lucene/search/TestExplanations.java index 47532a4fb90..af4d6124bcb 100644 --- a/lucene/src/test/org/apache/lucene/search/TestExplanations.java +++ b/lucene/src/test/org/apache/lucene/search/TestExplanations.java @@ -32,7 +32,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -68,7 +68,7 @@ public class TestExplanations extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer= new RandomIndexWriter(newRandom(), directory); for (int i = 0; i < docFields.length; i++) { Document doc = new Document(); diff --git a/lucene/src/test/org/apache/lucene/search/TestFieldCache.java b/lucene/src/test/org/apache/lucene/search/TestFieldCache.java index 0bc3c88d09a..7f0d4bc3257 100644 --- a/lucene/src/test/org/apache/lucene/search/TestFieldCache.java +++ b/lucene/src/test/org/apache/lucene/search/TestFieldCache.java @@ -24,7 +24,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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.util.LuceneTestCase; @@ -48,7 +48,7 @@ public class TestFieldCache extends LuceneTestCase { protected void setUp() throws Exception { super.setUp(); Random r = newRandom(); - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); RandomIndexWriter writer= new RandomIndexWriter(r, directory); long theLong = Long.MAX_VALUE; double theDouble = Double.MAX_VALUE; diff --git a/lucene/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java b/lucene/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java index 0d89d4f41fb..df01a298fdb 100644 --- a/lucene/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java +++ b/lucene/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java @@ -27,7 +27,7 @@ import org.apache.lucene.index.IndexWriter; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; /** * A basic 'positive' Unit test class for the FieldCacheRangeFilter class. @@ -516,7 +516,7 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter { // test using a sparse index (with deleted docs). public void testSparseIndex() throws IOException { - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); for (int d = -20; d <= 20; d++) { diff --git a/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java b/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java index 8a51ccf42e2..8328b192330 100644 --- a/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestFilteredQuery.java @@ -23,7 +23,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause.Occur; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.DocIdBitSet; import java.util.BitSet; @@ -40,14 +40,14 @@ public class TestFilteredQuery extends LuceneTestCase { private IndexSearcher searcher; private IndexReader reader; - private RAMDirectory directory; + private MockRAMDirectory directory; private Query query; private Filter filter; @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter (newRandom(), directory); Document doc = new Document(); diff --git a/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java b/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java index fd9adbba92c..3770746aca7 100644 --- a/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java +++ b/lucene/src/test/org/apache/lucene/search/TestFilteredSearch.java @@ -31,7 +31,7 @@ import org.apache.lucene.index.Term; import org.apache.lucene.index.IndexWriterConfig.OpenMode; import org.apache.lucene.store.Directory; import org.apache.lucene.store.LockObtainFailedException; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.OpenBitSet; @@ -48,7 +48,7 @@ public class TestFilteredSearch extends LuceneTestCase { public void testFilteredSearch() throws CorruptIndexException, LockObtainFailedException, IOException { boolean enforceSingleSegment = true; - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); int[] filterBits = {1, 36}; SimpleDocIdSetFilter filter = new SimpleDocIdSetFilter(filterBits); IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); diff --git a/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery.java b/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery.java index 09cef595378..eb3df66f21a 100644 --- a/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery.java @@ -30,7 +30,7 @@ import org.apache.lucene.index.Term; import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.store.Directory; import org.apache.lucene.store.MockRAMDirectory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -40,7 +40,7 @@ import org.apache.lucene.util.LuceneTestCase; public class TestFuzzyQuery extends LuceneTestCase { public void testFuzziness() throws Exception { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory); addDoc("aaaaa", writer); addDoc("aaaab", writer); @@ -193,7 +193,7 @@ public class TestFuzzyQuery extends LuceneTestCase { } public void testFuzzinessLong() throws Exception { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory); addDoc("aaaaaaa", writer); addDoc("segment", writer); @@ -283,7 +283,7 @@ public class TestFuzzyQuery extends LuceneTestCase { } public void testTokenLengthOpt() throws IOException { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory); addDoc("12345678911", writer); addDoc("segment", writer); @@ -320,7 +320,7 @@ public class TestFuzzyQuery extends LuceneTestCase { /** Test the TopTermsBoostOnlyBooleanQueryRewrite rewrite method. */ public void testBoostOnlyRewrite() throws Exception { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory); addDoc("Lucene", writer); addDoc("Lucene", writer); diff --git a/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java b/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java index 93ff89f3eed..cd46b7b9e04 100644 --- a/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java +++ b/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java @@ -29,7 +29,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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -86,7 +86,7 @@ public class TestFuzzyQuery2 extends LuceneTestCase { int bits = Integer.parseInt(reader.readLine()); int terms = (int) Math.pow(2, bits); - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, dir, new MockAnalyzer(MockTokenizer.KEYWORD, false)); Document doc = new Document(); diff --git a/lucene/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java b/lucene/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java index ef086f5ddfd..80024c6adb2 100644 --- a/lucene/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java @@ -27,7 +27,7 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.Term; import org.apache.lucene.index.IndexReader; import org.apache.lucene.queryParser.QueryParser; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; @@ -40,7 +40,7 @@ public class TestMatchAllDocsQuery extends LuceneTestCase { public void testQuery() throws Exception { - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig( TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(2)); addDoc("one", iw, 1f); diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiSearcher.java b/lucene/src/test/org/apache/lucene/search/TestMultiSearcher.java index 5d26d101e3a..584f67df8bd 100644 --- a/lucene/src/test/org/apache/lucene/search/TestMultiSearcher.java +++ b/lucene/src/test/org/apache/lucene/search/TestMultiSearcher.java @@ -29,7 +29,7 @@ import org.apache.lucene.index.Term; import org.apache.lucene.index.IndexWriterConfig.OpenMode; import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.MockRAMDirectory; import java.io.IOException; import java.util.Collections; @@ -235,11 +235,11 @@ public class TestMultiSearcher extends LuceneTestCase } public void testFieldSelector() throws Exception { - RAMDirectory ramDirectory1, ramDirectory2; + MockRAMDirectory ramDirectory1, ramDirectory2; IndexSearcher indexSearcher1, indexSearcher2; - ramDirectory1 = new RAMDirectory(); - ramDirectory2 = new RAMDirectory(); + ramDirectory1 = new MockRAMDirectory(); + ramDirectory2 = new MockRAMDirectory(); Query query = new TermQuery(new Term("contents", "doc0")); // Now put the documents in a different index @@ -292,7 +292,7 @@ public class TestMultiSearcher extends LuceneTestCase private void testNormalization(int nDocs, String message) throws IOException { Query query=new TermQuery(new Term("contents", "doc0")); - RAMDirectory ramDirectory1; + MockRAMDirectory ramDirectory1; IndexSearcher indexSearcher1; ScoreDoc[] hits; @@ -320,7 +320,7 @@ public class TestMultiSearcher extends LuceneTestCase - RAMDirectory ramDirectory2; + MockRAMDirectory ramDirectory2; IndexSearcher indexSearcher2; ramDirectory1=new MockRAMDirectory(); @@ -366,7 +366,7 @@ public class TestMultiSearcher extends LuceneTestCase * @throws IOException */ public void testCustomSimilarity () throws IOException { - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); initIndex(dir, 10, true, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc... IndexSearcher srchr = new IndexSearcher(dir, true); MultiSearcher msrchr = getMultiSearcherInstance(new Searcher[]{srchr}); @@ -406,8 +406,8 @@ public class TestMultiSearcher extends LuceneTestCase } public void testDocFreq() throws IOException{ - RAMDirectory dir1 = new RAMDirectory(); - RAMDirectory dir2 = new RAMDirectory(); + MockRAMDirectory dir1 = new MockRAMDirectory(); + MockRAMDirectory dir2 = new MockRAMDirectory(); initIndex(dir1, 10, true, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc... initIndex(dir2, 5, true, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc... @@ -419,8 +419,8 @@ public class TestMultiSearcher extends LuceneTestCase } public void testCreateDocFrequencyMap() throws IOException{ - RAMDirectory dir1 = new RAMDirectory(); - RAMDirectory dir2 = new RAMDirectory(); + MockRAMDirectory dir1 = new MockRAMDirectory(); + MockRAMDirectory dir2 = new MockRAMDirectory(); Term template = new Term("contents") ; String[] contents = {"a", "b", "c"}; HashSet 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 ea54b19dc46..efbe3ad83c5 100644 --- a/lucene/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java +++ b/lucene/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java @@ -26,7 +26,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import java.io.IOException; /** @@ -112,11 +112,11 @@ public class TestMultiSearcherRanking extends LuceneTestCase { protected void setUp() throws Exception { super.setUp(); // create MultiSearcher from two seperate searchers - Directory d1 = new RAMDirectory(); + Directory d1 = new MockRAMDirectory(); IndexWriter iw1 = new IndexWriter(d1, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); addCollection1(iw1); iw1.close(); - Directory d2 = new RAMDirectory(); + Directory d2 = new MockRAMDirectory(); IndexWriter iw2 = new IndexWriter(d2, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); addCollection2(iw2); iw2.close(); @@ -127,7 +127,7 @@ public class TestMultiSearcherRanking extends LuceneTestCase { multiSearcher = new MultiSearcher(s); // create IndexSearcher which contains all documents - Directory d = new RAMDirectory(); + Directory d = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(d, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); addCollection1(iw); addCollection2(iw); diff --git a/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java b/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java index 502d1f4f16a..58573219c1d 100644 --- a/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java +++ b/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java @@ -25,7 +25,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import java.io.IOException; import java.text.Collator; import java.util.Locale; @@ -55,7 +55,7 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter { "B 2 4 5 6", "Y 3 5 6", null, "C 3 6", "X 4 5 6" }; - small = new RAMDirectory(); + small = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(rand, small, new MockAnalyzer(MockTokenizer.WHITESPACE, false)); for (int i = 0; i < data.length; i++) { @@ -609,7 +609,7 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter { public void testFarsi() throws Exception { /* build an index */ - RAMDirectory farsiIndex = new RAMDirectory(); + MockRAMDirectory farsiIndex = new MockRAMDirectory(); 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 +649,7 @@ public class TestMultiTermConstantScore extends BaseTestRangeFilter { public void testDanish() throws Exception { /* build an index */ - RAMDirectory danishIndex = new RAMDirectory(); + MockRAMDirectory danishIndex = new MockRAMDirectory(); 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 4afccc02c4f..ef2caf606f5 100644 --- a/lucene/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java +++ b/lucene/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java @@ -25,13 +25,13 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.TermFreqVector; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.English; import java.io.IOException; public class TestMultiThreadTermVectors extends LuceneTestCase { - private RAMDirectory directory = new RAMDirectory(); + private MockRAMDirectory directory = new MockRAMDirectory(); 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 c184f02721a..538b76ef923 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; 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(); - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); 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 901da4a1216..56ab6de0d6d 100644 --- a/lucene/src/test/org/apache/lucene/search/TestNot.java +++ b/lucene/src/test/org/apache/lucene/search/TestNot.java @@ -22,7 +22,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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -38,7 +38,7 @@ public class TestNot extends LuceneTestCase { } public void testNot() throws Exception { - RAMDirectory store = new RAMDirectory(); + MockRAMDirectory store = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), 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 617eca40c21..f073614a411 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.LuceneTestCaseJ4; import org.apache.lucene.util.NumericUtils; @@ -46,13 +46,13 @@ public class TestNumericRangeQuery32 extends LuceneTestCaseJ4 { // number of docs to generate for testing private static final int noDocs = 10000 * RANDOM_MULTIPLIER; - private static RAMDirectory directory = null; + private static MockRAMDirectory directory = null; private static IndexReader reader = null; private static IndexSearcher searcher = null; @BeforeClass public static void beforeClass() throws Exception { - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); Random random = newStaticRandom(TestNumericRangeQuery32.class); RandomIndexWriter writer = new RandomIndexWriter(random, directory); @@ -280,7 +280,7 @@ public class TestNumericRangeQuery32 extends LuceneTestCaseJ4 { @Test public void testInfiniteValues() throws Exception { - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(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 87d2a09f970..999115682b5 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.LuceneTestCaseJ4; import org.apache.lucene.util.NumericUtils; @@ -45,13 +45,13 @@ public class TestNumericRangeQuery64 extends LuceneTestCaseJ4 { // number of docs to generate for testing private static final int noDocs = 10000 * RANDOM_MULTIPLIER; - private static RAMDirectory directory = null; + private static MockRAMDirectory directory = null; private static IndexReader reader = null; private static IndexSearcher searcher = null; @BeforeClass public static void beforeClass() throws Exception { - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); Random random = newStaticRandom(TestNumericRangeQuery64.class); RandomIndexWriter writer = new RandomIndexWriter(random, directory); @@ -298,7 +298,7 @@ public class TestNumericRangeQuery64 extends LuceneTestCaseJ4 { @Test public void testInfiniteValues() throws Exception { - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig( 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 4e069f8e16a..7a289240fd5 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import java.io.IOException; import java.util.LinkedList; @@ -43,7 +43,7 @@ public class TestPhrasePrefixQuery extends LuceneTestCase { * */ public void testPhrasePrefix() throws IOException { - RAMDirectory indexStore = new RAMDirectory(); + MockRAMDirectory indexStore = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), 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 89d69da74c2..36079999b55 100644 --- a/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java @@ -48,14 +48,14 @@ public class TestPhraseQuery extends LuceneTestCase { private IndexSearcher searcher; private IndexReader reader; private PhraseQuery query; - private RAMDirectory directory; + private MockRAMDirectory directory; private Random random; @Override public void setUp() throws Exception { super.setUp(); random = newRandom(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); Analyzer analyzer = new Analyzer() { @Override public TokenStream tokenStream(String fieldName, Reader reader) { @@ -213,7 +213,7 @@ public class TestPhraseQuery extends LuceneTestCase { } public void testPhraseQueryWithStopAnalyzer() throws Exception { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); 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 { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, directory); Document doc = new Document(); @@ -336,7 +336,7 @@ public class TestPhraseQuery extends LuceneTestCase { } public void testSlopScoring() throws IOException { - Directory directory = new RAMDirectory(); + Directory directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, directory); Document doc = new Document(); diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java b/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java index 4ce3b76ea07..4293cf28319 100644 --- a/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java +++ b/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java @@ -18,7 +18,7 @@ package org.apache.lucene.search; */ import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; @@ -31,7 +31,7 @@ import org.apache.lucene.document.Field; */ public class TestPrefixFilter extends LuceneTestCase { public void testPrefixFilter() throws Exception { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); 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 ccc304301a8..6f58d0fa452 100644 --- a/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java @@ -23,7 +23,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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; /** * https://issues.apache.org/jira/browse/LUCENE-1974 @@ -38,7 +38,7 @@ import org.apache.lucene.store.RAMDirectory; public class TestPrefixInBooleanQuery extends LuceneTestCase { private static final String FIELD = "name"; - private RAMDirectory directory = new RAMDirectory(); + private MockRAMDirectory directory = new MockRAMDirectory(); 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 595f9a6b2d3..0e240afc3b2 100644 --- a/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java @@ -18,7 +18,7 @@ package org.apache.lucene.search; */ import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; @@ -31,7 +31,7 @@ import org.apache.lucene.document.Field; */ public class TestPrefixQuery extends LuceneTestCase { public void testPrefixQuery() throws Exception { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); String[] categories = new String[] {"/Computers", "/Computers/Mac", diff --git a/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java b/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java index 505106209e0..c7765438032 100644 --- a/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java +++ b/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java @@ -26,13 +26,13 @@ import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestQueryWrapperFilter extends LuceneTestCase { public void testBasic() throws Exception { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), dir); Document doc = new Document(); doc.add(new Field("field", "value", Store.NO, Index.ANALYZED)); diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java b/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java index c08b989dace..8fd0c1aaaed 100644 --- a/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java @@ -26,7 +26,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.automaton.Automaton; import org.apache.lucene.util.automaton.AutomatonProvider; @@ -45,7 +45,7 @@ public class TestRegexpQuery extends LuceneTestCase { public void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory); Document doc = new Document(); doc.add(new Field(FN, diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java index 62e18d03504..0e198f74e99 100644 --- a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java +++ b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java @@ -29,7 +29,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -47,7 +47,7 @@ public class TestRegexpRandom extends LuceneTestCase { protected void setUp() throws Exception { super.setUp(); random = newRandom(); - dir = new RAMDirectory(); + dir = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, dir); Document doc = new Document(); diff --git a/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java b/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java index 79f2db7b812..c31279787b3 100755 --- a/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java +++ b/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java @@ -12,7 +12,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; @@ -46,7 +46,7 @@ public class TestScorerPerf extends LuceneTestCase { public void createDummySearcher() throws Exception { // Create a dummy index with nothing in it. // This could possibly fail if Lucene starts checking for docid ranges... - RAMDirectory rd = new RAMDirectory(); + MockRAMDirectory rd = new MockRAMDirectory(); IndexWriter iw = new IndexWriter(rd, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())); iw.addDocument(new Document()); iw.close(); diff --git a/lucene/src/test/org/apache/lucene/search/TestSetNorm.java b/lucene/src/test/org/apache/lucene/search/TestSetNorm.java index 21a12e96f47..d1f3df1d429 100644 --- a/lucene/src/test/org/apache/lucene/search/TestSetNorm.java +++ b/lucene/src/test/org/apache/lucene/search/TestSetNorm.java @@ -26,7 +26,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; /** Document boost unit test. * @@ -39,7 +39,7 @@ public class TestSetNorm extends LuceneTestCase { } public void testSetNorm() throws Exception { - RAMDirectory store = new RAMDirectory(); + MockRAMDirectory store = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(store, new IndexWriterConfig(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 7a8feec10c1..32a2316f4c0 100644 --- a/lucene/src/test/org/apache/lucene/search/TestSimilarity.java +++ b/lucene/src/test/org/apache/lucene/search/TestSimilarity.java @@ -27,7 +27,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -65,7 +65,7 @@ public class TestSimilarity extends LuceneTestCase { } public void testSimilarity() throws Exception { - RAMDirectory store = new RAMDirectory(); + MockRAMDirectory store = new MockRAMDirectory(); Random random = newRandom(); RandomIndexWriter writer = new RandomIndexWriter(random, store, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()) diff --git a/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java b/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java index f294bf3239d..b0b76279bda 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; 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); - RAMDirectory ramDir = new RAMDirectory(); + MockRAMDirectory ramDir = new MockRAMDirectory(); 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 2e347cd03f0..15dfeb2900c 100644 --- a/lucene/src/test/org/apache/lucene/search/TestSort.java +++ b/lucene/src/test/org/apache/lucene/search/TestSort.java @@ -43,7 +43,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.DocIdBitSet; @@ -110,7 +110,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 Searcher getIndex (boolean even, boolean odd) throws IOException { - RAMDirectory indexStore = new RAMDirectory(); + MockRAMDirectory indexStore = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, indexStore); for (int i=0; i doSearch(int numResults) throws IOException { diff --git a/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java b/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java index 57e23d853e2..765c374cff4 100644 --- a/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java +++ b/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java @@ -24,7 +24,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestTopScoreDocCollector extends LuceneTestCase { @@ -38,7 +38,7 @@ public class TestTopScoreDocCollector extends LuceneTestCase { public void testOutOfOrderCollection() throws Exception { - Directory dir = new RAMDirectory(); + Directory dir = new MockRAMDirectory(); Random random = newRandom(); RandomIndexWriter writer = new RandomIndexWriter(random, dir); for (int i = 0; i < 10; i++) { diff --git a/lucene/src/test/org/apache/lucene/search/TestWildcard.java b/lucene/src/test/org/apache/lucene/search/TestWildcard.java index 43a3283b5fb..7ac8ddb3bfa 100644 --- a/lucene/src/test/org/apache/lucene/search/TestWildcard.java +++ b/lucene/src/test/org/apache/lucene/search/TestWildcard.java @@ -26,7 +26,7 @@ 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.RAMDirectory; +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 { - RAMDirectory indexStore = getIndexStore("field", new String[]{"nowildcard", "nowildcardx"}); + MockRAMDirectory indexStore = getIndexStore("field", new String[]{"nowildcard", "nowildcardx"}); IndexSearcher searcher = new IndexSearcher(indexStore, true); MultiTermQuery wq = new WildcardQuery(new Term("field", "nowildcard")); @@ -105,7 +105,7 @@ public class TestWildcard * Tests if a WildcardQuery with an empty term is rewritten to an empty BooleanQuery */ public void testEmptyTerm() throws IOException { - RAMDirectory indexStore = getIndexStore("field", new String[]{"nowildcard", "nowildcardx"}); + MockRAMDirectory indexStore = getIndexStore("field", new String[]{"nowildcard", "nowildcardx"}); IndexSearcher searcher = new IndexSearcher(indexStore, true); MultiTermQuery wq = new WildcardQuery(new Term("field", "")); @@ -122,7 +122,7 @@ public class TestWildcard * preserved. */ public void testPrefixTerm() throws IOException { - RAMDirectory indexStore = getIndexStore("field", new String[]{"prefix", "prefixx"}); + MockRAMDirectory indexStore = getIndexStore("field", new String[]{"prefix", "prefixx"}); IndexSearcher searcher = new IndexSearcher(indexStore, true); MultiTermQuery wq = new WildcardQuery(new Term("field", "prefix*")); @@ -141,7 +141,7 @@ public class TestWildcard */ public void testAsterisk() throws IOException { - RAMDirectory indexStore = getIndexStore("body", new String[] + MockRAMDirectory indexStore = getIndexStore("body", new String[] {"metal", "metals"}); IndexSearcher searcher = new IndexSearcher(indexStore, true); Query query1 = new TermQuery(new Term("body", "metal")); @@ -180,7 +180,7 @@ public class TestWildcard */ public void testQuestionmark() throws IOException { - RAMDirectory indexStore = getIndexStore("body", new String[] + MockRAMDirectory indexStore = getIndexStore("body", new String[] {"metal", "metals", "mXtals", "mXtXls"}); IndexSearcher searcher = new IndexSearcher(indexStore, true); Query query1 = new WildcardQuery(new Term("body", "m?tal")); @@ -198,9 +198,9 @@ public class TestWildcard assertMatches(searcher, query6, 1); // Query: 'meta??' matches 'metals' not 'metal' } - private RAMDirectory getIndexStore(String field, String[] contents) + private MockRAMDirectory getIndexStore(String field, String[] contents) throws IOException { - RAMDirectory indexStore = new RAMDirectory(); + MockRAMDirectory indexStore = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, indexStore); for (int i = 0; i < contents.length; ++i) { Document doc = new Document(); @@ -256,7 +256,7 @@ public class TestWildcard }; // prepare the index - RAMDirectory dir = new RAMDirectory(); + MockRAMDirectory dir = new MockRAMDirectory(); 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 429bbed62db..5d92ddb30cb 100644 --- a/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java +++ b/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java @@ -29,7 +29,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; /** @@ -39,6 +39,7 @@ import org.apache.lucene.util.LuceneTestCase; */ public class TestWildcardRandom extends LuceneTestCase { private Searcher searcher; + private IndexReader reader; private Random random; private Directory dir; @@ -46,7 +47,7 @@ public class TestWildcardRandom extends LuceneTestCase { protected void setUp() throws Exception { super.setUp(); random = newRandom(); - dir = new RAMDirectory(); + dir = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, dir); Document doc = new Document(); @@ -59,7 +60,7 @@ public class TestWildcardRandom extends LuceneTestCase { writer.addDocument(doc); } - IndexReader reader = writer.getReader(); + reader = writer.getReader(); searcher = new IndexSearcher(reader); writer.close(); } @@ -92,6 +93,7 @@ public class TestWildcardRandom extends LuceneTestCase { @Override protected void tearDown() throws Exception { searcher.close(); + reader.close(); dir.close(); super.tearDown(); } diff --git a/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.java b/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.java index 311039cec1a..223e1965957 100755 --- a/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.java +++ b/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.java @@ -25,7 +25,7 @@ import org.apache.lucene.document.Fieldable; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCaseJ4; import org.apache.lucene.util._TestUtil; import java.util.Random; @@ -95,7 +95,7 @@ public class FunctionTestSetup extends LuceneTestCaseJ4 { public void setUp() throws Exception { super.setUp(); // prepare a small index with just a few documents. - dir = new RAMDirectory(); + dir = new MockRAMDirectory(); anlzr = new MockAnalyzer(); Random r = newRandom(); IndexWriterConfig iwc = newIndexWriterConfig(r, TEST_VERSION_CURRENT, anlzr); 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 aece003d8a4..043f0ce0967 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,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.util.English; @@ -104,7 +104,7 @@ public class PayloadHelper { * @throws IOException */ public IndexSearcher setUp(Similarity similarity, int numDocs) throws IOException { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); PayloadAnalyzer analyzer = new PayloadAnalyzer(); IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig( TEST_VERSION_CURRENT, analyzer).setSimilarity(similarity)); diff --git a/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java b/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java index bd6368d2491..7e66ea5105c 100644 --- a/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java +++ b/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java @@ -42,7 +42,7 @@ import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanNearQuery; import org.apache.lucene.search.spans.SpanTermQuery; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.English; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.search.Explanation.IDFExplanation; @@ -106,7 +106,7 @@ public class TestPayloadNearQuery extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); Random random = newRandom(); RandomIndexWriter writer = new RandomIndexWriter(random, directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new PayloadAnalyzer()) 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 632b32b1dc2..6ec19e50998 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.IndexWriterConfig; import org.apache.lucene.index.Payload; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; 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 RAMDirectory directory; + protected MockRAMDirectory directory; public TestPayloadTermQuery(String s) { super(s); @@ -112,7 +112,7 @@ public class TestPayloadTermQuery extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); Random random = newRandom(); RandomIndexWriter writer = new RandomIndexWriter(random, directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new PayloadAnalyzer()) @@ -261,6 +261,7 @@ public class TestPayloadTermQuery extends LuceneTestCase { while (spans.next()) { count++; } + theSearcher.close(); } public void testNoMatch() throws Exception { 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 5062305009b..0e07958758d 100644 --- a/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java +++ b/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java @@ -35,7 +35,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.English; import org.apache.lucene.util.LuceneTestCase; @@ -59,7 +59,7 @@ public class TestBasics extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer = new RandomIndexWriter(newRandom(), directory, new MockAnalyzer(MockTokenizer.SIMPLE, true)); //writer.infoStream = System.out; diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java b/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java index 319fa27e444..2c7018df3cd 100644 --- a/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java +++ b/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java @@ -30,7 +30,7 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.QueryUtils; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestFieldMaskingSpanQuery extends LuceneTestCase { @@ -54,7 +54,7 @@ public class TestFieldMaskingSpanQuery extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer= new RandomIndexWriter(newRandom(), directory); writer.addDocument(doc(new Field[] { field("id", "0") diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java b/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java index c734e00f2d0..a5dfdb0e2a8 100644 --- a/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java +++ b/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java @@ -30,7 +30,7 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Weight; import org.apache.lucene.search.Scorer; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestNearSpansOrdered extends LuceneTestCase { @@ -53,7 +53,7 @@ public class TestNearSpansOrdered extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer= new RandomIndexWriter(newRandom(), directory); for (int i = 0; i < docFields.length; i++) { Document doc = new Document(); 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 316e76cc236..34c8e66d601 100644 --- a/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java +++ b/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java @@ -47,7 +47,7 @@ import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.payloads.PayloadHelper; import org.apache.lucene.search.payloads.PayloadSpanUtil; import org.apache.lucene.store.LockObtainFailedException; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.util.LuceneTestCase; public class TestPayloadSpans extends LuceneTestCase { @@ -114,7 +114,7 @@ public class TestPayloadSpans extends LuceneTestCase { public IndexSearcher getSpanNotSearcher() throws IOException { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig( TEST_VERSION_CURRENT, new PayloadAnalyzer()).setSimilarity( similarity)); @@ -254,7 +254,7 @@ public class TestPayloadSpans extends LuceneTestCase { public void testShrinkToAfterShortestMatch() throws CorruptIndexException, LockObtainFailedException, IOException { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig( TEST_VERSION_CURRENT, new TestPayloadAnalyzer())); Document doc = new Document(); @@ -288,7 +288,7 @@ public class TestPayloadSpans extends LuceneTestCase { public void testShrinkToAfterShortestMatch2() throws CorruptIndexException, LockObtainFailedException, IOException { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig( TEST_VERSION_CURRENT, new TestPayloadAnalyzer())); Document doc = new Document(); @@ -321,7 +321,7 @@ public class TestPayloadSpans extends LuceneTestCase { public void testShrinkToAfterShortestMatch3() throws CorruptIndexException, LockObtainFailedException, IOException { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig( TEST_VERSION_CURRENT, new TestPayloadAnalyzer())); Document doc = new Document(); @@ -359,7 +359,7 @@ public class TestPayloadSpans extends LuceneTestCase { } public void testPayloadSpanUtil() throws Exception { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig( TEST_VERSION_CURRENT, new PayloadAnalyzer()).setSimilarity( similarity)); @@ -418,7 +418,7 @@ public class TestPayloadSpans extends LuceneTestCase { } private IndexSearcher getSearcher() throws Exception { - RAMDirectory directory = new RAMDirectory(); + MockRAMDirectory directory = new MockRAMDirectory(); String[] docs = new String[]{"xx rr yy mm pp","xx yy mm rr pp", "nopayload qq ss pp np", "one two three four five six seven eight nine ten eleven", "nine one two three four five six seven eight eleven ten"}; IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig( TEST_VERSION_CURRENT, new PayloadAnalyzer()).setSimilarity(similarity)); diff --git a/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java b/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java index f68262663dd..63cbeacfef8 100644 --- a/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java +++ b/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java @@ -26,7 +26,7 @@ import org.apache.lucene.search.DefaultSimilarity; import org.apache.lucene.search.Scorer; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.Searcher; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.store.MockRAMDirectory; import org.apache.lucene.analysis.MockAnalyzer; @@ -50,7 +50,7 @@ public class TestSpans extends LuceneTestCase { @Override protected void setUp() throws Exception { super.setUp(); - directory = new RAMDirectory(); + directory = new MockRAMDirectory(); RandomIndexWriter writer= new RandomIndexWriter(newRandom(), directory); for (int i = 0; i < docFields.length; i++) { Document doc = new Document(); 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 273291802e5..1a28a2555c0 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,7 @@ 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.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; /******************************************************************************* * Tests the span query bug in Lucene. It demonstrates that SpanTermQuerys don't @@ -59,7 +59,7 @@ public class TestSpansAdvanced extends LuceneTestCase { super.setUp(); random = newRandom(); // create test index - mDirectory = new RAMDirectory(); + mDirectory = new MockRAMDirectory(); final RandomIndexWriter writer = new RandomIndexWriter(random, mDirectory, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true)); diff --git a/lucene/src/test/org/apache/lucene/store/TestLockFactory.java b/lucene/src/test/org/apache/lucene/store/TestLockFactory.java index 9371d937c5d..58afe52a3ee 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 RAMDirectory(); + Directory dir = new MockRAMDirectory(); 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 RAMDirectory(); + Directory dir = new MockRAMDirectory(); 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 RAMDirectory(); + Directory dir = new MockRAMDirectory(); assertTrue("RAMDirectory did not use correct LockFactory: got " + dir.getLockFactory(), SingleInstanceLockFactory.class.isInstance(dir.getLockFactory())); diff --git a/lucene/src/test/org/apache/lucene/util/TestBitVector.java b/lucene/src/test/org/apache/lucene/util/TestBitVector.java index 77c0e6f61e2..deeb7347569 100644 --- a/lucene/src/test/org/apache/lucene/util/TestBitVector.java +++ b/lucene/src/test/org/apache/lucene/util/TestBitVector.java @@ -21,7 +21,7 @@ import java.io.IOException; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.store.MockRAMDirectory; /** * TestBitVector tests the BitVector, obviously. @@ -140,8 +140,8 @@ public class TestBitVector extends LuceneTestCase } private void doTestWriteRead(int n) throws Exception { - Directory d = new RAMDirectory(); - + MockRAMDirectory d = new MockRAMDirectory(); + d.setPreventDoubleWrite(false); BitVector bv = new BitVector(n); // test count when incrementally setting bits for(int i=0;i