You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2014/04/24 11:22:03 UTC

svn commit: r1589645 - in /lucene/dev/branches/LUCENE-5622: ./ lucene/ lucene/analysis/common/src/test/org/apache/lucene/analysis/core/ lucene/analysis/stempel/src/test/org/egothor/stemmer/ lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/...

Author: dweiss
Date: Thu Apr 24 09:22:03 2014
New Revision: 1589645

URL: http://svn.apache.org/r1589645
Log:
Branch for LUCENE-5622

Added:
    lucene/dev/branches/LUCENE-5622/   (props changed)
      - copied from r1589047, lucene/dev/trunk/
    lucene/dev/branches/LUCENE-5622/lucene/
      - copied from r1589108, lucene/dev/trunk/lucene/
    lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleDisallowSysouts.java   (with props)
Modified:
    lucene/dev/branches/LUCENE-5622/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestBugInSomething.java
    lucene/dev/branches/LUCENE-5622/lucene/analysis/stempel/src/test/org/egothor/stemmer/TestCompile.java
    lucene/dev/branches/LUCENE-5622/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java
    lucene/dev/branches/LUCENE-5622/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMATypeAwareAnalyzerTest.java
    lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/BenchmarkTestCase.java
    lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
    lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java
    lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java
    lucene/dev/branches/LUCENE-5622/lucene/common-build.xml
    lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestExceptionInBeforeClassHooks.java
    lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailIfDirectoryNotClosed.java
    lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSameRandomnessLocalePassedOrNot.java
    lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSeedFromUncaught.java
    lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/WithNestedTests.java
    lucene/dev/branches/LUCENE-5622/lucene/demo/src/test/org/apache/lucene/demo/TestDemo.java
    lucene/dev/branches/LUCENE-5622/lucene/facet/src/test/org/apache/lucene/facet/TestDrillDownQuery.java
    lucene/dev/branches/LUCENE-5622/lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java
    lucene/dev/branches/LUCENE-5622/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
    lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
    lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/RunListenerPrintReproduceInfo.java
    lucene/dev/branches/LUCENE-5622/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java

