Index: contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java =================================================================== --- contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java (revision 922888) +++ contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java (working copy) @@ -84,7 +84,7 @@ */ private void assertCorrectOutput(String snowballLanguage, String dataDirectory) throws IOException { - System.err.println("checking snowball language: " + snowballLanguage); + if (VERBOSE) System.out.println("checking snowball language: " + snowballLanguage); TokenStream filter = new SnowballFilter(tokenizer, snowballLanguage); InputStream vocFile = new FileInputStream(new File(dataRoot, dataDirectory + "/voc.txt")); Index: contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java =================================================================== --- contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java (revision 922888) +++ contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java (working copy) @@ -56,7 +56,6 @@ */ public class TestPerfTasksLogic extends LuceneTestCase { - private static final boolean DEBUG = false; static final String NEW_LINE = System.getProperty("line.separator"); // properties in effect in all tests here @@ -550,7 +549,7 @@ } private static void logTstLogic (String txt) { - if (!DEBUG) + if (!VERBOSE) return; System.out.println("Test logic of:"); System.out.println(txt); Index: contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java =================================================================== --- contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java (revision 922888) +++ contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java (working copy) @@ -127,7 +127,7 @@ Transaction txn = env.beginTransaction(null, null); Directory store = null; - System.out.println("Writing files byte by byte"); + if (VERBOSE) System.out.println("Writing files byte by byte"); try { store = new JEDirectory(txn, index, blocks); @@ -159,11 +159,13 @@ end = new Date(); - duration = (int) (end.getTime() - start.getTime()); - System.out.print(duration); - System.out.print(" total milliseconds to create, "); - System.out.print(totalLength / duration); - System.out.println(" kb/s"); + if (VERBOSE) { + duration = (int) (end.getTime() - start.getTime()); + System.out.print(duration); + System.out.print(" total milliseconds to create, "); + System.out.print(totalLength / duration); + System.out.println(" kb/s"); + } try { txn = env.beginTransaction(null, null); @@ -208,11 +210,13 @@ end = new Date(); - duration = (int) (end.getTime() - start.getTime()); - System.out.print(duration); - System.out.print(" total milliseconds to read, "); - System.out.print(totalLength / duration); - System.out.println(" kb/s"); + if (VERBOSE) { + duration = (int) (end.getTime() - start.getTime()); + System.out.print(duration); + System.out.print(" total milliseconds to read, "); + System.out.print(totalLength / duration); + System.out.println(" kb/s"); + } try { txn = env.beginTransaction(null, null); @@ -244,11 +248,13 @@ end = new Date(); - System.out.print(end.getTime() - start.getTime()); - System.out.println(" total milliseconds to delete"); + if (VERBOSE) { + System.out.print(end.getTime() - start.getTime()); + System.out.println(" total milliseconds to delete"); - System.out.print(end.getTime() - veryStart.getTime()); - System.out.println(" total milliseconds"); + System.out.print(end.getTime() - veryStart.getTime()); + System.out.println(" total milliseconds"); + } } public void testDelete() throws Exception { @@ -267,7 +273,7 @@ Transaction txn = env.beginTransaction(null, null); Directory store = null; - System.out.println("Writing files byte by byte"); + if (VERBOSE) System.out.println("Writing files byte by byte"); try { store = new JEDirectory(txn, index, blocks); @@ -299,11 +305,13 @@ end = new Date(); - duration = (int) (end.getTime() - start.getTime()); - System.out.print(duration); - System.out.print(" total milliseconds to read, "); - System.out.print(totalLength / duration); - System.out.println(" kb/s"); + if (VERBOSE) { + duration = (int) (end.getTime() - start.getTime()); + System.out.print(duration); + System.out.print(" total milliseconds to read, "); + System.out.print(totalLength / duration); + System.out.println(" kb/s"); + } try { txn = env.beginTransaction(null, null); @@ -337,14 +345,16 @@ end = new Date(); - System.out.print(end.getTime() - start.getTime()); - System.out.println(" total milliseconds to delete even files"); + if (VERBOSE) { + System.out.print(end.getTime() - start.getTime()); + System.out.println(" total milliseconds to delete even files"); - duration = (int) (end.getTime() - start.getTime()); - System.out.print(duration); - System.out.print(" total milliseconds to create, "); - System.out.print(totalLength / duration); - System.out.println(" kb/s"); + duration = (int) (end.getTime() - start.getTime()); + System.out.print(duration); + System.out.print(" total milliseconds to create, "); + System.out.print(totalLength / duration); + System.out.println(" kb/s"); + } try { txn = env.beginTransaction(null, null); @@ -395,11 +405,13 @@ end = new Date(); - duration = (int) (end.getTime() - start.getTime()); - System.out.print(duration); - System.out.print(" total milliseconds to read, "); - System.out.print(totalLength / duration); - System.out.println(" kb/s"); + if (VERBOSE) { + duration = (int) (end.getTime() - start.getTime()); + System.out.print(duration); + System.out.print(" total milliseconds to read, "); + System.out.print(totalLength / duration); + System.out.println(" kb/s"); + } try { txn = env.beginTransaction(null, null); @@ -434,11 +446,13 @@ end = new Date(); - System.out.print(end.getTime() - start.getTime()); - System.out.println(" total milliseconds to delete"); + if (VERBOSE) { + System.out.print(end.getTime() - start.getTime()); + System.out.println(" total milliseconds to delete"); - System.out.print(end.getTime() - veryStart.getTime()); - System.out.println(" total milliseconds"); + System.out.print(end.getTime() - veryStart.getTime()); + System.out.println(" total milliseconds"); + } Cursor cursor = null; try { @@ -491,7 +505,7 @@ Transaction txn = env.beginTransaction(null, null); Directory store = null; - System.out.println("Writing files as one byte array"); + if (VERBOSE) System.out.println("Writing files as one byte array"); try { store = new JEDirectory(txn, index, blocks); @@ -521,11 +535,13 @@ end = new Date(); - duration = (int) (end.getTime() - start.getTime()); - System.out.print(duration); - System.out.print(" total milliseconds to create, "); - System.out.print(totalLength / duration); - System.out.println(" kb/s"); + if (VERBOSE) { + duration = (int) (end.getTime() - start.getTime()); + System.out.print(duration); + System.out.print(" total milliseconds to create, "); + System.out.print(totalLength / duration); + System.out.println(" kb/s"); + } try { txn = env.beginTransaction(null, null); @@ -571,11 +587,13 @@ end = new Date(); - duration = (int) (end.getTime() - start.getTime()); - System.out.print(duration); - System.out.print(" total milliseconds to read, "); - System.out.print(totalLength / duration); - System.out.println(" kb/s"); + if (VERBOSE) { + duration = (int) (end.getTime() - start.getTime()); + System.out.print(duration); + System.out.print(" total milliseconds to read, "); + System.out.print(totalLength / duration); + System.out.println(" kb/s"); + } try { txn = env.beginTransaction(null, null); @@ -607,10 +625,12 @@ end = new Date(); - System.out.print(end.getTime() - start.getTime()); - System.out.println(" total milliseconds to delete"); + if (VERBOSE) { + System.out.print(end.getTime() - start.getTime()); + System.out.println(" total milliseconds to delete"); - System.out.print(end.getTime() - veryStart.getTime()); - System.out.println(" total milliseconds"); + System.out.print(end.getTime() - veryStart.getTime()); + System.out.println(" total milliseconds"); + } } } Index: contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java =================================================================== --- contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java (revision 922888) +++ contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java (working copy) @@ -129,7 +129,7 @@ Transaction txn = env.beginTransaction(null, null); Directory store = null; - System.out.println("Writing files byte by byte"); + if (VERBOSE) System.out.println("Writing files byte by byte"); try { store = new DbDirectory(txn, index, blocks); @@ -161,11 +161,13 @@ end = new Date(); - duration = (int) (end.getTime() - start.getTime()); - System.out.print(duration); - System.out.print(" total milliseconds to create, "); - System.out.print(totalLength / duration); - System.out.println(" kb/s"); + if (VERBOSE) { + duration = (int) (end.getTime() - start.getTime()); + System.out.print(duration); + System.out.print(" total milliseconds to create, "); + System.out.print(totalLength / duration); + System.out.println(" kb/s"); + } try { txn = env.beginTransaction(null, null); @@ -211,11 +213,13 @@ end = new Date(); - duration = (int) (end.getTime() - start.getTime()); - System.out.print(duration); - System.out.print(" total milliseconds to read, "); - System.out.print(totalLength / duration); - System.out.println(" kb/s"); + if (VERBOSE) { + duration = (int) (end.getTime() - start.getTime()); + System.out.print(duration); + System.out.print(" total milliseconds to read, "); + System.out.print(totalLength / duration); + System.out.println(" kb/s"); + } try { txn = env.beginTransaction(null, null); @@ -248,11 +252,13 @@ end = new Date(); - System.out.print(end.getTime() - start.getTime()); - System.out.println(" total milliseconds to delete"); + if (VERBOSE) { + System.out.print(end.getTime() - start.getTime()); + System.out.println(" total milliseconds to delete"); - System.out.print(end.getTime() - veryStart.getTime()); - System.out.println(" total milliseconds"); + System.out.print(end.getTime() - veryStart.getTime()); + System.out.println(" total milliseconds"); + } } public void testArrays() @@ -274,7 +280,7 @@ Transaction txn = env.beginTransaction(null, null); Directory store = null; - System.out.println("Writing files as one byte array"); + if (VERBOSE) System.out.println("Writing files as one byte array"); try { store = new DbDirectory(txn, index, blocks); @@ -304,11 +310,13 @@ end = new Date(); - duration = (int) (end.getTime() - start.getTime()); - System.out.print(duration); - System.out.print(" total milliseconds to create, "); - System.out.print(totalLength / duration); - System.out.println(" kb/s"); + if (VERBOSE) { + duration = (int) (end.getTime() - start.getTime()); + System.out.print(duration); + System.out.print(" total milliseconds to create, "); + System.out.print(totalLength / duration); + System.out.println(" kb/s"); + } try { txn = env.beginTransaction(null, null); @@ -355,11 +363,13 @@ end = new Date(); - duration = (int) (end.getTime() - start.getTime()); - System.out.print(duration); - System.out.print(" total milliseconds to read, "); - System.out.print(totalLength / duration); - System.out.println(" kb/s"); + if (VERBOSE) { + duration = (int) (end.getTime() - start.getTime()); + System.out.print(duration); + System.out.print(" total milliseconds to read, "); + System.out.print(totalLength / duration); + System.out.println(" kb/s"); + } try { txn = env.beginTransaction(null, null); @@ -392,10 +402,12 @@ end = new Date(); - System.out.print(end.getTime() - start.getTime()); - System.out.println(" total milliseconds to delete"); + if (VERBOSE) { + System.out.print(end.getTime() - start.getTime()); + System.out.println(" total milliseconds to delete"); - System.out.print(end.getTime() - veryStart.getTime()); - System.out.println(" total milliseconds"); + System.out.print(end.getTime() - veryStart.getTime()); + System.out.println(" total milliseconds"); + } } } Index: contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragListBuilderTest.java =================================================================== --- contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragListBuilderTest.java (revision 922888) +++ contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragListBuilderTest.java (working copy) @@ -48,7 +48,7 @@ SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.createFieldFragList( fpl( "\"abcdefgh jklmnopqrs\"", "abcdefgh jklmnopqrs" ), SimpleFragListBuilder.MIN_FRAG_CHAR_SIZE ); assertEquals( 1, ffl.fragInfos.size() ); - System.out.println( ffl.fragInfos.get( 0 ).toString() ); + if (VERBOSE) System.out.println( ffl.fragInfos.get( 0 ).toString() ); assertEquals( "subInfos=(abcdefghjklmnopqrs((0,21)))/1.0(0,21)", ffl.fragInfos.get( 0 ).toString() ); } Index: contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java =================================================================== --- contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java (revision 922888) +++ contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java (working copy) @@ -140,7 +140,7 @@ String fragment = highlighter.getBestFragment(stream, storedField); - System.out.println(fragment); + if (VERBOSE) System.out.println(fragment); } } @@ -156,7 +156,7 @@ Query q = parser.parse("\"world Flatland\"~3"); String expected = "I call our world Flatland, not because we call it so,"; String observed = highlightField(q, "SOME_FIELD_NAME", s1); - System.out.println("Expected: \"" + expected + "\n" + "Observed: \"" + observed); + if (VERBOSE) System.out.println("Expected: \"" + expected + "\n" + "Observed: \"" + observed); assertEquals("Query in the default field results in text for *ANY* field being highlighted", expected, observed); @@ -168,7 +168,7 @@ q = parser.parse("text:\"world Flatland\"~3"); expected = s1; observed = highlightField(q, FIELD_NAME, s1); - System.out.println("Expected: \"" + expected + "\n" + "Observed: \"" + observed); + if (VERBOSE) System.out.println("Expected: \"" + expected + "\n" + "Observed: \"" + observed); assertEquals( "Query in a named field does not result in highlighting when that field isn't in the query", s1, highlightField(q, FIELD_NAME, s1)); @@ -207,7 +207,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } // Not sure we can assert anything here - just running to check we dont @@ -256,7 +256,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", @@ -278,7 +278,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", @@ -300,7 +300,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", @@ -326,7 +326,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", @@ -350,7 +350,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", @@ -375,7 +375,7 @@ // String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired,"..."); - //System.out.println("\t" + result); + //if (VERBOSE) System.out.println("\t" + result); } @@ -396,7 +396,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", @@ -418,7 +418,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); assertTrue("Failed to find correct number of highlights " + numHighlights + " found", numHighlights == 3); @@ -441,7 +441,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } @@ -460,7 +460,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } } @@ -482,7 +482,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); assertTrue("Failed to find correct number of highlights " + numHighlights + " found", numHighlights == 4); @@ -551,7 +551,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } // Not sure we can assert anything here - just running to check we dont // throw any exceptions @@ -700,7 +700,7 @@ // can't rewrite ConstantScore if you want to highlight it - // it rewrites to ConstantScoreQuery which cannot be highlighted // query = unReWrittenQuery.rewrite(reader); - System.out.println("Searching for: " + query.toString(FIELD_NAME)); + if (VERBOSE) System.out.println("Searching for: " + query.toString(FIELD_NAME)); hits = searcher.search(query, null, 1000); for (int i = 0; i < hits.totalHits; i++) { @@ -720,7 +720,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, fragmentSeparator); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", numHighlights == 5); @@ -748,7 +748,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, fragmentSeparator); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", numHighlights == 5); @@ -776,7 +776,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, fragmentSeparator); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", numHighlights == 5); @@ -932,7 +932,7 @@ HighlighterTest.this); highlighter.setTextFragmenter(new SimpleFragmenter(40)); String result = highlighter.getBestFragment(tokenStream, text); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", numHighlights == 4); @@ -1063,7 +1063,7 @@ Highlighter highlighter = getHighlighter(query, FIELD_NAME, tokenStream, HighlighterTest.this); String result = highlighter.getBestFragment(tokenStream, text); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", numHighlights == 4); @@ -1097,7 +1097,7 @@ assertTrue("Failed to find correct number of text Fragments: " + fragmentResults.length + " vs " + stringResults.length, fragmentResults.length == stringResults.length); for (int j = 0; j < stringResults.length; j++) { - System.out.println(fragmentResults[j]); + if (VERBOSE) System.out.println(fragmentResults[j]); assertTrue("Failed to find same text Fragments: " + fragmentResults[j] + " found", fragmentResults[j].toString().equals(stringResults[j])); @@ -1215,7 +1215,7 @@ QueryParser parser = new QueryParser(TEST_VERSION_CURRENT, FIELD_NAME, analyzer); Query query = parser.parse("JF? or Kenned*"); - System.out.println("Searching with primitive query"); + if (VERBOSE) System.out.println("Searching with primitive query"); // forget to set this and... // query=query.rewrite(reader); TopDocs hits = searcher.search(query, null, 1000); @@ -1238,7 +1238,7 @@ String highlightedText = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println(highlightedText); + if (VERBOSE) System.out.println(highlightedText); } // We expect to have zero highlights if the query is multi-terms and is // not @@ -1353,7 +1353,7 @@ QueryParser parser = new QueryParser(TEST_VERSION_CURRENT, FIELD_NAME, new StandardAnalyzer(TEST_VERSION_CURRENT)); parser.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE); query = parser.parse("multi*"); - System.out.println("Searching for: " + query.toString(FIELD_NAME)); + if (VERBOSE) System.out.println("Searching for: " + query.toString(FIELD_NAME)); // at this point the multisearcher calls combine(query[]) hits = multiSearcher.search(query, null, 1000); @@ -1371,7 +1371,7 @@ String text = multiSearcher.doc(hits.scoreDocs[i].doc).get(FIELD_NAME); TokenStream tokenStream = analyzer.tokenStream(FIELD_NAME, new StringReader(text)); String highlightedText = highlighter.getBestFragment(tokenStream, text); - System.out.println(highlightedText); + if (VERBOSE) System.out.println(highlightedText); } assertTrue("Failed to find correct number of highlights " + numHighlights + " found", numHighlights == 2); @@ -1645,7 +1645,7 @@ for( int i = 0; i < hits.totalHits; i++ ){ Document doc = searcher.doc( hits.scoreDocs[i].doc ); String result = h.getBestFragment( a, "t_text1", doc.get( "t_text1" )); - System.out.println("result:" + result); + if (VERBOSE) System.out.println("result:" + result); assertEquals("more random words for second field", result); } searcher.close(); @@ -1698,7 +1698,7 @@ // for any multi-term queries to work (prefix, wildcard, range,fuzzy etc) // you must use a rewritten query! query = unReWrittenQuery.rewrite(reader); - System.out.println("Searching for: " + query.toString(FIELD_NAME)); + if (VERBOSE) System.out.println("Searching for: " + query.toString(FIELD_NAME)); hits = searcher.search(query, null, 1000); } @@ -1714,7 +1714,7 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, "..."); - System.out.println("\t" + result); + if (VERBOSE) System.out.println("\t" + result); assertTrue("Failed to find correct number of highlights " + numHighlights + " found", numHighlights == expectedHighlights); @@ -1936,16 +1936,16 @@ String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired, fragmentSeparator); - System.out.println("\t" + result); + if (HighlighterTest.VERBOSE) System.out.println("\t" + result); } } abstract void run() throws Exception; void start() throws Exception { - System.out.println("Run QueryScorer"); + if (HighlighterTest.VERBOSE) System.out.println("Run QueryScorer"); run(); - System.out.println("Run QueryTermScorer"); + if (HighlighterTest.VERBOSE) System.out.println("Run QueryTermScorer"); mode = QUERY_TERM; run(); } Index: contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java =================================================================== --- contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java (revision 922888) +++ contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java (working copy) @@ -202,8 +202,6 @@ private Analyzer analyzer; - private final boolean verbose = false; - private static final String FIELD_NAME = "content"; /** Runs the tests and/or benchmark */ @@ -227,7 +225,7 @@ "src/java/test/org/apache/lucene/queryParser/*.java", "contrib/memory/src/java/org/apache/lucene/index/memory/*.java", }); - System.out.println("files = " + java.util.Arrays.asList(files)); + if (VERBOSE) System.out.println("files = " + java.util.Arrays.asList(files)); String[] xargs = new String[] { "1", "1", "memram", "@contrib/memory/src/test/org/apache/lucene/index/memory/testqueries.txt", @@ -285,7 +283,7 @@ boolean first = true; for (int iter=0; iter < iters; iter++) { - System.out.println("\n########### iteration=" + iter); + if (VERBOSE) System.out.println("\n########### iteration=" + iter); long start = System.currentTimeMillis(); long bytes = 0; @@ -298,7 +296,7 @@ bytes += file.length(); String text = toString(new FileInputStream(file), null); Document doc = createDocument(text); - if (verbose) System.out.println("\n*********** FILE=" + file); + if (VERBOSE) System.out.println("\n*********** FILE=" + file); boolean measureIndexing = false; // toggle this to measure query performance MemoryIndex memind = null; @@ -342,7 +340,7 @@ } if (useRAMIndex) score2 = query(ramsearcher, query); if (useMemIndex && useRAMIndex) { - if (verbose) System.out.println("diff="+ (score1-score2) + ", query=" + queries[q] + ", s1=" + score1 + ", s2=" + score2); + if (VERBOSE) System.out.println("diff="+ (score1-score2) + ", query=" + queries[q] + ", s1=" + score1 + ", s2=" + score2); if (score1 != score2 || score1 < 0.0f || score2 < 0.0f || score1 > 1.0f || score2 > 1.0f) { throw new IllegalStateException("BUG DETECTED:" + (i*(q+1)) + " at query=" + queries[q] + ", file=" + file + ", anal=" + analyzer); } @@ -351,21 +349,25 @@ } catch (Throwable t) { if (t instanceof OutOfMemoryError) t.printStackTrace(); - System.out.println("Fatal error at query=" + queries[q] + ", file=" + file + ", anal=" + analyzer); + if (VERBOSE) System.out.println("Fatal error at query=" + queries[q] + ", file=" + file + ", anal=" + analyzer); throw t; } } } } long end = System.currentTimeMillis(); - System.out.println("\nsecs = " + ((end-start)/1000.0f)); - System.out.println("queries/sec= " + + if (VERBOSE) { + System.out.println("\nsecs = " + ((end-start)/1000.0f)); + System.out.println("queries/sec= " + (1.0f * runs * queries.length * analyzers.length * files.length / ((end-start)/1000.0f))); - float mb = (1.0f * bytes * queries.length * runs) / (1024.0f * 1024.0f); - System.out.println("MB/sec = " + (mb / ((end-start)/1000.0f))); + float mb = (1.0f * bytes * queries.length * runs) / (1024.0f * 1024.0f); + System.out.println("MB/sec = " + (mb / ((end-start)/1000.0f))); + } } + if (!VERBOSE) return; + if (useMemIndex && useRAMIndex) System.out.println("No bug found. done."); else Index: contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/TestSpanQueryParserSimpleSample.java =================================================================== --- contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/TestSpanQueryParserSimpleSample.java (revision 922888) +++ contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/TestSpanQueryParserSimpleSample.java (working copy) @@ -19,8 +19,6 @@ import javax.management.Query; -import junit.framework.TestCase; - import org.apache.lucene.queryParser.core.config.QueryConfigHandler; import org.apache.lucene.queryParser.core.nodes.OrQueryNode; import org.apache.lucene.queryParser.core.nodes.QueryNode; @@ -29,6 +27,7 @@ import org.apache.lucene.queryParser.standard.parser.StandardSyntaxParser; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanTermQuery; +import org.apache.lucene.util.LuceneTestCase; /** * This test case demonstrates how the new query parser can be used.
@@ -94,7 +93,7 @@ * @see UniqueFieldAttribute * */ -public class TestSpanQueryParserSimpleSample extends TestCase { +public class TestSpanQueryParserSimpleSample extends LuceneTestCase { public TestSpanQueryParserSimpleSample() { // empty constructor @@ -104,12 +103,6 @@ super(testName); } - public static junit.framework.Test suite() { - junit.framework.TestSuite suite = new junit.framework.TestSuite( - TestSpanQueryParserSimpleSample.class); - return suite; - } - public void testBasicDemo() throws Exception { SyntaxParser queryParser = new StandardSyntaxParser(); @@ -133,13 +126,13 @@ spanProcessorPipeline.addProcessor(new UniqueFieldQueryNodeProcessor()); // print to show out the QueryNode tree before being processed - System.out.println(queryTree); + if (VERBOSE) System.out.println(queryTree); // Process the QueryTree using our new Processors queryTree = spanProcessorPipeline.process(queryTree); // print to show out the QueryNode tree after being processed - System.out.println(queryTree); + if (VERBOSE) System.out.println(queryTree); // create a instance off the Builder SpansQueryTreeBuilder spansQueryTreeBuilder = new SpansQueryTreeBuilder(); Index: contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java =================================================================== --- contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java (revision 922888) +++ contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java (working copy) @@ -1071,7 +1071,7 @@ .parse("(fieldX:xxxxx OR fieldy:xxxxxxxx)^2 AND (fieldx:the OR fieldy:foo)"); assertNotNull("result is null and it shouldn't be", result); assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery); - System.out.println("Result: " + result); + if (VERBOSE) System.out.println("Result: " + result); assertTrue(((BooleanQuery) result).clauses().size() + " does not equal: " + 2, ((BooleanQuery) result).clauses().size() == 2); } Index: contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java =================================================================== --- contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java (revision 922888) +++ contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java (working copy) @@ -151,13 +151,15 @@ LatLng p1 = new FloatLatLng( 7.06, 171.2 ); LatLng p2 = new FloatLatLng( 21.6032207, -158.0 ); double miles = p1.arcDistance( p2, DistanceUnits.MILES ); - System.out.println("testDistances"); - System.out.println("miles:" + miles); + if (VERBOSE) { + System.out.println("testDistances"); + System.out.println("miles:" + miles); + } assertEquals(2288.82495932794, miles); LatLng p3 = new FloatLatLng( 41.6032207, -73.087749); LatLng p4 = new FloatLatLng( 55.0, 4.0 ); miles = p3.arcDistance( p4, DistanceUnits.MILES ); - System.out.println("miles:" + miles); + if (VERBOSE) System.out.println("miles:" + miles); assertEquals(3474.331719997617, miles); } @@ -170,12 +172,12 @@ lat = 21.6032207; lng = -158.0; - System.out.println("testAntiM"); + if (VERBOSE) System.out.println("testAntiM"); // create a distance query final DistanceQueryBuilder dq = new DistanceQueryBuilder(lat, lng, miles, latField, lngField, CartesianTierPlotter.DEFALT_FIELD_PREFIX, true); - System.out.println(dq); + if (VERBOSE) System.out.println(dq); //create a term query to search against all documents Query tq = new TermQuery(new Term("metafile", "doc")); @@ -188,7 +190,7 @@ return new CustomScoreProvider(reader) { @Override // TODO: broken, as reader is not used! public float customScore(int doc, float subQueryScore, float valSrcScore){ - System.out.println(doc); + if (VERBOSE) System.out.println(doc); if (dq.distanceFilter.getDistance(doc) == null) return 0; @@ -228,11 +230,13 @@ // Note Boundary Box filtering, is not accurate enough for most systems. - System.out.println("Distance Filter filtered: " + distances.size()); - System.out.println("Results: " + results); - System.out.println("============================="); - System.out.println("Distances should be 2 "+ distances.size()); - System.out.println("Results should be 2 "+ results); + if (VERBOSE) { + System.out.println("Distance Filter filtered: " + distances.size()); + System.out.println("Results: " + results); + System.out.println("============================="); + System.out.println("Distances should be 2 "+ distances.size()); + System.out.println("Results should be 2 "+ results); + } assertEquals(2, distances.size()); // fixed a store of only needed distances assertEquals(2, results); @@ -247,7 +251,7 @@ double distance = DistanceUtils.getInstance().getDistanceMi(lat, lng, rsLat, rsLng); double llm = DistanceUtils.getInstance().getLLMDistance(lat, lng, rsLat, rsLng); - System.out.println("Name: "+ name +", Distance "+ distance); //(res, ortho, harvesine):"+ distance +" |"+ geo_distance +"|"+ llm +" | score "+ hits.score(i)); + if (VERBOSE) System.out.println("Name: "+ name +", Distance "+ distance); //(res, ortho, harvesine):"+ distance +" |"+ geo_distance +"|"+ llm +" | score "+ hits.score(i)); assertTrue(Math.abs((distance - llm)) < 1); assertTrue((distance < miles )); assertTrue(geo_distance >= lastDistance); @@ -262,13 +266,13 @@ lat = 41.6032207; lng = -73.087749; - System.out.println("testPoleFlipping"); + if (VERBOSE) System.out.println("testPoleFlipping"); // create a distance query final DistanceQueryBuilder dq = new DistanceQueryBuilder(lat, lng, miles, latField, lngField, CartesianTierPlotter.DEFALT_FIELD_PREFIX, true); - System.out.println(dq); + if (VERBOSE) System.out.println(dq); //create a term query to search against all documents Query tq = new TermQuery(new Term("metafile", "doc")); @@ -281,7 +285,7 @@ return new CustomScoreProvider(reader) { @Override // TODO: broken, as reader is not used! public float customScore(int doc, float subQueryScore, float valSrcScore){ - System.out.println(doc); + if (VERBOSE) System.out.println(doc); if (dq.distanceFilter.getDistance(doc) == null) return 0; @@ -321,11 +325,13 @@ // Note Boundary Box filtering, is not accurate enough for most systems. - System.out.println("Distance Filter filtered: " + distances.size()); - System.out.println("Results: " + results); - System.out.println("============================="); - System.out.println("Distances should be 18 "+ distances.size()); - System.out.println("Results should be 18 "+ results); + if (VERBOSE) { + System.out.println("Distance Filter filtered: " + distances.size()); + System.out.println("Results: " + results); + System.out.println("============================="); + System.out.println("Distances should be 18 "+ distances.size()); + System.out.println("Results should be 18 "+ results); + } assertEquals(18, distances.size()); // fixed a store of only needed distances assertEquals(18, results); @@ -339,11 +345,11 @@ double distance = DistanceUtils.getInstance().getDistanceMi(lat, lng, rsLat, rsLng); double llm = DistanceUtils.getInstance().getLLMDistance(lat, lng, rsLat, rsLng); - System.out.println("Name: "+ name +", Distance "+ distance); //(res, ortho, harvesine):"+ distance +" |"+ geo_distance +"|"+ llm +" | score "+ hits.score(i)); + if (VERBOSE) System.out.println("Name: "+ name +", Distance "+ distance); //(res, ortho, harvesine):"+ distance +" |"+ geo_distance +"|"+ llm +" | score "+ hits.score(i)); assertTrue(Math.abs((distance - llm)) < 1); - System.out.println("checking limit "+ distance + " < " + miles); + if (VERBOSE) System.out.println("checking limit "+ distance + " < " + miles); assertTrue((distance < miles )); - System.out.println("checking sort "+ geo_distance + " >= " + lastDistance); + if (VERBOSE) System.out.println("checking sort "+ geo_distance + " >= " + lastDistance); assertTrue(geo_distance >= lastDistance); lastDistance = geo_distance; } @@ -363,7 +369,7 @@ final DistanceQueryBuilder dq = new DistanceQueryBuilder(lat, lng, miles, latField, lngField, CartesianTierPlotter.DEFALT_FIELD_PREFIX, true); - System.out.println(dq); + if (VERBOSE) System.out.println(dq); //create a term query to search against all documents Query tq = new TermQuery(new Term("metafile", "doc")); @@ -375,7 +381,7 @@ return new CustomScoreProvider(reader) { @Override // TODO: broken, as reader is not used! public float customScore(int doc, float subQueryScore, float valSrcScore){ - //System.out.println(doc); + if (VERBOSE) System.out.println(doc); if (dq.distanceFilter.getDistance(doc) == null) return 0; @@ -413,12 +419,13 @@ // Note Boundary Box filtering, is not accurate enough for most systems. - - System.out.println("Distance Filter filtered: " + distances.size()); - System.out.println("Results: " + results); - System.out.println("============================="); - System.out.println("Distances should be 7 "+ expected[x] + ":" + distances.size()); - System.out.println("Results should be 7 "+ expected[x] + ":" + results); + if (VERBOSE) { + System.out.println("Distance Filter filtered: " + distances.size()); + System.out.println("Results: " + results); + System.out.println("============================="); + System.out.println("Distances should be 7 "+ expected[x] + ":" + distances.size()); + System.out.println("Results should be 7 "+ expected[x] + ":" + results); + } assertEquals(expected[x], distances.size()); // fixed a store of only needed distances assertEquals(expected[x], results); @@ -433,7 +440,7 @@ double distance = DistanceUtils.getInstance().getDistanceMi(lat, lng, rsLat, rsLng); double llm = DistanceUtils.getInstance().getLLMDistance(lat, lng, rsLat, rsLng); - System.out.println("Name: "+ name +", Distance "+ distance); //(res, ortho, harvesine):"+ distance +" |"+ geo_distance +"|"+ llm +" | score "+ hits.score(i)); + if (VERBOSE) System.out.println("Name: "+ name +", Distance "+ distance); //(res, ortho, harvesine):"+ distance +" |"+ geo_distance +"|"+ llm +" | score "+ hits.score(i)); assertTrue(Math.abs((distance - llm)) < 1); assertTrue((distance < miles )); assertTrue(geo_distance > lastDistance); @@ -457,7 +464,7 @@ final DistanceQueryBuilder dq = new DistanceQueryBuilder(lat, lng, miles, geoHashPrefix, CartesianTierPlotter.DEFALT_FIELD_PREFIX, true); - System.out.println(dq); + if (VERBOSE) System.out.println(dq); //create a term query to search against all documents Query tq = new TermQuery(new Term("metafile", "doc")); @@ -468,7 +475,7 @@ return new CustomScoreProvider(reader) { @Override // TODO: broken, as reader is not used! public float customScore(int doc, float subQueryScore, float valSrcScore){ - //System.out.println(doc); + if (VERBOSE) System.out.println(doc); if (dq.distanceFilter.getDistance(doc) == null) return 0; @@ -506,12 +513,13 @@ // Note Boundary Box filtering, is not accurate enough for most systems. - - System.out.println("Distance Filter filtered: " + distances.size()); - System.out.println("Results: " + results); - System.out.println("============================="); - System.out.println("Distances should be 14 "+ expected[x] + ":" + distances.size()); - System.out.println("Results should be 7 "+ expected[x] + ":" + results); + if (VERBOSE) { + System.out.println("Distance Filter filtered: " + distances.size()); + System.out.println("Results: " + results); + System.out.println("============================="); + System.out.println("Distances should be 14 "+ expected[x] + ":" + distances.size()); + System.out.println("Results should be 7 "+ expected[x] + ":" + results); + } assertEquals(expected[x], distances.size()); assertEquals(expected[x], results); @@ -526,7 +534,7 @@ double distance = DistanceUtils.getInstance().getDistanceMi(lat, lng, rsLat, rsLng); double llm = DistanceUtils.getInstance().getLLMDistance(lat, lng, rsLat, rsLng); - System.out.println("Name: "+ name +", Distance (res, ortho, harvesine):"+ distance +" |"+ geo_distance +"|"+ llm +" | score "+ scoreDocs[i].score); + if (VERBOSE) System.out.println("Name: "+ name +", Distance (res, ortho, harvesine):"+ distance +" |"+ geo_distance +"|"+ llm +" | score "+ scoreDocs[i].score); assertTrue(Math.abs((distance - llm)) < 1); assertTrue((distance < miles )); Index: contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java =================================================================== --- contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java (revision 922888) +++ contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java (working copy) @@ -106,7 +106,7 @@ } } - + /* these tests do not test anything, as no assertions: public void testMiles() { double LLM = DistanceUtils.getInstance().getLLMDistance(lat, lng,39.012200001, -77.3942); System.out.println(LLM); @@ -120,7 +120,7 @@ System.out.println("-->"+DistanceUtils.getInstance().getDistanceMi(44.30073, -78.32131, 43.687267, -79.39842)); } - + */ // public void testDistanceQueryCacheable() throws IOException { // Index: contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java =================================================================== --- contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java (revision 922888) +++ contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java (working copy) @@ -5,8 +5,6 @@ import java.io.InputStream; import java.io.InputStreamReader; -import junit.framework.TestCase; - import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Field; @@ -20,6 +18,7 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.Version; +import org.apache.lucene.util.LuceneTestCase; /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -37,7 +36,7 @@ * limitations under the License. */ -public class TestParser extends TestCase { +public class TestParser extends LuceneTestCase { CoreParser builder; static Directory dir; @@ -45,11 +44,7 @@ Analyzer analyzer=new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_24); IndexReader reader; private IndexSearcher searcher; - - //CHANGE THIS TO SEE OUTPUT - boolean printResults=false; - - + /* * @see TestCase#setUp() */ @@ -143,7 +138,7 @@ { Query q=parse("FuzzyLikeThisQuery.xml"); //show rewritten fuzzyLikeThisQuery - see what is being matched on - if(printResults) + if(VERBOSE) { System.out.println(q.rewrite(reader)); } @@ -210,7 +205,7 @@ { TopDocs hits = searcher.search(q, null, numDocs); assertTrue(qType +" should produce results ", hits.totalHits>0); - if(printResults) + if(VERBOSE) { System.out.println("========="+qType+"============"); ScoreDoc[] scoreDocs = hits.scoreDocs; Index: src/test/org/apache/lucene/analysis/TestStopFilter.java =================================================================== --- src/test/org/apache/lucene/analysis/TestStopFilter.java (revision 922888) +++ src/test/org/apache/lucene/analysis/TestStopFilter.java (working copy) @@ -30,8 +30,6 @@ public class TestStopFilter extends BaseTokenStreamTestCase { - - private final static boolean VERBOSE = false; // other StopFilter functionality is already tested by TestStopAnalyzer Index: src/test/org/apache/lucene/index/TestByteSlices.java =================================================================== --- src/test/org/apache/lucene/index/TestByteSlices.java (revision 922888) +++ src/test/org/apache/lucene/index/TestByteSlices.java (working copy) @@ -65,36 +65,34 @@ counters[stream] = 0; } - boolean debug = false; - for(int iter=0;iter<10000;iter++) { int stream = r.nextInt(NUM_STREAM); - if (debug) + if (VERBOSE) System.out.println("write stream=" + stream); if (starts[stream] == -1) { final int spot = pool.newSlice(ByteBlockPool.FIRST_LEVEL_SIZE); starts[stream] = uptos[stream] = spot + pool.byteOffset; - if (debug) + if (VERBOSE) System.out.println(" init to " + starts[stream]); } writer.init(uptos[stream]); int numValue = r.nextInt(20); for(int j=0;j iterator = set.iterator(); iterator.hasNext();) { TermVectorEntry entry = iterator.next(); assertTrue("entry is null and it shouldn't be", entry != null); - System.out.println("Entry: " + entry); + if (VERBOSE) System.out.println("Entry: " + entry); } } @@ -869,7 +869,6 @@ */ public void testDiskFull() throws IOException { - boolean debug = false; Term searchTerm = new Term("content", "aaa"); int START_COUNT = 157; int END_COUNT = 144; @@ -926,14 +925,14 @@ if (diskRatio >= 6.0) { rate = 0.0; } - if (debug) { + if (VERBOSE) { System.out.println("\ncycle: " + diskFree + " bytes"); } testName = "disk full during reader.close() @ " + thisDiskFree + " bytes"; } else { thisDiskFree = 0; rate = 0.0; - if (debug) { + if (VERBOSE) { System.out.println("\ncycle: same writer: unlimited disk space"); } testName = "reader re-use after disk full"; @@ -957,7 +956,7 @@ done = true; } } catch (IOException e) { - if (debug) { + if (VERBOSE) { System.out.println(" hit IOException: " + e); e.printStackTrace(System.out); } Index: src/test/org/apache/lucene/index/TestIndexWriter.java =================================================================== --- src/test/org/apache/lucene/index/TestIndexWriter.java (revision 922888) +++ src/test/org/apache/lucene/index/TestIndexWriter.java (working copy) @@ -170,8 +170,6 @@ int NUM_DIR = 50; int END_COUNT = START_COUNT + NUM_DIR*25; - boolean debug = false; - // Build up a bunch of dirs that have indexes which we // will then merge together by calling addIndexesNoOptimize(*): Directory[] dirs = new Directory[NUM_DIR]; @@ -231,7 +229,7 @@ for(int iter=0;iter<3;iter++) { - if (debug) + if (VERBOSE) System.out.println("TEST: iter=" + iter); // Start with 100 bytes more than we are currently using: @@ -290,16 +288,16 @@ if (diskRatio >= 6.0) { rate = 0.0; } - if (debug) + if (VERBOSE) testName = "disk full test " + methodName + " with disk full at " + diskFree + " bytes"; } else { thisDiskFree = 0; rate = 0.0; - if (debug) + if (VERBOSE) testName = "disk full test " + methodName + " with unlimited disk space"; } - if (debug) + if (VERBOSE) System.out.println("\ncycle: " + testName); dir.setMaxSizeInBytes(thisDiskFree); @@ -327,7 +325,7 @@ } success = true; - if (debug) { + if (VERBOSE) { System.out.println(" success!"); } @@ -338,7 +336,7 @@ } catch (IOException e) { success = false; err = e; - if (debug) { + if (VERBOSE) { System.out.println(" hit IOException: " + e); e.printStackTrace(System.out); } @@ -353,7 +351,7 @@ // ConcurrentMergeScheduler are done _TestUtil.syncConcurrentMerges(writer); - if (debug) { + if (VERBOSE) { System.out.println(" now test readers"); } @@ -404,7 +402,7 @@ searcher.close(); reader.close(); - if (debug) { + if (VERBOSE) { System.out.println(" count is " + result); } @@ -413,7 +411,7 @@ } } - if (debug) { + if (VERBOSE) { System.out.println(" start disk = " + startDiskUsage + "; input disk = " + inputDiskUsage + "; max used = " + dir.getMaxUsedSizeInBytes()); } @@ -455,15 +453,13 @@ */ public void testAddDocumentOnDiskFull() throws IOException { - boolean debug = false; - for(int pass=0;pass<2;pass++) { - if (debug) + if (VERBOSE) System.out.println("TEST: pass=" + pass); boolean doAbort = pass == 1; long diskFree = 200; while(true) { - if (debug) + if (VERBOSE) System.out.println("TEST: cycle: diskFree=" + diskFree); MockRAMDirectory dir = new MockRAMDirectory(); dir.setMaxSizeInBytes(diskFree); @@ -482,7 +478,7 @@ addDoc(writer); } } catch (IOException e) { - if (debug) { + if (VERBOSE) { System.out.println("TEST: exception on addDoc"); e.printStackTrace(System.out); } @@ -496,7 +492,7 @@ try { writer.close(); } catch (IOException e) { - if (debug) { + if (VERBOSE) { System.out.println("TEST: exception on close"); e.printStackTrace(System.out); } Index: src/test/org/apache/lucene/index/TestIndexWriterDelete.java =================================================================== --- src/test/org/apache/lucene/index/TestIndexWriterDelete.java (revision 922888) +++ src/test/org/apache/lucene/index/TestIndexWriterDelete.java (working copy) @@ -407,7 +407,6 @@ */ private void testOperationsOnDiskFull(boolean updates) throws IOException { - boolean debug = false; Term searchTerm = new Term("content", "aaa"); int START_COUNT = 157; int END_COUNT = 144; @@ -464,7 +463,7 @@ if (diskRatio >= 6.0) { rate = 0.0; } - if (debug) { + if (VERBOSE) { System.out.println("\ncycle: " + diskFree + " bytes"); } testName = "disk full during reader.close() @ " + thisDiskFree @@ -472,7 +471,7 @@ } else { thisDiskFree = 0; rate = 0.0; - if (debug) { + if (VERBOSE) { System.out.println("\ncycle: same writer: unlimited disk space"); } testName = "reader re-use after disk full"; @@ -506,7 +505,7 @@ } } catch (IOException e) { - if (debug) { + if (VERBOSE) { System.out.println(" hit IOException: " + e); e.printStackTrace(System.out); } Index: src/test/org/apache/lucene/index/TestIndexWriterExceptions.java =================================================================== --- src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (revision 922888) +++ src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (working copy) @@ -30,8 +30,6 @@ public class TestIndexWriterExceptions extends LuceneTestCase { - final private static boolean DEBUG = false; - private class IndexerThread extends Thread { IndexWriter writer; @@ -72,7 +70,7 @@ try { writer.updateDocument(idTerm, doc); } catch (RuntimeException re) { - if (DEBUG) { + if (VERBOSE) { System.out.println("EXC: "); re.printStackTrace(System.out); } @@ -120,7 +118,7 @@ @Override boolean testPoint(String name) { if (doFail.get() != null && !name.equals("startDoFlush") && r.nextInt(20) == 17) { - if (DEBUG) { + if (VERBOSE) { System.out.println(Thread.currentThread().getName() + ": NOW FAIL: " + name); //new Throwable().printStackTrace(System.out); } @@ -137,7 +135,7 @@ ((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).setSuppressExceptions(); //writer.setMaxBufferedDocs(10); - if (DEBUG) + if (VERBOSE) writer.setInfoStream(System.out); IndexerThread thread = new IndexerThread(0, writer); @@ -174,7 +172,7 @@ ((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).setSuppressExceptions(); //writer.setMaxBufferedDocs(10); - if (DEBUG) + if (VERBOSE) writer.setInfoStream(System.out); final int NUM_THREADS = 4; Index: src/test/org/apache/lucene/index/TestStressIndexing2.java =================================================================== --- src/test/org/apache/lucene/index/TestStressIndexing2.java (revision 922888) +++ src/test/org/apache/lucene/index/TestStressIndexing2.java (working copy) @@ -407,13 +407,8 @@ Collections.sort(ff1, fieldNameComparator); Collections.sort(ff2, fieldNameComparator); - if (ff1.size() != ff2.size()) { - System.out.println(ff1); - System.out.println(ff2); - assertEquals(ff1.size(), ff2.size()); - } + assertEquals(ff1 + " : " + ff2, ff1.size(), ff2.size()); - for (int i=0; i 2 protected static final String ID_FIELD = "id"; @@ -163,7 +161,7 @@ // debug messages (change DBG to true for anything to print) protected void log(Object o) { - if (DBG) { + if (VERBOSE) { System.out.println(o.toString()); } } Index: src/test/org/apache/lucene/search/payloads/PayloadHelper.java =================================================================== --- src/test/org/apache/lucene/search/payloads/PayloadHelper.java (revision 922888) +++ src/test/org/apache/lucene/search/payloads/PayloadHelper.java (working copy) @@ -108,7 +108,7 @@ PayloadAnalyzer analyzer = new PayloadAnalyzer(); IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig( TEST_VERSION_CURRENT, analyzer).setSimilarity(similarity)); - //writer.infoStream = System.out; + // writer.infoStream = System.out; for (int i = 0; i < numDocs; i++) { Document doc = new Document(); doc.add(new Field(FIELD, English.intToEnglish(i), Field.Store.YES, Field.Index.ANALYZED)); Index: src/test/org/apache/lucene/search/spans/TestPayloadSpans.java =================================================================== --- src/test/org/apache/lucene/search/spans/TestPayloadSpans.java (revision 922888) +++ src/test/org/apache/lucene/search/spans/TestPayloadSpans.java (working copy) @@ -50,7 +50,6 @@ import org.apache.lucene.util.LuceneTestCase; public class TestPayloadSpans extends LuceneTestCase { - private final static boolean DEBUG = true; private IndexSearcher searcher; private Similarity similarity = new DefaultSimilarity(); protected IndexReader indexReader; @@ -349,7 +348,7 @@ } } assertEquals(2, payloadSet.size()); - if(DEBUG) { + if(VERBOSE) { for (final String payload : payloadSet) System.out.println("match:" + payload); @@ -375,10 +374,10 @@ PayloadSpanUtil psu = new PayloadSpanUtil(reader); Collection payloads = psu.getPayloadsForQuery(new TermQuery(new Term(PayloadHelper.FIELD, "rr"))); - if(DEBUG) + if(VERBOSE) System.out.println("Num payloads:" + payloads.size()); for (final byte [] bytes : payloads) { - if(DEBUG) + if(VERBOSE) System.out.println(new String(bytes)); } @@ -441,14 +440,14 @@ int cnt = 0; while (spans.next() == true) { - if(DEBUG) + if(VERBOSE) System.out.println("\nSpans Dump --"); if (spans.isPayloadAvailable()) { Collection payload = spans.getPayload(); - if(DEBUG) + if(VERBOSE) System.out.println("payloads for span:" + payload.size()); for (final byte [] bytes : payload) { - if(DEBUG) + if(VERBOSE) System.out.println("doc:" + spans.doc() + " s:" + spans.start() + " e:" + spans.end() + " " + new String(bytes)); } Index: src/test/org/apache/lucene/search/TestCustomSearcherSort.java =================================================================== --- src/test/org/apache/lucene/search/TestCustomSearcherSort.java (revision 922888) +++ src/test/org/apache/lucene/search/TestCustomSearcherSort.java (working copy) @@ -214,7 +214,7 @@ // Simply write to console - choosen to be independant of log4j etc private void log(String message) { - System.out.println(message); + if (VERBOSE) System.out.println(message); } public class CustomSearcher extends IndexSearcher { Index: src/test/org/apache/lucene/search/TestMultiSearcherRanking.java =================================================================== --- src/test/org/apache/lucene/search/TestMultiSearcherRanking.java (revision 922888) +++ src/test/org/apache/lucene/search/TestMultiSearcherRanking.java (working copy) @@ -36,7 +36,6 @@ */ public class TestMultiSearcherRanking extends LuceneTestCase { - private final boolean verbose = false; // set to true to output hits private final String FIELD_NAME = "body"; private Searcher multiSearcher; private Searcher singleSearcher; @@ -86,7 +85,7 @@ */ private void checkQuery(String queryStr) throws IOException, ParseException { // check result hit ranking - if(verbose) System.out.println("Query: " + queryStr); + if(VERBOSE) System.out.println("Query: " + queryStr); QueryParser queryParser = new QueryParser(TEST_VERSION_CURRENT, FIELD_NAME, new StandardAnalyzer(TEST_VERSION_CURRENT)); Query query = queryParser.parse(queryStr); ScoreDoc[] multiSearcherHits = multiSearcher.search(query, null, 1000).scoreDocs; @@ -95,15 +94,15 @@ for (int i = 0; i < multiSearcherHits.length; i++) { Document docMulti = multiSearcher.doc(multiSearcherHits[i].doc); Document docSingle = singleSearcher.doc(singleSearcherHits[i].doc); - if(verbose) System.out.println("Multi: " + docMulti.get(FIELD_NAME) + " score=" + if(VERBOSE) System.out.println("Multi: " + docMulti.get(FIELD_NAME) + " score=" + multiSearcherHits[i].score); - if(verbose) System.out.println("Single: " + docSingle.get(FIELD_NAME) + " score=" + if(VERBOSE) System.out.println("Single: " + docSingle.get(FIELD_NAME) + " score=" + singleSearcherHits[i].score); assertEquals(multiSearcherHits[i].score, singleSearcherHits[i].score, 0.001f); assertEquals(docMulti.get(FIELD_NAME), docSingle.get(FIELD_NAME)); } - if(verbose) System.out.println(); + if(VERBOSE) System.out.println(); } /** Index: src/test/org/apache/lucene/search/TestScorerPerf.java =================================================================== --- src/test/org/apache/lucene/search/TestScorerPerf.java (revision 922888) +++ src/test/org/apache/lucene/search/TestScorerPerf.java (working copy) @@ -207,7 +207,7 @@ if (validate) assertEquals(result.cardinality(), hc.getCount()); // System.out.println(hc.getCount()); } - System.out.println("Average number of matches="+(nMatches/iter)); + if (VERBOSE) System.out.println("Average number of matches="+(nMatches/iter)); return ret; } @@ -240,7 +240,7 @@ nMatches += hc.getCount(); ret += hc.getSum(); } - System.out.println("Average number of matches="+(nMatches/iter)); + if (VERBOSE) System.out.println("Average number of matches="+(nMatches/iter)); return ret; } @@ -282,7 +282,7 @@ nMatches += hc.getCount(); ret += hc.getSum(); } - System.out.println("Average number of matches="+(nMatches/iter)); + if (VERBOSE) System.out.println("Average number of matches="+(nMatches/iter)); return ret; } @@ -335,7 +335,7 @@ long start = System.currentTimeMillis(); doConjunctions(500,6); long end = System.currentTimeMillis(); - System.out.println("milliseconds="+(end-start)); + if (VERBOSE) System.out.println("milliseconds="+(end-start)); } s.close(); } @@ -349,7 +349,7 @@ long start = System.currentTimeMillis(); doNestedConjunctions(500,3,3); long end = System.currentTimeMillis(); - System.out.println("milliseconds="+(end-start)); + if (VERBOSE) System.out.println("milliseconds="+(end-start)); } s.close(); } @@ -359,15 +359,15 @@ r = newRandom(); validate=false; RAMDirectory dir = new RAMDirectory(); - System.out.println("Creating index"); + if (VERBOSE) System.out.println("Creating index"); createRandomTerms(100000,25,.5, dir); s = new IndexSearcher(dir, true); - System.out.println("Starting performance test"); + if (VERBOSE) System.out.println("Starting performance test"); for (int i=0; i