Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-2313: Add VERBOSE flag usage to lots of tests

Uwe Schindler06b51a380b56
diff --git a/CHANGES.txt b/CHANGES.txt
index 8ab623bd977..07156d8e54b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -258,10 +258,11 @@ Test Cases
from LuceneTestCase(J4), that contains the release version.
(Uwe Schindler, Simon Willnauer, Shai Erera)
-* LUCENE-2313: Add VERBOSE to LuceneTestCase(J4) to control verbosity
- of tests. If VERBOSE==false (default) tests should not print anything
- other than errors to System.(out|err). The setting can be changed with
- -Dtests.verbose=true on test invokation. (Shai Erera via Uwe Schindler)
+* LUCENE-2313, LUCENE-2322: Add VERBOSE to LuceneTestCase(J4) to control
+ verbosity of tests. If VERBOSE==false (default) tests should not print
+ anything other than errors to System.(out|err). The setting can be
+ changed with -Dtests.verbose=true on test invokation.
+ (Shai Erera, Paul Elschot, Uwe Schindler)
* LUCENE-2318: Remove inconsistent system property code for retrieving
temp and data directories inside test cases. It is now centralized in
diff --git a/contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java b/contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java
index 4cf3b9b34a2..26c13e1ad09 100644
--- a/contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java
+++ b/contrib/analyzers/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballVocab.java
@@ -84,7 +84,7 @@ public class TestSnowballVocab extends BaseTokenStreamTestCase {
*/
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"));
diff --git a/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java b/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
index 834f67df12d..3845e1d308e 100755
--- a/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
+++ b/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
@@ -56,7 +56,6 @@ import org.apache.lucene.util.LuceneTestCase;
*/
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 @@ public class TestPerfTasksLogic extends LuceneTestCase {
}
private static void logTstLogic (String txt) {
- if (!DEBUG)
+ if (!VERBOSE)
return;
System.out.println("Test logic of:");
System.out.println(txt);
diff --git a/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java b/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java
index eaf022b6001..ff1b182689b 100644
--- a/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java
+++ b/contrib/db/bdb-je/src/test/org/apache/lucene/store/je/JEStoreTest.java
@@ -127,7 +127,7 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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 @@ public class JEStoreTest extends LuceneTestCase {
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");
+ }
}
}
diff --git a/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java b/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java
index 586c7cf65dd..5d08e4dbb11 100644
--- a/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java
+++ b/contrib/db/bdb/src/test/org/apache/lucene/store/db/DbStoreTest.java
@@ -129,7 +129,7 @@ public class DbStoreTest extends LuceneTestCase {
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 @@ public class DbStoreTest extends LuceneTestCase {
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 @@ public class DbStoreTest extends LuceneTestCase {
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 @@ public class DbStoreTest extends LuceneTestCase {
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 @@ public class DbStoreTest extends LuceneTestCase {
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 @@ public class DbStoreTest extends LuceneTestCase {
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 @@ public class DbStoreTest extends LuceneTestCase {
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 @@ public class DbStoreTest extends LuceneTestCase {
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");
+ }
}
}
diff --git a/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragListBuilderTest.java b/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragListBuilderTest.java
index 996dfed2e01..59f7aba8bc6 100644
--- a/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragListBuilderTest.java
+++ b/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragListBuilderTest.java
@@ -48,7 +48,7 @@ public class SimpleFragListBuilderTest extends AbstractTestCase {
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() );
}
diff --git a/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java b/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
index d87c9675dda..bc7fd90974d 100644
--- a/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
+++ b/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
@@ -140,7 +140,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
String fragment = highlighter.getBestFragment(stream, storedField);
- System.out.println(fragment);
+ if (VERBOSE) System.out.println(fragment);
}
}
@@ -156,7 +156,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
Query q = parser.parse("\"world Flatland\"~3");
String expected = "I call our <B>world</B> <B>Flatland</B>, 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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
// String result =
highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired,"...");
- //System.out.println("\t" + result);
+ //if (VERBOSE) System.out.println("\t" + result);
}
@@ -396,7 +396,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
String result = highlighter.getBestFragments(tokenStream, text,
maxNumFragmentsRequired, "...");
- System.out.println("\t" + result);
+ if (VERBOSE) System.out.println("\t" + result);
}
@@ -460,7 +460,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
String result = highlighter.getBestFragments(tokenStream, text,
maxNumFragmentsRequired, "...");
- System.out.println("\t" + result);
+ if (VERBOSE) System.out.println("\t" + result);
}
}
@@ -482,7 +482,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
// 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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 <B>random</B> words for second field", result);
}
searcher.close();
@@ -1698,7 +1698,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
// 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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ class SynonymTokenizer extends TokenStream {
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();
}
diff --git a/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java b/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
index 23b951440df..b9c394a8ed7 100644
--- a/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
+++ b/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
@@ -202,8 +202,6 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
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 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
"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 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
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 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
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 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
}
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 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
} 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
diff --git a/contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/TestSpanQueryParserSimpleSample.java b/contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/TestSpanQueryParserSimpleSample.java
index 1e31a62054d..d71aa74915c 100644
--- a/contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/TestSpanQueryParserSimpleSample.java
+++ b/contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/TestSpanQueryParserSimpleSample.java
@@ -19,8 +19,6 @@ package org.apache.lucene.queryParser.spans;
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.core.processors.QueryNodeProcessorPipeline;
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.<br/>
@@ -94,7 +93,7 @@ import org.apache.lucene.search.spans.SpanTermQuery;
* @see UniqueFieldAttribute
*
*/
-public class TestSpanQueryParserSimpleSample extends TestCase {
+public class TestSpanQueryParserSimpleSample extends LuceneTestCase {
public TestSpanQueryParserSimpleSample() {
// empty constructor
@@ -104,12 +103,6 @@ public class TestSpanQueryParserSimpleSample extends TestCase {
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 @@ public class TestSpanQueryParserSimpleSample extends TestCase {
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();
diff --git a/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java b/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
index 1eb5801cd71..3efa83d6d03 100644
--- a/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
+++ b/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
@@ -1071,7 +1071,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
.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);
}
diff --git a/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java b/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
index 4f2cb004306..d4a63f0f99d 100644
--- a/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
+++ b/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
@@ -151,13 +151,15 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
// 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 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
// 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 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
// 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 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
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 @@ public class TestCartesian extends LuceneTestCase {
// 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 @@ public class TestCartesian extends LuceneTestCase {
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 ));
diff --git a/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java b/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java
index 5dac9e264f5..286f9421039 100644
--- a/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java
+++ b/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java
@@ -106,7 +106,7 @@ public class TestDistance extends LuceneTestCase {
}
}
-
+ /* 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 @@ public class TestDistance extends LuceneTestCase {
System.out.println("-->"+DistanceUtils.getInstance().getDistanceMi(44.30073, -78.32131, 43.687267, -79.39842));
}
-
+ */
// public void testDistanceQueryCacheable() throws IOException {
//
diff --git a/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndPrefixQuery.java b/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndPrefixQuery.java
index 87beb5a657d..c39b2f008f5 100644
--- a/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndPrefixQuery.java
+++ b/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndPrefixQuery.java
@@ -54,7 +54,6 @@ public class SrndPrefixQuery extends SimpleTerm {
{
/* inspired by PrefixQuery.rewrite(): */
TermEnum enumerator = reader.terms(getLucenePrefixTerm(fieldName));
- boolean expanded = false;
try {
do {
Term term = enumerator.term();
@@ -62,7 +61,6 @@ public class SrndPrefixQuery extends SimpleTerm {
&& term.text().startsWith(getPrefix())
&& term.field().equals(fieldName)) {
mtv.visitMatchingTerm(term);
- expanded = true;
} else {
break;
}
@@ -70,8 +68,5 @@ public class SrndPrefixQuery extends SimpleTerm {
} finally {
enumerator.close();
}
- if (! expanded) {
- System.out.println("No terms in " + fieldName + " field for: " + toString());
- }
}
}
diff --git a/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndTermQuery.java b/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndTermQuery.java
index 1812295d540..79de254bd91 100644
--- a/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndTermQuery.java
+++ b/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndTermQuery.java
@@ -53,8 +53,6 @@ public class SrndTermQuery extends SimpleTerm {
&& it.text().equals(getTermText())
&& it.field().equals(fieldName)) {
mtv.visitMatchingTerm(it);
- } else {
- System.out.println("No term in " + fieldName + " field for: " + toString());
}
} finally {
enumerator.close();
diff --git a/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndTruncQuery.java b/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndTruncQuery.java
index 55a41f27d89..4f281012c46 100644
--- a/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndTruncQuery.java
+++ b/contrib/surround/src/java/org/apache/lucene/queryParser/surround/query/SrndTruncQuery.java
@@ -83,7 +83,6 @@ public class SrndTruncQuery extends SimpleTerm {
String fieldName,
MatchingTermVisitor mtv) throws IOException
{
- boolean expanded = false;
int prefixLength = prefix.length();
TermEnum enumerator = reader.terms(new Term(fieldName, prefix));
Matcher matcher = pattern.matcher("");
@@ -98,7 +97,6 @@ public class SrndTruncQuery extends SimpleTerm {
matcher.reset( text.substring(prefixLength));
if (matcher.matches()) {
mtv.visitMatchingTerm(term);
- expanded = true;
}
}
}
@@ -107,8 +105,5 @@ public class SrndTruncQuery extends SimpleTerm {
enumerator.close();
matcher.reset();
}
- if (! expanded) {
- System.out.println("No terms in " + fieldName + " field for: " + toString());
- }
}
}
diff --git a/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java b/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
index e8fe52ca0f9..599dc50d096 100644
--- a/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
+++ b/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
@@ -5,8 +5,6 @@ import java.io.IOException;
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.search.TopDocs;
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 @@ import org.apache.lucene.util.Version;
* limitations under the License.
*/
-public class TestParser extends TestCase {
+public class TestParser extends LuceneTestCase {
CoreParser builder;
static Directory dir;
@@ -45,11 +44,7 @@ public class TestParser extends TestCase {
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 @@ public class TestParser extends TestCase {
{
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 @@ public class TestParser extends TestCase {
{
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;
diff --git a/src/test/org/apache/lucene/analysis/TestStopFilter.java b/src/test/org/apache/lucene/analysis/TestStopFilter.java
index 5c9db5f686a..5415a745f87 100644
--- a/src/test/org/apache/lucene/analysis/TestStopFilter.java
+++ b/src/test/org/apache/lucene/analysis/TestStopFilter.java
@@ -30,8 +30,6 @@ import java.util.HashSet;
public class TestStopFilter extends BaseTokenStreamTestCase {
-
- private final static boolean VERBOSE = false;
// other StopFilter functionality is already tested by TestStopAnalyzer
diff --git a/src/test/org/apache/lucene/index/TestByteSlices.java b/src/test/org/apache/lucene/index/TestByteSlices.java
index 06b601500e2..fefc74cd546 100644
--- a/src/test/org/apache/lucene/index/TestByteSlices.java
+++ b/src/test/org/apache/lucene/index/TestByteSlices.java
@@ -65,36 +65,34 @@ public class TestByteSlices extends LuceneTestCase {
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<numValue;j++) {
- if (debug)
+ if (VERBOSE)
System.out.println(" write " + (counters[stream]+j));
writer.writeVInt(counters[stream]+j);
//writer.writeVInt(ti);
}
counters[stream] += numValue;
uptos[stream] = writer.getAddress();
- if (debug)
+ if (VERBOSE)
System.out.println(" addr now " + uptos[stream]);
}
for(int stream=0;stream<NUM_STREAM;stream++) {
- if (debug)
+ if (VERBOSE)
System.out.println(" stream=" + stream + " count=" + counters[stream]);
if (starts[stream] != uptos[stream]) {
diff --git a/src/test/org/apache/lucene/index/TestCheckIndex.java b/src/test/org/apache/lucene/index/TestCheckIndex.java
index 3f13c1b8a0a..2444306cf66 100644
--- a/src/test/org/apache/lucene/index/TestCheckIndex.java
+++ b/src/test/org/apache/lucene/index/TestCheckIndex.java
@@ -48,7 +48,7 @@ public class TestCheckIndex extends LuceneTestCase {
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
CheckIndex checker = new CheckIndex(dir);
checker.setInfoStream(new PrintStream(bos));
- //checker.setInfoStream(System.out);
+ if (VERBOSE) checker.setInfoStream(System.out);
CheckIndex.Status indexStatus = checker.checkIndex();
if (indexStatus.clean == false) {
System.out.println("CheckIndex failed");
diff --git a/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java b/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
index e0e58ec5f87..a9892e3515e 100644
--- a/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
+++ b/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
@@ -50,7 +50,6 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
for (int i = 0; i < trace.length; i++) {
if ("doFlush".equals(trace[i].getMethodName())) {
hitExc = true;
- //new RuntimeException().printStackTrace(System.out);
throw new IOException("now failing during flush");
}
}
diff --git a/src/test/org/apache/lucene/index/TestFieldsReader.java b/src/test/org/apache/lucene/index/TestFieldsReader.java
index 3892e2d59c8..afc5868131d 100644
--- a/src/test/org/apache/lucene/index/TestFieldsReader.java
+++ b/src/test/org/apache/lucene/index/TestFieldsReader.java
@@ -267,8 +267,10 @@ public class TestFieldsReader extends LuceneTestCase {
reader.close();
}
- System.out.println("Average Non-lazy time (should be very close to zero): " + regularTime / length + " ms for " + length + " reads");
- System.out.println("Average Lazy Time (should be greater than zero): " + lazyTime / length + " ms for " + length + " reads");
+ if (VERBOSE) {
+ System.out.println("Average Non-lazy time (should be very close to zero): " + regularTime / length + " ms for " + length + " reads");
+ System.out.println("Average Lazy Time (should be greater than zero): " + lazyTime / length + " ms for " + length + " reads");
+ }
}
public void testLoadSize() throws IOException {
diff --git a/src/test/org/apache/lucene/index/TestIndexReader.java b/src/test/org/apache/lucene/index/TestIndexReader.java
index 7f5a1f0f516..07a419c4785 100644
--- a/src/test/org/apache/lucene/index/TestIndexReader.java
+++ b/src/test/org/apache/lucene/index/TestIndexReader.java
@@ -277,7 +277,7 @@ public class TestIndexReader extends LuceneTestCase
for (Iterator<TermVectorEntry> 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 class TestIndexReader extends LuceneTestCase
*/
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 @@ public class TestIndexReader extends LuceneTestCase
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 @@ public class TestIndexReader extends LuceneTestCase
done = true;
}
} catch (IOException e) {
- if (debug) {
+ if (VERBOSE) {
System.out.println(" hit IOException: " + e);
e.printStackTrace(System.out);
}
diff --git a/src/test/org/apache/lucene/index/TestIndexWriter.java b/src/test/org/apache/lucene/index/TestIndexWriter.java
index 08a6f406b4e..71004cb5b69 100644
--- a/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -170,8 +170,6 @@ public class TestIndexWriter extends LuceneTestCase {
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 @@ public class TestIndexWriter extends LuceneTestCase {
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 @@ public class TestIndexWriter extends LuceneTestCase {
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 @@ public class TestIndexWriter extends LuceneTestCase {
}
success = true;
- if (debug) {
+ if (VERBOSE) {
System.out.println(" success!");
}
@@ -338,7 +336,7 @@ public class TestIndexWriter extends LuceneTestCase {
} 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 @@ public class TestIndexWriter extends LuceneTestCase {
// ConcurrentMergeScheduler are done
_TestUtil.syncConcurrentMerges(writer);
- if (debug) {
+ if (VERBOSE) {
System.out.println(" now test readers");
}
@@ -404,7 +402,7 @@ public class TestIndexWriter extends LuceneTestCase {
searcher.close();
reader.close();
- if (debug) {
+ if (VERBOSE) {
System.out.println(" count is " + result);
}
@@ -413,7 +411,7 @@ public class TestIndexWriter extends LuceneTestCase {
}
}
- if (debug) {
+ if (VERBOSE) {
System.out.println(" start disk = " + startDiskUsage + "; input disk = " + inputDiskUsage + "; max used = " + dir.getMaxUsedSizeInBytes());
}
@@ -455,15 +453,13 @@ public class TestIndexWriter extends LuceneTestCase {
*/
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 @@ public class TestIndexWriter extends LuceneTestCase {
addDoc(writer);
}
} catch (IOException e) {
- if (debug) {
+ if (VERBOSE) {
System.out.println("TEST: exception on addDoc");
e.printStackTrace(System.out);
}
@@ -496,7 +492,7 @@ public class TestIndexWriter extends LuceneTestCase {
try {
writer.close();
} catch (IOException e) {
- if (debug) {
+ if (VERBOSE) {
System.out.println("TEST: exception on close");
e.printStackTrace(System.out);
}
diff --git a/src/test/org/apache/lucene/index/TestIndexWriterDelete.java b/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
index 736d57c05b5..0bd5f9b0cde 100644
--- a/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
+++ b/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
@@ -407,7 +407,6 @@ public class TestIndexWriterDelete extends LuceneTestCase {
*/
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 @@ public class TestIndexWriterDelete extends LuceneTestCase {
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 @@ public class TestIndexWriterDelete extends LuceneTestCase {
} 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 @@ public class TestIndexWriterDelete extends LuceneTestCase {
}
}
catch (IOException e) {
- if (debug) {
+ if (VERBOSE) {
System.out.println(" hit IOException: " + e);
e.printStackTrace(System.out);
}
diff --git a/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java b/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
index 44fe61b012d..b6afdf85359 100644
--- a/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
+++ b/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
@@ -30,8 +30,6 @@ import org.apache.lucene.document.Field;
public class TestIndexWriterExceptions extends LuceneTestCase {
- final private static boolean DEBUG = false;
-
private class IndexerThread extends Thread {
IndexWriter writer;
@@ -72,7 +70,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
try {
writer.updateDocument(idTerm, doc);
} catch (RuntimeException re) {
- if (DEBUG) {
+ if (VERBOSE) {
System.out.println("EXC: ");
re.printStackTrace(System.out);
}
@@ -120,7 +118,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
@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 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
((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 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).setSuppressExceptions();
//writer.setMaxBufferedDocs(10);
- if (DEBUG)
+ if (VERBOSE)
writer.setInfoStream(System.out);
final int NUM_THREADS = 4;
diff --git a/src/test/org/apache/lucene/index/TestStressIndexing2.java b/src/test/org/apache/lucene/index/TestStressIndexing2.java
index 808c90019d8..63e95c9b737 100644
--- a/src/test/org/apache/lucene/index/TestStressIndexing2.java
+++ b/src/test/org/apache/lucene/index/TestStressIndexing2.java
@@ -407,12 +407,7 @@ public class TestStressIndexing2 extends LuceneTestCase {
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<ff1.size(); i++) {
Fieldable f1 = ff1.get(i);
@@ -422,12 +417,7 @@ public class TestStressIndexing2 extends LuceneTestCase {
} else {
String s1 = f1.stringValue();
String s2 = f2.stringValue();
- if (!s1.equals(s2)) {
- // print out whole doc on error
- System.out.println(ff1);
- System.out.println(ff2);
- assertEquals(s1,s2);
- }
+ assertEquals(ff1 + " : " + ff2, s1,s2);
}
}
}
diff --git a/src/test/org/apache/lucene/index/TestTermdocPerf.java b/src/test/org/apache/lucene/index/TestTermdocPerf.java
index 5c357af5529..7a48e0e37a3 100644
--- a/src/test/org/apache/lucene/index/TestTermdocPerf.java
+++ b/src/test/org/apache/lucene/index/TestTermdocPerf.java
@@ -91,7 +91,7 @@ public class TestTermdocPerf extends LuceneTestCase {
long start = System.currentTimeMillis();
addDocs(dir, ndocs, "foo", "val", maxTF, percentDocs);
long end = System.currentTimeMillis();
- System.out.println("milliseconds for creation of " + ndocs + " docs = " + (end-start));
+ if (VERBOSE) System.out.println("milliseconds for creation of " + ndocs + " docs = " + (end-start));
IndexReader reader = IndexReader.open(dir, true);
TermEnum tenum = reader.terms(new Term("foo","val"));
@@ -108,7 +108,7 @@ public class TestTermdocPerf extends LuceneTestCase {
}
end = System.currentTimeMillis();
- System.out.println("milliseconds for " + iter + " TermDocs iteration: " + (end-start));
+ if (VERBOSE) System.out.println("milliseconds for " + iter + " TermDocs iteration: " + (end-start));
return ret;
}
diff --git a/src/test/org/apache/lucene/queryParser/TestQueryParser.java b/src/test/org/apache/lucene/queryParser/TestQueryParser.java
index a48bc0aa14d..da7b46813c5 100644
--- a/src/test/org/apache/lucene/queryParser/TestQueryParser.java
+++ b/src/test/org/apache/lucene/queryParser/TestQueryParser.java
@@ -968,7 +968,7 @@ public class TestQueryParser extends LocalizedTestCase {
result = qp.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);
}
diff --git a/src/test/org/apache/lucene/search/TestCustomSearcherSort.java b/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
index 5821be0677c..93c99aae3ed 100644
--- a/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
+++ b/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
@@ -214,7 +214,7 @@ implements Serializable {
// 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 {
diff --git a/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java b/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
index a1b42a706c8..b9be604341d 100644
--- a/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
+++ b/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
@@ -36,7 +36,6 @@ import java.io.IOException;
*/
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 @@ public class TestMultiSearcherRanking extends LuceneTestCase {
*/
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 @@ public class TestMultiSearcherRanking extends LuceneTestCase {
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();
}
/**
diff --git a/src/test/org/apache/lucene/search/TestScorerPerf.java b/src/test/org/apache/lucene/search/TestScorerPerf.java
index 7b7c2d2ab3c..dfbf8647368 100755
--- a/src/test/org/apache/lucene/search/TestScorerPerf.java
+++ b/src/test/org/apache/lucene/search/TestScorerPerf.java
@@ -207,7 +207,7 @@ public class TestScorerPerf extends LuceneTestCase {
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 @@ public class TestScorerPerf extends LuceneTestCase {
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 @@ public class TestScorerPerf extends LuceneTestCase {
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 @@ public class TestScorerPerf extends LuceneTestCase {
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 @@ public class TestScorerPerf extends LuceneTestCase {
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 @@ public class TestScorerPerf extends LuceneTestCase {
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<bigIter; i++) {
long start = System.currentTimeMillis();
doTermConjunctions(s,25,5,1000);
long end = System.currentTimeMillis();
- System.out.println("milliseconds="+(end-start));
+ if (VERBOSE) System.out.println("milliseconds="+(end-start));
}
s.close();
}
@@ -376,15 +376,15 @@ public class TestScorerPerf extends LuceneTestCase {
r = newRandom();
validate=false;
RAMDirectory dir = new RAMDirectory();
- System.out.println("Creating index");
+ if (VERBOSE) System.out.println("Creating index");
createRandomTerms(100000,25,.2, 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<bigIter; i++) {
long start = System.currentTimeMillis();
doNestedTermConjunctions(s,25,3,3,200);
long end = System.currentTimeMillis();
- System.out.println("milliseconds="+(end-start));
+ if (VERBOSE) System.out.println("milliseconds="+(end-start));
}
s.close();
}
@@ -394,15 +394,15 @@ public class TestScorerPerf extends LuceneTestCase {
r = newRandom();
validate=false;
RAMDirectory dir = new RAMDirectory();
- System.out.println("Creating index");
+ if (VERBOSE) System.out.println("Creating index");
createRandomTerms(100000,25,2,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<bigIter; i++) {
long start = System.currentTimeMillis();
doSloppyPhrase(s,25,2,1000);
long end = System.currentTimeMillis();
- System.out.println("milliseconds="+(end-start));
+ if (VERBOSE) System.out.println("milliseconds="+(end-start));
}
s.close();
}
diff --git a/src/test/org/apache/lucene/search/TestWildcard.java b/src/test/org/apache/lucene/search/TestWildcard.java
index a1e76c2cec3..7cd5ce02470 100644
--- a/src/test/org/apache/lucene/search/TestWildcard.java
+++ b/src/test/org/apache/lucene/search/TestWildcard.java
@@ -240,7 +240,6 @@ public class TestWildcard
*/
public void testParsingAndSearching() throws Exception {
String field = "content";
- boolean dbg = false;
QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, field, new WhitespaceAnalyzer(TEST_VERSION_CURRENT));
qp.setAllowLeadingWildcard(true);
String docs[] = {
@@ -285,7 +284,7 @@ public class TestWildcard
for (int i = 0; i < matchAll.length; i++) {
String qtxt = matchAll[i];
Query q = qp.parse(qtxt);
- if (dbg) System.out.println("matchAll: qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
+ if (VERBOSE) System.out.println("matchAll: qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
assertEquals(docs.length,hits.length);
}
@@ -294,7 +293,7 @@ public class TestWildcard
for (int i = 0; i < matchNone.length; i++) {
String qtxt = matchNone[i];
Query q = qp.parse(qtxt);
- if (dbg) System.out.println("matchNone: qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
+ if (VERBOSE) System.out.println("matchNone: qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
assertEquals(0,hits.length);
}
@@ -304,7 +303,7 @@ public class TestWildcard
for (int j = 0; j < matchOneDocPrefix[i].length; j++) {
String qtxt = matchOneDocPrefix[i][j];
Query q = qp.parse(qtxt);
- if (dbg) System.out.println("match 1 prefix: doc="+docs[i]+" qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
+ if (VERBOSE) System.out.println("match 1 prefix: doc="+docs[i]+" qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
assertEquals(PrefixQuery.class, q.getClass());
ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
assertEquals(1,hits.length);
@@ -317,7 +316,7 @@ public class TestWildcard
for (int j = 0; j < matchOneDocWild[i].length; j++) {
String qtxt = matchOneDocWild[i][j];
Query q = qp.parse(qtxt);
- if (dbg) System.out.println("match 1 wild: doc="+docs[i]+" qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
+ if (VERBOSE) System.out.println("match 1 wild: doc="+docs[i]+" qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
assertEquals(WildcardQuery.class, q.getClass());
ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
assertEquals(1,hits.length);
diff --git a/src/test/org/apache/lucene/search/function/FunctionTestSetup.java b/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
index 6a339317e3c..1c7b269b98e 100755
--- a/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
+++ b/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
@@ -43,8 +43,6 @@ public class FunctionTestSetup extends LuceneTestCaseJ4 {
*/
protected static float TEST_SCORE_TOLERANCE_DELTA = 0.001f;
- protected static final boolean DBG = false; // change to true for logging to print
-
protected static final int N_DOCS = 17; // select a primary number > 2
protected static final String ID_FIELD = "id";
@@ -163,7 +161,7 @@ public class FunctionTestSetup extends LuceneTestCaseJ4 {
// debug messages (change DBG to true for anything to print)
protected void log(Object o) {
- if (DBG) {
+ if (VERBOSE) {
System.out.println(o.toString());
}
}
diff --git a/src/test/org/apache/lucene/search/payloads/PayloadHelper.java b/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
index e4600c0ebc4..99a99780c18 100644
--- a/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
+++ b/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
@@ -108,7 +108,7 @@ public class PayloadHelper {
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));
diff --git a/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java b/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
index 49a7e202337..d548a72b9d0 100644
--- a/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
+++ b/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
@@ -50,7 +50,6 @@ import org.apache.lucene.store.RAMDirectory;
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 @@ public class TestPayloadSpans extends LuceneTestCase {
}
}
assertEquals(2, payloadSet.size());
- if(DEBUG) {
+ if(VERBOSE) {
for (final String payload : payloadSet)
System.out.println("match:" + payload);
@@ -375,10 +374,10 @@ public class TestPayloadSpans extends LuceneTestCase {
PayloadSpanUtil psu = new PayloadSpanUtil(reader);
Collection<byte[]> 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 @@ public class TestPayloadSpans extends LuceneTestCase {
int cnt = 0;
while (spans.next() == true) {
- if(DEBUG)
+ if(VERBOSE)
System.out.println("\nSpans Dump --");
if (spans.isPayloadAvailable()) {
Collection<byte[]> 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));
}