lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r925462 [2/2] - in /lucene/java/trunk: ./ backwards/src/java/org/apache/lucene/index/ backwards/src/test/org/apache/lucene/index/ contrib/ant/src/java/org/apache/lucene/ant/ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/task...
Date Fri, 19 Mar 2010 22:25:58 GMT
Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java Fri Mar 19 22:25:56 2010
@@ -41,13 +41,15 @@ public class TestIndexFileDeleter extend
 
     Directory dir = new RAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(10));
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+        .setMaxBufferedDocs(10));
     int i;
     for(i=0;i<35;i++) {
       addDoc(writer, i);
     }
-    ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundFile(false);
-    ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundDocStore(false);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
     for(;i<45;i++) {
       addDoc(writer, i);
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java Fri Mar 19 22:25:56 2010
@@ -175,7 +175,7 @@ public class TestIndexReader extends Luc
         writer = new IndexWriter(d, new IndexWriterConfig(TEST_VERSION_CURRENT,
             new StandardAnalyzer(TEST_VERSION_CURRENT)).setOpenMode(OpenMode.APPEND));
         // want to get some more segments here
-        int mergeFactor = ((LogMergePolicy) writer.getMergePolicy()).getMergeFactor();
+        int mergeFactor = ((LogMergePolicy) writer.getConfig().getMergePolicy()).getMergeFactor();
         for (int i = 0; i < 5*mergeFactor; i++) {
             addDocumentWithFields(writer);
         }
@@ -255,7 +255,7 @@ public class TestIndexReader extends Luc
         TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT)));
     // want to get some more segments here
     // new termvector fields
-    int mergeFactor = ((LogMergePolicy) writer.getMergePolicy()).getMergeFactor();
+    int mergeFactor = ((LogMergePolicy) writer.getConfig().getMergePolicy()).getMergeFactor();
     for (int i = 0; i < 5 * mergeFactor; i++) {
       Document doc = new Document();
         doc.add(new Field("tvnot","one two two three three three", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO));
@@ -559,8 +559,8 @@ public class TestIndexReader extends Luc
 
         //  add 1 documents with term : aaa
         writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)));
-        ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundFile(false);
-        ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundDocStore(false);
+        ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
+        ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
         addDoc(writer, searchTerm.text());
         writer.close();
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderClone.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderClone.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderClone.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderClone.java Fri Mar 19 22:25:56 2010
@@ -487,8 +487,8 @@ public class TestIndexReaderClone extend
     final Directory dir = new MockRAMDirectory();
     IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(
         TEST_VERSION_CURRENT, new SimpleAnalyzer(TEST_VERSION_CURRENT)));
-    ((LogMergePolicy) w.getMergePolicy()).setUseCompoundFile(false);
-    ((LogMergePolicy) w.getMergePolicy()).setUseCompoundDocStore(false);
+    ((LogMergePolicy) w.getConfig().getMergePolicy()).setUseCompoundFile(false);
+    ((LogMergePolicy) w.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
     Document doc = new Document();
     doc.add(new Field("field", "yes it's stored", Field.Store.YES, Field.Index.ANALYZED));
     w.addDocument(doc);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java Fri Mar 19 22:25:56 2010
@@ -116,7 +116,7 @@ public class TestIndexReaderCloneNorms e
     IndexWriter iw = new IndexWriter(dir3, new IndexWriterConfig(
         TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.APPEND)
         .setMaxBufferedDocs(5));
-    ((LogMergePolicy) iw.getMergePolicy()).setMergeFactor(3);
+    ((LogMergePolicy) iw.getConfig().getMergePolicy()).setMergeFactor(3);
     iw.addIndexesNoOptimize(new Directory[] { dir1, dir2 });
     iw.optimize();
     iw.close();
@@ -134,7 +134,7 @@ public class TestIndexReaderCloneNorms e
     // now with optimize
     iw = new IndexWriter(dir3, new IndexWriterConfig(TEST_VERSION_CURRENT,
         anlzr).setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(5));
-    ((LogMergePolicy) iw.getMergePolicy()).setMergeFactor(3);
+    ((LogMergePolicy) iw.getConfig().getMergePolicy()).setMergeFactor(3);
     iw.optimize();
     iw.close();
     verifyIndex(dir3);
@@ -236,7 +236,7 @@ public class TestIndexReaderCloneNorms e
     IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(
         TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.CREATE)
         .setMaxBufferedDocs(5).setSimilarity(similarityOne));
-    LogMergePolicy lmp = (LogMergePolicy) iw.getMergePolicy();
+    LogMergePolicy lmp = (LogMergePolicy) iw.getConfig().getMergePolicy();
     lmp.setMergeFactor(3);
     lmp.setUseCompoundFile(true);
     lmp.setUseCompoundDocStore(true);
@@ -286,13 +286,14 @@ public class TestIndexReaderCloneNorms e
 
   private void addDocs(Directory dir, int ndocs, boolean compound)
       throws IOException {
-    IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(
-        TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.APPEND)
-        .setMaxBufferedDocs(5).setSimilarity(similarityOne));
-    LogMergePolicy lmp = (LogMergePolicy) iw.getMergePolicy();
+    IndexWriterConfig conf = new IndexWriterConfig(
+            TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.APPEND)
+            .setMaxBufferedDocs(5).setSimilarity(similarityOne);
+    LogMergePolicy lmp = (LogMergePolicy) conf.getMergePolicy();
     lmp.setMergeFactor(3);
     lmp.setUseCompoundFile(compound);
     lmp.setUseCompoundDocStore(compound);
+    IndexWriter iw = new IndexWriter(dir, conf);
     for (int i = 0; i < ndocs; i++) {
       iw.addDocument(newDoc());
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java Fri Mar 19 22:25:56 2010
@@ -949,9 +949,9 @@ public class TestIndexReaderReopen exten
   
   public static void createIndex(Directory dir, boolean multiSegment) throws IOException {
     IndexWriter.unlock(dir);
-    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)));
-
-    w.setMergePolicy(new LogDocMergePolicy(w));
+    IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+        .setMergePolicy(new LogDocMergePolicy()));
     
     for (int i = 0; i < 100; i++) {
       w.addDocument(createDocument(i, 4));

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java Fri Mar 19 22:25:56 2010
@@ -606,13 +606,13 @@ public class TestIndexWriter extends Luc
       doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED));
 
       for(int numDocs=38;numDocs<500;numDocs += 38) {
-        IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
-          TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setOpenMode(OpenMode.CREATE)
-          .setMaxBufferedDocs(2));
-        LogDocMergePolicy ldmp = new LogDocMergePolicy(writer);
+        LogDocMergePolicy ldmp = new LogDocMergePolicy();
         ldmp.setMinMergeDocs(1);
         ldmp.setMergeFactor(5);
-        writer.setMergePolicy(ldmp);
+        IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+          TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+          .setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(2).setMergePolicy(
+              ldmp));
         for(int j=0;j<numDocs;j++)
           writer.addDocument(doc);
         writer.close();
@@ -621,9 +621,10 @@ public class TestIndexWriter extends Luc
         sis.read(dir);
         final int segCount = sis.size();
 
-        writer  = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)));
+        ldmp = new LogDocMergePolicy();
         ldmp.setMergeFactor(5);
-        writer.setMergePolicy(ldmp);
+        writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
+          new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMergePolicy(ldmp));
         writer.optimize(3);
         writer.close();
 
@@ -644,12 +645,12 @@ public class TestIndexWriter extends Luc
       final Document doc = new Document();
       doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED));
 
-      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
-        TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2));
-      LogDocMergePolicy ldmp = new LogDocMergePolicy(writer);
+      LogDocMergePolicy ldmp = new LogDocMergePolicy();
       ldmp.setMinMergeDocs(1);
       ldmp.setMergeFactor(4);
-      writer.setMergePolicy(ldmp);
+      IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+        .setMaxBufferedDocs(2).setMergePolicy(ldmp));
 
       for(int iter=0;iter<10;iter++) {
         for(int i=0;i<19;i++)
@@ -1526,9 +1527,9 @@ public class TestIndexWriter extends Luc
       Directory dir = new MockRAMDirectory();
       for(int pass=0;pass<2;pass++) {
         IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
-          TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setOpenMode(OpenMode.CREATE)
-          .setMaxBufferedDocs(2));
-        ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(101);
+          TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+          .setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(2));
+        ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(101);
         Document doc = new Document();
         doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
         for(int i=0;i<200;i++)
@@ -1652,10 +1653,11 @@ public class TestIndexWriter extends Luc
     int pri = Thread.currentThread().getPriority();
     try {
       MockRAMDirectory dir = new MockRAMDirectory();
-      IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(
+      IndexWriterConfig conf = new IndexWriterConfig(
           TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT))
-          .setMaxBufferedDocs(2));
-      ((LogMergePolicy) iw.getMergePolicy()).setMergeFactor(2);
+          .setMaxBufferedDocs(2);
+      ((LogMergePolicy) conf.getMergePolicy()).setMergeFactor(2);
+      IndexWriter iw = new IndexWriter(dir, conf);
       Document document = new Document();
       document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED,
                              Field.TermVector.YES));
@@ -1693,12 +1695,13 @@ public class TestIndexWriter extends Luc
   // LUCENE-1013
   public void testSetMaxMergeDocs() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(
+    IndexWriterConfig conf = new IndexWriterConfig(
         TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT))
-        .setMergeScheduler(new MyMergeScheduler()).setMaxBufferedDocs(2));
-    LogMergePolicy lmp = (LogMergePolicy) iw.getMergePolicy();
+        .setMergeScheduler(new MyMergeScheduler()).setMaxBufferedDocs(2);
+    LogMergePolicy lmp = (LogMergePolicy) conf.getMergePolicy();
     lmp.setMaxMergeDocs(20);
     lmp.setMergeFactor(2);
+    IndexWriter iw = new IndexWriter(dir, conf);
     Document document = new Document();
     document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED,
                            Field.TermVector.YES));
@@ -2060,7 +2063,7 @@ public class TestIndexWriter extends Luc
     int delID = 0;
     for(int i=0;i<20;i++) {
       IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2));
-      LogMergePolicy lmp = (LogMergePolicy) writer.getMergePolicy();
+      LogMergePolicy lmp = (LogMergePolicy) writer.getConfig().getMergePolicy();
       lmp.setMergeFactor(2);
       lmp.setUseCompoundFile(false);
       lmp.setUseCompoundDocStore(false);
@@ -2097,7 +2100,7 @@ public class TestIndexWriter extends Luc
 
       if (0 == i % 4) {
         writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)));
-        LogMergePolicy lmp2 = (LogMergePolicy) writer.getMergePolicy();
+        LogMergePolicy lmp2 = (LogMergePolicy) writer.getConfig().getMergePolicy();
         lmp2.setUseCompoundFile(false);
         lmp2.setUseCompoundDocStore(false);
         writer.optimize();
@@ -2122,7 +2125,7 @@ public class TestIndexWriter extends Luc
         conf.setMergeScheduler(new SerialMergeScheduler());
       }
       IndexWriter writer = new IndexWriter(directory, conf);