Modified: lucene/dev/branches/LUCENE-5622/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestBugInSomething.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestBugInSomething.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestBugInSomething.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestBugInSomething.java Thu Apr 24 09:22:03 2014
@@ -219,7 +219,7 @@ public class TestBugInSomething extends 
     @Override
     public boolean incrementToken() throws IOException {
       if (input.incrementToken()) {
-        System.out.println(input.getClass().getSimpleName() + "->" + this.reflectAsString(false));
+        if (VERBOSE) System.out.println(input.getClass().getSimpleName() + "->" + this.reflectAsString(false));
         return true;
       } else {
         return false;
@@ -229,19 +229,19 @@ public class TestBugInSomething extends 
     @Override
     public void end() throws IOException {
       super.end();
-      System.out.println(input.getClass().getSimpleName() + ".end()");
+      if (VERBOSE) System.out.println(input.getClass().getSimpleName() + ".end()");
     }
 
     @Override
     public void close() throws IOException {
       super.close();
-      System.out.println(input.getClass().getSimpleName() + ".close()");
+      if (VERBOSE) System.out.println(input.getClass().getSimpleName() + ".close()");
     }
 
     @Override
     public void reset() throws IOException {
       super.reset();
-      System.out.println(input.getClass().getSimpleName() + ".reset()");
+      if (VERBOSE) System.out.println(input.getClass().getSimpleName() + ".reset()");
     }
   }
   

Modified: lucene/dev/branches/LUCENE-5622/lucene/analysis/stempel/src/test/org/egothor/stemmer/TestCompile.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/analysis/stempel/src/test/org/egothor/stemmer/TestCompile.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/analysis/stempel/src/test/org/egothor/stemmer/TestCompile.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/analysis/stempel/src/test/org/egothor/stemmer/TestCompile.java Thu Apr 24 09:22:03 2014
@@ -70,8 +70,9 @@ import java.util.Locale;
 import java.util.StringTokenizer;
 
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 
+@SuppressSysoutChecks(bugUrl = "External tool.")
 public class TestCompile extends LuceneTestCase {
   
   public void testCompile() throws Exception {

Modified: lucene/dev/branches/LUCENE-5622/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java Thu Apr 24 09:22:03 2014
@@ -31,6 +31,7 @@ import org.apache.lucene.search.MatchAll
 import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -41,6 +42,7 @@ import java.util.Map;
 /**
  * Testcase for {@link UIMABaseAnalyzer}
  */
+@SuppressSysoutChecks(bugUrl = "UIMA logs via ju.logging")
 public class UIMABaseAnalyzerTest extends BaseTokenStreamTestCase {
 
   private UIMABaseAnalyzer analyzer;

Modified: lucene/dev/branches/LUCENE-5622/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMATypeAwareAnalyzerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMATypeAwareAnalyzerTest.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMATypeAwareAnalyzerTest.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMATypeAwareAnalyzerTest.java Thu Apr 24 09:22:03 2014
@@ -19,6 +19,7 @@ package org.apache.lucene.analysis.uima;
 
 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
 import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -26,6 +27,7 @@ import org.junit.Test;
 /**
  * Testcase for {@link UIMATypeAwareAnalyzer}
  */
+@SuppressSysoutChecks(bugUrl = "UIMA logs via ju.logging")
 public class UIMATypeAwareAnalyzerTest extends BaseTokenStreamTestCase {
 
   private UIMATypeAwareAnalyzer analyzer;

Modified: lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/BenchmarkTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/BenchmarkTestCase.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/BenchmarkTestCase.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/BenchmarkTestCase.java Thu Apr 24 09:22:03 2014
@@ -26,11 +26,12 @@ import java.io.StringReader;
 
 import org.apache.lucene.benchmark.byTask.Benchmark;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
 /** Base class for all Benchmark unit tests. */
+@SuppressSysoutChecks(bugUrl = "Output expected.")
 public abstract class BenchmarkTestCase extends LuceneTestCase {
   private static File WORKDIR;
   

Modified: lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java Thu Apr 24 09:22:03 2014
@@ -62,10 +62,12 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 
 /**
  * Test very simply that perf tasks - simple algorithms - are doing what they should.
  */
+@SuppressSysoutChecks(bugUrl = "Output expected.")
 public class TestPerfTasksLogic extends BenchmarkTestCase {
 
   @Override

Modified: lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java Thu Apr 24 09:22:03 2014
@@ -37,13 +37,12 @@ import org.apache.lucene.benchmark.byTas
 import org.apache.lucene.search.Query;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.TestUtil;
-
-import com.carrotsearch.randomizedtesting.RandomizedTest;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 
 import conf.ConfLoader;
 
 /** Test very simply that perf tasks are parses as expected. */
+@SuppressSysoutChecks(bugUrl = "Output expected.")
 public class TestPerfTasksParse extends LuceneTestCase {
 
   static final String NEW_LINE = System.getProperty("line.separator");
@@ -52,8 +51,7 @@ public class TestPerfTasksParse extends 
   // properties in effect in all tests here
   static final String propPart = 
     INDENT + "directory=RAMDirectory" + NEW_LINE +
-    INDENT + "print.props=false" + NEW_LINE
-  ;
+    INDENT + "print.props=false" + NEW_LINE;
 
   /** Test the repetiotion parsing for parallel tasks */
   public void testParseParallelTaskSequenceRepetition() throws Exception {

Modified: lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java Thu Apr 24 09:22:03 2014
@@ -26,6 +26,7 @@ import org.apache.lucene.index.Directory
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -43,6 +44,7 @@ import java.nio.charset.StandardCharsets
  * this test will not work correctly, as it does not dynamically
  * generate its test trec topics/qrels!
  */
+@SuppressSysoutChecks(bugUrl = "Output expected.")
 public class TestQualityRun extends BenchmarkTestCase {
   
   @Override

Modified: lucene/dev/branches/LUCENE-5622/lucene/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/common-build.xml?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/common-build.xml (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/common-build.xml Thu Apr 24 09:22:03 2014
@@ -118,7 +118,7 @@
   <property name="tests.verbose" value="false"/>
   <property name="tests.infostream" value="${tests.verbose}"/>
   <property name="tests.filterstacks" value="true"/>
-  
+
   <condition property="tests.heapsize" value="768M">
     <isset property="run.clover"/>
   </condition>
@@ -1008,6 +1008,7 @@
                 <propertyref prefix="tests.leavetmpdir" />
                 <propertyref prefix="tests.leaveTemporary" />
                 <propertyref prefix="tests.leavetemporary" />
+            	<propertyref prefix="tests.sysouts" />
                 <propertyref prefix="solr.test.leavetmpdir" />
             </syspropertyset>
 

Modified: lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestExceptionInBeforeClassHooks.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestExceptionInBeforeClassHooks.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestExceptionInBeforeClassHooks.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestExceptionInBeforeClassHooks.java Thu Apr 24 09:22:03 2014
@@ -106,7 +106,7 @@ public class TestExceptionInBeforeClassH
   @Test
   public void testExceptionInBeforeClassFailsTheTest() {
     Result runClasses = JUnitCore.runClasses(Nested1.class);
-    Assert.assertEquals(1, runClasses.getFailureCount());
+    assertFailureCount(1, runClasses);
     Assert.assertEquals(1, runClasses.getRunCount());
     Assert.assertTrue(runClasses.getFailures().get(0).getTrace().contains("foobar"));
   }
@@ -114,7 +114,7 @@ public class TestExceptionInBeforeClassH
   @Test
   public void testExceptionWithinTestFailsTheTest() {
     Result runClasses = JUnitCore.runClasses(Nested2.class);
-    Assert.assertEquals(3, runClasses.getFailureCount());
+    assertFailureCount(3, runClasses);
     Assert.assertEquals(3, runClasses.getRunCount());
     
     ArrayList<String> foobars = new ArrayList<>();
@@ -133,7 +133,7 @@ public class TestExceptionInBeforeClassH
   @Test
   public void testExceptionWithinBefore() {
     Result runClasses = JUnitCore.runClasses(Nested3.class);
-    Assert.assertEquals(1, runClasses.getFailureCount());
+    assertFailureCount(1, runClasses);
     Assert.assertEquals(1, runClasses.getRunCount());
     Assert.assertTrue(runClasses.getFailures().get(0).getTrace().contains("foobar"));
   }  

Modified: lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailIfDirectoryNotClosed.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailIfDirectoryNotClosed.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailIfDirectoryNotClosed.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestFailIfDirectoryNotClosed.java Thu Apr 24 09:22:03 2014
@@ -18,11 +18,11 @@ package org.apache.lucene.util.junitcomp
  */
 
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.JUnitCore;
 import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
 
 import com.carrotsearch.randomizedtesting.RandomizedTest;
 
@@ -31,6 +31,7 @@ public class TestFailIfDirectoryNotClose
     super(true);
   }
   
+  @SuppressSysoutChecks(bugUrl = "Expected.")
   public static class Nested1 extends WithNestedTests.AbstractNestedTest {
     public void testDummy() throws Exception {
       Directory dir = newDirectory();
@@ -43,11 +44,7 @@ public class TestFailIfDirectoryNotClose
     Result r = JUnitCore.runClasses(Nested1.class);
     RandomizedTest.assumeTrue("Ignoring nested test, very likely zombie threads present.", 
         r.getIgnoreCount() == 0);
-
-    for (Failure f : r.getFailures()) {
-      System.out.println("Failure: " + f);
-    }
-    Assert.assertEquals(1, r.getFailureCount());
+    assertFailureCount(1, r);
     Assert.assertTrue(r.getFailures().get(0).toString().contains("Resource in scope SUITE failed to close"));
   }
 }

Modified: lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSameRandomnessLocalePassedOrNot.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSameRandomnessLocalePassedOrNot.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSameRandomnessLocalePassedOrNot.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSameRandomnessLocalePassedOrNot.java Thu Apr 24 09:22:03 2014
@@ -3,6 +3,7 @@ package org.apache.lucene.util.junitcomp
 import java.util.*;
 
 import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 import org.junit.*;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TestRule;
@@ -42,6 +43,7 @@ public class TestSameRandomnessLocalePas
     super(true);
   }
   
+  @SuppressSysoutChecks(bugUrl = "Expected.")
   public static class Nested extends WithNestedTests.AbstractNestedTest {
     public static String pickString;
     public static Locale defaultLocale;

Modified: lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSeedFromUncaught.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSeedFromUncaught.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSeedFromUncaught.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestSeedFromUncaught.java Thu Apr 24 09:22:03 2014
@@ -18,6 +18,7 @@ package org.apache.lucene.util.junitcomp
  */
 
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.JUnitCore;
@@ -29,6 +30,7 @@ import org.junit.runner.notification.Fai
  * console. 
  */
 public class TestSeedFromUncaught extends WithNestedTests {
+  @SuppressSysoutChecks(bugUrl = "Expected.")
   public static class ThrowInUncaught extends AbstractNestedTest {
     @Test
     public void testFoo() throws Exception {
@@ -53,7 +55,7 @@ public class TestSeedFromUncaught extend
   @Test
   public void testUncaughtDumpsSeed() {
     Result result = JUnitCore.runClasses(ThrowInUncaught.class);
-    Assert.assertEquals(1, result.getFailureCount());
+    assertFailureCount(1, result);
     Failure f = result.getFailures().get(0);
     String trace = f.getTrace();
     Assert.assertTrue(trace.contains("SeedInfo.seed("));

Modified: lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/WithNestedTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/WithNestedTests.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/WithNestedTests.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/core/src/test/org/apache/lucene/util/junitcompat/WithNestedTests.java Thu Apr 24 09:22:03 2014
@@ -29,6 +29,7 @@ import org.apache.lucene.util.LuceneTest
 import org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures;
 import org.apache.lucene.util.TestRuleIgnoreTestSuites;
 import org.apache.lucene.util.TestRuleMarkFailure;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Assume;
@@ -37,6 +38,8 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TestRule;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
 
 import com.carrotsearch.randomizedtesting.RandomizedRunner;
 import com.carrotsearch.randomizedtesting.RandomizedTest;
@@ -57,6 +60,7 @@ import com.carrotsearch.randomizedtestin
  * cause havoc (static fields).
  */
 public abstract class WithNestedTests {
+  @SuppressSysoutChecks(bugUrl = "WithNestedTests has its own stream capture.")
   public static abstract class AbstractNestedTest extends LuceneTestCase 
     implements TestRuleIgnoreTestSuites.NestedTestSuite {
     protected static boolean isRunningNested() {
@@ -164,6 +168,20 @@ public abstract class WithNestedTests {
     }
   }
 
+  protected void assertFailureCount(int expected, Result result) {
+    if (result.getFailureCount() != expected) {
+      StringBuilder b = new StringBuilder();
+      for (Failure f : result.getFailures()) {
+        b.append("\n\n");
+        b.append(f.getMessage());
+        b.append("\n");
+        b.append(f.getTrace());
+      }
+      RandomizedTest.assertFalse("Expected failures: " + expected + " but was " + 
+          result.getFailureCount() + ", failures below: " + b.toString(), true);
+    }
+  }
+
   protected String getSysOut() {
     Assert.assertTrue(suppressOutputStreams);
     System.out.flush();

Modified: lucene/dev/branches/LUCENE-5622/lucene/demo/src/test/org/apache/lucene/demo/TestDemo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/demo/src/test/org/apache/lucene/demo/TestDemo.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/demo/src/test/org/apache/lucene/demo/TestDemo.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/demo/src/test/org/apache/lucene/demo/TestDemo.java Thu Apr 24 09:22:03 2014
@@ -23,8 +23,9 @@ import java.io.PrintStream;
 import java.nio.charset.Charset;
 
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 
+@SuppressSysoutChecks(bugUrl = "Output expected.")
 public class TestDemo extends LuceneTestCase {
 
   private void testOneSearch(File indexPath, String query, int expectedHitCount) throws Exception {

Modified: lucene/dev/branches/LUCENE-5622/lucene/facet/src/test/org/apache/lucene/facet/TestDrillDownQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/facet/src/test/org/apache/lucene/facet/TestDrillDownQuery.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/facet/src/test/org/apache/lucene/facet/TestDrillDownQuery.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/facet/src/test/org/apache/lucene/facet/TestDrillDownQuery.java Thu Apr 24 09:22:03 2014
@@ -133,7 +133,6 @@ public class TestDrillDownQuery extends 
     // Making sure the query yields 25 documents with the facet "a"
     DrillDownQuery q = new DrillDownQuery(config);
     q.add("a");
-    System.out.println("q=" + q);
     QueryUtils.check(q);
     TopDocs docs = searcher.search(q, 100);
     assertEquals(25, docs.totalHits);

Modified: lucene/dev/branches/LUCENE-5622/lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java Thu Apr 24 09:22:03 2014
@@ -17,9 +17,6 @@
 package org.apache.lucene.document;
 
 import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
 import java.util.Set;
 import java.util.HashSet;
 import java.util.Map;
@@ -28,7 +25,6 @@ import java.io.IOException;
 
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.store.*;
-import org.apache.lucene.document.*;
 import org.apache.lucene.analysis.*;
 import org.apache.lucene.index.*;
 import org.apache.lucene.search.*;
@@ -118,7 +114,7 @@ public class TestLazyDocument extends Lu
           assertFalse(f.name() + " is loaded", lf.hasBeenLoaded());
         }
       }
-      System.out.println("numFieldValues == " + numFieldValues);
+      if (VERBOSE) System.out.println("numFieldValues == " + numFieldValues);
       assertEquals("numFieldValues", 1 + (NUM_VALUES * FIELDS.length), 
                    numFieldValues);
         

Modified: lucene/dev/branches/LUCENE-5622/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java Thu Apr 24 09:22:03 2014
@@ -22,7 +22,9 @@ import org.apache.lucene.document.Field;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 
+@SuppressSysoutChecks(bugUrl = "Output expected (external tool).")
 public class TestMultiPassIndexSplitter extends LuceneTestCase {
   IndexReader input;
   int NUM_DOCS = 11;

Modified: lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Thu Apr 24 09:22:03 2014
@@ -246,6 +246,13 @@ public abstract class LuceneTestCase ext
 
   /** @see #ignoreAfterMaxFailures*/
   public static final String SYSPROP_FAILFAST = "tests.failfast";
+  
+  /**
+   * If true, enables assertions on writing to system streams.
+   * 
+   * @see TestRuleDisallowSysouts
+   */
+  public static final String SYSPROP_SYSOUTS = "tests.sysouts";
 
   /**
    * Annotation for tests that should only be run during nightly builds.
@@ -346,6 +353,21 @@ public abstract class LuceneTestCase ext
     public String bugUrl() default "None";
   }
 
+  /**
+   * Marks any suite which is known to print to {@link System#out} or {@link System#err},
+   * even when {@link #VERBOSE} is disabled.
+   * 
+   * @see TestRuleDisallowSysouts
+   */
+  @Documented
+  @Inherited
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.TYPE)
+  public @interface SuppressSysoutChecks {
+    /** Point to JIRA entry. */
+    public String bugUrl();
+  }
+  
   // -----------------------------------------------------------------
   // Truly immutable fields and constants, initialized once and valid 
   // for all suites ever since.
@@ -360,11 +382,13 @@ public abstract class LuceneTestCase ext
 
   /**
    * True if and only if tests are run in verbose mode. If this flag is false
-   * tests are not expected to print any messages.
+   * tests are not expected to print any messages. Enforced with {@link TestRuleDisallowSysouts}.
    */
   public static final boolean VERBOSE = systemPropertyAsBoolean("tests.verbose", false);
 
-  /** TODO: javadoc? */
+  /**
+   * Enables or disables dumping of {@link InfoStream} messages. 
+   */
   public static final boolean INFOSTREAM = systemPropertyAsBoolean("tests.infostream", VERBOSE);
 
   /**
@@ -478,7 +502,7 @@ public abstract class LuceneTestCase ext
   /**
    * Suite failure marker (any error in the test or suite scope).
    */
-  public static TestRuleMarkFailure suiteFailureMarker;
+  private static TestRuleMarkFailure suiteFailureMarker;
 
   /**
    * Ignore tests after hitting a designated number of initial failures. This
@@ -511,6 +535,15 @@ public abstract class LuceneTestCase ext
             new TestRuleIgnoreAfterMaxFailures(maxFailures));
     ignoreAfterMaxFailures = TestRuleDelegate.of(ignoreAfterMaxFailuresDelegate);
   }
+  
+  /**
+   * Try to capture streams early so that other classes don't have a chance to steal references
+   * to them (as is the case with ju.logging handlers).
+   */
+  static {
+    TestRuleDisallowSysouts.checkCaptureStreams();
+    Logger.getGlobal().getHandlers();
+  }
 
   /**
    * Temporarily substitute the global {@link TestRuleIgnoreAfterMaxFailures}. See
@@ -545,6 +578,7 @@ public abstract class LuceneTestCase ext
     .around(ignoreAfterMaxFailures)
     .around(suiteFailureMarker = new TestRuleMarkFailure())
     .around(new TestRuleAssertionsRequired())
+    .around(new TestRuleDisallowSysouts(suiteFailureMarker))
     .around(new TemporaryFilesCleanupRule())
     .around(new StaticFieldsInvariantRule(STATIC_LEAK_THRESHOLD, true) {
       @Override
@@ -2359,6 +2393,12 @@ public abstract class LuceneTestCase ext
     }
   }
 
+  /**
+   * Checks and cleans up temporary files.
+   * 
+   * @see LuceneTestCase#createTempDir()
+   * @see LuceneTestCase#createTempFile()
+   */
   private static class TemporaryFilesCleanupRule extends TestRuleAdapter {
     @Override
     protected void before() throws Throwable {

Modified: lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/RunListenerPrintReproduceInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/RunListenerPrintReproduceInfo.java?rev=1589645&r1=1589108&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/RunListenerPrintReproduceInfo.java (original)
+++ lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/RunListenerPrintReproduceInfo.java Thu Apr 24 09:22:03 2014
@@ -154,6 +154,9 @@ public final class RunListenerPrintRepro
     addVmOpt(b, "testcase", RandomizedContext.current().getTargetClass().getSimpleName());
     addVmOpt(b, "tests.method", testName);
     addVmOpt(b, "tests.seed", RandomizedContext.current().getRunnerSeedAsString());
+    
+    // Misc switches.
+    addVmOpt(b, SYSPROP_SYSOUTS, System.getProperty(SYSPROP_SYSOUTS));
 
     // Test groups and multipliers.
     if (RANDOM_MULTIPLIER > 1) addVmOpt(b, "tests.multiplier", RANDOM_MULTIPLIER);

Added: lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleDisallowSysouts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleDisallowSysouts.java?rev=1589645&view=auto
==============================================================================
--- lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleDisallowSysouts.java (added)
+++ lucene/dev/branches/LUCENE-5622/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleDisallowSysouts.java Thu Apr 24 09:22:03 2014
@@ -0,0 +1,193 @@
+package org.apache.lucene.util;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
+
+import com.carrotsearch.randomizedtesting.RandomizedTest;
+import com.carrotsearch.randomizedtesting.rules.TestRuleAdapter;
+
+
+/*
+ * 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.
+ */
+
+/**
+ * Fails the suite if it prints anything to {@link System#out} or {@link System#err},
+ * unless the condition is not enforced (see {@link #isEnforced()}).
+ */
+public class TestRuleDisallowSysouts extends TestRuleAdapter {
+  /** 
+   * Stack trace of any thread that wrote something to sysout or syserr. 
+   */
+  private final static AtomicReference<StackTraceElement[]> firstWriteStack = new AtomicReference<StackTraceElement[]>();
+
+  private final static DelegateStream capturedSystemOut;
+  private final static DelegateStream capturedSystemErr;
+  
+  static {
+    System.out.flush();
+    System.err.flush();
+
+    final String csn = Charset.defaultCharset().name();
+    capturedSystemOut = new DelegateStream(System.out, csn, firstWriteStack);
+    capturedSystemErr = new DelegateStream(System.err, csn, firstWriteStack);
+
+    System.setOut(capturedSystemOut.printStream);
+    System.setErr(capturedSystemErr.printStream);
+  }
+
+  /**
+   * Test failures from any tests or rules before.
+   */
+  private final TestRuleMarkFailure failureMarker;
+
+  /**
+   * Sets {@link #firstWriteStack} to the current stack trace upon the first actual write
+   * to an underlying stream.
+   */
+  static class DelegateStream extends FilterOutputStream {
+    private final AtomicReference<StackTraceElement[]> firstWriteStack;
+    final PrintStream printStream;
+
+    public DelegateStream(OutputStream delegate, String charset, AtomicReference<StackTraceElement[]> firstWriteStack) {
+      super(delegate);
+      try {
+        this.firstWriteStack = firstWriteStack;
+        this.printStream = new PrintStream(this, true, charset);
+      } catch (UnsupportedEncodingException e) {
+        throw new RuntimeException(e);
+      }
+    }
+
+    // Do override all three write() methods to make sure nothing slips through.
+
+    @Override
+    public void write(byte[] b) throws IOException {
+      if (b.length > 0) {
+        bytesWritten();
+      }
+      super.write(b);
+    }
+    
+    @Override
+    public void write(byte[] b, int off, int len) throws IOException {
+      if (len > 0) {
+        bytesWritten();
+      }
+      super.write(b, off, len);
+    }
+
+    @Override
+    public void write(int b) throws IOException {
+      bytesWritten();
+      super.write(b);
+    }
+    
+    private void bytesWritten() {
+      // This check isn't really needed, but getting the stack is expensive and may involve
+      // jit deopts, so we'll do it anyway.
+      if (firstWriteStack.get() == null) {
+        firstWriteStack.compareAndSet(null, Thread.currentThread().getStackTrace());
+      }
+    }
+  }
+  
+  public TestRuleDisallowSysouts(TestRuleMarkFailure failureMarker) {
+    this.failureMarker = failureMarker;
+  }
+
+  
+  /** */
+  @Override
+  protected void before() throws Throwable {
+    if (isEnforced()) {
+      checkCaptureStreams();
+    }
+    resetCaptureState();
+  }
+
+  /**
+   * Ensures {@link System#out} and {@link System#err} point to delegate streams.
+   */
+  public static void checkCaptureStreams() {
+    // Make sure we still hold the right references to wrapper streams.
+    if (System.out != capturedSystemOut.printStream) {
+      throw new AssertionError("Something has changed System.out to: " + System.out.getClass().getName());
+    }
+    if (System.err != capturedSystemErr.printStream) {
+      throw new AssertionError("Something has changed System.err to: " + System.err.getClass().getName());
+    }
+  }
+
+  protected boolean isEnforced() {
+    if (LuceneTestCase.VERBOSE || 
+        LuceneTestCase.INFOSTREAM ||
+        RandomizedTest.getContext().getTargetClass().isAnnotationPresent(SuppressSysoutChecks.class)) {
+      return false;
+    }
+    
+    return !RandomizedTest.systemPropertyAsBoolean(LuceneTestCase.SYSPROP_SYSOUTS, true);
+  }
+
+  /**
+   * We're only interested in failing the suite if it was successful. Otherwise
+   * just propagate the original problem and don't bother.
+   */
+  @Override
+  protected void afterIfSuccessful() throws Throwable {
+    if (isEnforced()) {
+      checkCaptureStreams();
+  
+      // Flush any buffers.
+      capturedSystemOut.printStream.flush();
+      capturedSystemErr.printStream.flush();
+  
+      // And check for offenders, but only if everything was successful so far.
+      StackTraceElement[] offenderStack = firstWriteStack.get();
+      if (offenderStack != null && failureMarker.wasSuccessful()) {
+        AssertionError e = new AssertionError("The test or suite printed information to stdout or stderr," +
+            " even though verbose mode is turned off and it's not annotated with @" + 
+            SuppressSysoutChecks.class.getSimpleName() + ". This exception contains the stack" +
+                " trace of the first offending call.");
+        e.setStackTrace(offenderStack);
+        throw e;
+      }
+    }
+  }
+
+  /**
+   * Restore original streams.
+   */
+  @Override
+  protected void afterAlways(List<Throwable> errors) throws Throwable {
+    resetCaptureState();
+  }
+
+  private void resetCaptureState() {
+    capturedSystemOut.printStream.flush();
+    capturedSystemErr.printStream.flush();
+    firstWriteStack.set(null);
+  }  
+}
+

Modified: lucene/dev/branches/LUCENE-5622/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-5622/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1589645&r1=1589047&r2=1589645&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-5622/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/branches/LUCENE-5622/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Thu Apr 24 09:22:03 2014
@@ -58,6 +58,7 @@ import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.QuickPatchThreadsFilter;
 import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
 import org.apache.solr.client.solrj.impl.HttpClientConfigurer;
 import org.apache.solr.client.solrj.impl.HttpClientUtil;
 import org.apache.solr.client.solrj.util.ClientUtils;
@@ -118,6 +119,7 @@ import com.carrotsearch.randomizedtestin
     SolrIgnoredThreadsFilter.class,
     QuickPatchThreadsFilter.class
 })
+@SuppressSysoutChecks(bugUrl = "Solr dumps logs to console.")
 public abstract class SolrTestCaseJ4 extends LuceneTestCase {
   private static String coreName = ConfigSolrXmlOld.DEFAULT_DEFAULT_CORE_NAME;
   public static int DEFAULT_CONNECTION_TIMEOUT = 60000;  // default socket connection timeout in ms