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
This commit is contained in:
Robert Muir 2010-08-10 22:03:54 +00:00
parent ca4c8f3ae9
commit d2165cf08e
143 changed files with 471 additions and 466 deletions

View File

@ -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 {

View File

@ -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++) {

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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();

View File

@ -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");

View File

@ -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);

View File

@ -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() {

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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() {

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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));

View File

@ -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();

View File

@ -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

View File

@ -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();

View File

@ -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,

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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(

View File

@ -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();

View File

@ -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();

View File

@ -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));

View File

@ -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()));

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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<IndexSearcher>());
// create the spellChecker
spellindex = new RAMDirectory();
spellindex = new MockRAMDirectory();
spellChecker = new SpellCheckerMock(spellindex);
}

View File

@ -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)

View File

@ -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++)
{

View File

@ -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

View File

@ -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(

View File

@ -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();

View File

@ -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();

View File

@ -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() {

View File

@ -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");

View File

@ -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);

View File

@ -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 });

View File

@ -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());

View File

@ -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);

View File

@ -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<N+1;i++) {
try {
IndexReader reader = IndexReader.open(dir, true);
@ -678,7 +678,6 @@ public class TestDeletionPolicy extends LuceneTestCase {
}
gen--;
}
dir.close();
}
}
@ -698,7 +697,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)

View File

