LUCENE-3771: Test renames/fixes after IndexReader refactoring

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1243061 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-02-11 13:40:26 +00:00
parent d17d600da5
commit a53da14ec6
4 changed files with 993 additions and 1125 deletions

View File

@ -46,7 +46,7 @@ import org.apache.lucene.util.Bits;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
public class TestIndexReaderReopen extends LuceneTestCase {
public class TestDirectoryReaderReopen extends LuceneTestCase {
public void testReopen() throws Exception {
final Directory dir1 = newDirectory();
@ -56,7 +56,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
@Override
protected void modifyIndex(int i) throws IOException {
TestIndexReaderReopen.modifyIndex(i, dir1);
TestDirectoryReaderReopen.modifyIndex(i, dir1);
}
@Override
@ -74,7 +74,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
@Override
protected void modifyIndex(int i) throws IOException {
TestIndexReaderReopen.modifyIndex(i, dir2);
TestDirectoryReaderReopen.modifyIndex(i, dir2);
}
@Override
@ -158,7 +158,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
DirectoryReader index1 = test.openReader();
DirectoryReader index2 = test.openReader();
TestIndexReader.assertIndexEquals(index1, index2);
TestDirectoryReader.assertIndexEquals(index1, index2);
// verify that reopen() does not return a new reader instance
// in case the index has no changes
@ -173,7 +173,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
index2.close();
// test if refreshed reader and newly opened reader return equal results
TestIndexReader.assertIndexEquals(index1, index2_refreshed);
TestDirectoryReader.assertIndexEquals(index1, index2_refreshed);
index2_refreshed.close();
assertReaderClosed(index2, true, true);
@ -190,7 +190,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
index2 = couple.refreshedReader;
index1 = couple.newReader;
TestIndexReader.assertIndexEquals(index1, index2);
TestDirectoryReader.assertIndexEquals(index1, index2);
}
index1.close();
@ -203,7 +203,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
DirectoryReader index1 = test.openReader();
DirectoryReader index2 = test.openReader();
TestIndexReader.assertIndexEquals(index1, index2);
TestDirectoryReader.assertIndexEquals(index1, index2);
try {
refreshReader(index1, test, 0, true);
@ -213,7 +213,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
}
// index2 should still be usable and unaffected by the failed reopen() call
TestIndexReader.assertIndexEquals(index1, index2);
TestDirectoryReader.assertIndexEquals(index1, index2);
index1.close();
index2.close();
@ -315,7 +315,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
int numReaders = readers.size();
if (numReaders > 0) {
ReaderCouple c = readers.get(rnd.nextInt(numReaders));
TestIndexReader.assertIndexEquals(c.newReader, c.refreshedReader);
TestDirectoryReader.assertIndexEquals(c.newReader, c.refreshedReader);
}
synchronized(this) {

View File

@ -1,56 +0,0 @@
package org.apache.lucene.index;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.IOException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockDirectoryWrapper;
public class TestMultiReader extends TestDirectoryReader {
// TODO: files are never fsynced if you do what this test is doing,
// so the checkindex is disabled.
@Override
protected Directory createDirectory() throws IOException {
MockDirectoryWrapper mdw = newDirectory();
mdw.setCheckIndexOnClose(false);
return mdw;
}
@Override
protected IndexReader openReader() throws IOException {
IndexReader reader;
sis.read(dir);
SegmentReader reader1 = new SegmentReader(sis.info(0), DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
SegmentReader reader2 = new SegmentReader(sis.info(1), DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
readers[0] = reader1;
readers[1] = reader2;
assertTrue(reader1 != null);
assertTrue(reader2 != null);
reader = new MultiReader(readers);
assertTrue(dir != null);
assertTrue(sis != null);
return reader;
}
}