-      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(100);
+      ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(100);
       
       //System.out.println("TEST: pass=" + pass + " cms=" + (pass >= 2));
       for(int iter=0;iter<10;iter++) {
@@ -2140,7 +2143,7 @@ public class TestIndexWriter extends Luc
 
         // Force a bunch of merge threads to kick off so we
         // stress out aborting them on close:
-        ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(2);
+        ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
 
         final IndexWriter finalWriter = writer;
         final ArrayList<Throwable> failure = new ArrayList<Throwable>();
@@ -2268,7 +2271,7 @@ public class TestIndexWriter extends Luc
       // We expect AlreadyClosedException
       ((ConcurrentMergeScheduler) conf.getMergeScheduler()).setSuppressExceptions();
       IndexWriter writer = new IndexWriter(dir, conf);
-      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(4);
+      ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
 
       IndexerThread[] threads = new IndexerThread[NUM_THREADS];
 
@@ -2360,7 +2363,7 @@ public class TestIndexWriter extends Luc
       // We expect disk full exceptions in the merge threads
       ((ConcurrentMergeScheduler) conf.getMergeScheduler()).setSuppressExceptions();
       IndexWriter writer = new IndexWriter(dir, conf);
-      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(4);
+      ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
       dir.setMaxSizeInBytes(4*1024+20*iter);
 
       IndexerThread[] threads = new IndexerThread[NUM_THREADS];
@@ -2449,7 +2452,7 @@ public class TestIndexWriter extends Luc
       // We expect disk full exceptions in the merge threads
       ((ConcurrentMergeScheduler) conf.getMergeScheduler()).setSuppressExceptions();
       IndexWriter writer = new IndexWriter(dir, conf);
-      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(4);
+      ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
 
       IndexerThread[] threads = new IndexerThread[NUM_THREADS];
 
@@ -2666,7 +2669,7 @@ public class TestIndexWriter extends Luc
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
         TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
         .setMaxBufferedDocs(2));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(5);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(5);
 
     for (int i = 0; i < 23; i++)
       addDoc(writer);
@@ -2720,7 +2723,7 @@ public class TestIndexWriter extends Luc
 
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2));
     failure.setDoFail();
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(5);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(5);
 
     for (int i = 0; i < 23; i++) {
       addDoc(writer);
@@ -2750,10 +2753,11 @@ public class TestIndexWriter extends Luc
     Directory dir = new MockRAMDirectory();
     for(int iter=0;iter<2;iter++) {
       IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
-          TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2).setRAMBufferSizeMB(
-          IndexWriterConfig.DISABLE_AUTO_FLUSH).setMergeScheduler(
-          new SerialMergeScheduler()));
-      writer.setMergePolicy(new LogDocMergePolicy(writer));
+          TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT))
+          .setMaxBufferedDocs(2).setRAMBufferSizeMB(
+              IndexWriterConfig.DISABLE_AUTO_FLUSH).setMergeScheduler(
+              new SerialMergeScheduler()).setMergePolicy(
+              new LogDocMergePolicy()));
 
       Document document = new Document();
 
@@ -2784,8 +2788,8 @@ public class TestIndexWriter extends Luc
       writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
           new StandardAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2)
           .setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH)
-          .setMergeScheduler(new SerialMergeScheduler()));
-      writer.setMergePolicy(new LogDocMergePolicy(writer));
+          .setMergeScheduler(new SerialMergeScheduler()).setMergePolicy(
+              new LogDocMergePolicy()));
 
       Directory[] indexDirs = {new MockRAMDirectory(dir)};
       writer.addIndexesNoOptimize(indexDirs);
@@ -2803,8 +2807,8 @@ public class TestIndexWriter extends Luc
           TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT))
           .setMaxBufferedDocs(2).setRAMBufferSizeMB(
               IndexWriterConfig.DISABLE_AUTO_FLUSH).setMergeScheduler(
-              new SerialMergeScheduler()));
-      writer.setMergePolicy(new LogDocMergePolicy(writer));
+              new SerialMergeScheduler()).setMergePolicy(
+              new LogDocMergePolicy()));
 
       Document document = new Document();
 
@@ -2840,8 +2844,7 @@ public class TestIndexWriter extends Luc
         TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT))
         .setMaxBufferedDocs(2).setRAMBufferSizeMB(
             IndexWriterConfig.DISABLE_AUTO_FLUSH).setMergeScheduler(
-            new SerialMergeScheduler()));
-    writer.setMergePolicy(new LogDocMergePolicy(writer));
+            new SerialMergeScheduler()).setMergePolicy(new LogDocMergePolicy()));
 
     Document document = new Document();
 
@@ -2860,8 +2863,8 @@ public class TestIndexWriter extends Luc
     writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
         new StandardAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2)
         .setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH)
-        .setMergeScheduler(new SerialMergeScheduler()));
-    writer.setMergePolicy(new LogDocMergePolicy(writer));
+        .setMergeScheduler(new SerialMergeScheduler()).setMergePolicy(
+            new LogDocMergePolicy()));
     for(int i=0;i<6;i++)
       writer.addDocument(document);
 
@@ -2951,7 +2954,7 @@ public class TestIndexWriter extends Luc
         TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT))
         .setMaxBufferedDocs(2).setRAMBufferSizeMB(
             IndexWriterConfig.DISABLE_AUTO_FLUSH));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(50);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(50);
 
     Document document = new Document();
 
@@ -2977,7 +2980,7 @@ public class TestIndexWriter extends Luc
 
     writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
         new StandardAnalyzer(TEST_VERSION_CURRENT)));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(3);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(3);
     assertEquals(49, writer.numDocs());
     writer.expungeDeletes();
     writer.close();
@@ -2996,7 +2999,7 @@ public class TestIndexWriter extends Luc
         TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT))
         .setMaxBufferedDocs(2).setRAMBufferSizeMB(
             IndexWriterConfig.DISABLE_AUTO_FLUSH));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(50);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(50);
 
     Document document = new Document();
 
@@ -3022,7 +3025,7 @@ public class TestIndexWriter extends Luc
 
     writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT)));
     // Force many merges to happen
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(3);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(3);
     writer.expungeDeletes(false);
     writer.close();
     ir = IndexReader.open(dir, true);
