lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1363400 [14/31] - in /lucene/dev/branches/pforcodec_3892: ./ dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/ dev-tools/idea/.idea/copyright/ dev-tools/idea/.idea/libraries/ dev-tools/idea/lucene/ dev-tools/maven/ dev-tools/maven/lucene...
Date Thu, 19 Jul 2012 15:59:32 GMT
Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java Thu Jul 19 15:58:54 2012
@@ -22,7 +22,6 @@ import org.apache.lucene.util.LuceneTest
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.store.RAMDirectory;
-import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.LogMergePolicy;
@@ -47,7 +46,7 @@ public class TestMergeSchedulerExternal 
   private class MyMergeScheduler extends ConcurrentMergeScheduler {
 
     private class MyMergeThread extends ConcurrentMergeScheduler.MergeThread {
-      public MyMergeThread(IndexWriter writer, MergePolicy.OneMerge merge) throws IOException {
+      public MyMergeThread(IndexWriter writer, MergePolicy.OneMerge merge) {
         super(writer, merge);
         mergeThreadCreated = true;
       }
@@ -114,7 +113,7 @@ public class TestMergeSchedulerExternal 
   private static class ReportingMergeScheduler extends MergeScheduler {
 
     @Override
-    public void merge(IndexWriter writer) throws CorruptIndexException, IOException {
+    public void merge(IndexWriter writer) throws IOException {
       OneMerge merge = null;
       while ((merge = writer.getNextMerge()) != null) {
         if (VERBOSE) {
@@ -125,7 +124,7 @@ public class TestMergeSchedulerExternal 
     }
 
     @Override
-    public void close() throws CorruptIndexException, IOException {}
+    public void close() throws IOException {}
     
   }
 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java Thu Jul 19 15:58:54 2012
@@ -45,7 +45,7 @@ public class TestCachingTokenFilter exte
       private OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class);
       
       @Override
-      public boolean incrementToken() throws IOException {
+      public boolean incrementToken() {
         if (index == tokens.length) {
           return false;
         } else {

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java Thu Jul 19 15:58:54 2012
@@ -123,7 +123,7 @@ public class TestMockAnalyzer extends Ba
     for (int i = 0; i < num; i++) {
       String s = _TestUtil.randomHtmlishString(random(), 20);
       StringReader reader = new StringReader(s);
-      MockCharFilter charfilter = new MockCharFilter(CharReader.get(reader), 2);
+      MockCharFilter charfilter = new MockCharFilter(reader, 2);
       MockAnalyzer analyzer = new MockAnalyzer(random());
       TokenStream ts = analyzer.tokenStream("bogus", charfilter);
       ts.reset();

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestMockCharFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestMockCharFilter.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestMockCharFilter.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/TestMockCharFilter.java Thu Jul 19 15:58:54 2012
@@ -33,7 +33,7 @@ public class TestMockCharFilter extends 
 
       @Override
       protected Reader initReader(String fieldName, Reader reader) {
-        return new MockCharFilter(CharReader.get(reader), 7);
+        return new MockCharFilter(reader, 7);
       }
     };
     

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestCharTermAttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestCharTermAttributeImpl.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestCharTermAttributeImpl.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestCharTermAttributeImpl.java Thu Jul 19 15:58:54 2012
@@ -159,7 +159,7 @@ public class TestCharTermAttributeImpl e
 
   public void testAppendableInterface() {
     CharTermAttributeImpl t = new CharTermAttributeImpl();
-    Formatter formatter = new Formatter(t, Locale.US);
+    Formatter formatter = new Formatter(t, Locale.ROOT);
     formatter.format("%d", 1234);
     assertEquals("1234", t.toString());
     formatter.format("%d", 5678);

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestAllFilesHaveCodecHeader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestAllFilesHaveCodecHeader.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestAllFilesHaveCodecHeader.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/lucene40/TestAllFilesHaveCodecHeader.java Thu Jul 19 15:58:54 2012
@@ -21,6 +21,7 @@ import java.io.IOException;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.codecs.Codec;
+import org.apache.lucene.codecs.CodecUtil;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexFileNames;
@@ -29,7 +30,6 @@ import org.apache.lucene.index.RandomInd
 import org.apache.lucene.store.CompoundFileDirectory;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
-import org.apache.lucene.util.CodecUtil;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util._TestUtil;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat.java Thu Jul 19 15:58:54 2012
@@ -30,7 +30,6 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
@@ -189,7 +188,7 @@ public class TestPerFieldPostingsFormat 
   }
 
   public void assertQuery(Term t, Directory dir, int num)
-      throws CorruptIndexException, IOException {
+      throws IOException {
     if (VERBOSE) {
       System.out.println("\nTEST: assertQuery " + t);
     }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/pfor/TestPForUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/pfor/TestPForUtil.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/pfor/TestPForUtil.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/pfor/TestPForUtil.java Thu Jul 19 15:58:54 2012
@@ -17,13 +17,15 @@ package org.apache.lucene.codecs.pfor;
  * limitations under the License.
  */
 
-import java.util.Collections;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Locale;
 import java.util.Random;
-import java.nio.IntBuffer;
-import java.nio.ByteBuffer;
-import org.apache.lucene.codecs.pfor.PForUtil;
+
 import org.apache.lucene.codecs.pfor.ForPostingsFormat;
+import org.apache.lucene.codecs.pfor.PForUtil;
 import org.apache.lucene.util.LuceneTestCase;
 
 /**
@@ -245,7 +247,7 @@ public class TestPForUtil extends Lucene
       return false;
     for (int i=0; i<sza; ++i) {
       if (a[i]!=b[i]) {
-        System.err.println(String.format("! %08x != %08x in %d",a[i],b[i],i));
+        System.err.println(String.format(Locale.ENGLISH, "! %08x != %08x in %d",a[i],b[i],i));
         return false;
       }
     }
@@ -275,17 +277,17 @@ public class TestPForUtil extends Lucene
     for ( int i=0; i<sz; i++ ) {
       if (i>0 && i%8 == 0)
         hex.append("\n");
-      hex.append(String.format("%08x ",raw[i]));
+      hex.append(String.format(Locale.ENGLISH, "%08x ",raw[i]));
     }
     return hex.toString();
   }
   static void eprintln(String format, Object... args) {
-    System.err.println(String.format(format,args)); 
+    System.err.println(String.format(Locale.ENGLISH, format,args)); 
   }
   static void println(String format, Object... args) {
-    System.out.println(String.format(format,args)); 
+    System.out.println(String.format(Locale.ENGLISH, format,args)); 
   }
   static void print(String format, Object... args) {
-    System.out.print(String.format(format,args)); 
+    System.out.print(String.format(Locale.ENGLISH, format,args)); 
   }
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/pulsing/Test10KPulsings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/pulsing/Test10KPulsings.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/pulsing/Test10KPulsings.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/codecs/pulsing/Test10KPulsings.java Thu Jul 19 15:58:54 2012
@@ -71,7 +71,7 @@ public class Test10KPulsings extends Luc
     Field field = newField("field", "", ft);
     document.add(field);
     
-    NumberFormat df = new DecimalFormat("00000", new DecimalFormatSymbols(Locale.ENGLISH));
+    NumberFormat df = new DecimalFormat("00000", new DecimalFormatSymbols(Locale.ROOT));
 
     for (int i = 0; i < 10050; i++) {
       field.setStringValue(df.format(i));
@@ -122,7 +122,7 @@ public class Test10KPulsings extends Luc
     Field field = newField("field", "", ft);
     document.add(field);
     
-    NumberFormat df = new DecimalFormat("00000", new DecimalFormatSymbols(Locale.ENGLISH));
+    NumberFormat df = new DecimalFormat("00000", new DecimalFormatSymbols(Locale.ROOT));
 
     final int freq = freqCutoff + 1;
     

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java Thu Jul 19 15:58:54 2012
@@ -37,7 +37,7 @@ public class TestBinaryDocument extends 
   {
     FieldType ft = new FieldType();
     ft.setStored(true);
-    IndexableField binaryFldStored = new StoredField("binaryStored", binaryValStored.getBytes());
+    IndexableField binaryFldStored = new StoredField("binaryStored", binaryValStored.getBytes("UTF-8"));
     IndexableField stringFldStored = new Field("stringStored", binaryValStored, ft);
 
     Document doc = new Document();
@@ -62,7 +62,7 @@ public class TestBinaryDocument extends 
     /** fetch the binary stored field and compare it's content with the original one */
     BytesRef bytes = docFromReader.getBinaryValue("binaryStored");
     assertNotNull(bytes);
-    String binaryFldStoredTest = new String(bytes.bytes, bytes.offset, bytes.length);
+    String binaryFldStoredTest = new String(bytes.bytes, bytes.offset, bytes.length, "UTF-8");
     assertTrue(binaryFldStoredTest.equals(binaryValStored));
     
     /** fetch the string field and compare it's content with the original one */
@@ -75,7 +75,7 @@ public class TestBinaryDocument extends 
   }
   
   public void testCompressionTools() throws Exception {
-    IndexableField binaryFldCompressed = new StoredField("binaryCompressed", CompressionTools.compress(binaryValCompressed.getBytes()));
+    IndexableField binaryFldCompressed = new StoredField("binaryCompressed", CompressionTools.compress(binaryValCompressed.getBytes("UTF-8")));
     IndexableField stringFldCompressed = new StoredField("stringCompressed", CompressionTools.compressString(binaryValCompressed));
     
     Document doc = new Document();
@@ -94,7 +94,7 @@ public class TestBinaryDocument extends 
     assertTrue(docFromReader != null);
     
     /** fetch the binary compressed field and compare it's content with the original one */
-    String binaryFldCompressedTest = new String(CompressionTools.decompress(docFromReader.getBinaryValue("binaryCompressed")));
+    String binaryFldCompressedTest = new String(CompressionTools.decompress(docFromReader.getBinaryValue("binaryCompressed")), "UTF-8");
     assertTrue(binaryFldCompressedTest.equals(binaryValCompressed));
     assertTrue(CompressionTools.decompressString(docFromReader.getBinaryValue("stringCompressed")).equals(binaryValCompressed));
 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestDateTools.java Thu Jul 19 15:58:54 2012
@@ -61,12 +61,12 @@ public class TestDateTools extends Lucen
   
   public void testStringtoTime() throws ParseException {
     long time = DateTools.stringToTime("197001010000");
-    Calendar cal = new GregorianCalendar();
+    // we use default locale since LuceneTestCase randomizes it
+    Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.getDefault());
     cal.clear();
     cal.set(1970, 0, 1,    // year=1970, month=january, day=1
         0, 0, 0);          // hour, minute, second
     cal.set(Calendar.MILLISECOND, 0);
-    cal.setTimeZone(TimeZone.getTimeZone("GMT"));
     assertEquals(cal.getTime().getTime(), time);
     cal.set(1980, 1, 2,    // year=1980, month=february, day=2
         11, 5, 0);          // hour, minute, second
@@ -76,9 +76,9 @@ public class TestDateTools extends Lucen
   }
   
   public void testDateAndTimetoString() throws ParseException {
-    Calendar cal = new GregorianCalendar();
+    // we use default locale since LuceneTestCase randomizes it
+    Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.getDefault());
     cal.clear();
-    cal.setTimeZone(TimeZone.getTimeZone("GMT"));
     cal.set(2004, 1, 3,   // year=2004, month=february(!), day=3
         22, 8, 56);       // hour, minute, second
     cal.set(Calendar.MILLISECOND, 333);
@@ -141,9 +141,9 @@ public class TestDateTools extends Lucen
   }
   
   public void testRound() {
-    Calendar cal = new GregorianCalendar();
+    // we use default locale since LuceneTestCase randomizes it
+    Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.getDefault());
     cal.clear();
-    cal.setTimeZone(TimeZone.getTimeZone("GMT"));
     cal.set(2004, 1, 3,   // year=2004, month=february(!), day=3
         22, 8, 56);       // hour, minute, second
     cal.set(Calendar.MILLISECOND, 333);
@@ -180,7 +180,7 @@ public class TestDateTools extends Lucen
   }
 
   private String isoFormat(Date date) {
-    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.US);
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.ROOT);
     sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
     return sdf.format(date);
   }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestDocument.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestDocument.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/document/TestDocument.java Thu Jul 19 15:58:54 2012
@@ -51,8 +51,8 @@ public class TestDocument extends Lucene
     FieldType ft = new FieldType();
     ft.setStored(true);
     IndexableField stringFld = new Field("string", binaryVal, ft);
-    IndexableField binaryFld = new StoredField("binary", binaryVal.getBytes());
-    IndexableField binaryFld2 = new StoredField("binary", binaryVal2.getBytes());
+    IndexableField binaryFld = new StoredField("binary", binaryVal.getBytes("UTF-8"));
+    IndexableField binaryFld2 = new StoredField("binary", binaryVal2.getBytes("UTF-8"));
     
     doc.add(stringFld);
     doc.add(binaryFld);
@@ -62,7 +62,6 @@ public class TestDocument extends Lucene
     assertTrue(binaryFld.binaryValue() != null);
     assertTrue(binaryFld.fieldType().stored());
     assertFalse(binaryFld.fieldType().indexed());
-    assertFalse(binaryFld.fieldType().tokenized());
     
     String binaryTest = doc.getBinaryValue("binary").utf8ToString();
     assertTrue(binaryTest.equals(binaryVal));

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/BinaryTokenStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/BinaryTokenStream.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/BinaryTokenStream.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/BinaryTokenStream.java Thu Jul 19 15:58:54 2012
@@ -17,8 +17,6 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import java.io.IOException;
-
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
 import org.apache.lucene.util.AttributeImpl;
@@ -36,7 +34,7 @@ public final class BinaryTokenStream ext
   }
   
   @Override
-  public boolean incrementToken() throws IOException {
+  public boolean incrementToken() {
     if (available) {
       available = false;
       return true;
@@ -45,7 +43,7 @@ public final class BinaryTokenStream ext
   }
   
   @Override
-  public void reset() throws IOException {
+  public void reset() {
     available = true;
   }
   

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/Test2BPostings.java Thu Jul 19 15:58:54 2012
@@ -17,8 +17,6 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import java.io.IOException;
-
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
@@ -94,7 +92,7 @@ public class Test2BPostings extends Luce
     }
     
     @Override
-    public boolean incrementToken() throws IOException {
+    public boolean incrementToken() {
       if (index <= 'z') {
         buffer[0] = (char) index++;
         return true;
@@ -103,7 +101,7 @@ public class Test2BPostings extends Luce
     }
     
     @Override
-    public void reset() throws IOException {
+    public void reset() {
       index = 'a';
     }
   }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java Thu Jul 19 15:58:54 2012
@@ -25,6 +25,7 @@ import org.apache.lucene.analysis.*;
 import org.apache.lucene.analysis.tokenattributes.*;
 import org.apache.lucene.document.*;
 import org.apache.lucene.index.FieldInfo.IndexOptions;
+import org.junit.Ignore;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -135,7 +136,7 @@ public class Test2BTerms extends LuceneT
     }
   }
 
-  @Slow
+  @Ignore("Very slow. Enable manually by removing @Ignore.")
   public void test2BTerms() throws IOException {
 
     System.out.println("Starting Test2B");

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Thu Jul 19 15:58:54 2012
@@ -219,10 +219,10 @@ public class TestBackwardsCompatibility 
       
       ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
       CheckIndex checker = new CheckIndex(dir);
-      checker.setInfoStream(new PrintStream(bos));
+      checker.setInfoStream(new PrintStream(bos, false, "UTF-8"));
       CheckIndex.Status indexStatus = checker.checkIndex();
       assertFalse(indexStatus.clean);
-      assertTrue(bos.toString().contains(IndexFormatTooOldException.class.getName()));
+      assertTrue(bos.toString("UTF-8").contains(IndexFormatTooOldException.class.getName()));
 
       dir.close();
       _TestUtil.rmDir(oldIndxeDir);

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java Thu Jul 19 15:58:54 2012
@@ -25,8 +25,11 @@ import java.util.ArrayList;
 
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.analysis.CannedTokenStream;
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.analysis.Token;
 import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.util.Constants;
@@ -52,12 +55,12 @@ public class TestCheckIndex extends Luce
 
     ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
     CheckIndex checker = new CheckIndex(dir);
-    checker.setInfoStream(new PrintStream(bos));
+    checker.setInfoStream(new PrintStream(bos, false, "UTF-8"));
     if (VERBOSE) checker.setInfoStream(System.out);
     CheckIndex.Status indexStatus = checker.checkIndex();
     if (indexStatus.clean == false) {
       System.out.println("CheckIndex failed");
-      System.out.println(bos.toString());
+      System.out.println(bos.toString("UTF-8"));
       fail();
     }
     
@@ -93,14 +96,42 @@ public class TestCheckIndex extends Luce
     assertTrue(checker.checkIndex(onlySegments).clean == true);
     dir.close();
   }
+  
+  // LUCENE-4221: we have to let these thru, for now
+  public void testBogusTermVectors() throws IOException {
+    Directory dir = newDirectory();
+    IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
+    Document doc = new Document();
+    FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
+    ft.setStoreTermVectors(true);
+    ft.setStoreTermVectorOffsets(true);
+    Field field = new Field("foo", "", ft);
+    field.setTokenStream(new CannedTokenStream(
+        new Token("bar", 5, 10), new Token("bar", 1, 4)
+    ));
+    doc.add(field);
+    iw.addDocument(doc);
+    iw.close();
+    dir.close(); // checkindex
+  }
 
   public void testLuceneConstantVersion() throws IOException {
     // common-build.xml sets lucene.version
     final String version = System.getProperty("lucene.version");
     assertNotNull( "null version", version);
+    final String constantVersion;
+    String parts[] = Constants.LUCENE_MAIN_VERSION.split("\\.");
+    if (parts.length == 4) {
+      // alpha/beta version: pull the real portion
+      assert parts[2].equals("0");
+      constantVersion = parts[0] + "." + parts[1];
+    } else {
+      // normal version
+      constantVersion = Constants.LUCENE_MAIN_VERSION;
+    }
     assertTrue("Invalid version: "+version,
-               version.equals(Constants.LUCENE_MAIN_VERSION+"-SNAPSHOT") ||
-               version.equals(Constants.LUCENE_MAIN_VERSION));
+               version.equals(constantVersion+"-SNAPSHOT") ||
+               version.equals(constantVersion));
     assertTrue(Constants.LUCENE_VERSION + " should start with: "+version,
                Constants.LUCENE_VERSION.startsWith(version));
   }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java Thu Jul 19 15:58:54 2012
@@ -76,7 +76,7 @@ public class TestCodecs extends LuceneTe
   private final static int TERM_DOC_FREQ_RAND = 20;
 
   @BeforeClass
-  public static void beforeClass() throws Exception {
+  public static void beforeClass() {
     NUM_TEST_ITER = atLeast(20);
   }
 
@@ -559,6 +559,7 @@ public class TestCodecs extends LuceneTe
             }
             assertNotNull(docs);
             int upto2 = -1;
+            boolean ended = false;
             while(upto2 < term.docs.length-1) {
               // Maybe skip:
               final int left = term.docs.length-upto2;
@@ -574,6 +575,7 @@ public class TestCodecs extends LuceneTe
                   if (doc == DocIdSetIterator.NO_MORE_DOCS) {
                     // skipped past last doc
                     assert upto2 == term.docs.length-1;
+                    ended = true;
                     break;
                   } else {
                     // skipped to next doc
@@ -597,7 +599,9 @@ public class TestCodecs extends LuceneTe
               }
             }
 
-            assertEquals(DocIdSetIterator.NO_MORE_DOCS, docs.nextDoc());
+            if (!ended) {
+              assertEquals(DocIdSetIterator.NO_MORE_DOCS, docs.nextDoc());
+            }
           }
           upto++;
 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java Thu Jul 19 15:58:54 2012
@@ -117,7 +117,6 @@ public class TestCrashCausesCorruptIndex
    * Run an example search.
    * 
    * @throws IOException
-   * @throws ParseException
    */
   private void searchForFleas(final int expectedTotalHits) throws IOException {
     Directory realDirectory = newFSDirectory(path);

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java Thu Jul 19 15:58:54 2012
@@ -44,7 +44,7 @@ import org.apache.lucene.util._TestUtil;
 
 public class TestDeletionPolicy extends LuceneTestCase {
   
-  private void verifyCommitOrder(List<? extends IndexCommit> commits) throws IOException {
+  private void verifyCommitOrder(List<? extends IndexCommit> commits) {
     final IndexCommit firstCommit =  commits.get(0);
     long last = SegmentInfos.generationFromSegmentsFileName(firstCommit.getSegmentsFileName());
     assertEquals(last, firstCommit.getGeneration());

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java Thu Jul 19 15:58:54 2012
@@ -39,7 +39,6 @@ import org.apache.lucene.index.IndexWrit
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.FieldCache;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.store.NoSuchDirectoryException;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
@@ -1003,7 +1002,7 @@ public void testFilesOpenClose() throws 
     dir.close();
   }
   
-  public void testTryIncRef() throws CorruptIndexException, LockObtainFailedException, IOException {
+  public void testTryIncRef() throws IOException {
     Directory dir = newDirectory();
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     writer.addDocument(new Document());
@@ -1017,7 +1016,7 @@ public void testFilesOpenClose() throws 
     dir.close();
   }
   
-  public void testStressTryIncRef() throws CorruptIndexException, LockObtainFailedException, IOException, InterruptedException {
+  public void testStressTryIncRef() throws IOException, InterruptedException {
     Directory dir = newDirectory();
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
     writer.addDocument(new Document());

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDoc.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDoc.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDoc.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDoc.java Thu Jul 19 15:58:54 2012
@@ -17,11 +17,14 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.io.Writer;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -78,14 +81,14 @@ public class TestDoc extends LuceneTestC
     }
 
     private File createOutput(String name, String text) throws IOException {
-        FileWriter fw = null;
+        Writer fw = null;
         PrintWriter pw = null;
 
         try {
             File f = new File(workDir, name);
             if (f.exists()) f.delete();
 
-            fw = new FileWriter(f);
+            fw = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
             pw = new PrintWriter(fw);
             pw.println(text);
             return f;
@@ -182,9 +185,11 @@ public class TestDoc extends LuceneTestC
    {
       File file = new File(workDir, fileName);
       Document doc = new Document();
-      doc.add(new TextField("contents", new FileReader(file), Field.Store.NO));
+      InputStreamReader is = new InputStreamReader(new FileInputStream(file), "UTF-8");
+      doc.add(new TextField("contents", is, Field.Store.NO));
       writer.addDocument(doc);
       writer.commit();
+      is.close();
       return writer.newestSegment();
    }
 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocValuesIndexing.java Thu Jul 19 15:58:54 2012
@@ -18,8 +18,17 @@ package org.apache.lucene.index;
  */
 import java.io.Closeable;
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.ByteDocValuesField;
@@ -39,9 +48,14 @@ import org.apache.lucene.document.TextFi
 import org.apache.lucene.index.DocValues.SortedSource;
 import org.apache.lucene.index.DocValues.Source;
 import org.apache.lucene.index.DocValues.Type;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefHash;
 import org.apache.lucene.util.FixedBitSet;
@@ -62,7 +76,7 @@ public class TestDocValuesIndexing exten
   /*
    * Simple test case to show how to use the API
    */
-  public void testDocValuesSimple() throws CorruptIndexException, IOException {
+  public void testDocValuesSimple() throws IOException {
     Directory dir = newDirectory();
     IndexWriter writer = new IndexWriter(dir, writerConfig(false));
     for (int i = 0; i < 5; i++) {
@@ -357,7 +371,7 @@ public class TestDocValuesIndexing exten
   }
   
   public void runTestIndexBytes(IndexWriterConfig cfg, boolean withDeletions)
-      throws CorruptIndexException, LockObtainFailedException, IOException {
+      throws IOException {
     final Directory d = newDirectory();
     IndexWriter w = new IndexWriter(d, cfg);
     final List<Type> byteVariantList = new ArrayList<Type>(BYTES);
@@ -443,7 +457,7 @@ public class TestDocValuesIndexing exten
     d.close();
   }
   
-  public void testGetArrayNumerics() throws CorruptIndexException, IOException {
+  public void testGetArrayNumerics() throws IOException {
     Directory d = newDirectory();
     IndexWriterConfig cfg = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(d, cfg);
@@ -525,7 +539,7 @@ public class TestDocValuesIndexing exten
     d.close();
   }
   
-  public void testGetArrayBytes() throws CorruptIndexException, IOException {
+  public void testGetArrayBytes() throws IOException {
     Directory d = newDirectory();
     IndexWriterConfig cfg = newIndexWriterConfig(TEST_VERSION_CURRENT,
         new MockAnalyzer(random()));
@@ -596,7 +610,7 @@ public class TestDocValuesIndexing exten
 
   private FixedBitSet indexValues(IndexWriter w, int numValues, Type valueType,
       List<Type> valueVarList, boolean withDeletions, int bytesSize)
-      throws CorruptIndexException, IOException {
+      throws IOException {
     final boolean isNumeric = NUMERICS.contains(valueType);
     FixedBitSet deleted = new FixedBitSet(numValues);
     Document doc = new Document();

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocValuesTypeCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocValuesTypeCompatibility.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocValuesTypeCompatibility.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocValuesTypeCompatibility.java Thu Jul 19 15:58:54 2012
@@ -33,7 +33,6 @@ import org.apache.lucene.document.Sorted
 import org.apache.lucene.document.StraightBytesDocValuesField;
 import org.apache.lucene.index.DocValues.Type;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
 
@@ -42,8 +41,7 @@ import org.apache.lucene.util.LuceneTest
  */
 public class TestDocValuesTypeCompatibility extends LuceneTestCase {
   
-  public void testAddCompatibleIntTypes() throws CorruptIndexException,
-      LockObtainFailedException, IOException {
+  public void testAddCompatibleIntTypes() throws IOException {
     int numIter = atLeast(10);
     for (int i = 0; i < numIter; i++) {
       Directory dir = newDirectory();
@@ -97,8 +95,7 @@ public class TestDocValuesTypeCompatibil
     }
   }
   
-  public void testAddCompatibleDoubleTypes() throws CorruptIndexException,
-      LockObtainFailedException, IOException {
+  public void testAddCompatibleDoubleTypes() throws IOException {
     int numIter = atLeast(10);
     for (int i = 0; i < numIter; i++) {
       Directory dir = newDirectory();
@@ -151,8 +148,7 @@ public class TestDocValuesTypeCompatibil
     }
   }
   
-  public void testAddCompatibleDoubleTypes2() throws CorruptIndexException,
-      LockObtainFailedException, IOException {
+  public void testAddCompatibleDoubleTypes2() throws IOException {
     int numIter = atLeast(10);
     for (int i = 0; i < numIter; i++) {
       Directory dir = newDirectory();
@@ -183,8 +179,7 @@ public class TestDocValuesTypeCompatibil
     
   }
   
-  public void testAddCompatibleByteTypes() throws CorruptIndexException,
-      LockObtainFailedException, IOException {
+  public void testAddCompatibleByteTypes() throws IOException {
     int numIter = atLeast(10);
     for (int i = 0; i < numIter; i++) {
       Directory dir = newDirectory();
@@ -262,7 +257,7 @@ public class TestDocValuesTypeCompatibil
   }
   
   private void addDoc(IndexWriter writer, IndexableField... fields)
-      throws CorruptIndexException, IOException {
+      throws IOException {
     Document doc = new Document();
     for (IndexableField indexableField : fields) {
       doc.add(indexableField);

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java Thu Jul 19 15:58:54 2012
@@ -171,8 +171,9 @@ public class TestDocsAndPositions extend
           }
 
           if (random().nextInt(10) == 0) { // once is a while advance
-            docsAndPosEnum
-                .advance(docID + 1 + random().nextInt((maxDoc - docID)));
+            if (docsAndPosEnum.advance(docID + 1 + random().nextInt((maxDoc - docID))) == DocIdSetIterator.NO_MORE_DOCS) {
+              break;
+            }
           }
 
         } while (docsAndPosEnum.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java Thu Jul 19 15:58:54 2012
@@ -226,7 +226,7 @@ public class TestDocumentWriter extends 
       private CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
       
       @Override
-      public boolean incrementToken() throws IOException {
+      public boolean incrementToken() {
         if (index == tokens.length) {
           return false;
         } else {

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java Thu Jul 19 15:58:54 2012
@@ -24,7 +24,6 @@ import java.util.concurrent.CountDownLat
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.apache.lucene.index.DocumentsWriterStallControl.MemoryController;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.ThreadInterruptedException;
 
@@ -38,11 +37,8 @@ public class TestDocumentsWriterStallCon
   
   public void testSimpleStall() throws InterruptedException {
     DocumentsWriterStallControl ctrl = new DocumentsWriterStallControl();
-    SimpleMemCtrl memCtrl = new SimpleMemCtrl();
-    memCtrl.limit = 1000;
-    memCtrl.netBytes = 1000;
-    memCtrl.flushBytes = 20;
-    ctrl.updateStalled(memCtrl);
+   
+    ctrl.updateStalled(false);
     Thread[] waitThreads = waitThreads(atLeast(1), ctrl);
     start(waitThreads);
     assertFalse(ctrl.hasBlocked());
@@ -50,43 +46,30 @@ public class TestDocumentsWriterStallCon
     join(waitThreads, 10);
     
     // now stall threads and wake them up again
-    memCtrl.netBytes = 1001;
-    memCtrl.flushBytes = 100;
-    ctrl.updateStalled(memCtrl);
+    ctrl.updateStalled(true);
     waitThreads = waitThreads(atLeast(1), ctrl);
     start(waitThreads);
     awaitState(100, Thread.State.WAITING, waitThreads);
     assertTrue(ctrl.hasBlocked());
     assertTrue(ctrl.anyStalledThreads());
-    memCtrl.netBytes = 50;
-    memCtrl.flushBytes = 0;
-    ctrl.updateStalled(memCtrl);
+    ctrl.updateStalled(false);
     assertFalse(ctrl.anyStalledThreads());
     join(waitThreads, 500);
   }
   
   public void testRandom() throws InterruptedException {
     final DocumentsWriterStallControl ctrl = new DocumentsWriterStallControl();
-    SimpleMemCtrl memCtrl = new SimpleMemCtrl();
-    memCtrl.limit = 1000;
-    memCtrl.netBytes = 1;
-    ctrl.updateStalled(memCtrl);
+    ctrl.updateStalled(false);
+    
     Thread[] stallThreads = new Thread[atLeast(3)];
     for (int i = 0; i < stallThreads.length; i++) {
-      final int threadId = i;
+      final int stallProbability = 1 +random().nextInt(10);
       stallThreads[i] = new Thread() {
         public void run() {
-          int baseBytes = threadId % 2 == 0 ? 500 : 700;
-          SimpleMemCtrl memCtrl = new SimpleMemCtrl();
-          memCtrl.limit = 1000;
-          memCtrl.netBytes = 1;
-          memCtrl.flushBytes = 0;
 
           int iters = atLeast(1000);
           for (int j = 0; j < iters; j++) {
-            memCtrl.netBytes = baseBytes + random().nextInt(1000);
-            memCtrl.flushBytes = random().nextInt((int)memCtrl.netBytes);
-            ctrl.updateStalled(memCtrl);
+            ctrl.updateStalled(random().nextInt(stallProbability) == 0);
             if (random().nextInt(5) == 0) { // thread 0 only updates
               ctrl.waitIfStalled();
             }
@@ -102,7 +85,7 @@ public class TestDocumentsWriterStallCon
      */
     while ((System.currentTimeMillis() - time) < 100 * 1000
         && !terminated(stallThreads)) {
-      ctrl.updateStalled(memCtrl);
+      ctrl.updateStalled(false);
       if (random().nextBoolean()) {
         Thread.yield();
       } else {
@@ -116,11 +99,7 @@ public class TestDocumentsWriterStallCon
   
   public void testAccquireReleaseRace() throws InterruptedException {
     final DocumentsWriterStallControl ctrl = new DocumentsWriterStallControl();
-    SimpleMemCtrl memCtrl = new SimpleMemCtrl();
-    memCtrl.limit = 1000;
-    memCtrl.netBytes = 1;
-    memCtrl.flushBytes = 0;
-    ctrl.updateStalled(memCtrl);
+    ctrl.updateStalled(false);
     final AtomicBoolean stop = new AtomicBoolean(false);
     final AtomicBoolean checkPoint = new AtomicBoolean(true);
     
@@ -191,10 +170,7 @@ public class TestDocumentsWriterStallCon
     
     
     for (int i = 0; i < threads.length; i++) {
-      memCtrl.limit = 1000;
-      memCtrl.netBytes = 1;
-      memCtrl.flushBytes = 0;
-      ctrl.updateStalled(memCtrl);
+      ctrl.updateStalled(false);
       threads[i].join(2000);
       if (threads[i].isAlive() && threads[i] instanceof Waiter) {
         if (threads[i].getState() == Thread.State.WAITING) {
@@ -290,14 +266,11 @@ public class TestDocumentsWriterStallCon
     
     public void run() {
       try {
-        SimpleMemCtrl memCtrl = new SimpleMemCtrl();
-        memCtrl.limit = 1000;
-        memCtrl.netBytes = release ? 1 : 2000;
-        memCtrl.flushBytes = random().nextInt((int)memCtrl.netBytes);
+       
         while (!stop.get()) {
           int internalIters = release && random().nextBoolean() ? atLeast(5) : 1;
           for (int i = 0; i < internalIters; i++) {
-            ctrl.updateStalled(memCtrl);
+            ctrl.updateStalled(random().nextBoolean());
           }
           if (checkPoint.get()) {
             sync.updateJoin.countDown();
@@ -379,28 +352,6 @@ public class TestDocumentsWriterStallCon
         + " ms");
   }
   
-  private static class SimpleMemCtrl implements MemoryController {
-    long netBytes;
-    long limit;
-    long flushBytes;
-    
-    @Override
-    public long netBytes() {
-      return netBytes;
-    }
-    
-    @Override
-    public long stallLimitBytes() {
-      return limit;
-    }
-
-    @Override
-    public long flushBytes() {
-      return flushBytes;
-    }
-    
-  }
-  
   private static final class Synchronizer {
     volatile CountDownLatch waiter;
     volatile CountDownLatch updateJoin;

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java Thu Jul 19 15:58:54 2012
@@ -115,7 +115,7 @@ public class TestFieldsReader extends Lu
 
     Directory fsDir;
     
-    public FaultyFSDirectory(File dir) throws IOException {
+    public FaultyFSDirectory(File dir) {
       fsDir = newFSDirectory(dir);
       lockFactory = fsDir.getLockFactory();
     }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFilterAtomicReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFilterAtomicReader.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFilterAtomicReader.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFilterAtomicReader.java Thu Jul 19 15:58:54 2012
@@ -175,7 +175,7 @@ public class TestFilterAtomicReader exte
     target.close();
   }
   
-  private void checkOverrideMethods(Class<?> clazz) throws Exception {
+  private void checkOverrideMethods(Class<?> clazz) {
     boolean fail = false;
     for (Method m : clazz.getMethods()) {
       int mods = m.getModifiers();

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java Thu Jul 19 15:58:54 2012
@@ -26,7 +26,6 @@ import org.apache.lucene.analysis.MockAn
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.DocumentsWriterPerThreadPool.ThreadState;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.LuceneTestCase;
@@ -48,22 +47,19 @@ public class TestFlushByRamOrCountsPolic
     lineDocFile = null;
   }
 
-  public void testFlushByRam() throws CorruptIndexException,
-      LockObtainFailedException, IOException, InterruptedException {
+  public void testFlushByRam() throws IOException, InterruptedException {
     final double ramBuffer = (TEST_NIGHTLY ? 1 : 10) + atLeast(2)
         + random().nextDouble();
     runFlushByRam(1 + random().nextInt(TEST_NIGHTLY ? 5 : 1), ramBuffer, false);
   }
   
-  public void testFlushByRamLargeBuffer() throws CorruptIndexException,
-      LockObtainFailedException, IOException, InterruptedException {
+  public void testFlushByRamLargeBuffer() throws IOException, InterruptedException {
     // with a 256 mb ram buffer we should never stall
     runFlushByRam(1 + random().nextInt(TEST_NIGHTLY ? 5 : 1), 256.d, true);
   }
 
   protected void runFlushByRam(int numThreads, double maxRamMB,
-      boolean ensureNotStalled) throws IOException, CorruptIndexException,
-      LockObtainFailedException, InterruptedException {
+      boolean ensureNotStalled) throws IOException, InterruptedException {
     final int numDocumentsToIndex = 10 + atLeast(30);
     AtomicInteger numDocs = new AtomicInteger(numDocumentsToIndex);
     Directory dir = newDirectory();
@@ -109,15 +105,14 @@ public class TestFlushByRamOrCountsPolic
       assertTrue(maxRAMBytes < flushControl.peakActiveBytes);
     }
     if (ensureNotStalled) {
-      assertFalse(docsWriter.flushControl.stallControl.wasStalled);
+      assertFalse(docsWriter.flushControl.stallControl.wasStalled());
     }
     writer.close();
     assertEquals(0, flushControl.activeBytes());
     dir.close();
   }
 
-  public void testFlushDocCount() throws CorruptIndexException,
-      LockObtainFailedException, IOException, InterruptedException {
+  public void testFlushDocCount() throws IOException, InterruptedException {
     int[] numThreads = new int[] { 2 + atLeast(1), 1 };
     for (int i = 0; i < numThreads.length; i++) {
 
@@ -222,7 +217,7 @@ public class TestFlushByRamOrCountsPolic
     assertEquals(numDocumentsToIndex, r.numDocs());
     assertEquals(numDocumentsToIndex, r.maxDoc());
     if (!flushPolicy.flushOnRAM()) {
-      assertFalse("never stall if we don't flush on RAM", docsWriter.flushControl.stallControl.wasStalled);
+      assertFalse("never stall if we don't flush on RAM", docsWriter.flushControl.stallControl.wasStalled());
       assertFalse("never block if we don't flush on RAM", docsWriter.flushControl.stallControl.hasBlocked());
     }
     r.close();
@@ -230,8 +225,7 @@ public class TestFlushByRamOrCountsPolic
     dir.close();
   }
 
-  public void testStallControl() throws InterruptedException,
-      CorruptIndexException, LockObtainFailedException, IOException {
+  public void testStallControl() throws InterruptedException, IOException {
 
     int[] numThreads = new int[] { 4 + random().nextInt(8), 1 };
     final int numDocumentsToIndex = 50 + random().nextInt(50);
@@ -275,7 +269,7 @@ public class TestFlushByRamOrCountsPolic
             docsWriter.flushControl.stallControl.hasBlocked());
       }
       if (docsWriter.flushControl.peakNetBytes > (2.d * iwc.getRAMBufferSizeMB() * 1024.d * 1024.d)) {
-        assertTrue(docsWriter.flushControl.stallControl.wasStalled);
+        assertTrue(docsWriter.flushControl.stallControl.wasStalled());
       }
       assertActiveBytesAfter(flushControl);
       writer.close(true);

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestForceMergeForever.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestForceMergeForever.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestForceMergeForever.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestForceMergeForever.java Thu Jul 19 15:58:54 2012
@@ -40,7 +40,7 @@ public class TestForceMergeForever exten
     }
 
     @Override
-    public void merge(MergePolicy.OneMerge merge) throws CorruptIndexException, IOException {
+    public void merge(MergePolicy.OneMerge merge) throws IOException {
       if (merge.maxNumSegments != -1 && (first || merge.segments.size() == 1)) {
         first = false;
         if (VERBOSE) {

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexCommit.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexCommit.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexCommit.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexCommit.java Thu Jul 19 15:58:54 2012
@@ -17,7 +17,6 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import java.io.IOException;
 import java.util.Collection;
 import java.util.Map;
 
@@ -35,10 +34,10 @@ public class TestIndexCommit extends Luc
     IndexCommit ic1 = new IndexCommit() {
       @Override public String getSegmentsFileName() { return "a"; }
       @Override public Directory getDirectory() { return dir; }
-      @Override public Collection<String> getFileNames() throws IOException { return null; }
+      @Override public Collection<String> getFileNames() { return null; }
       @Override public void delete() {}
       @Override public long getGeneration() { return 0; }
-      @Override public Map<String, String> getUserData() throws IOException { return null; }
+      @Override public Map<String, String> getUserData() { return null; }
       @Override public boolean isDeleted() { return false; }
       @Override public int getSegmentCount() { return 2; }
     };
@@ -46,10 +45,10 @@ public class TestIndexCommit extends Luc
     IndexCommit ic2 = new IndexCommit() {
       @Override public String getSegmentsFileName() { return "b"; }
       @Override public Directory getDirectory() { return dir; }
-      @Override public Collection<String> getFileNames() throws IOException { return null; }
+      @Override public Collection<String> getFileNames() { return null; }
       @Override public void delete() {}
       @Override public long getGeneration() { return 0; }
-      @Override public Map<String, String> getUserData() throws IOException { return null; }
+      @Override public Map<String, String> getUserData() { return null; }
       @Override public boolean isDeleted() { return false; }
       @Override public int getSegmentCount() { return 2; }
     };

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java Thu Jul 19 15:58:54 2012
@@ -820,7 +820,7 @@ public class TestIndexWriter extends Luc
     }
 
     @Override
-    protected void doBeforeFlush() throws IOException {
+    protected void doBeforeFlush() {
       beforeWasCalled = true;
     }
   }
@@ -1520,14 +1520,14 @@ public class TestIndexWriter extends Luc
     public StringSplitTokenizer(Reader r) {
       super(r);
       try {
-        reset(r);
+        setReader(r);
       } catch (IOException e) {
         throw new RuntimeException(e);
       }
     }
 
     @Override
-    public final boolean incrementToken() throws IOException {
+    public final boolean incrementToken() {
       clearAttributes();      
       if (upto < tokens.length) {
         termAtt.setEmpty();
@@ -1540,7 +1540,7 @@ public class TestIndexWriter extends Luc
     }
 
     @Override
-    public void reset(Reader input) throws IOException {
+    public void setReader(Reader input) throws IOException {
        this.upto = 0;
        final StringBuilder b = new StringBuilder();
        final char[] buffer = new char[1024];

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java Thu Jul 19 15:58:54 2012
@@ -25,6 +25,8 @@ import java.util.Set;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.codecs.Codec;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field.Store;
 import org.apache.lucene.index.DocumentsWriterPerThread.IndexingChain;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.search.IndexSearcher;
@@ -326,4 +328,30 @@ public class TestIndexWriterConfig exten
     assertEquals(LogByteSizeMergePolicy.class, conf.getMergePolicy().getClass());
   }
 
+  public void testLiveChangeToCFS() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
+    iwc.setMergePolicy(newLogMergePolicy());
+
+    // Start false:
+    ((LogMergePolicy) iwc.getMergePolicy()).setUseCompoundFile(false); 
+    IndexWriter w = new IndexWriter(dir, iwc);
+
+    // Change to true:
+    ((LogMergePolicy) w.getConfig().getMergePolicy()).setNoCFSRatio(1.0);
+    ((LogMergePolicy) w.getConfig().getMergePolicy()).setUseCompoundFile(true);
+
+    Document doc = new Document();
+    doc.add(newStringField("field", "foo", Store.NO));
+    w.addDocument(doc);
+    w.commit();
+
+    for(String file : dir.listAll()) {
+      // frq file should be stuck into CFS
+      assertFalse(file.endsWith(".frq"));
+    }
+    w.close();
+    dir.close();
+  }
+
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Thu Jul 19 15:58:54 2012
@@ -983,7 +983,7 @@ public class TestIndexWriterExceptions e
         }
         
         @Override
-        public void close() throws IOException {}
+        public void close() {}
       }));
 
     try {

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java Thu Jul 19 15:58:54 2012
@@ -227,7 +227,7 @@ public class TestIndexWriterMergePolicy 
     writer.addDocument(doc);
   }
 
-  private void checkInvariants(IndexWriter writer) throws IOException {
+  private void checkInvariants(IndexWriter writer) {
     writer.waitForMerges();
     int maxBufferedDocs = writer.getConfig().getMaxBufferedDocs();
     int mergeFactor = ((LogMergePolicy) writer.getConfig().getMergePolicy()).getMergeFactor();

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java Thu Jul 19 15:58:54 2012
@@ -312,7 +312,7 @@ public class TestIndexWriterMerging exte
   private class MyMergeScheduler extends MergeScheduler {
     @Override
     synchronized public void merge(IndexWriter writer)
-      throws CorruptIndexException, IOException {
+      throws IOException {
 
       while(true) {
         MergePolicy.OneMerge merge = writer.getNextMerge();

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterNRTIsCurrent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterNRTIsCurrent.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterNRTIsCurrent.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterNRTIsCurrent.java Thu Jul 19 15:58:54 2012
@@ -25,7 +25,6 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
 
@@ -36,8 +35,8 @@ public class TestIndexWriterNRTIsCurrent
     volatile boolean stop = false;
   }
 
-  public void testIsCurrentWithThreads() throws CorruptIndexException,
-      LockObtainFailedException, IOException, InterruptedException {
+  public void testIsCurrentWithThreads() throws
+      IOException, InterruptedException {
     Directory dir = newDirectory();
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT,
         new MockAnalyzer(random()));

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java Thu Jul 19 15:58:54 2012
@@ -411,6 +411,7 @@ public class TestIndexWriterReader exten
       this.mainWriter = mainWriter;
       addDir = newDirectory();
       IndexWriter writer = new IndexWriter(addDir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMaxBufferedDocs(2));
+      _TestUtil.reduceOpenFiles(writer);
       for (int i = 0; i < NUM_INIT_DOCS; i++) {
         Document doc = DocHelper.createDocument(i, "addindex", 4);
         writer.addDocument(doc);

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java Thu Jul 19 15:58:54 2012
@@ -19,6 +19,10 @@ package org.apache.lucene.index;
 
 import java.io.IOException;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
@@ -31,13 +35,16 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.ThreadInterruptedException;
 import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.LuceneTestCase.Slow;
 
 /**
  * MultiThreaded IndexWriter tests
  */
+@Slow
 public class TestIndexWriterWithThreads extends LuceneTestCase {
 
   // Used by test cases below
@@ -456,41 +463,132 @@ public class TestIndexWriterWithThreads 
      dir.close();
   }
   
-   static class DelayedIndexAndCloseRunnable extends Thread {
-     private final Directory dir;
-     boolean failed = false;
-     Throwable failure = null;
-     private final CountDownLatch startIndexing = new CountDownLatch(1);
-     private CountDownLatch iwConstructed;
-
-     public DelayedIndexAndCloseRunnable(Directory dir,
-         CountDownLatch iwConstructed) {
-       this.dir = dir;
-       this.iwConstructed = iwConstructed;
-     }
-
-     public void startIndexing() {
-       this.startIndexing.countDown();
-     }
-
-     @Override
-     public void run() {
-       try {
-         Document doc = new Document();
-         Field field = newTextField("field", "testData", Field.Store.YES);
-         doc.add(field);
-         IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
-             TEST_VERSION_CURRENT, new MockAnalyzer(random())));
-         iwConstructed.countDown();
-         startIndexing.await();
-         writer.addDocument(doc);
-         writer.close();
-       } catch (Throwable e) {
-         failed = true;
-         failure = e;
-         failure.printStackTrace(System.out);
-         return;
-       }
-     }
-   }
+  static class DelayedIndexAndCloseRunnable extends Thread {
+    private final Directory dir;
+    boolean failed = false;
+    Throwable failure = null;
+    private final CountDownLatch startIndexing = new CountDownLatch(1);
+    private CountDownLatch iwConstructed;
+
+    public DelayedIndexAndCloseRunnable(Directory dir,
+                                        CountDownLatch iwConstructed) {
+      this.dir = dir;
+      this.iwConstructed = iwConstructed;
+    }
+
+    public void startIndexing() {
+      this.startIndexing.countDown();
+    }
+
+    @Override
+    public void run() {
+      try {
+        Document doc = new Document();
+        Field field = newTextField("field", "testData", Field.Store.YES);
+        doc.add(field);
+        IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
+                                                                       TEST_VERSION_CURRENT, new MockAnalyzer(random())));
+        iwConstructed.countDown();
+        startIndexing.await();
+        writer.addDocument(doc);
+        writer.close();
+      } catch (Throwable e) {
+        failed = true;
+        failure = e;
+        failure.printStackTrace(System.out);
+        return;
+      }
+    }
+  }
+
+  // LUCENE-4147
+  public void testRollbackAndCommitWithThreads() throws Exception {
+    final MockDirectoryWrapper d = newFSDirectory(_TestUtil.getTempDir("RollbackAndCommitWithThreads"));
+    d.setPreventDoubleWrite(false);
+
+    final int threadCount = _TestUtil.nextInt(random(), 2, 6);
+
+    final AtomicReference<IndexWriter> writerRef = new AtomicReference<IndexWriter>();
+    writerRef.set(new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))));
+    final LineFileDocs docs = new LineFileDocs(random());
+    final Thread[] threads = new Thread[threadCount];
+    final int iters = atLeast(1000);
+    final AtomicBoolean failed = new AtomicBoolean();
+    final Lock rollbackLock = new ReentrantLock();
+    final Lock commitLock = new ReentrantLock();
+    for(int threadID=0;threadID<threadCount;threadID++) {
+      threads[threadID] = new Thread() {
+          @Override
+          public void run() {
+            for(int iter=0;iter<iters && !failed.get();iter++) {
+              //final int x = random().nextInt(5);
+              final int x = random().nextInt(3);
+              try {
+                switch(x) {
+                case 0:
+                  rollbackLock.lock();
+                  if (VERBOSE) {
+                    System.out.println("\nTEST: " + Thread.currentThread().getName() + ": now rollback");
+                  }
+                  try {
+                    writerRef.get().rollback();
+                    if (VERBOSE) {
+                      System.out.println("TEST: " + Thread.currentThread().getName() + ": rollback done; now open new writer");
+                    }
+                    writerRef.set(new IndexWriter(d, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))));
+                  } finally {
+                    rollbackLock.unlock();
+                  }
+                  break;
+                case 1:
+                  commitLock.lock();
+                  if (VERBOSE) {
+                    System.out.println("\nTEST: " + Thread.currentThread().getName() + ": now commit");
+                  }
+                  try {
+                    if (random().nextBoolean()) {
+                      writerRef.get().prepareCommit();
+                    }
+                    writerRef.get().commit();
+                  } catch (AlreadyClosedException ace) {
+                    // ok
+                  } catch (NullPointerException npe) {
+                    // ok
+                  } finally {
+                    commitLock.unlock();
+                  }
+                  break;
+                case 2:
+                  if (VERBOSE) {
+                    System.out.println("\nTEST: " + Thread.currentThread().getName() + ": now add");
+                  }
+                  try {
+                    writerRef.get().addDocument(docs.nextDoc());
+                  } catch (AlreadyClosedException ace) {
+                    // ok
+                  } catch (NullPointerException npe) {
+                    // ok
+                  } catch (AssertionError ae) {
+                    // ok
+                  }
+                  break;
+                }
+              } catch (Throwable t) {
+                failed.set(true);
+                throw new RuntimeException(t);
+              }
+            }
+          }
+        };
+      threads[threadID].start();
+    }
+
+    for(int threadID=0;threadID<threadCount;threadID++) {
+      threads[threadID].join();
+    }
+
+    assertTrue(!failed.get());
+    writerRef.get().close();
+    d.close();
+  }
 }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestNorms.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestNorms.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestNorms.java Thu Jul 19 15:58:54 2012
@@ -31,6 +31,7 @@ import org.apache.lucene.search.similari
 import org.apache.lucene.search.similarities.Similarity;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LineFileDocs;
+import org.apache.lucene.util.LuceneTestCase.Slow;
 import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util._TestUtil;
@@ -40,6 +41,7 @@ import org.apache.lucene.util._TestUtil;
  * separate norms, addDocument, addIndexes, forceMerge.
  */
 @SuppressCodecs({ "SimpleText", "Memory" })
+@Slow
 public class TestNorms extends LuceneTestCase {
   final String byteTestField = "normsTestByte";
 
@@ -175,8 +177,7 @@ public class TestNorms extends LuceneTes
     otherDir.close();
   }
 
-  public void buildIndex(Directory dir, boolean writeNorms) throws IOException,
-      CorruptIndexException {
+  public void buildIndex(Directory dir, boolean writeNorms) throws IOException {
     Random random = random();
     IndexWriterConfig config = newIndexWriterConfig(TEST_VERSION_CURRENT,
         new MockAnalyzer(random()));

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java Thu Jul 19 15:58:54 2012
@@ -50,7 +50,7 @@ public class TestPayloadProcessorProvide
     }
 
     @Override
-    public ReaderPayloadProcessor getReaderProcessor(AtomicReader reader) throws IOException {
+    public ReaderPayloadProcessor getReaderProcessor(AtomicReader reader) {
       if (reader instanceof SegmentReader) {
         return processors.get(((SegmentReader) reader).directory());
       } else {
@@ -63,7 +63,7 @@ public class TestPayloadProcessorProvide
   private static final class PerTermPayloadProcessor extends ReaderPayloadProcessor {
 
     @Override
-    public PayloadProcessor getProcessor(String field, BytesRef text) throws IOException {
+    public PayloadProcessor getProcessor(String field, BytesRef text) {
       // don't process payloads of terms other than "p:p1"
       if (!field.equals("p") || !text.bytesEquals(new BytesRef("p1"))) {
         return null;
@@ -79,7 +79,7 @@ public class TestPayloadProcessorProvide
   private static final class DeletePayloadProcessor extends PayloadProcessor {
 
     @Override
-    public void processPayload(BytesRef payload) throws IOException {
+    public void processPayload(BytesRef payload) {
       payload.length = 0;      
     }
 
@@ -98,7 +98,7 @@ public class TestPayloadProcessorProvide
     }
 
     @Override
-    public boolean incrementToken() throws IOException {
+    public boolean incrementToken() {
       if (called) {
         return false;
       }

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java Thu Jul 19 15:58:54 2012
@@ -43,9 +43,8 @@ public class TestPayloads extends Lucene
     
     // Simple tests to test the Payload class
     public void testPayload() throws Exception {
-        byte[] testData = "This is a test!".getBytes();
-        BytesRef payload = new BytesRef(testData);
-        assertEquals("Wrong payload length.", testData.length, payload.length);
+        BytesRef payload = new BytesRef("This is a test!");
+        assertEquals("Wrong payload length.", "This is a test!".length(), payload.length);
         
         BytesRef clone = payload.clone();
         assertEquals(payload.length, clone.length);
@@ -73,7 +72,7 @@ public class TestPayloads extends Lucene
         // enabled in only some documents
         d.add(newTextField("f3", "This field has payloads in some docs", Field.Store.NO));
         // only add payload data for field f2
-        analyzer.setPayloadData("f2", "somedata".getBytes(), 0, 1);
+        analyzer.setPayloadData("f2", "somedata".getBytes("UTF-8"), 0, 1);
         writer.addDocument(d);
         // flush
         writer.close();
@@ -96,8 +95,8 @@ public class TestPayloads extends Lucene
         d.add(newTextField("f2", "This field has payloads in all docs", Field.Store.NO));
         d.add(newTextField("f3", "This field has payloads in some docs", Field.Store.NO));
         // add payload data for field f2 and f3
-        analyzer.setPayloadData("f2", "somedata".getBytes(), 0, 1);
-        analyzer.setPayloadData("f3", "somedata".getBytes(), 0, 3);
+        analyzer.setPayloadData("f2", "somedata".getBytes("UTF-8"), 0, 1);
+        analyzer.setPayloadData("f3", "somedata".getBytes("UTF-8"), 0, 3);
         writer.addDocument(d);
 
         // force merge

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java Thu Jul 19 15:58:54 2012
@@ -258,7 +258,7 @@ public class TestPerSegmentDeletes exten
 
     @Override
     public MergeSpecification findMerges(SegmentInfos segmentInfos)
-        throws CorruptIndexException, IOException {
+        throws IOException {
       MergeSpecification ms = new MergeSpecification();
       if (doMerge) {
         OneMerge om = new OneMerge(segmentInfos.asList().subList(start, start + length));
@@ -272,13 +272,13 @@ public class TestPerSegmentDeletes exten
     @Override
     public MergeSpecification findForcedMerges(SegmentInfos segmentInfos,
         int maxSegmentCount, Map<SegmentInfoPerCommit,Boolean> segmentsToMerge)
-        throws CorruptIndexException, IOException {
+        throws IOException {
       return null;
     }
 
     @Override
     public MergeSpecification findForcedDeletesMerges(
-        SegmentInfos segmentInfos) throws CorruptIndexException, IOException {
+        SegmentInfos segmentInfos) throws IOException {
       return null;
     }
 

Modified: lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java Thu Jul 19 15:58:54 2012
@@ -330,17 +330,17 @@ public class TestPostingsOffsets extends
           docsAndPositionsAndOffsets = termsEnum.docsAndPositions(null, docsAndPositions, true);
           assertNotNull(docsAndPositionsAndOffsets);
           //System.out.println("    doc/freq/pos/offs");
-          while((doc = docsAndPositions.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
+          while((doc = docsAndPositionsAndOffsets.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
             final List<Token> expected = actualTokens.get(term).get(docIDToID[doc]);
             //System.out.println("      doc=" + docIDToID[doc] + " " + expected.size() + " freq");
             assertNotNull(expected);
-            assertEquals(expected.size(), docsAndPositions.freq());
+            assertEquals(expected.size(), docsAndPositionsAndOffsets.freq());
             for(Token token : expected) {
               int pos = Integer.parseInt(token.type());
               //System.out.println("        pos=" + pos);
-              assertEquals(pos, docsAndPositions.nextPosition());
-              assertEquals(token.startOffset(), docsAndPositions.startOffset());
-              assertEquals(token.endOffset(), docsAndPositions.endOffset());
+              assertEquals(pos, docsAndPositionsAndOffsets.nextPosition());
+              assertEquals(token.startOffset(), docsAndPositionsAndOffsets.startOffset());
+              assertEquals(token.endOffset(), docsAndPositionsAndOffsets.endOffset());
             }
           }
         }



Mime
View raw message