From 561fddd8a770ee627e4adf0d7a8caafd9da1415a Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Tue, 26 Aug 2014 22:03:45 +0000 Subject: [PATCH] LUCENE-5907: merge test cases forward to 5.0 (the issue only affects 4.x) git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1620751 13f79535-47bb-0310-9956-ffa450edef68 --- .../index/TestBackwardsCompatibility.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java index 87970c3fd8c..e8b353729f2 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java @@ -1119,4 +1119,38 @@ public class TestBackwardsCompatibility extends LuceneTestCase { dir.close(); } + // LUCENE-5907 + public void testUpgradeWithNRTReader() throws Exception { + for (String name : oldNames) { + Directory dir = newDirectory(oldIndexDirs.get(name)); + + IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())) + .setOpenMode(OpenMode.APPEND)); + writer.addDocument(new Document()); + DirectoryReader r = DirectoryReader.open(writer, true); + writer.commit(); + r.close(); + writer.forceMerge(1); + writer.commit(); + writer.rollback(); + new SegmentInfos().read(dir); + dir.close(); + } + } + + // LUCENE-5907 + public void testUpgradeThenMultipleCommits() throws Exception { + for (String name : oldNames) { + Directory dir = newDirectory(oldIndexDirs.get(name)); + + IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())) + .setOpenMode(OpenMode.APPEND)); + writer.addDocument(new Document()); + writer.commit(); + writer.addDocument(new Document()); + writer.commit(); + writer.close(); + dir.close(); + } + } }