@@ -3132,8 +3135,9 @@ public class TestIndexWriter extends Luc
   // LUCENE-1210
   public void testExceptionOnMergeInit() throws IOException {
     MockRAMDirectory dir = new MockRAMDirectory();
-    MockIndexWriter2 w = new MockIndexWriter2(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2));
-    ((LogMergePolicy) w.getMergePolicy()).setMergeFactor(2);
+    IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2);
+    ((LogMergePolicy) conf.getMergePolicy()).setMergeFactor(2);
+    MockIndexWriter2 w = new MockIndexWriter2(dir, conf);
     w.doFail = true;
     Document doc = new Document();
     doc.add(new Field("field", "a field", Field.Store.YES,
@@ -3526,7 +3530,7 @@ public class TestIndexWriter extends Luc
     Directory dir = new MockRAMDirectory();
 
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(5);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(5);
 
     for (int i = 0; i < 23; i++)
       addDoc(writer);
@@ -3577,7 +3581,7 @@ public class TestIndexWriter extends Luc
     dir.setPreventDoubleWrite(false);
 
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(5);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(5);
 
     for (int i = 0; i < 23; i++)
       addDoc(writer);
@@ -4014,15 +4018,16 @@ public class TestIndexWriter extends Luc
 
   public void testOptimizeExceptions() throws IOException {
     RAMDirectory startDir = new MockRAMDirectory();
-    IndexWriter w = new IndexWriter(startDir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2));
-    ((LogMergePolicy) w.getMergePolicy()).setMergeFactor(100);
+    IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2);
+    ((LogMergePolicy) conf.getMergePolicy()).setMergeFactor(100);
+    IndexWriter w = new IndexWriter(startDir, conf);
     for(int i=0;i<27;i++)
       addDoc(w);
     w.close();
 
     for(int i=0;i<200;i++) {
       MockRAMDirectory dir = new MockRAMDirectory(startDir);
-      IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT));
+      conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT));
       ((ConcurrentMergeScheduler) conf.getMergeScheduler()).setSuppressExceptions();
       w = new IndexWriter(dir, conf);
       dir.setRandomIOExceptionRate(0.5, 100);
@@ -4392,8 +4397,11 @@ public class TestIndexWriter extends Luc
             if (w != null) {
               w.close();
             }
-            w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2));
-            ((LogMergePolicy) w.getMergePolicy()).setMergeFactor(2);
+            IndexWriterConfig conf = new IndexWriterConfig(
+                TEST_VERSION_CURRENT, new WhitespaceAnalyzer(
+                    TEST_VERSION_CURRENT)).setMaxBufferedDocs(2);
+            ((LogMergePolicy) conf.getMergePolicy()).setMergeFactor(2);
+            w = new IndexWriter(dir, conf);
 
             //((ConcurrentMergeScheduler) w.getMergeScheduler()).setSuppressExceptions();
             if (!first && !allowInterrupt) {
@@ -4611,7 +4619,7 @@ public class TestIndexWriter extends Luc
     Directory dir = new MockRAMDirectory();
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
         TEST_VERSION_CURRENT, new SimpleAnalyzer(TEST_VERSION_CURRENT)));
-    LogMergePolicy lmp = (LogMergePolicy) writer.getMergePolicy();
+    LogMergePolicy lmp = (LogMergePolicy) writer.getConfig().getMergePolicy();
     lmp.setUseCompoundFile(false);
     lmp.setUseCompoundDocStore(false);
     ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterConfig.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterConfig.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterConfig.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterConfig.java Fri Mar 19 22:25:56 2010
@@ -80,6 +80,8 @@ public class TestIndexWriterConfig exten
     assertEquals(IndexWriterConfig.DEFAULT_MAX_BUFFERED_DOCS, conf.getMaxBufferedDocs());
     assertTrue(DocumentsWriter.defaultIndexingChain == conf.getIndexingChain());
     assertNull(conf.getMergedSegmentWarmer());
+    assertEquals(IndexWriterConfig.DEFAULT_MAX_THREAD_STATES, conf.getMaxThreadStates());
+    assertEquals(LogByteSizeMergePolicy.class, conf.getMergePolicy().getClass());
     
     // Sanity check - validate that all getters are covered.
     Set<String> getters = new HashSet<String>();
@@ -98,6 +100,7 @@ public class TestIndexWriterConfig exten
     getters.add("getMaxBufferedDocs");
     getters.add("getIndexingChain");
     getters.add("getMergedSegmentWarmer");
+    getters.add("getMergePolicy");
     getters.add("getMaxThreadStates");
     for (Method m : IndexWriterConfig.class.getDeclaredMethods()) {
       if (m.getDeclaringClass() == IndexWriterConfig.class && m.getName().startsWith("get")) {
@@ -130,6 +133,7 @@ public class TestIndexWriterConfig exten
     assertEquals(IndexWriterConfig.DISABLE_AUTO_FLUSH, IndexWriterConfig.DEFAULT_MAX_BUFFERED_DELETE_TERMS);
     assertEquals(IndexWriterConfig.DISABLE_AUTO_FLUSH, IndexWriterConfig.DEFAULT_MAX_BUFFERED_DOCS);
     assertEquals(16.0, IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB, 0.0);
+    assertEquals(8, IndexWriterConfig.DEFAULT_MAX_THREAD_STATES);
   }
   
   @Test
@@ -225,7 +229,19 @@ public class TestIndexWriterConfig exten
     } catch (IllegalArgumentException e) {
       // this is expected
     }
