LUCENE-2598: factor the behavior of MockRAMDirectory into MockDirectoryWrapper, add experimental -Dtests.directory= to allow running the tests under different directory impls [but the default is still RAMDirectory]

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@988206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-08-23 17:00:43 +00:00
parent 9b62d49e92
commit 07df8d5210
157 changed files with 801 additions and 580 deletions

2
.hgignore Normal file
View File

@ -0,0 +1,2 @@
syntax: glob
*/build/*

View File

@ -60,6 +60,7 @@
<property name="tests.codec" value="random" />
<property name="tests.locale" value="random" />
<property name="tests.timezone" value="random" />
<property name="tests.directory" value="RAMDirectory" />
<property name="javac.deprecation" value="off"/>
<property name="javac.debug" value="on"/>
@ -444,6 +445,8 @@
<sysproperty key="tests.locale" value="${tests.locale}"/>
<!-- set the timezone tests should run with -->
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
<!-- set the directory tests should run with -->
<sysproperty key="tests.directory" value="${tests.directory}"/>
<!-- TODO: create propertyset for test properties, so each project can have its own set -->
<sysproperty key="random.multiplier" value="${random.multiplier}"/>

View File

@ -35,7 +35,6 @@ import org.apache.lucene.document.Field.TermVector;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermPositionVector;
import org.apache.lucene.search.Collector;
@ -49,7 +48,6 @@ import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.OpenBitSet;

View File

@ -78,7 +78,6 @@ import org.apache.lucene.search.spans.SpanOrQuery;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.automaton.BasicAutomata;
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
import org.apache.lucene.util.automaton.RegExp;
@ -95,7 +94,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
static final String FIELD_NAME = "contents";
private static final String NUMERIC_FIELD_NAME = "nfield";
private Query query;
MockRAMDirectory ramDir;
Directory ramDir;
public IndexSearcher searcher = null;
int numHighlights = 0;
final Analyzer analyzer = new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true);
@ -1323,7 +1322,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
public void testMultiSearcher() throws Exception {
// setup index 1
MockRAMDirectory ramDir1 = newDirectory(random);
Directory ramDir1 = newDirectory(random);
IndexWriter writer1 = new IndexWriter(ramDir1, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true)));
Document d = new Document();
@ -1335,7 +1334,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
IndexReader reader1 = IndexReader.open(ramDir1, true);
// setup index 2
MockRAMDirectory ramDir2 = newDirectory(random);
Directory ramDir2 = newDirectory(random);
IndexWriter writer2 = new IndexWriter(ramDir2, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true)));
d = new Document();

View File

@ -44,7 +44,6 @@ import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public abstract class AbstractTestCase extends LuceneTestCase {

View File

@ -23,14 +23,12 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public class TestEmptyIndex extends LuceneTestCase {

View File

@ -41,7 +41,6 @@ import org.apache.lucene.index.FieldsEnum;
import org.apache.lucene.index.TermFreqVector;
import org.apache.lucene.index.TermPositionVector;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.AttributeImpl;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
@ -63,7 +62,7 @@ public class TestIndicesEquals extends LuceneTestCase {
public void testLoadIndexReader() throws Exception {
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
// create dir data
IndexWriter indexWriter = new IndexWriter(dir, newIndexWriterConfig(random,
@ -88,7 +87,7 @@ public class TestIndicesEquals extends LuceneTestCase {
public void testInstantiatedIndexWriter() throws Exception {
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
InstantiatedIndex ii = new InstantiatedIndex();
// create dir data

View File

@ -22,7 +22,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.analysis.MockAnalyzer;

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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util._TestUtil;
/**
@ -106,7 +106,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
termField.append(randomTerm());
}
MockRAMDirectory ramdir = newDirectory(random);
Directory ramdir = newDirectory(random);
Analyzer analyzer = randomAnalyzer();
IndexWriter writer = new IndexWriter(ramdir,
new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
@ -128,7 +128,7 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
/**
* Run all queries against both the RAMDirectory and MemoryIndex, ensuring they are the same.
*/
public void assertAllQueries(MemoryIndex memory, MockRAMDirectory ramdir, Analyzer analyzer) throws Exception {
public void assertAllQueries(MemoryIndex memory, Directory ramdir, Analyzer analyzer) throws Exception {
IndexSearcher ram = new IndexSearcher(ramdir);
IndexSearcher mem = memory.createSearcher();
QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "foo", analyzer);

View File

@ -31,7 +31,6 @@ import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**

View File

@ -22,7 +22,6 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
@ -30,7 +29,7 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase {
IndexReader input;
int NUM_DOCS = 11;
private Random random;
MockRAMDirectory dir;
Directory dir;
@Override
protected void setUp() throws Exception {

View File

@ -4,10 +4,8 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import java.util.Collections;
import java.util.Random;
/*
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -42,7 +42,8 @@ import org.apache.lucene.index.codecs.SegmentInfosReader;
import org.apache.lucene.index.codecs.SegmentInfosWriter;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.Version;
@ -118,7 +119,11 @@ public class TestAppendingCodec extends LuceneTestCase {
}
@SuppressWarnings("serial")
private static class AppendingRAMDirectory extends MockRAMDirectory {
private static class AppendingRAMDirectory extends MockDirectoryWrapper {
public AppendingRAMDirectory(Directory delegate) {
super(delegate);
}
@Override
public IndexOutput createOutput(String name) throws IOException {
@ -130,7 +135,7 @@ public class TestAppendingCodec extends LuceneTestCase {
private static final String text = "the quick brown fox jumped over the lazy dog";
public void testCodec() throws Exception {
Directory dir = new AppendingRAMDirectory();
Directory dir = new AppendingRAMDirectory(new RAMDirectory());
IndexWriterConfig cfg = new IndexWriterConfig(Version.LUCENE_40, new MockAnalyzer());
cfg.setCodecProvider(new AppendingCodecProvider());

View File

@ -21,10 +21,9 @@ import java.util.Random;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
@ -33,7 +32,7 @@ import org.apache.lucene.document.Field;
public class TestHighFreqTerms extends LuceneTestCase {
private static IndexWriter writer =null;
private static MockRAMDirectory dir = null;
private static Directory dir = null;
private static IndexReader reader =null;
public void setUp() throws Exception {

View File

@ -35,7 +35,6 @@ import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**

View File

@ -28,11 +28,11 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.SlowMultiReaderWrapper;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
public class BooleanFilterTest extends LuceneTestCase {
private MockRAMDirectory directory;
private Directory directory;
private IndexReader mainReader;
private IndexReader reader;

View File

@ -39,13 +39,12 @@ import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeFilter;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public class ChainedFilterTest extends LuceneTestCase {
public static final int MAX = 500;
private MockRAMDirectory directory;
private Directory directory;
private IndexSearcher searcher;
private IndexReader reader;
private Query query;

View File

@ -28,13 +28,13 @@ import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.DocsEnum;
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
public class DuplicateFilterTest extends LuceneTestCase {
private static final String KEY_FIELD = "url";
private MockRAMDirectory directory;
private Directory directory;
private IndexReader reader;
TermQuery tq=new TermQuery(new Term("text","lucene"));
private IndexSearcher searcher;

View File

@ -28,11 +28,11 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
public class FuzzyLikeThisQueryTest extends LuceneTestCase {
private MockRAMDirectory directory;
private Directory directory;
private IndexSearcher searcher;
private IndexReader reader;
private Analyzer analyzer=new MockAnalyzer();

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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.index.SlowMultiReaderWrapper;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.OpenBitSet;
@ -53,7 +53,7 @@ public class TermsFilterTest extends LuceneTestCase {
public void testMissingTerms() throws Exception {
String fieldName="field1";
Random random = newRandom();
MockRAMDirectory rd=newDirectory(random);
Directory rd=newDirectory(random);
RandomIndexWriter w = new RandomIndexWriter(random, rd);
for (int i = 0; i < 100; i++) {
Document doc=new Document();

View File

@ -20,7 +20,6 @@ package org.apache.lucene.search.regex;
import java.util.Random;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;

View File

@ -35,7 +35,6 @@ import org.apache.lucene.search.spans.SpanNearQuery;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public class TestSpanRegexQuery extends LuceneTestCase {
@ -60,7 +59,7 @@ public class TestSpanRegexQuery extends LuceneTestCase {
}
public void testSpanRegex() throws Exception {
MockRAMDirectory directory = newDirectory(random);
Directory directory = newDirectory(random);
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();

View File

@ -34,11 +34,11 @@ import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
public class TestMoreLikeThis extends LuceneTestCase {
private MockRAMDirectory directory;
private Directory directory;
private IndexReader reader;
private IndexSearcher searcher;

View File

@ -25,17 +25,16 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
public class TestComplexPhraseQuery extends LuceneTestCase {
MockRAMDirectory rd;
Directory rd;
Analyzer analyzer = new MockAnalyzer();
DocData docsContent[] = { new DocData("john smith", "1"),

View File

@ -28,7 +28,6 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.queryParser.core.QueryNodeException;
import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute.Operator;
import org.apache.lucene.search.BooleanClause;
@ -37,7 +36,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**

View File

@ -36,7 +36,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**

View File

@ -48,7 +48,6 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.messages.MessageImpl;
import org.apache.lucene.queryParser.core.QueryNodeException;
@ -73,8 +72,7 @@ import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeQuery;
import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LocalizedTestCase;
import org.apache.lucene.util.automaton.BasicAutomata;
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
@ -655,7 +653,7 @@ public class TestQPHelper extends LocalizedTestCase {
public void testFarsiRangeCollating() throws Exception {
Random random = newRandom();
MockRAMDirectory ramDir = newDirectory(random);
Directory ramDir = newDirectory(random);
IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
Document doc = new Document();
doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES,
@ -1079,7 +1077,7 @@ public class TestQPHelper extends LocalizedTestCase {
public void testLocalDateFormat() throws IOException, QueryNodeException {
Random random = newRandom();
MockRAMDirectory ramDir = newDirectory(random);
Directory ramDir = newDirectory(random);
IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
addDateDoc("a", 2005, 12, 2, 10, 15, 33, iw);
addDateDoc("b", 2005, 12, 4, 22, 15, 00, iw);
@ -1279,7 +1277,7 @@ public class TestQPHelper extends LocalizedTestCase {
public void testMultiPhraseQuery() throws Exception {
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new CannedAnalyzer()));
Document doc = new Document();
doc.add(new Field("field", "", Field.Store.NO, Field.Index.ANALYZED));

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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LocalizedTestCase;
import org.apache.lucene.util.automaton.BasicAutomata;
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
@ -654,7 +654,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
public void testFarsiRangeCollating() throws Exception {
MockRAMDirectory ramDir = newDirectory(newRandom());
Directory ramDir = newDirectory(newRandom());
IndexWriter iw = new IndexWriter(ramDir, new MockAnalyzer(MockTokenizer.WHITESPACE, false), true,
IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
@ -1063,7 +1063,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
public void testLocalDateFormat() throws IOException, ParseException {
MockRAMDirectory ramDir = newDirectory(newRandom());
Directory ramDir = newDirectory(newRandom());
IndexWriter iw = new IndexWriter(ramDir, new MockAnalyzer(MockTokenizer.WHITESPACE, false), true,
IndexWriter.MaxFieldLength.LIMITED);
addDateDoc("a", 2005, 12, 2, 10, 15, 33, iw);

View File

@ -18,7 +18,8 @@ package org.apache.lucene.queryParser.surround.query;
*/
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.Version;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@ -33,7 +34,7 @@ public class SingleFieldTestDb {
public SingleFieldTestDb(String[] documents, String fName) {
try {
db = new MockRAMDirectory();
db = new MockDirectoryWrapper(new RAMDirectory());
docs = documents;
fieldName = fName;
IndexWriter writer = new IndexWriter(db, new IndexWriterConfig(

View File

@ -24,7 +24,7 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -35,7 +35,7 @@ import static org.junit.Assert.*;
* Tests that the index is cached on the searcher side of things.
*/
public class TestRemoteCachingWrapperFilter extends RemoteTestCaseJ4 {
private static MockRAMDirectory indexStore;
private static Directory indexStore;
private static Searchable local;
@BeforeClass

View File

@ -21,7 +21,7 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.*;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -34,7 +34,7 @@ import java.util.Set;
import java.util.HashSet;
public class TestRemoteSearchable extends RemoteTestCaseJ4 {
private static MockRAMDirectory indexStore;
private static Directory indexStore;
private static Searchable local;
@BeforeClass

View File

@ -30,10 +30,9 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LogMergePolicy;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.junit.AfterClass;
import org.junit.Before;
@ -49,7 +48,7 @@ import org.junit.Test;
public class TestRemoteSort extends RemoteTestCaseJ4 {
private static IndexSearcher full;
private static MockRAMDirectory indexStore;
private static Directory indexStore;
private Query queryX;
private Query queryY;
private Query queryA;

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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
public class TestDistance extends LuceneTestCase {
private MockRAMDirectory directory;
private Directory directory;
// reston va
private double lat = 38.969398;
private double lng= -77.386398;

View File

@ -23,14 +23,11 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**

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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
/**
@ -33,7 +33,7 @@ public class TestPlainTextDictionary extends LuceneTestCase {
final String LF = System.getProperty("line.separator");
String input = "oneword" + LF + "twoword" + LF + "threeword";
PlainTextDictionary ptd = new PlainTextDictionary(new StringReader(input));
MockRAMDirectory ramDir = newDirectory(newRandom());
Directory ramDir = newDirectory(newRandom());
SpellChecker spellChecker = new SpellChecker(ramDir);
spellChecker.indexDictionary(ptd);
String[] similar = spellChecker.suggestSimilar("treeword", 2);

View File

@ -14,13 +14,11 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.Version;
import org.apache.lucene.util.LuceneTestCase;
/**

View File

@ -12,10 +12,9 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@ -45,7 +44,7 @@ public class TestQueryTemplateManager extends LuceneTestCase {
CoreParser builder;
Analyzer analyzer=new MockAnalyzer();
private IndexSearcher searcher;
private MockRAMDirectory dir;
private Directory dir;
//A collection of documents' field values for use in our tests
String docFieldValues []=

View File

@ -30,11 +30,10 @@ import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.NumericRangeFilter;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.xmlparser.ParserException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@ -63,7 +62,7 @@ public class TestNumericRangeFilterBuilder extends LuceneTestCase {
Document doc = getDocumentFromString(xml);
Filter filter = filterBuilder.getFilter(doc.getDocumentElement());
Random random = newRandom();
MockRAMDirectory ramDir = newDirectory(random);
Directory ramDir = newDirectory(random);
IndexWriter writer = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, null));
writer.commit();
try

View File

@ -135,7 +135,6 @@ final class FieldsWriter
final void close() throws IOException {
if (doClose) {
try {
if (fieldsStream != null) {
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.MockRAMDirectory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**
@ -49,7 +49,7 @@ public class TestDemo extends LuceneTestCase {
Analyzer analyzer = new MockAnalyzer();
// Store the index in memory:
Directory directory = new MockRAMDirectory();
Directory directory = newDirectory(newRandom());
// To store an index on disk, use this instead:
//Directory directory = FSDirectory.open("/tmp/testindex");
IndexWriter iwriter = new IndexWriter(directory, new IndexWriterConfig(

View File

@ -20,7 +20,7 @@ import java.io.IOException;
import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LogMergePolicy;
@ -71,9 +71,9 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
}
}
private static class FailOnlyOnMerge extends MockRAMDirectory.Failure {
private static class FailOnlyOnMerge extends MockDirectoryWrapper.Failure {
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
StackTraceElement[] trace = new Exception().getStackTrace();
for (int i = 0; i < trace.length; i++) {
if ("doMerge".equals(trace[i].getMethodName()))
@ -84,7 +84,7 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
public void testSubclassConcurrentMergeScheduler() throws IOException {
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
dir.failOn(new FailOnlyOnMerge());
Document doc = new Document();

View File

@ -6,7 +6,7 @@ import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -58,7 +58,7 @@ public class TestBinaryDocument extends LuceneTestCase {
/** add the doc to a ram index */
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(doc);
@ -98,7 +98,7 @@ public class TestBinaryDocument extends LuceneTestCase {
/** add the doc to a ram index */
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(doc);

View File

@ -10,7 +10,7 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
/**
@ -155,7 +155,7 @@ public class TestDocument extends LuceneTestCase {
*/
public void testGetValuesForIndexedDocument() throws Exception {
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(makeDocumentWithFields());
IndexReader reader = writer.getReader();
@ -234,7 +234,7 @@ public class TestDocument extends LuceneTestCase {
Field.Index.NOT_ANALYZED));
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
writer.addDocument(doc);
field.setValue("id2");

View File

@ -26,8 +26,8 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.search.DocIdSetIterator;
@ -368,7 +368,7 @@ public class TestAddIndexes extends LuceneTestCase {
.setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(10));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
writer.addIndexes(new Directory[] { aux, new MockRAMDirectory(aux) });
writer.addIndexes(new Directory[] { aux, new MockDirectoryWrapper(new RAMDirectory(aux)) });
assertEquals(1060, writer.maxDoc());
assertEquals(1000, writer.getDocCount(0));
writer.close();
@ -400,7 +400,7 @@ public class TestAddIndexes extends LuceneTestCase {
.setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(4));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
writer.addIndexes(new Directory[] { aux, new MockRAMDirectory(aux) });
writer.addIndexes(new Directory[] { aux, new MockDirectoryWrapper(new RAMDirectory(aux)) });
assertEquals(1060, writer.maxDoc());
assertEquals(1000, writer.getDocCount(0));
writer.close();

View File

@ -189,7 +189,7 @@ public class TestAtomicUpdate extends LuceneTestCase {
Directory directory;
// First in a RAM directory:
directory = new MockRAMDirectory();
directory = new MockDirectoryWrapper(new RAMDirectory());
runTest(directory);
directory.close();

View File

@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@ -35,7 +35,7 @@ public class TestCheckIndex extends LuceneTestCase {
public void testDeletedDocs() throws IOException {
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
Document doc = new Document();
doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));

View File

@ -39,8 +39,6 @@ import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.MultiCodecTestCase;
import org.apache.lucene.util.Version;

View File

@ -17,8 +17,7 @@ package org.apache.lucene.index;
* limitations under the License.
*/
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@ -30,7 +29,7 @@ import java.util.Random;
public class TestConcurrentMergeScheduler extends LuceneTestCase {
private static class FailOnlyOnFlush extends MockRAMDirectory.Failure {
private static class FailOnlyOnFlush extends MockDirectoryWrapper.Failure {
boolean doFail;
boolean hitExc;
@ -45,7 +44,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
}
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
if (doFail && Thread.currentThread().getName().equals("main")) {
StackTraceElement[] trace = new Exception().getStackTrace();
for (int i = 0; i < trace.length; i++) {
@ -62,7 +61,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
// we are hitting exceptions during flushing.
public void testFlushExceptions() throws IOException {
Random random = newRandom();
MockRAMDirectory directory = newDirectory(random);
MockDirectoryWrapper directory = newDirectory(random);
FailOnlyOnFlush failure = new FailOnlyOnFlush();
directory.failOn(failure);
@ -108,7 +107,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
// before it finishes, are correctly merged back:
public void testDeleteMerging() throws IOException {
Random random = newRandom();
MockRAMDirectory directory = newDirectory(random);
MockDirectoryWrapper directory = newDirectory(random);
LogDocMergePolicy mp = new LogDocMergePolicy();
// Force degenerate merging so we can get a mix of
@ -147,7 +146,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
public void testNoExtraFiles() throws IOException {
Random random = newRandom();
MockRAMDirectory directory = newDirectory(random);
MockDirectoryWrapper directory = newDirectory(random);
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2));
@ -176,7 +175,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
public void testNoWaitClose() throws IOException {
Random random = newRandom();
MockRAMDirectory directory = newDirectory(random);
MockDirectoryWrapper directory = newDirectory(random);
Document doc = new Document();
Field idField = new Field("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
doc.add(idField);

View File

@ -21,7 +21,7 @@ import java.io.IOException;
import java.util.Random;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.NoLockFactory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@ -33,7 +33,7 @@ public class TestCrash extends LuceneTestCase {
return initIndex(random, newDirectory(random), initialCommit);
}
private IndexWriter initIndex(Random random, MockRAMDirectory dir, boolean initialCommit) throws IOException {
private IndexWriter initIndex(Random random, MockDirectoryWrapper dir, boolean initialCommit) throws IOException {
dir.setLockFactory(NoLockFactory.getNoLockFactory());
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
@ -53,7 +53,7 @@ public class TestCrash extends LuceneTestCase {
}
private void crash(final IndexWriter writer) throws IOException {
final MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
final MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
ConcurrentMergeScheduler cms = (ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler();
cms.sync();
dir.crash();
@ -66,7 +66,7 @@ public class TestCrash extends LuceneTestCase {
// happened, so we must create an initial commit just to allow that, but
// before any documents were added.
IndexWriter writer = initIndex(newRandom(), true);
MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
crash(writer);
IndexReader reader = IndexReader.open(dir, false);
assertTrue(reader.numDocs() < 157);
@ -80,7 +80,7 @@ public class TestCrash extends LuceneTestCase {
// before any documents were added.
Random random = newRandom();
IndexWriter writer = initIndex(random, true);
MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
dir.setPreventDoubleWrite(false);
crash(writer);
writer = initIndex(random, dir, false);
@ -95,7 +95,7 @@ public class TestCrash extends LuceneTestCase {
public void testCrashAfterReopen() throws IOException {
Random random = newRandom();
IndexWriter writer = initIndex(random, false);
MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
writer.close();
writer = initIndex(random, dir, false);
assertEquals(314, writer.maxDoc());
@ -119,7 +119,7 @@ public class TestCrash extends LuceneTestCase {
public void testCrashAfterClose() throws IOException {
IndexWriter writer = initIndex(newRandom(), false);
MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
writer.close();
dir.crash();
@ -140,7 +140,7 @@ public class TestCrash extends LuceneTestCase {
public void testCrashAfterCloseNoWait() throws IOException {
IndexWriter writer = initIndex(newRandom(), false);
MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
writer.close(false);
@ -161,7 +161,7 @@ public class TestCrash extends LuceneTestCase {
public void testCrashReaderDeletes() throws IOException {
IndexWriter writer = initIndex(newRandom(), false);
MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
writer.close(false);
IndexReader reader = IndexReader.open(dir, false);
@ -184,7 +184,7 @@ public class TestCrash extends LuceneTestCase {
public void testCrashReaderDeletesAfterClose() throws IOException {
IndexWriter writer = initIndex(newRandom(), false);
MockRAMDirectory dir = (MockRAMDirectory) writer.getDirectory();
MockDirectoryWrapper dir = (MockDirectoryWrapper) writer.getDirectory();
writer.close(false);
IndexReader reader = IndexReader.open(dir, false);

View File

@ -33,8 +33,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/*

View File

@ -24,7 +24,6 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.BytesRef;
import java.io.IOException;
@ -137,9 +136,9 @@ public class TestDirectoryReader extends LuceneTestCase {
}
public void testIsCurrent() throws IOException {
MockRAMDirectory ramDir1=newDirectory(random);
Directory ramDir1=newDirectory(random);
addDoc(random, ramDir1, "test foo", true);
MockRAMDirectory ramDir2=newDirectory(random);
Directory ramDir2=newDirectory(random);
addDoc(random, ramDir2, "test blah", true);
IndexReader[] readers = new IndexReader[]{IndexReader.open(ramDir1, false), IndexReader.open(ramDir2, false)};
MultiReader mr = new MultiReader(readers);
@ -160,11 +159,11 @@ public class TestDirectoryReader extends LuceneTestCase {
}
public void testMultiTermDocs() throws IOException {
MockRAMDirectory ramDir1=newDirectory(random);
Directory ramDir1=newDirectory(random);
addDoc(random, ramDir1, "test foo", true);
MockRAMDirectory ramDir2=newDirectory(random);
Directory ramDir2=newDirectory(random);
addDoc(random, ramDir2, "test blah", true);
MockRAMDirectory ramDir3=newDirectory(random);
Directory ramDir3=newDirectory(random);
addDoc(random, ramDir3, "test wow", true);
IndexReader[] readers1 = new IndexReader[]{IndexReader.open(ramDir1, false), IndexReader.open(ramDir3, false)};
@ -204,7 +203,7 @@ public class TestDirectoryReader extends LuceneTestCase {
ramDir3.close();
}
private void addDoc(Random random, MockRAMDirectory ramDir1, String s, boolean create) throws IOException {
private void addDoc(Random random, Directory ramDir1, String s, boolean create) throws IOException {
IndexWriter iw = new IndexWriter(ramDir1, newIndexWriterConfig(random,
TEST_VERSION_CURRENT,
new MockAnalyzer()).setOpenMode(

View File

@ -35,14 +35,14 @@ import org.apache.lucene.document.Fieldable;
import org.apache.lucene.document.Field.Index;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.Field.TermVector;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.AttributeSource;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.util.BytesRef;
public class TestDocumentWriter extends LuceneTestCase {
private MockRAMDirectory dir;
private Directory dir;
private Random random;
public TestDocumentWriter(String s) {

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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IndexOutput;
import java.io.IOException;
@ -47,16 +47,15 @@ public class TestFieldInfos extends LuceneTestCase {
fieldInfos.add(testDoc);
//Since the complement is stored as well in the fields map
assertTrue(fieldInfos.size() == DocHelper.all.size()); //this is all b/c we are using the no-arg constructor
MockRAMDirectory dir = newDirectory(newRandom());
Directory dir = newDirectory(newRandom());
String name = "testFile";
IndexOutput output = dir.createOutput(name);
assertTrue(output != null);
//Use a RAMOutputStream
try {
fieldInfos.write(output);
output.close();
assertTrue(output.length() > 0);
assertTrue(dir.fileLength(name) > 0);
FieldInfos readIn = new FieldInfos(dir, name);
assertTrue(fieldInfos.size() == readIn.size());
FieldInfo info = readIn.fieldInfo("textField1");
@ -80,10 +79,5 @@ public class TestFieldInfos extends LuceneTestCase {
assertTrue(info.omitNorms == true);
dir.close();
} catch (IOException e) {
assertTrue(false);
}
}
}

View File

@ -40,12 +40,11 @@ import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
public class TestFieldsReader extends LuceneTestCase {
private MockRAMDirectory dir;
private Directory dir;
private Document testDoc = new Document();
private FieldInfos fieldInfos = null;
private Random random;

View File

@ -22,8 +22,7 @@ import org.apache.lucene.util.LuceneTestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@ -132,7 +131,7 @@ public class TestFilterIndexReader extends LuceneTestCase {
*/
public void testFilterIndexReader() throws Exception {
Random random = newRandom();
MockRAMDirectory directory = newDirectory(random);
Directory directory = newDirectory(random);
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document d1 = new Document();
@ -150,7 +149,7 @@ public class TestFilterIndexReader extends LuceneTestCase {
writer.close();
//IndexReader reader = new TestReader(IndexReader.open(directory, true));
MockRAMDirectory target = newDirectory(random);
Directory target = newDirectory(random);
writer = new IndexWriter(target, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
IndexReader reader = new TestReader(IndexReader.open(directory, true));
writer.addIndexes(reader);

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.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@ -39,7 +39,7 @@ public class TestIndexFileDeleter extends LuceneTestCase {
public void testDeleteLeftoverFiles() throws IOException {
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
dir.setPreventDoubleWrite(false);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer())

View File

@ -51,8 +51,10 @@ import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.NoSuchDirectoryException;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.LockReleaseFailedException;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.util.BytesRef;
@ -82,7 +84,7 @@ public class TestIndexReader extends LuceneTestCase
}
public void testCommitUserData() throws Exception {
MockRAMDirectory d = newDirectory(random);
Directory d = newDirectory(random);
Map<String,String> commitUserData = new HashMap<String,String>();
commitUserData.put("foo", "fighters");
@ -137,7 +139,7 @@ public class TestIndexReader extends LuceneTestCase
}
public void testIsCurrent() throws Exception {
MockRAMDirectory d = newDirectory(random);
Directory d = newDirectory(random);
IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
@ -166,7 +168,7 @@ public class TestIndexReader extends LuceneTestCase
* @throws Exception on error
*/
public void testGetFieldNames() throws Exception {
MockRAMDirectory d = newDirectory(random);
Directory d = newDirectory(random);
// set up writer
IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
@ -258,7 +260,7 @@ public class TestIndexReader extends LuceneTestCase
}
public void testTermVectors() throws Exception {
MockRAMDirectory d = newDirectory(random);
Directory d = newDirectory(random);
// set up writer
IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
@ -794,7 +796,7 @@ public class TestIndexReader extends LuceneTestCase
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
writer.close();
writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
IndexReader reader = IndexReader.open(dir, false);
try {
reader.deleteDocument(0);
@ -802,7 +804,11 @@ public class TestIndexReader extends LuceneTestCase
} catch(IOException e) {
// expected exception
}
IndexWriter.unlock(dir); // this should not be done in the real world!
try {
IndexWriter.unlock(dir); // this should not be done in the real world!
} catch (LockReleaseFailedException lrfe) {
writer.close();
}
reader.deleteDocument(0);
reader.close();
writer.close();
@ -881,7 +887,7 @@ public class TestIndexReader extends LuceneTestCase
int END_COUNT = 144;
// First build up a starting index:
MockRAMDirectory startDir = newDirectory(random);
MockDirectoryWrapper startDir = newDirectory(random);
IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
for(int i=0;i<157;i++) {
Document d = new Document();
@ -893,7 +899,7 @@ public class TestIndexReader extends LuceneTestCase
}
writer.close();
long diskUsage = ((MockRAMDirectory) startDir).getRecomputedActualSizeInBytes();
long diskUsage = startDir.getRecomputedActualSizeInBytes();
long diskFree = diskUsage+100;
IOException err = null;
@ -903,7 +909,7 @@ public class TestIndexReader extends LuceneTestCase
// Iterate w/ ever increasing free disk space:
while(!done) {
MockRAMDirectory dir = new MockRAMDirectory(startDir);
MockDirectoryWrapper dir = new MockDirectoryWrapper(new RAMDirectory(startDir));
// If IndexReader hits disk full, it can write to
// the same files again.
@ -1150,7 +1156,7 @@ public class TestIndexReader extends LuceneTestCase
}
public void testMultiReaderDeletes() throws Exception {
Directory dir = new MockRAMDirectory();
Directory dir = newDirectory(random);
RandomIndexWriter w = new RandomIndexWriter(random, dir);
Document doc = new Document();
doc.add(new Field("f", "doctor", Field.Store.NO, Field.Index.NOT_ANALYZED));
@ -1417,7 +1423,7 @@ public class TestIndexReader extends LuceneTestCase
public void testGetIndexCommit() throws IOException {
MockRAMDirectory d = newDirectory(random);
Directory d = newDirectory(random);
// set up writer
IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
@ -1466,7 +1472,7 @@ public class TestIndexReader extends LuceneTestCase
}
public void testReadOnly() throws Throwable {
MockRAMDirectory d = newDirectory(random);
Directory d = newDirectory(random);
IndexWriter writer = new IndexWriter(d, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
addDocumentWithFields(writer);
@ -1553,7 +1559,7 @@ public class TestIndexReader extends LuceneTestCase
// LUCENE-1647
public void testIndexReaderUnDeleteAll() throws Exception {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
dir.setPreventDoubleWrite(false);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));

View File

@ -68,9 +68,9 @@ import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.Lock;
import org.apache.lucene.store.LockFactory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.NoLockFactory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.SingleInstanceLockFactory;
import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util._TestUtil;
@ -203,7 +203,7 @@ public class TestIndexWriter extends LuceneTestCase {
// Now, build a starting index that has START_COUNT docs. We
// will then try to addIndexesNoOptimize into a copy of this:
MockRAMDirectory startDir = newDirectory(random);
MockDirectoryWrapper startDir = newDirectory(random);
IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
for(int j=0;j<START_COUNT;j++) {
addDocWithIndex(writer, j);
@ -266,7 +266,7 @@ public class TestIndexWriter extends LuceneTestCase {
while(!done) {
// Make a new dir that will enforce disk usage:
MockRAMDirectory dir = new MockRAMDirectory(startDir);
MockDirectoryWrapper dir = new MockDirectoryWrapper(new RAMDirectory(startDir));
writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND));
IOException err = null;
@ -477,7 +477,7 @@ public class TestIndexWriter extends LuceneTestCase {
while(true) {
if (VERBOSE)
System.out.println("TEST: cycle: diskFree=" + diskFree);
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
dir.setMaxSizeInBytes(diskFree);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
MergeScheduler ms = writer.getConfig().getMergeScheduler();
@ -557,7 +557,7 @@ public class TestIndexWriter extends LuceneTestCase {
public void testOptimizeMaxNumSegments() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
final Document doc = new Document();
doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED));
@ -598,7 +598,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testOptimizeMaxNumSegments2() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
final Document doc = new Document();
doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED));
@ -646,7 +646,7 @@ public class TestIndexWriter extends LuceneTestCase {
*/
public void testOptimizeTempSpaceUsage() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10));
for(int j=0;j<500;j++) {
@ -721,7 +721,7 @@ 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 {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
dir.setPreventDoubleWrite(false);
IndexWriter writer = null;
@ -946,7 +946,7 @@ public class TestIndexWriter extends LuceneTestCase {
* and add docs to it.
*/
public void testCommitOnCloseAbort() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10));
for (int i = 0; i < 14; i++) {
addDoc(writer);
@ -1014,11 +1014,11 @@ public class TestIndexWriter extends LuceneTestCase {
* Verify that a writer with "commit on close" indeed
* cleans up the temp segments created after opening
* that are not referenced by the starting segments
* file. We check this by using MockRAMDirectory to
* file. We check this by using MockDirectoryWrapper to
* measure max temp disk space used.
*/
public void testCommitOnCloseDiskUsage() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10));
((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
for(int j=0;j<30;j++) {
@ -1064,7 +1064,7 @@ public class TestIndexWriter extends LuceneTestCase {
* and close().
*/
public void testCommitOnCloseOptimize() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
// Must disable throwing exc on double-write: this
// test uses IW.rollback which easily results in
// writing to same file more than once
@ -1113,7 +1113,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testIndexNoDocuments() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.commit();
writer.close();
@ -1135,7 +1135,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testManyFields() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
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();
@ -1165,7 +1165,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testSmallRAMBuffer() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
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;
@ -1192,7 +1192,7 @@ public class TestIndexWriter extends LuceneTestCase {
* session won't be possible.
*/
public void testChangingRAMBuffer() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10).setRAMBufferSizeMB(
IndexWriterConfig.DISABLE_AUTO_FLUSH));
@ -1250,7 +1250,7 @@ public class TestIndexWriter extends LuceneTestCase {
* changing those settings on IW won't be possible.
*/
public void testChangingRAMBuffer2() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10).setMaxBufferedDeleteTerms(
10).setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH));
@ -1309,7 +1309,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testDiverseDocs() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
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
@ -1356,7 +1356,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testEnablingNorms() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
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++) {
@ -1402,7 +1402,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testHighFreqTerm() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
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
@ -1440,9 +1440,10 @@ public class TestIndexWriter extends LuceneTestCase {
// compatibility.
public void testNullLockFactory() throws IOException {
final class MyRAMDirectory extends MockRAMDirectory {
final class MyRAMDirectory extends MockDirectoryWrapper {
private LockFactory myLockFactory;
MyRAMDirectory() {
MyRAMDirectory(Directory delegate) {
super(delegate);
lockFactory = null;
myLockFactory = new SingleInstanceLockFactory();
}
@ -1452,7 +1453,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
}
Directory dir = new MyRAMDirectory();
Directory dir = new MyRAMDirectory(new RAMDirectory());
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < 100; i++) {
@ -1569,7 +1570,7 @@ public class TestIndexWriter extends LuceneTestCase {
*
*/
public void testBadSegment() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
@ -1582,7 +1583,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1008
public void testNoTermVectorAfterTermVector() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document document = new Document();
@ -1609,7 +1610,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1010
public void testNoTermVectorAfterTermVectorMerge() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document document = new Document();
@ -1642,7 +1643,7 @@ public class TestIndexWriter extends LuceneTestCase {
public void testMaxThreadPriority() throws IOException {
int pri = Thread.currentThread().getPriority();
try {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriterConfig conf = newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2);
@ -1684,7 +1685,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1013
public void testSetMaxMergeDocs() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriterConfig conf = newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMergeScheduler(new MyMergeScheduler()).setMaxBufferedDocs(2);
@ -1703,7 +1704,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1072
public void testExceptionFromTokenStream() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new Analyzer() {
@Override
@ -1769,7 +1770,7 @@ public class TestIndexWriter extends LuceneTestCase {
dir.close();
}
private static class FailOnlyOnFlush extends MockRAMDirectory.Failure {
private static class FailOnlyOnFlush extends MockDirectoryWrapper.Failure {
boolean doFail = false;
int count;
@ -1783,7 +1784,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
if (doFail) {
StackTraceElement[] trace = new Exception().getStackTrace();
boolean sawAppend = false;
@ -1806,7 +1807,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1072: make sure an errant exception on flushing
// one segment only takes out those docs in that one flush
public void testDocumentsWriterAbort() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
FailOnlyOnFlush failure = new FailOnlyOnFlush();
failure.setDoFail();
dir.failOn(failure);
@ -1866,7 +1867,7 @@ public class TestIndexWriter extends LuceneTestCase {
};
for(int i=0;i<2;i++) {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, analyzer));
//writer.setInfoStream(System.out);
Document doc = new Document();
@ -1951,7 +1952,7 @@ public class TestIndexWriter extends LuceneTestCase {
final int NUM_ITER = 100;
for(int i=0;i<2;i++) {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
{
final IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(-1));
@ -2051,7 +2052,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testVariableSchema() throws Exception {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
int delID = 0;
for(int i=0;i<20;i++) {
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
@ -2103,7 +2104,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testNoWaitClose() throws Throwable {
MockRAMDirectory directory = newDirectory(random);
Directory directory = newDirectory(random);
final Document doc = new Document();
Field idField = new Field("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
@ -2259,7 +2260,7 @@ public class TestIndexWriter extends LuceneTestCase {
int NUM_THREADS = 3;
for(int iter=0;iter<7;iter++) {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(10).setMergeScheduler(new ConcurrentMergeScheduler());
// We expect AlreadyClosedException
@ -2318,7 +2319,7 @@ public class TestIndexWriter extends LuceneTestCase {
// an IndexWriter (hit during DW.ThreadState.init()) is
// OK:
public void testImmediateDiskFull() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2).setMergeScheduler(new ConcurrentMergeScheduler()));
dir.setMaxSizeInBytes(Math.max(1, dir.getRecomputedActualSizeInBytes()));
@ -2356,7 +2357,7 @@ public class TestIndexWriter extends LuceneTestCase {
int NUM_THREADS = 3;
for(int iter=0;iter<10;iter++) {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2).setMergeScheduler(new ConcurrentMergeScheduler());
// We expect disk full exceptions in the merge threads
@ -2389,13 +2390,13 @@ public class TestIndexWriter extends LuceneTestCase {
}
// Throws IOException during FieldsWriter.flushDocument and during DocumentsWriter.abort
private static class FailOnlyOnAbortOrFlush extends MockRAMDirectory.Failure {
private static class FailOnlyOnAbortOrFlush extends MockDirectoryWrapper.Failure {
private boolean onlyOnce;
public FailOnlyOnAbortOrFlush(boolean onlyOnce) {
this.onlyOnce = onlyOnce;
}
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
if (doFail) {
StackTraceElement[] trace = new Exception().getStackTrace();
for (int i = 0; i < trace.length; i++) {
@ -2414,8 +2415,8 @@ public class TestIndexWriter extends LuceneTestCase {
// Runs test, with one thread, using the specific failure
// to trigger an IOException
public void _testSingleThreadFailure(MockRAMDirectory.Failure failure) throws IOException {
MockRAMDirectory dir = newDirectory(random);
public void _testSingleThreadFailure(MockDirectoryWrapper.Failure failure) throws IOException {
MockDirectoryWrapper dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2).setMergeScheduler(new ConcurrentMergeScheduler()));
@ -2442,12 +2443,12 @@ public class TestIndexWriter extends LuceneTestCase {
// Runs test, with multiple threads, using the specific
// failure to trigger an IOException
public void _testMultipleThreadsFailure(MockRAMDirectory.Failure failure) throws Exception {
public void _testMultipleThreadsFailure(MockDirectoryWrapper.Failure failure) throws Exception {
int NUM_THREADS = 3;
for(int iter=0;iter<2;iter++) {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT,
new MockAnalyzer()).setMaxBufferedDocs(2).setMergeScheduler(new ConcurrentMergeScheduler());
// We expect disk full exceptions in the merge threads
@ -2523,13 +2524,13 @@ public class TestIndexWriter extends LuceneTestCase {
}
// Throws IOException during DocumentsWriter.closeDocStore
private static class FailOnlyInCloseDocStore extends MockRAMDirectory.Failure {
private static class FailOnlyInCloseDocStore extends MockDirectoryWrapper.Failure {
private boolean onlyOnce;
public FailOnlyInCloseDocStore(boolean onlyOnce) {
this.onlyOnce = onlyOnce;
}
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
if (doFail) {
StackTraceElement[] trace = new Exception().getStackTrace();
for (int i = 0; i < trace.length; i++) {
@ -2564,13 +2565,13 @@ public class TestIndexWriter extends LuceneTestCase {
}
// Throws IOException during DocumentsWriter.writeSegment
private static class FailOnlyInWriteSegment extends MockRAMDirectory.Failure {
private static class FailOnlyInWriteSegment extends MockDirectoryWrapper.Failure {
private boolean onlyOnce;
public FailOnlyInWriteSegment(boolean onlyOnce) {
this.onlyOnce = onlyOnce;
}
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
if (doFail) {
StackTraceElement[] trace = new Exception().getStackTrace();
for (int i = 0; i < trace.length; i++) {
@ -2702,15 +2703,15 @@ public class TestIndexWriter extends LuceneTestCase {
dir.close();
}
// Throws IOException during MockRAMDirectory.sync
private static class FailOnlyInSync extends MockRAMDirectory.Failure {
// Throws IOException during MockDirectoryWrapper.sync
private static class FailOnlyInSync extends MockDirectoryWrapper.Failure {
boolean didFail;
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
if (doFail) {
StackTraceElement[] trace = new Exception().getStackTrace();
for (int i = 0; i < trace.length; i++) {
if (doFail && "org.apache.lucene.store.MockRAMDirectory".equals(trace[i].getClassName()) && "sync".equals(trace[i].getMethodName())) {
if (doFail && "org.apache.lucene.store.MockDirectoryWrapper".equals(trace[i].getClassName()) && "sync".equals(trace[i].getMethodName())) {
didFail = true;
throw new IOException("now failing on purpose during sync");
}
@ -2721,7 +2722,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1044: test exception during sync
public void testExceptionDuringSync() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
FailOnlyInSync failure = new FailOnlyInSync();
dir.failOn(failure);
@ -2796,7 +2797,7 @@ public class TestIndexWriter extends LuceneTestCase {
.setMergeScheduler(new SerialMergeScheduler()).setMergePolicy(
new LogDocMergePolicy()));
Directory[] indexDirs = {new MockRAMDirectory(dir)};
Directory[] indexDirs = {new MockDirectoryWrapper(new RAMDirectory(dir))};
writer.addIndexes(indexDirs);
writer.optimize();
writer.close();
@ -3042,7 +3043,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1179
public void testEmptyFieldName() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("", "a b c", Field.Store.NO, Field.Index.ANALYZED));
@ -3070,7 +3071,7 @@ public class TestIndexWriter extends LuceneTestCase {
public void testExceptionDocumentsWriterInit() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
MockIndexWriter w = new MockIndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("field", "a field", Field.Store.YES,
@ -3090,7 +3091,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1208
public void testExceptionJustBeforeFlush() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
MockIndexWriter w = new MockIndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
Document doc = new Document();
doc.add(new Field("field", "a field", Field.Store.YES,
@ -3140,7 +3141,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1210
public void testExceptionOnMergeInit() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2).setMergeScheduler(new ConcurrentMergeScheduler());
((LogMergePolicy) conf.getMergePolicy()).setMergeFactor(2);
@ -3185,7 +3186,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1222
public void testDoBeforeAfterFlush() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
MockIndexWriter3 w = new MockIndexWriter3(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("field", "a field", Field.Store.YES,
@ -3210,19 +3211,19 @@ public class TestIndexWriter extends LuceneTestCase {
dir.close();
}
private static class FailOnlyInCommit extends MockRAMDirectory.Failure {
private static class FailOnlyInCommit extends MockDirectoryWrapper.Failure {
boolean fail1, fail2;
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
StackTraceElement[] trace = new Exception().getStackTrace();
boolean isCommit = false;
boolean isDelete = false;
for (int i = 0; i < trace.length; i++) {
if ("org.apache.lucene.index.SegmentInfos".equals(trace[i].getClassName()) && "prepareCommit".equals(trace[i].getMethodName()))
isCommit = true;
if ("org.apache.lucene.store.MockRAMDirectory".equals(trace[i].getClassName()) && "deleteFile".equals(trace[i].getMethodName()))
if ("org.apache.lucene.store.MockDirectoryWrapper".equals(trace[i].getClassName()) && "deleteFile".equals(trace[i].getMethodName()))
isDelete = true;
}
@ -3241,7 +3242,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1214
public void testExceptionsDuringCommit() throws Throwable {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
FailOnlyInCommit failure = new FailOnlyInCommit();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
@ -3290,7 +3291,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-510
public void testInvalidUTF16() throws Throwable {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
@ -3500,7 +3501,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
};
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
doc.add(new Field("field", tokens));
@ -3587,7 +3588,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1274: test writer.prepareCommit()
public void testPrepareCommitRollback() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
dir.setPreventDoubleWrite(false);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
@ -3640,7 +3641,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1274
public void testPrepareCommitNoChanges() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
writer.prepareCommit();
@ -3667,7 +3668,7 @@ public class TestIndexWriter extends LuceneTestCase {
public RunAddIndexesThreads(int numCopy) throws Throwable {
NUM_COPY = numCopy;
dir = new MockRAMDirectory();
dir = new MockDirectoryWrapper(new RAMDirectory());
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer())
.setMaxBufferedDocs(2));
@ -3675,7 +3676,7 @@ public class TestIndexWriter extends LuceneTestCase {
addDoc(writer);
writer.close();
dir2 = new MockRAMDirectory();
dir2 = new MockDirectoryWrapper(new RAMDirectory());
writer2 = new IndexWriter(dir2, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()));
writer2.commit();
@ -3694,7 +3695,7 @@ public class TestIndexWriter extends LuceneTestCase {
final Directory[] dirs = new Directory[NUM_COPY];
for(int k=0;k<NUM_COPY;k++)
dirs[k] = new MockRAMDirectory(dir);
dirs[k] = new MockDirectoryWrapper(new RAMDirectory(dir));
int j=0;
@ -3946,7 +3947,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1347
public void testRollbackExceptionHang() throws Throwable {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
MockIndexWriter4 w = new MockIndexWriter4(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
addDoc(w);
@ -3966,7 +3967,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1219
public void testBinaryFieldOffsetLength() throws IOException {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
byte[] b = new byte[50];
for(int i=0;i<50;i++)
@ -4033,7 +4034,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testOptimizeExceptions() throws IOException {
MockRAMDirectory startDir = newDirectory(random);
Directory startDir = newDirectory(random);
IndexWriterConfig conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2);
((LogMergePolicy) conf.getMergePolicy()).setMergeFactor(100);
IndexWriter w = new IndexWriter(startDir, conf);
@ -4042,7 +4043,7 @@ public class TestIndexWriter extends LuceneTestCase {
w.close();
for(int i=0;i<200;i++) {
MockRAMDirectory dir = new MockRAMDirectory(startDir);
MockDirectoryWrapper dir = new MockDirectoryWrapper(new RAMDirectory(startDir));
conf = newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMergeScheduler(new ConcurrentMergeScheduler());
((ConcurrentMergeScheduler) conf.getMergeScheduler()).setSuppressExceptions();
w = new IndexWriter(dir, conf);
@ -4091,7 +4092,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1442
public void testDoubleOffsetCounting() throws Exception {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
@ -4127,7 +4128,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1442
public void testDoubleOffsetCounting2() throws Exception {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
Field f = new Field("field", "abcd", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
@ -4149,7 +4150,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionCharAnalyzer() throws Exception {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
Field f = new Field("field", "abcd ", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
@ -4171,7 +4172,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionWithCachingTokenFilter() throws Exception {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
Analyzer analyzer = new MockAnalyzer();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, analyzer));
Document doc = new Document();
@ -4195,7 +4196,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionStopFilter() throws Exception {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true)));
Document doc = new Document();
@ -4218,7 +4219,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionStandard() throws Exception {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
@ -4249,7 +4250,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionStandardEmptyField() throws Exception {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
@ -4277,7 +4278,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-1448
public void testEndOffsetPositionStandardEmptyField2() throws Exception {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
@ -4331,7 +4332,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testDeadlock() throws Exception {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2));
Document doc = new Document();
doc.add(new Field("content", "aaa bbb ccc ddd eee fff ggg hhh iii", Field.Store.YES,
@ -4342,7 +4343,7 @@ public class TestIndexWriter extends LuceneTestCase {
writer.commit();
// index has 2 segments
MockRAMDirectory dir2 = newDirectory(random);
Directory dir2 = newDirectory(random);
IndexWriter writer2 = new IndexWriter(dir2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
writer2.addDocument(doc);
writer2.close();
@ -4371,7 +4372,7 @@ public class TestIndexWriter extends LuceneTestCase {
@Override
public void run() {
MockRAMDirectory dir;
Directory dir;
try {
dir = newDirectory(random);
} catch (IOException e) { throw new RuntimeException(e); }
@ -4470,7 +4471,11 @@ public class TestIndexWriter extends LuceneTestCase {
e.printStackTrace(System.out);
}
}
dir.close();
try {
dir.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
@ -4501,7 +4506,7 @@ public class TestIndexWriter extends LuceneTestCase {
public void testIndexStoreCombos() throws Exception {
MockRAMDirectory dir = newDirectory(random);
Directory dir = newDirectory(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
byte[] b = new byte[50];
for(int i=0;i<50;i++)
@ -5204,12 +5209,12 @@ public class TestIndexWriter extends LuceneTestCase {
_TestUtil.rmDir(index);
}
private static class FailTwiceDuringMerge extends MockRAMDirectory.Failure {
private static class FailTwiceDuringMerge extends MockDirectoryWrapper.Failure {
public boolean didFail1;
public boolean didFail2;
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
if (!doFail) {
return;
}
@ -5229,7 +5234,7 @@ public class TestIndexWriter extends LuceneTestCase {
// LUCENE-2593
public void testCorruptionAfterDiskFullDuringMerge() throws IOException {
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
final Random rand = random;
//IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new MockAnalyzer()).setReaderPooling(true));
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(rand, TEST_VERSION_CURRENT, new MockAnalyzer()).setMergeScheduler(new SerialMergeScheduler()).setReaderPooling(true));

View File

@ -34,7 +34,6 @@ 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.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCaseJ4;
import org.junit.Test;

View File

@ -28,7 +28,8 @@ import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
@ -423,7 +424,7 @@ public class TestIndexWriterDelete extends LuceneTestCase {
int END_COUNT = 144;
// First build up a starting index:
MockRAMDirectory startDir = newDirectory(random);
MockDirectoryWrapper startDir = newDirectory(random);
// TODO: find the resource leak that only occurs sometimes here.
startDir.setNoDeleteOpenFile(false);
IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
@ -446,7 +447,7 @@ public class TestIndexWriterDelete extends LuceneTestCase {
// Iterate w/ ever increasing free disk space:
while (!done) {
MockRAMDirectory dir = new MockRAMDirectory(startDir);
MockDirectoryWrapper dir = new MockDirectoryWrapper(new RAMDirectory(startDir));
dir.setPreventDoubleWrite(false);
IndexWriter modifier = new IndexWriter(dir,
newIndexWriterConfig(random,
@ -599,34 +600,34 @@ public class TestIndexWriterDelete extends LuceneTestCase {
}
searcher.close();
newReader.close();
dir.close();
if (result2 == END_COUNT) {
break;
}
}
dir.close();
modifier.close();
startDir.close();
// Try again with 10 more bytes of free space:
diskFree += 10;
}
startDir.close();
}
// This test tests that buffered deletes are cleared when
// an Exception is hit during flush.
public void testErrorAfterApplyDeletes() throws IOException {
MockRAMDirectory.Failure failure = new MockRAMDirectory.Failure() {
MockDirectoryWrapper.Failure failure = new MockDirectoryWrapper.Failure() {
boolean sawMaybe = false;
boolean failed = false;
@Override
public MockRAMDirectory.Failure reset() {
public MockDirectoryWrapper.Failure reset() {
sawMaybe = false;
failed = false;
return this;
}
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
if (sawMaybe && !failed) {
boolean seen = false;
StackTraceElement[] trace = new Exception().getStackTrace();
@ -662,7 +663,7 @@ public class TestIndexWriterDelete extends LuceneTestCase {
"Venice has lots of canals" };
String[] text = { "Amsterdam", "Venice" };
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random,
TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)).setMaxBufferedDeleteTerms(2).setReaderPooling(false));
LogMergePolicy lmp = (LogMergePolicy) modifier.getConfig().getMergePolicy();
@ -748,15 +749,15 @@ public class TestIndexWriterDelete extends LuceneTestCase {
public void testErrorInDocsWriterAdd() throws IOException {
MockRAMDirectory.Failure failure = new MockRAMDirectory.Failure() {
MockDirectoryWrapper.Failure failure = new MockDirectoryWrapper.Failure() {
boolean failed = false;
@Override
public MockRAMDirectory.Failure reset() {
public MockDirectoryWrapper.Failure reset() {
failed = false;
return this;
}
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
if (!failed) {
failed = true;
throw new IOException("fail in add doc");
@ -772,7 +773,7 @@ public class TestIndexWriterDelete extends LuceneTestCase {
"Venice has lots of canals" };
String[] text = { "Amsterdam", "Venice" };
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
modifier.commit();
dir.failOn(failure.reset());

View File

@ -22,8 +22,8 @@ import java.io.IOException;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@ -130,7 +130,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
public void testRandomExceptions() throws Throwable {
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
MockIndexWriter writer = new MockIndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
.setRAMBufferSizeMB(0.1).setMergeScheduler(new ConcurrentMergeScheduler()));
@ -171,7 +171,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
public void testRandomExceptionsThreads() throws Throwable {
Random random = newRandom();
MockRAMDirectory dir = newDirectory(random);
MockDirectoryWrapper dir = newDirectory(random);
MockIndexWriter writer = new MockIndexWriter(dir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())
.setRAMBufferSizeMB(0.2).setMergeScheduler(new ConcurrentMergeScheduler()));
((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).setSuppressExceptions();

View File

@ -16,7 +16,6 @@ package org.apache.lucene.index;
*/
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;

View File

@ -34,8 +34,9 @@ import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.util.BytesRef;
@ -355,7 +356,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
try {
final Directory[] dirs = new Directory[numDirs];
for (int k = 0; k < numDirs; k++)
dirs[k] = new MockRAMDirectory(addDir);
dirs[k] = new MockDirectoryWrapper(new RAMDirectory(addDir));
//int j = 0;
//while (true) {
// System.out.println(Thread.currentThread().getName() + ": iter
@ -631,7 +632,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
final Directory[] dirs = new Directory[10];
for (int i=0;i<10;i++) {
dirs[i] = new MockRAMDirectory(dir1);
dirs[i] = new MockDirectoryWrapper(new RAMDirectory(dir1));
}
IndexReader r = writer.getReader();

View File

@ -31,7 +31,6 @@ 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.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;

View File

@ -29,7 +29,8 @@ 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.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
@ -46,7 +47,11 @@ public class TestLazyProxSkipping extends LuceneTestCase {
private String term2 = "yy";
private String term3 = "zz";
private class SeekCountingDirectory extends MockRAMDirectory {
private class SeekCountingDirectory extends MockDirectoryWrapper {
public SeekCountingDirectory(Directory delegate) {
super(delegate);
}
@Override
public IndexInput openInput(String name) throws IOException {
IndexInput ii = super.openInput(name);
@ -56,12 +61,13 @@ public class TestLazyProxSkipping extends LuceneTestCase {
}
return ii;
}
}
private void createIndex(Random random, int numHits) throws IOException {
int numDocs = 500;
Directory directory = new SeekCountingDirectory();
Directory directory = new SeekCountingDirectory(new RAMDirectory());
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10));
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);

View File

@ -31,7 +31,8 @@ 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.IndexInput;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.util.BytesRef;
@ -46,7 +47,11 @@ import org.apache.lucene.util.BytesRef;
*/
public class TestMultiLevelSkipList extends LuceneTestCase {
class CountingRAMDirectory extends MockRAMDirectory {
class CountingRAMDirectory extends MockDirectoryWrapper {
public CountingRAMDirectory(Directory delegate) {
super(delegate);
}
public IndexInput openInput(String fileName) throws IOException {
IndexInput in = super.openInput(fileName);
if (fileName.endsWith(".frq"))
@ -56,7 +61,7 @@ public class TestMultiLevelSkipList extends LuceneTestCase {
}
public void testSimpleSkip() throws IOException {
Directory dir = new CountingRAMDirectory();
Directory dir = new CountingRAMDirectory(new RAMDirectory());
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(newRandom(), TEST_VERSION_CURRENT, new PayloadAnalyzer()).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
Term term = new Term("test", "a");
for (int i = 0; i < 5000; i++) {

View File

@ -23,7 +23,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public class TestNRTReaderWithThreads extends LuceneTestCase {

View File

@ -22,14 +22,13 @@ import java.util.Random;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
public class TestNewestSegment extends LuceneTestCase {
public void testNewestSegment() throws Exception {
Random random = newRandom();
MockRAMDirectory directory = newDirectory(random);
Analyzer analyzer = new MockAnalyzer();
Directory directory = newDirectory(random);
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
assertNull(writer.newestSegment());
writer.close();

View File

@ -31,7 +31,6 @@ 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.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCaseJ4;
import org.junit.Test;

View File

@ -31,7 +31,6 @@ 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.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**

View File

@ -30,12 +30,9 @@ import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
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.search.BooleanClause.Occur;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public class TestParallelReader extends LuceneTestCase {

View File

@ -20,6 +20,7 @@ package org.apache.lucene.index;
import java.io.IOException;
import java.util.Random;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
@ -30,8 +31,6 @@ 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.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
/**
* Some tests for {@link ParallelReader}s with empty indexes
@ -48,13 +47,13 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase {
*/
public void testEmptyIndex() throws IOException {
Random random = newRandom();
MockRAMDirectory rd1 = newDirectory(random);
Directory rd1 = newDirectory(random);
IndexWriter iw = new IndexWriter(rd1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
iw.close();
MockRAMDirectory rd2 = newDirectory(random, rd1);
Directory rd2 = newDirectory(random, rd1);
MockRAMDirectory rdOut = newDirectory(random);
Directory rdOut = newDirectory(random);
IndexWriter iwOut = new IndexWriter(rdOut, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
ParallelReader pr = new ParallelReader();
@ -79,7 +78,7 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase {
*/
public void testEmptyIndexWithVectors() throws IOException {
Random random = newRandom();
MockRAMDirectory rd1 = newDirectory(random);
Directory rd1 = newDirectory(random);
{
IndexWriter iw = new IndexWriter(rd1, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
@ -100,7 +99,7 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase {
iw.close();
}
MockRAMDirectory rd2 = newDirectory(random);
Directory rd2 = newDirectory(random);
{
IndexWriter iw = new IndexWriter(rd2, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
Document doc = new Document();
@ -108,7 +107,7 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase {
iw.close();
}
MockRAMDirectory rdOut = newDirectory(random);
Directory rdOut = newDirectory(random);
IndexWriter iwOut = new IndexWriter(rdOut, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()));
ParallelReader pr = new ParallelReader();

View File

@ -26,14 +26,14 @@ 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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Bits;
public class TestParallelTermEnum extends LuceneTestCase {
private IndexReader ir1;
private IndexReader ir2;
private MockRAMDirectory rd1;
private MockRAMDirectory rd2;
private Directory rd1;
private Directory rd2;
@Override
protected void setUp() throws Exception {

View File

@ -37,7 +37,6 @@ import org.apache.lucene.index.PayloadProcessorProvider.DirPayloadProcessor;
import org.apache.lucene.index.PayloadProcessorProvider.PayloadProcessor;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCaseJ4;
import org.junit.Test;

View File

@ -39,7 +39,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.LuceneTestCase;

View File

@ -20,7 +20,6 @@ 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.MockRAMDirectory;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.util.BytesRef;

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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
public class TestSegmentReader extends LuceneTestCase {
private MockRAMDirectory dir;
private Directory dir;
private Document testDoc = new Document();
private SegmentReader reader = null;

View File

@ -13,7 +13,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.index.IndexCommit;
import org.apache.lucene.index.IndexWriterConfig;
@ -102,7 +101,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
_TestUtil.rmDir(dir);
}
MockRAMDirectory dir2 = newDirectory(random);
Directory dir2 = newDirectory(random);
runTest(random, dir2);
dir2.close();
}

View File

@ -35,7 +35,6 @@ import org.apache.lucene.document.Fieldable;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
public class TestStressIndexing2 extends MultiCodecTestCase {
static int maxFields=4;

View File

@ -32,7 +32,7 @@ import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
@ -44,7 +44,7 @@ public class TestTermVectorsReader extends LuceneTestCase {
private String[] testTerms = {"this", "is", "a", "test"};
private int[][] positions = new int[testTerms.length][];
private TermVectorOffsetInfo[][] offsets = new TermVectorOffsetInfo[testTerms.length][];
private MockRAMDirectory dir;
private Directory dir;
private String seg;
private FieldInfos fieldInfos = new FieldInfos();
private static int TERM_FREQ = 3;
@ -171,7 +171,7 @@ public class TestTermVectorsReader extends LuceneTestCase {
}
}
public void test() {
public void test() throws IOException {
//Check to see the files were created properly in setup
assertTrue(dir.fileExists(IndexFileNames.segmentFileName(seg, "", IndexFileNames.VECTORS_DOCUMENTS_EXTENSION)));
assertTrue(dir.fileExists(IndexFileNames.segmentFileName(seg, "", IndexFileNames.VECTORS_INDEX_EXTENSION)));

View File

@ -28,7 +28,6 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;

View File

@ -22,7 +22,6 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@ -31,7 +30,6 @@ import org.apache.lucene.util.English;
import org.apache.lucene.util.LuceneTestCase;
import java.io.IOException;
import java.io.File;
import java.util.Random;

View File

@ -24,7 +24,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.MockRAMDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.English;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
@ -34,9 +34,9 @@ public class TestTransactions extends LuceneTestCase {
private Random RANDOM;
private static volatile boolean doFail;
private class RandomFailure extends MockRAMDirectory.Failure {
private class RandomFailure extends MockDirectoryWrapper.Failure {
@Override
public void eval(MockRAMDirectory dir) throws IOException {
public void eval(MockDirectoryWrapper dir) throws IOException {
if (TestTransactions.doFail && RANDOM.nextInt() % 10 <= 3)
throw new IOException("now failing randomly but on purpose");
}
@ -195,8 +195,8 @@ public class TestTransactions extends LuceneTestCase {
public void testTransactions() throws Throwable {
RANDOM = newRandom();
MockRAMDirectory dir1 = newDirectory(RANDOM);
MockRAMDirectory dir2 = newDirectory(RANDOM);
MockDirectoryWrapper dir1 = newDirectory(RANDOM);
MockDirectoryWrapper dir2 = newDirectory(RANDOM);
dir1.setPreventDoubleWrite(false);
dir2.setPreventDoubleWrite(false);
dir1.failOn(new RandomFailure());

View File

@ -29,14 +29,12 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
/**

View File

@ -43,7 +43,6 @@ import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.BooleanQuery;
@ -59,9 +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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
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;
@ -571,7 +568,7 @@ public class TestQueryParser extends LocalizedTestCase {
public void testFarsiRangeCollating() throws Exception {
Random random = newRandom();
MockRAMDirectory ramDir = newDirectory(random);
Directory ramDir = newDirectory(random);
IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
Document doc = new Document();
doc.add(new Field("content","\u0633\u0627\u0628",
@ -981,7 +978,7 @@ public class TestQueryParser extends LocalizedTestCase {
public void testLocalDateFormat() throws IOException, ParseException {
Random random = newRandom();
MockRAMDirectory ramDir = newDirectory(random);
Directory ramDir = newDirectory(random);
IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false)));
addDateDoc("a", 2005, 12, 2, 10, 15, 33, iw);
addDateDoc("b", 2005, 12, 4, 22, 15, 00, iw);

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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
public class BaseTestRangeFilter extends LuceneTestCase {
@ -46,7 +46,7 @@ public class BaseTestRangeFilter extends LuceneTestCase {
int maxR;
int minR;
boolean allowNegativeRandomInts;
MockRAMDirectory index;
Directory index;
TestIndex(int minR, int maxR, boolean allowNegativeRandomInts) {
this.minR = minR;

View File

@ -14,7 +14,10 @@ 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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import static org.apache.lucene.util.LuceneTestCaseJ4.TEST_VERSION_CURRENT;
/**
@ -197,9 +200,9 @@ public class QueryUtils {
return out;
}
private static MockRAMDirectory makeEmptyIndex(final int numDeletedDocs)
private static Directory makeEmptyIndex(final int numDeletedDocs)
throws IOException {
MockRAMDirectory d = new MockRAMDirectory();
Directory d = new MockDirectoryWrapper(new RAMDirectory());
IndexWriter w = new IndexWriter(d, new IndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer()));
for (int i = 0; i < numDeletedDocs; i++) {

View File

@ -27,7 +27,6 @@ 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.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.BasicAutomata;

View File

@ -26,7 +26,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.RegExp;

View File

@ -23,17 +23,15 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.RandomIndexWriter;
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.MockRAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
/** Test BooleanQuery2 against BooleanQuery by overriding the standard query parser.
* This also tests the scoring order of BooleanQuery.
@ -65,13 +63,13 @@ public class TestBoolean2 extends LuceneTestCase {
searcher = new IndexSearcher(directory, true);
// Make big index
dir2 = new MockRAMDirectory(directory);
dir2 = new MockDirectoryWrapper(new RAMDirectory(directory));
// First multiply small test index:
mulFactor = 1;
int docCount = 0;
do {
final Directory copy = new MockRAMDirectory(dir2);
final Directory copy = new MockDirectoryWrapper(new RAMDirectory(dir2));
RandomIndexWriter w = new RandomIndexWriter(rnd, dir2);
w.addIndexes(new Directory[] {copy});
docCount = w.maxDoc();

View File

@ -24,7 +24,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import java.text.DecimalFormat;
import java.util.Random;

View File

@ -31,7 +31,6 @@ 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.MockRAMDirectory;
public class TestBooleanOr extends LuceneTestCase {

View File

@ -23,7 +23,6 @@ import org.apache.lucene.util.LuceneTestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.IndexReader;
@ -32,6 +31,7 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.store.Directory;
/**
*
@ -68,7 +68,7 @@ public class TestBooleanPrefixQuery extends LuceneTestCase {
public void testMethod() throws Exception {
Random random = newRandom();
MockRAMDirectory directory = newDirectory(random);
Directory directory = newDirectory(random);
String[] categories = new String[]{"food",
"foodanddrink",

View File

@ -23,7 +23,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.index.Term;

View File

@ -26,7 +26,7 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
@ -41,7 +41,7 @@ public class TestBooleanScorer extends LuceneTestCase
public void testMethod() throws Exception {
Random random = newRandom();
MockRAMDirectory directory = newDirectory(random);
Directory directory = newDirectory(random);
String[] values = new String[] { "1", "2", "3", "4" };

View File

@ -27,7 +27,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.SlowMultiReaderWrapper;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.OpenBitSet;
import org.apache.lucene.util.OpenBitSetDISI;

View File

@ -17,6 +17,7 @@ package org.apache.lucene.search;
* limitations under the License.
*/
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.Document;
@ -24,7 +25,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.MockRAMDirectory;
import java.io.IOException;
import java.util.Random;
@ -46,7 +46,7 @@ public class TestDateFilter extends LuceneTestCase {
public void testBefore() throws IOException {
// create an index
Random random = newRandom();
MockRAMDirectory indexStore = newDirectory(random);
Directory indexStore = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, indexStore);
long now = System.currentTimeMillis();
@ -113,7 +113,7 @@ public class TestDateFilter extends LuceneTestCase {
public void testAfter() throws IOException {
// create an index
Random random = newRandom();
MockRAMDirectory indexStore = newDirectory(random);
Directory indexStore = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, indexStore);
long now = System.currentTimeMillis();

View File

@ -34,7 +34,6 @@ 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.MockRAMDirectory;
/**
* Test date sorting, i.e. auto-sorting of fields with type "long".

View File

@ -26,7 +26,6 @@ import org.apache.lucene.index.SlowMultiReaderWrapper;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
import java.text.DecimalFormat;
import java.util.Random;

View File

@ -25,7 +25,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.MockRAMDirectory;
import org.apache.lucene.store.Directory;
/** Document boost unit test.
*
@ -39,7 +39,7 @@ public class TestDocBoost extends LuceneTestCase {
public void testDocBoost() throws Exception {
Random random = newRandom();
MockRAMDirectory store = newDirectory(random);
Directory store = newDirectory(random);
RandomIndexWriter writer = new RandomIndexWriter(random, store);
Fieldable f1 = new Field("field", "word", Field.Store.YES, Field.Index.ANALYZED);

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