You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2010/07/20 17:40:54 UTC

svn commit: r965883 - /lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java

Author: uschindler
Date: Tue Jul 20 15:40:54 2010
New Revision: 965883

URL: http://svn.apache.org/viewvc?rev=965883&view=rev
Log:
LUCENE-2523: Modify the test to check only for failure on IR.open(), add TODO to make IW.ctor() fail early, too

Modified:
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=965883&r1=965882&r2=965883&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Tue Jul 20 15:40:54 2010
@@ -28,6 +28,7 @@ import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.List;
+import java.util.Random;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
@@ -147,6 +148,7 @@ public class TestBackwardsCompatibility 
   
   /** This test checks that *only* IndexFormatTooOldExceptions are throws when you open and operate on too old indexes! */
   public void testUnsupportedOldIndexes() throws Exception {
+    final Random rnd = newRandom();
     for(int i=0;i<unsupportedNames.length;i++) {
       unzip(getDataFile("unsupported." + unsupportedNames[i] + ".zip"), unsupportedNames[i]);
 
@@ -157,8 +159,6 @@ public class TestBackwardsCompatibility 
       IndexWriter writer = null;
       try {
         reader = IndexReader.open(dir);
-        MultiFields.getFields(reader).terms("content");
-        reader.document(0); // to catch also 2.9->3.0 stored field change
         fail("IndexReader.open should not pass for "+unsupportedNames[i]);
       } catch (IndexFormatTooOldException e) {
         // pass
@@ -172,9 +172,12 @@ public class TestBackwardsCompatibility 
           TEST_VERSION_CURRENT, new MockAnalyzer())
           .setMergeScheduler(new SerialMergeScheduler()) // no threads!
         );
-        writer.optimize();
-        reader = writer.getReader();
-        reader.document(0); // to catch also 2.9->3.0 stored field change
+        // TODO: Make IndexWriter fail on open!
+        if (rnd.nextBoolean()) {
+          writer.optimize();
+        } else {
+          reader = writer.getReader();
+        }
         fail("IndexWriter creation should not pass for "+unsupportedNames[i]);
       } catch (IndexFormatTooOldException e) {
         // pass