mirror of https://github.com/apache/lucene.git
LUCENE-2858: fix tests
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene2858@1237368 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b8df3e0398
commit
24129e1fa2
|
@ -51,7 +51,7 @@ public class TestIndexWriterCommit extends LuceneTestCase {
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
Term searchTerm = new Term("content", "aaa");
|
Term searchTerm = new Term("content", "aaa");
|
||||||
IndexReader reader = IndexReader.open(dir);
|
DirectoryReader reader = IndexReader.open(dir);
|
||||||
IndexSearcher searcher = new IndexSearcher(reader);
|
IndexSearcher searcher = new IndexSearcher(reader);
|
||||||
ScoreDoc[] hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
|
ScoreDoc[] hits = searcher.search(new TermQuery(searchTerm), null, 1000).scoreDocs;
|
||||||
assertEquals("first number of hits", 14, hits.length);
|
assertEquals("first number of hits", 14, hits.length);
|
||||||
|
@ -279,7 +279,7 @@ public class TestIndexWriterCommit extends LuceneTestCase {
|
||||||
writer.forceMerge(1);
|
writer.forceMerge(1);
|
||||||
|
|
||||||
// Open a reader before closing (commiting) the writer:
|
// Open a reader before closing (commiting) the writer:
|
||||||
IndexReader reader = IndexReader.open(dir);
|
DirectoryReader reader = IndexReader.open(dir);
|
||||||
|
|
||||||
// Reader should see index as multi-seg at this
|
// Reader should see index as multi-seg at this
|
||||||
// point:
|
// point:
|
||||||
|
@ -339,7 +339,7 @@ public class TestIndexWriterCommit extends LuceneTestCase {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final Document doc = new Document();
|
final Document doc = new Document();
|
||||||
IndexReader r = IndexReader.open(dir);
|
DirectoryReader r = IndexReader.open(dir);
|
||||||
Field f = newField("f", "", StringField.TYPE_UNSTORED);
|
Field f = newField("f", "", StringField.TYPE_UNSTORED);
|
||||||
doc.add(f);
|
doc.add(f);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -350,7 +350,7 @@ public class TestIndexWriterCommit extends LuceneTestCase {
|
||||||
f.setValue(s);
|
f.setValue(s);
|
||||||
w.addDocument(doc);
|
w.addDocument(doc);
|
||||||
w.commit();
|
w.commit();
|
||||||
IndexReader r2 = IndexReader.openIfChanged(r);
|
DirectoryReader r2 = DirectoryReader.openIfChanged(r);
|
||||||
assertNotNull(r2);
|
assertNotNull(r2);
|
||||||
assertTrue(r2 != r);
|
assertTrue(r2 != r);
|
||||||
r.close();
|
r.close();
|
||||||
|
@ -390,10 +390,10 @@ public class TestIndexWriterCommit extends LuceneTestCase {
|
||||||
for (int i = 0; i < 23; i++)
|
for (int i = 0; i < 23; i++)
|
||||||
TestIndexWriter.addDoc(writer);
|
TestIndexWriter.addDoc(writer);
|
||||||
|
|
||||||
IndexReader reader = IndexReader.open(dir);
|
DirectoryReader reader = IndexReader.open(dir);
|
||||||
assertEquals(0, reader.numDocs());
|
assertEquals(0, reader.numDocs());
|
||||||
writer.commit();
|
writer.commit();
|
||||||
IndexReader reader2 = IndexReader.openIfChanged(reader);
|
DirectoryReader reader2 = DirectoryReader.openIfChanged(reader);
|
||||||
assertNotNull(reader2);
|
assertNotNull(reader2);
|
||||||
assertEquals(0, reader.numDocs());
|
assertEquals(0, reader.numDocs());
|
||||||
assertEquals(23, reader2.numDocs());
|
assertEquals(23, reader2.numDocs());
|
||||||
|
@ -501,7 +501,7 @@ public class TestIndexWriterCommit extends LuceneTestCase {
|
||||||
for (int i = 0; i < 23; i++)
|
for (int i = 0; i < 23; i++)
|
||||||
TestIndexWriter.addDoc(writer);
|
TestIndexWriter.addDoc(writer);
|
||||||
|
|
||||||
IndexReader reader = IndexReader.open(dir);
|
DirectoryReader reader = IndexReader.open(dir);
|
||||||
assertEquals(0, reader.numDocs());
|
assertEquals(0, reader.numDocs());
|
||||||
|
|
||||||
writer.prepareCommit();
|
writer.prepareCommit();
|
||||||
|
@ -511,7 +511,7 @@ public class TestIndexWriterCommit extends LuceneTestCase {
|
||||||
|
|
||||||
writer.commit();
|
writer.commit();
|
||||||
|
|
||||||
IndexReader reader3 = IndexReader.openIfChanged(reader);
|
IndexReader reader3 = DirectoryReader.openIfChanged(reader);
|
||||||
assertNotNull(reader3);
|
assertNotNull(reader3);
|
||||||
assertEquals(0, reader.numDocs());
|
assertEquals(0, reader.numDocs());
|
||||||
assertEquals(0, reader2.numDocs());
|
assertEquals(0, reader2.numDocs());
|
||||||
|
@ -558,7 +558,7 @@ public class TestIndexWriterCommit extends LuceneTestCase {
|
||||||
for (int i = 0; i < 23; i++)
|
for (int i = 0; i < 23; i++)
|
||||||
TestIndexWriter.addDoc(writer);
|
TestIndexWriter.addDoc(writer);
|
||||||
|
|
||||||
IndexReader reader = IndexReader.open(dir);
|
DirectoryReader reader = IndexReader.open(dir);
|
||||||
assertEquals(0, reader.numDocs());
|
assertEquals(0, reader.numDocs());
|
||||||
|
|
||||||
writer.prepareCommit();
|
writer.prepareCommit();
|
||||||
|
@ -568,7 +568,7 @@ public class TestIndexWriterCommit extends LuceneTestCase {
|
||||||
|
|
||||||
writer.rollback();
|
writer.rollback();
|
||||||
|
|
||||||
IndexReader reader3 = IndexReader.openIfChanged(reader);
|
IndexReader reader3 = DirectoryReader.openIfChanged(reader);
|
||||||
assertNull(reader3);
|
assertNull(reader3);
|
||||||
assertEquals(0, reader.numDocs());
|
assertEquals(0, reader.numDocs());
|
||||||
assertEquals(0, reader2.numDocs());
|
assertEquals(0, reader2.numDocs());
|
||||||
|
@ -622,7 +622,7 @@ public class TestIndexWriterCommit extends LuceneTestCase {
|
||||||
|
|
||||||
assertEquals(0, DirectoryReader.getCommitUserData(dir).size());
|
assertEquals(0, DirectoryReader.getCommitUserData(dir).size());
|
||||||
|
|
||||||
IndexReader r = IndexReader.open(dir);
|
DirectoryReader r = IndexReader.open(dir);
|
||||||
// commit(Map) never called for this index
|
// commit(Map) never called for this index
|
||||||
assertEquals(0, r.getCommitUserData().size());
|
assertEquals(0, r.getCommitUserData().size());
|
||||||
r.close();
|
r.close();
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class TestIndexWriterConfig extends LuceneTestCase {
|
||||||
assertEquals(IndexWriterConfig.DISABLE_AUTO_FLUSH, IndexWriterConfig.DEFAULT_MAX_BUFFERED_DOCS);
|
assertEquals(IndexWriterConfig.DISABLE_AUTO_FLUSH, IndexWriterConfig.DEFAULT_MAX_BUFFERED_DOCS);
|
||||||
assertEquals(16.0, IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB, 0.0);
|
assertEquals(16.0, IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB, 0.0);
|
||||||
assertEquals(false, IndexWriterConfig.DEFAULT_READER_POOLING);
|
assertEquals(false, IndexWriterConfig.DEFAULT_READER_POOLING);
|
||||||
assertEquals(IndexReader.DEFAULT_TERMS_INDEX_DIVISOR, IndexWriterConfig.DEFAULT_READER_TERMS_INDEX_DIVISOR);
|
assertEquals(DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, IndexWriterConfig.DEFAULT_READER_TERMS_INDEX_DIVISOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -186,7 +186,7 @@ public class TestIndexWriterForceMerge extends LuceneTestCase {
|
||||||
|
|
||||||
if (0 == pass) {
|
if (0 == pass) {
|
||||||
writer.close();
|
writer.close();
|
||||||
IndexReader reader = IndexReader.open(dir);
|
DirectoryReader reader = IndexReader.open(dir);
|
||||||
assertEquals(1, reader.getSequentialSubReaders().length);
|
assertEquals(1, reader.getSequentialSubReaders().length);
|
||||||
reader.close();
|
reader.close();
|
||||||
} else {
|
} else {
|
||||||
|
@ -196,7 +196,7 @@ public class TestIndexWriterForceMerge extends LuceneTestCase {
|
||||||
writer.addDocument(doc);
|
writer.addDocument(doc);
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
IndexReader reader = IndexReader.open(dir);
|
DirectoryReader reader = IndexReader.open(dir);
|
||||||
assertTrue(reader.getSequentialSubReaders().length > 1);
|
assertTrue(reader.getSequentialSubReaders().length > 1);
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue