You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2013/04/30 20:51:16 UTC

svn commit: r1477776 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/test-framework/ lucene/test-framework/src/java/org/apache/lucene/util/

Author: mikemccand
Date: Tue Apr 30 18:51:15 2013
New Revision: 1477776

URL: http://svn.apache.org/r1477776
Log:
also set IW's infoStream in LTC.newIndexWriterConfig, so we get a new messageID each time an IW is created when running verbose

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1477776&r1=1477775&r2=1477776&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Tue Apr 30 18:51:15 2013
@@ -704,6 +704,16 @@ public abstract class LuceneTestCase ext
   public static IndexWriterConfig newIndexWriterConfig(Random r, Version v, Analyzer a) {
     IndexWriterConfig c = new IndexWriterConfig(v, a);
     c.setSimilarity(classEnvRule.similarity);
+    if (VERBOSE) {
+      // Even though TestRuleSetupAndRestoreClassEnv calls
+      // InfoStream.setDefault, we do it again here so that
+      // the PrintStreamInfoStream.messageID increments so
+      // that when there are separate instances of
+      // IndexWriter created we see "IW 0", "IW 1", "IW 2",
+      // ... instead of just always "IW 0":
+      c.setInfoStream(new TestRuleSetupAndRestoreClassEnv.ThreadNameFixingPrintStreamInfoStream(System.out));
+    }
+
     if (r.nextBoolean()) {
       c.setMergeScheduler(new SerialMergeScheduler());
     }

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java?rev=1477776&r1=1477775&r2=1477776&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java Tue Apr 30 18:51:15 2013
@@ -17,6 +17,7 @@ package org.apache.lucene.util;
  * limitations under the License.
  */
 
+import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
@@ -35,21 +36,17 @@ import org.apache.lucene.codecs.assertin
 import org.apache.lucene.codecs.lucene3x.PreFlexRWCodec;
 import org.apache.lucene.codecs.cheapbastard.CheapBastardCodec;
 import org.apache.lucene.codecs.compressing.CompressingCodec;
-import org.apache.lucene.codecs.lucene40.Lucene40Codec;
 import org.apache.lucene.codecs.lucene40.Lucene40RWCodec;
 import org.apache.lucene.codecs.lucene40.Lucene40RWPostingsFormat;
-import org.apache.lucene.codecs.lucene41.Lucene41Codec;
 import org.apache.lucene.codecs.lucene41.Lucene41RWCodec;
 import org.apache.lucene.codecs.lucene42.Lucene42Codec;
-import org.apache.lucene.codecs.mockrandom.MockRandomPostingsFormat;
 import org.apache.lucene.codecs.simpletext.SimpleTextCodec;
 import org.apache.lucene.index.RandomCodec;
 import org.apache.lucene.search.RandomSimilarityProvider;
 import org.apache.lucene.search.similarities.DefaultSimilarity;
 import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
+import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;  // javadocs
 import org.junit.internal.AssumptionViolatedException;
-
 import com.carrotsearch.randomizedtesting.RandomizedContext;
 
 import static org.apache.lucene.util.LuceneTestCase.*;
@@ -81,6 +78,25 @@ final class TestRuleSetupAndRestoreClass
    */
   HashSet<String> avoidCodecs;
 
+  static class ThreadNameFixingPrintStreamInfoStream extends PrintStreamInfoStream {
+
+    public ThreadNameFixingPrintStreamInfoStream(PrintStream out) {
+      super(out);
+    }
+
+    @Override
+    public void message(String component, String message) {
+      final String name;
+      if (Thread.currentThread().getName().startsWith("TEST-")) {
+        // The name of the main thread is way too
+        // long when looking at IW verbose output...
+        name = "main";
+      } else {
+        name = Thread.currentThread().getName();
+      }
+      stream.println(component + " " + messageID + " [" + new Date() + "; " + name + "]: " + message);    
+    }
+  }
 
   @Override
   protected void before() throws Exception {
@@ -113,20 +129,7 @@ final class TestRuleSetupAndRestoreClass
     final Random random = RandomizedContext.current().getRandom();
     final boolean v = random.nextBoolean();
     if (INFOSTREAM) {
-      InfoStream.setDefault(new PrintStreamInfoStream(System.out) {
-          @Override
-          public void message(String component, String message) {
-            final String name;
-            if (Thread.currentThread().getName().startsWith("TEST-")) {
-              // The name of the main thread is way too
-              // long when looking at IW verbose output...
-              name = "main";
-            } else {
-              name = Thread.currentThread().getName();
-            }
-            stream.println(component + " " + messageID + " [" + new Date() + "; " + name + "]: " + message);    
-          }
-        });
+      InfoStream.setDefault(new ThreadNameFixingPrintStreamInfoStream(System.out));
     } else if (v) {
       InfoStream.setDefault(new NullInfoStream());
     }