@ -24,7 +24,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.BytesRef;
import java.io.IOException;
@ -45,7 +45,7 @@ public class TestDirectoryReader extends LuceneTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
dir = new RAMDirectory();
dir = new MockRAMDirectory();
doc1 = new Document();
doc2 = new Document();
DocHelper.setupDoc(doc1);
@ -126,9 +126,9 @@ public class TestDirectoryReader extends LuceneTestCase {
public void testIsCurrent() throws IOException {
Random random = newRandom();
RAMDirectory ramDir1=new RAMDirectory();
MockRAMDirectory ramDir1=new MockRAMDirectory();
addDoc(random, ramDir1, "test foo", true);
RAMDirectory ramDir2=new RAMDirectory();
MockRAMDirectory ramDir2=new MockRAMDirectory();
addDoc(random, ramDir2, "test blah", true);
IndexReader[] readers = new IndexReader[]{IndexReader.open(ramDir1, false), IndexReader.open(ramDir2, false)};
MultiReader mr = new MultiReader(readers);
@ -148,11 +148,11 @@ public class TestDirectoryReader extends LuceneTestCase {
public void testMultiTermDocs() throws IOException {
Random random = newRandom();
RAMDirectory ramDir1=new RAMDirectory();
MockRAMDirectory ramDir1=new MockRAMDirectory();
addDoc(random, ramDir1, "test foo", true);
RAMDirectory ramDir2=new RAMDirectory();
MockRAMDirectory ramDir2=new MockRAMDirectory();
addDoc(random, ramDir2, "test blah", true);
RAMDirectory ramDir3=new RAMDirectory();
MockRAMDirectory ramDir3=new MockRAMDirectory();
addDoc(random, ramDir3, "test wow", true);
IndexReader[] readers1 = new IndexReader[]{IndexReader.open(ramDir1, false), IndexReader.open(ramDir3, false)};
@ -184,7 +184,7 @@ public class TestDirectoryReader extends LuceneTestCase {
assertTrue(ret > 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(

View File

@ -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() {

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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"; }

View File

@ -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));

View File

@ -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<String,String> commitUserData = new HashMap<String,String>();
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"));

View File

@ -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<NUM_DIR;i++) {
dirs[i] = new RAMDirectory();
dirs[i] = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dirs[i], newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
for(int j=0;j<25;j++) {
addDocWithIndex(writer, 25*i+j);
@ -201,7 +201,7 @@ public class TestIndexWriter extends LuceneTestCase {
// Now, build a starting index that has START_COUNT docs. We
// will then try to addIndexesNoOptimize into a copy of this:
RAMDirectory startDir = new RAMDirectory();
MockRAMDirectory startDir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
for(int j=0;j<START_COUNT;j++) {
addDocWithIndex(writer, j);
@ -714,7 +714,8 @@ public class TestIndexWriter extends LuceneTestCase {
// gracefully fallback to the previous segments file),
// and that we can add to the index:
public void testSimulatedCrashedWriter() throws IOException {
Directory dir = new RAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
dir.setPreventDoubleWrite(false);
IndexWriter writer = null;
@ -775,7 +776,7 @@ public class TestIndexWriter extends LuceneTestCase {
// latest segments file and make sure we get an
// IOException trying to open the index:
public void testSimulatedCorruptIndex1() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = null;
@ -818,7 +819,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testChangesAfterClose() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = null;
@ -840,7 +841,7 @@ public class TestIndexWriter extends LuceneTestCase {
// files and make sure we get an IOException trying to
// open the index:
public void testSimulatedCorruptIndex2() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = null;
@ -886,7 +887,7 @@ public class TestIndexWriter extends LuceneTestCase {
* these docs until writer is closed.
*/
public void testCommitOnClose() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < 14; i++) {
addDoc(writer);
@ -1049,7 +1050,8 @@ public class TestIndexWriter extends LuceneTestCase {
* and close().
*/
public void testCommitOnCloseOptimize() throws IOException {
RAMDirectory dir = new RAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
dir.setPreventDoubleWrite(false); // TODO: should this be disabled here?
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(10);
for(int j=0;j<17;j++) {
@ -1093,7 +1095,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testIndexNoDocuments() throws IOException {
RAMDirectory dir = new RAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.commit();
writer.close();
@ -1114,7 +1116,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testManyFields() throws IOException {
RAMDirectory dir = new RAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10));
for(int j=0;j<100;j++) {
Document doc = new Document();
@ -1144,7 +1146,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testSmallRAMBuffer() throws IOException {
RAMDirectory dir = new RAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setRAMBufferSizeMB(0.000001));
((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
int lastNumFile = dir.listAll().length;
@ -1171,7 +1173,7 @@ public class TestIndexWriter extends LuceneTestCase {
* session won't be possible.
*/
public void testChangingRAMBuffer() throws IOException {
RAMDirectory dir = new RAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10).setRAMBufferSizeMB(
IndexWriterConfig.DISABLE_AUTO_FLUSH));
@ -1229,7 +1231,7 @@ public class TestIndexWriter extends LuceneTestCase {
* changing those settings on IW won't be possible.
*/
public void testChangingRAMBuffer2() throws IOException {
RAMDirectory dir = new RAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10).setMaxBufferedDeleteTerms(
10).setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH));
@ -1288,7 +1290,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testDiverseDocs() throws IOException {
RAMDirectory dir = new RAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setRAMBufferSizeMB(0.5));
for(int i=0;i<3;i++) {
// First, docs where every term is unique (heavy on
@ -1335,7 +1337,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testEnablingNorms() throws IOException {
RAMDirectory dir = new RAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10));
// Enable norms for only 1 doc, pre flush
for(int j=0;j<10;j++) {
@ -1381,7 +1383,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testHighFreqTerm() throws IOException {
RAMDirectory dir = new RAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxFieldLength(100000000).setRAMBufferSizeMB(0.01));
// Massive doc that has 128 K a's
@ -1419,7 +1421,7 @@ public class TestIndexWriter extends LuceneTestCase {
// compatibility.
public void testNullLockFactory() throws IOException {
final class MyRAMDirectory extends RAMDirectory {
final class MyRAMDirectory extends MockRAMDirectory {
private LockFactory myLockFactory;
MyRAMDirectory() {
lockFactory = null;
@ -1442,17 +1444,17 @@ public class TestIndexWriter extends LuceneTestCase {
IndexSearcher searcher = new IndexSearcher(dir, false);
ScoreDoc[] hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
assertEquals("did not get right number of hits", 100, hits.length);
writer.close();
searcher.close();
writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
.setOpenMode(OpenMode.CREATE));
writer.close();
searcher.close();
dir.close();
}
public void testFlushWithNoMerging() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
@ -1472,7 +1474,7 @@ public class TestIndexWriter extends LuceneTestCase {
// Make sure we can flush segment w/ norms, then add
// empty doc (no norms) and flush
public void testEmptyDocAfterFlushingRealDoc() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
@ -1678,7 +1680,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1072
public void testExceptionFromTokenStream() throws IOException {
RAMDirectory dir = new MockRAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new Analyzer() {
@Override
@ -2080,7 +2082,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testNoWaitClose() throws Throwable {
RAMDirectory directory = new MockRAMDirectory();
MockRAMDirectory directory = new MockRAMDirectory();
final Document doc = new Document();
Field idField = new Field("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
@ -4005,7 +4007,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testOptimizeExceptions() throws IOException {
RAMDirectory startDir = new MockRAMDirectory();
MockRAMDirectory startDir = new MockRAMDirectory();
IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2);
((LogMergePolicy) conf.getMergePolicy()).setMergeFactor(100);
IndexWriter w = new IndexWriter(startDir, conf);
@ -4341,7 +4343,7 @@ public class TestIndexWriter extends LuceneTestCase {
@Override
public void run() {
RAMDirectory dir = new RAMDirectory();
MockRAMDirectory dir = new MockRAMDirectory();
IndexWriter w = null;
boolean first = true;
while(!finish) {
@ -4939,7 +4941,7 @@ public class TestIndexWriter extends LuceneTestCase {
// Tests that if we don't call commit(), the directory has 0 commits. This has
// changed since LUCENE-2386, where before IW would always commit on a fresh
// new index.
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
try {
IndexReader.listCommits(dir);

View File

@ -34,7 +34,7 @@ import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.Similarity;
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;
@ -264,7 +264,7 @@ public class TestIndexWriterConfig extends LuceneTestCaseJ4 {
// iw.getConfig().getXYZ(), he'll get the same value he passed to
// iw.setXYZ().
IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer());
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, conf);
writer.setSimilarity(new MySimilarity());

View File

@ -24,7 +24,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._TestUtil;
import org.apache.lucene.util.LuceneTestCase;
@ -33,7 +33,7 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// Test the normal case
public void testNormalCase() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
@ -49,7 +49,7 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// Test to see if there is over merge
public void testNoOverMerge() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
@ -70,7 +70,7 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// Test the case where flush is forced after every addDoc
public void testForceFlush() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
LogDocMergePolicy mp = new LogDocMergePolicy();
mp.setMinMergeDocs(100);
@ -97,7 +97,7 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// Test the case where mergeFactor changes
public void testMergeFactorChange() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
@ -122,7 +122,7 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// Test the case where both mergeFactor and maxBufferedDocs change
public void testMaxBufferedDocsChange() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
@ -170,7 +170,7 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase {
// Test the case where a merge results in no doc at all
public void testMergeDocCount0() throws IOException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
LogDocMergePolicy ldmp = new LogDocMergePolicy();
ldmp.setMergeFactor(100);

View File

@ -31,7 +31,7 @@ import org.apache.lucene.document.FieldSelector;
import org.apache.lucene.document.FieldSelectorResult;
import org.apache.lucene.document.Fieldable;
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 TestLazyBug extends LuceneTestCase {
};
private Directory makeIndex() throws RuntimeException {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
try {
Random r = newRandom();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(r,

View File

@ -29,7 +29,7 @@ import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
@ -46,7 +46,7 @@ public class TestLazyProxSkipping extends LuceneTestCase {
private String term2 = "yy";
private String term3 = "zz";
private class SeekCountingDirectory extends RAMDirectory {
private class SeekCountingDirectory extends MockRAMDirectory {
@Override
public IndexInput openInput(String name) throws IOException {
IndexInput ii = super.openInput(name);
@ -120,7 +120,7 @@ public class TestLazyProxSkipping extends LuceneTestCase {
}
public void testSeek() throws IOException {
Directory directory = new RAMDirectory();
Directory directory = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(newRandom(), TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < 10; i++) {
Document doc = new Document();

View File

@ -20,12 +20,12 @@ package org.apache.lucene.index;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public class TestNewestSegment extends LuceneTestCase {
public void testNewestSegment() throws Exception {
RAMDirectory directory = new RAMDirectory();
MockRAMDirectory directory = new MockRAMDirectory();
Analyzer analyzer = new MockAnalyzer();
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(newRandom(), TEST_VERSION_CURRENT, new MockAnalyzer()));
assertNull(writer.newestSegment());

View File

@ -30,7 +30,7 @@ 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.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCaseJ4;
import org.junit.Test;
@ -73,7 +73,7 @@ public class TestNoDeletionPolicy extends LuceneTestCaseJ4 {
@Test
public void testAllCommitsRemain() throws Exception {
Directory dir = new RAMDirectory();
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(newRandom(),
TEST_VERSION_CURRENT, new MockAnalyzer())
.setIndexDeletionPolicy(NoDeletionPolicy.INSTANCE));

View File

@ -31,7 +31,7 @@ import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**
@ -76,7 +76,7 @@ public class TestNorms extends LuceneTestCase {
*/
public void testNorms() throws IOException {
Random random = newRandom();
Directory dir1 = new RAMDirectory();
Directory dir1 = new MockRAMDirectory();
norms = new ArrayList<Float>();
modifiedNorms = new ArrayList<Float>();
@ -93,13 +93,13 @@ public class TestNorms extends LuceneTestCase {
modifiedNorms = new ArrayList<Float>();
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,

View File

@ -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));

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -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();

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -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;

View File

@ -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++) {

View File

@ -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,

View File

@ -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,

View File

@ -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();

View File

@ -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++) {

View File

@ -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();
//

View File

@ -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",

View File

@ -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" };

View File

@ -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();

View File

@ -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

View File

@ -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();

View File

@ -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:

View File

@ -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())

View File

@ -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);

View File

@ -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));

View File

@ -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();

View File

@ -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;

View File

@ -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++) {

View File

@ -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();

View File

@ -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()));

View File

@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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<Term> termsSet = new HashSet<Term>();

View File

@ -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);

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