-    
+
+    assertEquals(IndexWriterConfig.DEFAULT_MAX_THREAD_STATES, conf.getMaxThreadStates());
+    conf.setMaxThreadStates(5);
+    assertEquals(5, conf.getMaxThreadStates());
+    conf.setMaxThreadStates(0);
+    assertEquals(IndexWriterConfig.DEFAULT_MAX_THREAD_STATES, conf.getMaxThreadStates());
+    
+    // Test MergePolicy
+    assertEquals(LogByteSizeMergePolicy.class, conf.getMergePolicy().getClass());
+    conf.setMergePolicy(new LogDocMergePolicy());
+    assertEquals(LogDocMergePolicy.class, conf.getMergePolicy().getClass());
+    conf.setMergePolicy(null);
+    assertEquals(LogByteSizeMergePolicy.class, conf.getMergePolicy().getClass());
   }
 
   /**
@@ -268,5 +284,9 @@ public class TestIndexWriterConfig exten
     
     writer.setMergedSegmentWarmer(new MyWarmer());
     assertEquals(MyWarmer.class, writer.getConfig().getMergedSegmentWarmer().getClass());
+    
+    writer.setMergePolicy(new LogDocMergePolicy());
+    assertEquals(LogDocMergePolicy.class, writer.getConfig().getMergePolicy().getClass());
   }
+
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterDelete.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterDelete.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterDelete.java Fri Mar 19 22:25:56 2010
@@ -641,7 +641,7 @@ public class TestIndexWriterDelete exten
     MockRAMDirectory dir = new MockRAMDirectory();
     IndexWriter modifier = new IndexWriter(dir, new IndexWriterConfig(
         TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDeleteTerms(2));
-    LogMergePolicy lmp = (LogMergePolicy) modifier.getMergePolicy();
+    LogMergePolicy lmp = (LogMergePolicy) modifier.getConfig().getMergePolicy();
     lmp.setUseCompoundFile(true);
     lmp.setUseCompoundDocStore(true);
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java Fri Mar 19 22:25:56 2010
@@ -35,9 +35,9 @@ public class TestIndexWriterMergePolicy 
   public void testNormalCase() throws IOException {
     Directory dir = new RAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(10));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
-    writer.setMergePolicy(new LogDocMergePolicy(writer));
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+        .setMaxBufferedDocs(10).setMergePolicy(new LogDocMergePolicy()));
 
     for (int i = 0; i < 100; i++) {
       addDoc(writer);
@@ -51,9 +51,9 @@ public class TestIndexWriterMergePolicy 
   public void testNoOverMerge() throws IOException {
     Directory dir = new RAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(10));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
-    writer.setMergePolicy(new LogDocMergePolicy(writer));
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+        .setMaxBufferedDocs(10).setMergePolicy(new LogDocMergePolicy()));
 
     boolean noOverMerge = false;
     for (int i = 0; i < 100; i++) {
@@ -72,21 +72,23 @@ public class TestIndexWriterMergePolicy 
   public void testForceFlush() throws IOException {
     Directory dir = new RAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(10));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
-    LogDocMergePolicy mp = new LogDocMergePolicy(writer);
+    LogDocMergePolicy mp = new LogDocMergePolicy();
     mp.setMinMergeDocs(100);
-    writer.setMergePolicy(mp);
+    mp.setMergeFactor(10);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+        .setMaxBufferedDocs(10).setMergePolicy(mp));
 
     for (int i = 0; i < 100; i++) {
       addDoc(writer);
       writer.close();
 
-      writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
-          .setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(10));
-      writer.setMergePolicy(mp);
+      mp = new LogDocMergePolicy();
+      mp.setMergeFactor(10);
+      writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
+          new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setOpenMode(
+          OpenMode.APPEND).setMaxBufferedDocs(10).setMergePolicy(mp));
       mp.setMinMergeDocs(100);
-      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
       checkInvariants(writer);
     }
 
@@ -97,16 +99,16 @@ public class TestIndexWriterMergePolicy 
   public void testMergeFactorChange() throws IOException {
     Directory dir = new RAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(10));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(100);
-    writer.setMergePolicy(new LogDocMergePolicy(writer));
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+        .setMaxBufferedDocs(10).setMergePolicy(new LogDocMergePolicy()));
 
     for (int i = 0; i < 250; i++) {
       addDoc(writer);
       checkInvariants(writer);
     }
 
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(5);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(5);
 
     // merge policy only fixes segments on levels where merges
     // have been triggered, so check invariants after all adds
@@ -122,9 +124,9 @@ public class TestIndexWriterMergePolicy 
   public void testMaxBufferedDocsChange() throws IOException {
     Directory dir = new RAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(101));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(101);
-    writer.setMergePolicy(new LogDocMergePolicy(writer));
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+        .setMaxBufferedDocs(101).setMergePolicy(new LogDocMergePolicy()));
 
     // leftmost* segment has 1 doc
     // rightmost* segment has 100 docs
@@ -135,17 +137,18 @@ public class TestIndexWriterMergePolicy 
       }
       writer.close();
 
-      writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
-          .setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(101));
-      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(101);
-      writer.setMergePolicy(new LogDocMergePolicy(writer));
+      writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
+          new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setOpenMode(
+          OpenMode.APPEND).setMaxBufferedDocs(101).setMergePolicy(
+          new LogDocMergePolicy()));
     }
 
     writer.close();
-    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
-        .setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(10));
-    writer.setMergePolicy(new LogDocMergePolicy(writer));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10);
+    LogDocMergePolicy ldmp = new LogDocMergePolicy();
+    ldmp.setMergeFactor(10);
+    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
+        new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setOpenMode(
+        OpenMode.APPEND).setMaxBufferedDocs(10).setMergePolicy(ldmp));
 
     // merge policy only fixes segments on levels where merges
     // have been triggered, so check invariants after all adds
@@ -169,9 +172,11 @@ public class TestIndexWriterMergePolicy 
   public void testMergeDocCount0() throws IOException {
     Directory dir = new RAMDirectory();
 
-    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(10));
-    writer.setMergePolicy(new LogDocMergePolicy(writer));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(100);
+    LogDocMergePolicy ldmp = new LogDocMergePolicy();
+    ldmp.setMergeFactor(100);
+    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
+        TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+        .setMaxBufferedDocs(10).setMergePolicy(ldmp));
 
     for (int i = 0; i < 250; i++) {
       addDoc(writer);
@@ -183,10 +188,11 @@ public class TestIndexWriterMergePolicy 
     reader.deleteDocuments(new Term("content", "aaa"));
     reader.close();
 
-    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
-        .setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(10));
-    writer.setMergePolicy(new LogDocMergePolicy(writer));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(5);
+    ldmp = new LogDocMergePolicy();
+    ldmp.setMergeFactor(5);
+    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
+        new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setOpenMode(
+        OpenMode.APPEND).setMaxBufferedDocs(10).setMergePolicy(ldmp));
 
     // merge factor is changed, so check invariants after all adds
     for (int i = 0; i < 10; i++) {
@@ -210,8 +216,8 @@ public class TestIndexWriterMergePolicy 
   private void checkInvariants(IndexWriter writer) throws IOException {
     _TestUtil.syncConcurrentMerges(writer);
     int maxBufferedDocs = writer.getConfig().getMaxBufferedDocs();
-    int mergeFactor = ((LogMergePolicy) writer.getMergePolicy()).getMergeFactor();
-    int maxMergeDocs = ((LogMergePolicy) writer.getMergePolicy()).getMaxMergeDocs();
+    int mergeFactor = ((LogMergePolicy) writer.getConfig().getMergePolicy()).getMergeFactor();
+    int maxMergeDocs = ((LogMergePolicy) writer.getConfig().getMergePolicy()).getMaxMergeDocs();
 
     int ramSegmentCount = writer.getNumBufferedDocuments();
     assertTrue(ramSegmentCount < maxBufferedDocs);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterMerging.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterMerging.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterMerging.java Fri Mar 19 22:25:56 2010
@@ -58,7 +58,7 @@ public class TestIndexWriterMerging exte
     Directory merged = new MockRAMDirectory();
 
     IndexWriter writer = new IndexWriter(merged, new IndexWriterConfig(TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT)));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(2);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
 
     writer.addIndexesNoOptimize(new Directory[]{indexA, indexB});
     writer.optimize();
@@ -97,7 +97,7 @@ public class TestIndexWriterMerging exte
         TEST_VERSION_CURRENT, 
         new StandardAnalyzer(TEST_VERSION_CURRENT))
         .setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(2));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(2);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
 
     for (int i = start; i < (start + numDocs); i++)
     {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterReader.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriterReader.java Fri Mar 19 22:25:56 2010
@@ -491,8 +491,9 @@ public class TestIndexWriterReader exten
   
   public static void createIndex(Directory dir1, String indexName,
       boolean multiSegment) throws IOException {
-    IndexWriter w = new IndexWriter(dir1, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)));
-    w.setMergePolicy(new LogDocMergePolicy(w));
+    IndexWriter w = new IndexWriter(dir1, new IndexWriterConfig(
+        TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
+        .setMergePolicy(new LogDocMergePolicy()));
     for (int i = 0; i < 100; i++) {
       w.addDocument(createDocument(i, indexName, 4));
       if (multiSegment && (i % 10) == 0) {
@@ -538,7 +539,7 @@ public class TestIndexWriterReader exten
     // get a reader to put writer into near real-time mode
     IndexReader r1 = writer.getReader();
     
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(2);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
 
     for (int i = 0; i < 10; i++) {
       writer.addDocument(createDocument(i, "test", 4));
@@ -622,7 +623,7 @@ public class TestIndexWriterReader exten
     Directory dir1 = new MockRAMDirectory();
     final IndexWriter writer = new IndexWriter(dir1, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)));
     writer.setInfoStream(infoStream);
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(2);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
 
     // create the index
     createIndexNoClose(false, "test", writer);
@@ -699,7 +700,7 @@ public class TestIndexWriterReader exten
     Directory dir1 = new MockRAMDirectory();
     final IndexWriter writer = new IndexWriter(dir1, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)));
     writer.setInfoStream(infoStream);
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(2);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
 
     // create the index
     createIndexNoClose(false, "test", writer);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyBug.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyBug.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyBug.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyBug.java Fri Mar 19 22:25:56 2010
@@ -73,7 +73,7 @@ public class TestLazyBug extends LuceneT
       Random r = newRandom();
       IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
           TEST_VERSION_CURRENT, new SimpleAnalyzer(TEST_VERSION_CURRENT)));
-      LogMergePolicy lmp = (LogMergePolicy) writer.getMergePolicy();
+      LogMergePolicy lmp = (LogMergePolicy) writer.getConfig().getMergePolicy();
       lmp.setUseCompoundFile(false);
       lmp.setUseCompoundDocStore(false);
       

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java Fri Mar 19 22:25:56 2010
@@ -61,8 +61,8 @@ public class TestLazyProxSkipping extend
         
         Directory directory = new SeekCountingDirectory();
         IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(10));
-        ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundFile(false);
-        ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundDocStore(false);
+        ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
+        ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
         for (int i = 0; i < numDocs; i++) {
             Document doc = new Document();
             String content;

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java Fri Mar 19 22:25:56 2010
@@ -33,9 +33,9 @@ public class TestNRTReaderWithThreads ex
   public void testIndexing() throws Exception {
     Directory mainDir = new MockRAMDirectory();
     IndexWriter writer = new IndexWriter(mainDir, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(10));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(2);
-    ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundFile(false);
-    ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundDocStore(false);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
     IndexReader reader = writer.getReader(); // start pooling readers
     reader.close();
     RunThread[] indexThreads = new RunThread[4];

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestNorms.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestNorms.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestNorms.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestNorms.java Fri Mar 19 22:25:56 2010
@@ -103,7 +103,7 @@ public class TestNorms extends LuceneTes
     IndexWriter iw = new IndexWriter(dir3, new IndexWriterConfig(
         TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.APPEND)
         .setMaxBufferedDocs(5));
-    ((LogMergePolicy) iw.getMergePolicy()).setMergeFactor(3);
+    ((LogMergePolicy) iw.getConfig().getMergePolicy()).setMergeFactor(3);
     iw.addIndexesNoOptimize(new Directory[]{dir1,dir2});
     iw.optimize();
     iw.close();
@@ -121,7 +121,7 @@ public class TestNorms extends LuceneTes
     // now with optimize
     iw = new IndexWriter(dir3, new IndexWriterConfig(TEST_VERSION_CURRENT,
         anlzr).setOpenMode(OpenMode.APPEND).setMaxBufferedDocs(5));
-    ((LogMergePolicy) iw.getMergePolicy()).setMergeFactor(3);
+    ((LogMergePolicy) iw.getConfig().getMergePolicy()).setMergeFactor(3);
     iw.optimize();
     iw.close();
     verifyIndex(dir3);
@@ -148,7 +148,7 @@ public class TestNorms extends LuceneTes
     IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(
         TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.CREATE)
         .setMaxBufferedDocs(5).setSimilarity(similarityOne));
-    LogMergePolicy lmp = (LogMergePolicy) iw.getMergePolicy();
+    LogMergePolicy lmp = (LogMergePolicy) iw.getConfig().getMergePolicy();
     lmp.setMergeFactor(3);
     lmp.setUseCompoundFile(true);
     lmp.setUseCompoundDocStore(true);
@@ -192,7 +192,7 @@ public class TestNorms extends LuceneTes
     IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(
         TEST_VERSION_CURRENT, anlzr).setOpenMode(OpenMode.APPEND)
         .setMaxBufferedDocs(5).setSimilarity(similarityOne));
-    LogMergePolicy lmp = (LogMergePolicy) iw.getMergePolicy();
+    LogMergePolicy lmp = (LogMergePolicy) iw.getConfig().getMergePolicy();
     lmp.setMergeFactor(3);
     lmp.setUseCompoundFile(compound);
     lmp.setUseCompoundDocStore(compound);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestOmitTf.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestOmitTf.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestOmitTf.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestOmitTf.java Fri Mar 19 22:25:56 2010
@@ -115,7 +115,7 @@ public class TestOmitTf extends LuceneTe
     Analyzer analyzer = new StandardAnalyzer(TEST_VERSION_CURRENT);
     IndexWriter writer = new IndexWriter(ram, new IndexWriterConfig(
         TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(3));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(2);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
     Document d = new Document();
         
     // this field will have Tf
@@ -168,7 +168,7 @@ public class TestOmitTf extends LuceneTe
     Analyzer analyzer = new StandardAnalyzer(TEST_VERSION_CURRENT);
     IndexWriter writer = new IndexWriter(ram, new IndexWriterConfig(
         TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(10));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(2);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
     Document d = new Document();
         
     // this field will have Tf
@@ -216,7 +216,7 @@ public class TestOmitTf extends LuceneTe
     Analyzer analyzer = new StandardAnalyzer(TEST_VERSION_CURRENT);
     IndexWriter writer = new IndexWriter(ram, new IndexWriterConfig(
         TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(3));
-    LogMergePolicy lmp = (LogMergePolicy) writer.getMergePolicy();
+    LogMergePolicy lmp = (LogMergePolicy) writer.getConfig().getMergePolicy();
     lmp.setMergeFactor(2);
     lmp.setUseCompoundFile(false);
     lmp.setUseCompoundDocStore(false);
@@ -250,8 +250,7 @@ public class TestOmitTf extends LuceneTe
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
         TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(2)
         .setSimilarity(new SimpleSimilarity()));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(2);
-        
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
         
     StringBuilder sb = new StringBuilder(265);
     String term = "term";

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing2.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing2.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing2.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestStressIndexing2.java Fri Mar 19 22:25:56 2010
@@ -139,7 +139,7 @@ public class TestStressIndexing2 extends
     IndexWriter w = new MockIndexWriter(dir, new IndexWriterConfig(
         TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setOpenMode(OpenMode.CREATE).setRAMBufferSizeMB(
         0.1).setMaxBufferedDocs(maxBufferedDocs));
-    LogMergePolicy lmp = (LogMergePolicy) w.getMergePolicy();
+    LogMergePolicy lmp = (LogMergePolicy) w.getConfig().getMergePolicy();
     lmp.setUseCompoundFile(false);
     lmp.setUseCompoundDocStore(false);
     lmp.setMergeFactor(mergeFactor);
@@ -190,7 +190,7 @@ public class TestStressIndexing2 extends
       IndexWriter w = new MockIndexWriter(dir, new IndexWriterConfig(
           TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setOpenMode(OpenMode.CREATE)
                .setRAMBufferSizeMB(0.1).setMaxBufferedDocs(maxBufferedDocs).setMaxThreadStates(maxThreadStates));
-      LogMergePolicy lmp = (LogMergePolicy) w.getMergePolicy();
+      LogMergePolicy lmp = (LogMergePolicy) w.getConfig().getMergePolicy();
       lmp.setUseCompoundFile(false);
       lmp.setUseCompoundDocStore(false);
       lmp.setMergeFactor(mergeFactor);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestTermVectorsReader.java Fri Mar 19 22:25:56 2010
@@ -93,8 +93,8 @@ public class TestTermVectorsReader exten
     Arrays.sort(tokens);
 
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MyAnalyzer()));
-    ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundFile(false);
-    ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundDocStore(false);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
     Document doc = new Document();
     for(int i=0;i<testFields.length;i++) {
       final Field.TermVector tv;

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestTermdocPerf.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestTermdocPerf.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestTermdocPerf.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestTermdocPerf.java Fri Mar 19 22:25:56 2010
@@ -74,7 +74,7 @@ public class TestTermdocPerf extends Luc
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
         TEST_VERSION_CURRENT, analyzer)
         .setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(100));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(100);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(100);
 
     for (int i=0; i<ndocs; i++) {
       writer.addDocument(doc);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestThreadedOptimize.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestThreadedOptimize.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestThreadedOptimize.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestThreadedOptimize.java Fri Mar 19 22:25:56 2010
@@ -62,7 +62,7 @@ public class TestThreadedOptimize extend
     for(int iter=0;iter<NUM_ITER;iter++) {
       final int iterFinal = iter;
 
-      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(1000);
+      ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(1000);
 
       for(int i=0;i<200;i++) {
         Document d = new Document();
@@ -71,7 +71,7 @@ public class TestThreadedOptimize extend
         writer.addDocument(d);
       }
 
-      ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(4);
+      ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(4);
       //writer.setInfoStream(System.out);
 
       Thread[] threads = new Thread[NUM_THREADS];

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactions.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactions.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactions.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestTransactions.java Fri Mar 19 22:25:56 2010
@@ -93,13 +93,13 @@ public class TestTransactions extends Lu
     public void doWork() throws Throwable {
 
       IndexWriter writer1 = new IndexWriter(dir1, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(3));
-      ((LogMergePolicy) writer1.getMergePolicy()).setMergeFactor(2);
+      ((LogMergePolicy) writer1.getConfig().getMergePolicy()).setMergeFactor(2);
       ((ConcurrentMergeScheduler) writer1.getConfig().getMergeScheduler()).setSuppressExceptions();
 
       // Intentionally use different params so flush/merge
       // happen @ different times
       IndexWriter writer2 = new IndexWriter(dir2, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2));
-      ((LogMergePolicy) writer2.getMergePolicy()).setMergeFactor(3);
+      ((LogMergePolicy) writer2.getConfig().getMergePolicy()).setMergeFactor(3);
       ((ConcurrentMergeScheduler) writer2.getConfig().getMergeScheduler()).setSuppressExceptions();
 
       update(writer1);

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java Fri Mar 19 22:25:56 2010
@@ -36,7 +36,7 @@ public class TestElevationComparator ext
   public void testSorting() throws Throwable {
     Directory directory = new MockRAMDirectory();
     IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)).setMaxBufferedDocs(2));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(1000);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(1000);
     writer.addDocument(adoc(new String[] {"id", "a", "title", "ipod", "str_s", "a"}));
     writer.addDocument(adoc(new String[] {"id", "b", "title", "ipod ipod", "str_s", "b"}));
     writer.addDocument(adoc(new String[] {"id", "c", "title", "ipod ipod ipod", "str_s","c"}));

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java Fri Mar 19 22:25:56 2010
@@ -109,7 +109,7 @@ public class TestSort extends LuceneTest
     IndexWriter writer = new IndexWriter(indexStore, new IndexWriterConfig(
         TEST_VERSION_CURRENT, new SimpleAnalyzer(
         TEST_VERSION_CURRENT)).setMaxBufferedDocs(2));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(1000);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(1000);
     for (int i=0; i<data.length; ++i) {
       if (((i%2)==0 && even) || ((i%2)==1 && odd)) {
         Document doc = new Document();
@@ -146,7 +146,7 @@ public class TestSort extends LuceneTest
     IndexWriter writer = new IndexWriter(indexStore, new IndexWriterConfig(
         TEST_VERSION_CURRENT, new SimpleAnalyzer(
         TEST_VERSION_CURRENT)).setMaxBufferedDocs(4));
-    ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(97);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(97);
     for (int i=0; i<NUM_STRINGS; i++) {
         Document doc = new Document();
         String num = getRandomCharString(getRandomNumber(2, 8), 48, 52);

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java Fri Mar 19 22:25:56 2010
@@ -248,7 +248,7 @@ public class TestBufferedIndexInput exte
         IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
           TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT))
           .setOpenMode(OpenMode.CREATE));
-        ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundFile(false);
+        ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
         for(int i=0;i<37;i++) {
           Document doc = new Document();
           doc.add(new Field("content", "aaa bbb ccc ddd" + i, Field.Store.YES, Field.Index.ANALYZED));

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java?rev=925462&r1=925461&r2=925462&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java Fri Mar 19 22:25:56 2010
@@ -45,8 +45,8 @@ public class TestFileSwitchDirectory ext
     
     FileSwitchDirectory fsd = new FileSwitchDirectory(fileExtensions, primaryDir, secondaryDir, true);
     IndexWriter writer = new IndexWriter(fsd, new IndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)));
-    ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundFile(false);
-    ((LogMergePolicy) writer.getMergePolicy()).setUseCompoundDocStore(false);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundFile(false);
+    ((LogMergePolicy) writer.getConfig().getMergePolicy()).setUseCompoundDocStore(false);
     TestIndexWriterReader.createIndexNoClose(true, "ram", writer);
     IndexReader reader = writer.getReader();
     assertEquals(100, reader.maxDoc());

Added: lucene/java/trunk/src/test/org/apache/lucene/util/TestSetOnce.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/TestSetOnce.java?rev=925462&view=auto
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/TestSetOnce.java (added)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/TestSetOnce.java Fri Mar 19 22:25:56 2010
@@ -0,0 +1,103 @@
+package org.apache.lucene.util;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import static org.junit.Assert.*;
+
+import java.util.Random;
+
+import org.apache.lucene.util.SetOnce.AlreadySetException;
+import org.junit.Test;
+
+public class TestSetOnce extends LuceneTestCaseJ4 {
+
+  private static final class SetOnceThread extends Thread {
+    SetOnce<Integer> set;
+    boolean success = false;
+    
+    @Override
+    public void run() {
+      try {
+        sleep(RAND.nextInt(10)); // sleep for a short time
+        set.set(new Integer(Integer.parseInt(getName().substring(2))));
+        success = true;
+      } catch (InterruptedException e) {
+        // ignore
+      } catch (RuntimeException e) {
+        // TODO: change exception type
+        // expected.
+        success = false;
+      }
+    }
+  }
+  
+  private static final Random RAND = new Random();
+  
+  @Test
+  public void testEmptyCtor() throws Exception {
+    SetOnce<Integer> set = new SetOnce<Integer>();
+    assertNull(set.get());
+  }
+  
+  @Test(expected=AlreadySetException.class)
+  public void testSettingCtor() throws Exception {
+    SetOnce<Integer> set = new SetOnce<Integer>(new Integer(5));
+    assertEquals(5, set.get().intValue());
+    set.set(new Integer(7));
+  }
+  
+  @Test(expected=AlreadySetException.class)
+  public void testSetOnce() throws Exception {
+    SetOnce<Integer> set = new SetOnce<Integer>();
+    set.set(new Integer(5));
+    assertEquals(5, set.get().intValue());
+    set.set(new Integer(7));
+  }
+  
+  @Test
+  public void testSetMultiThreaded() throws Exception {
+    long seed = RAND.nextLong();
+    RAND.setSeed(seed);
+    if (VERBOSE) {
+      System.out.println("testSetMultiThreaded: seed=" + seed);
+    }
+    final SetOnce<Integer> set = new SetOnce<Integer>();
+    SetOnceThread[] threads = new SetOnceThread[10];
+    for (int i = 0; i < threads.length; i++) {
+      threads[i] = new SetOnceThread();
+      threads[i].setName("t-" + (i+1));
+      threads[i].set = set;
+    }
+    
+    for (Thread t : threads) {
+      t.start();
+    }
+
+    for (Thread t : threads) {
+      t.join();
+    }
+    
+    for (SetOnceThread t : threads) {
+      if (t.success) {
+        int expectedVal = Integer.parseInt(t.getName().substring(2));
+        assertEquals("thread " + t.getName(), expectedVal, t.set.get().intValue());
+      }
+    }
+  }
+  
+}

Propchange: lucene/java/trunk/src/test/org/apache/lucene/util/TestSetOnce.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message