You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by us...@apache.org on 2010/03/17 13:06:29 UTC
svn commit: r924247 [4/4] - in /lucene/java/branches/flex_1458: ./
backwards/ backwards/src/ contrib/ contrib/analyzers/common/
contrib/analyzers/common/src/java/org/apache/lucene/analysis/hi/
contrib/analyzers/common/src/test/org/apache/lucene/analysi...
Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java Wed Mar 17 12:06:27 2010
@@ -105,9 +105,24 @@ public final class ASCIIFoldingFilter ex
output = new char[ArrayUtil.oversize(maxSizeNeeded, RamUsageEstimator.NUM_BYTES_CHAR)];
}
- outputPos = 0;
+ outputPos = foldToASCII(input, 0, output, 0, length);
+ }
- for (int pos = 0 ; pos < length ; ++pos) {
+ /**
+ * Converts characters above ASCII to their ASCII equivalents. For example,
+ * accents are removed from accented characters.
+ * @param input The characters to fold
+ * @param inputPos Index of the first character to fold
+ * @param output The result of the folding. Should be of size >= {@code length * 4}.
+ * @param outputPos Index of output where to put the result of the folding
+ * @param length The number of characters to fold
+ * @return length of output
+ * @lucene.internal
+ */
+ public static final int foldToASCII(char input[], int inputPos, char output[], int outputPos, int length)
+ {
+ final int end = inputPos + length;
+ for (int pos = inputPos; pos < end ; ++pos) {
final char c = input[pos];
// Quick test: if it's not in range then just keep current character
@@ -2028,5 +2043,6 @@ public final class ASCIIFoldingFilter ex
}
}
}
+ return outputPos;
}
}
Propchange: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/Tokenizer.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 17 12:06:27 2010
@@ -1,2 +1,2 @@
/lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/analysis/Tokenizer.java:909334
-/lucene/java/trunk/src/java/org/apache/lucene/analysis/Tokenizer.java:916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499
+/lucene/java/trunk/src/java/org/apache/lucene/analysis/Tokenizer.java:916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499,922013,922277,922525,922528,922602,922624,922797,922799,922886-922887,923112,924151,924207
Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java Wed Mar 17 12:06:27 2010
@@ -4877,8 +4877,13 @@ public class IndexWriter implements Clos
private IndexReaderWarmer mergedSegmentWarmer;
- /** Set the merged segment warmer. See {@link
- * IndexReaderWarmer}. */
+ /**
+ * Set the merged segment warmer. See {@link IndexReaderWarmer}.
+ *
+ * @deprecated use
+ * {@link IndexWriterConfig#setMergedSegmentWarmer}
+ * instead.
+ */
public void setMergedSegmentWarmer(IndexReaderWarmer warmer) {
mergedSegmentWarmer = warmer;
}
Propchange: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 17 12:06:27 2010
@@ -1,2 +1,2 @@
/lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:909334
-/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499
+/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499,922013,922277,922525,922528,922602,922624,922797,922799,922886-922887,923112,924151,924207
Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/AttributeSource.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/AttributeSource.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/AttributeSource.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/AttributeSource.java Wed Mar 17 12:06:27 2010
@@ -365,8 +365,10 @@ public class AttributeSource {
do {
AttributeImpl targetImpl = attributeImpls.get(state.attribute.getClass());
- if (targetImpl == null)
- throw new IllegalArgumentException("State contains an AttributeImpl that is not in this AttributeSource");
+ if (targetImpl == null) {
+ throw new IllegalArgumentException("State contains AttributeImpl of type " +
+ state.attribute.getClass().getName() + " that is not in in this AttributeSource");
+ }
state.attribute.copyTo(targetImpl);
state = state.next;
} while (state != null);
@@ -446,28 +448,54 @@ public class AttributeSource {
/**
* Performs a clone of all {@link AttributeImpl} instances returned in a new
- * AttributeSource instance. This method can be used to e.g. create another TokenStream
- * with exactly the same attributes (using {@link #AttributeSource(AttributeSource)})
+ * {@code AttributeSource} instance. This method can be used to e.g. create another TokenStream
+ * with exactly the same attributes (using {@link #AttributeSource(AttributeSource)}).
+ * You can also use it as a (non-performant) replacement for {@link #captureState}, if you need to look
+ * into / modify the captured state.
*/
public AttributeSource cloneAttributes() {
- AttributeSource clone = new AttributeSource(this.factory);
+ final AttributeSource clone = new AttributeSource(this.factory);
- // first clone the impls
if (hasAttributes()) {
+ // first clone the impls
if (currentState == null) {
computeCurrentState();
}
for (State state = currentState; state != null; state = state.next) {
clone.attributeImpls.put(state.attribute.getClass(), (AttributeImpl) state.attribute.clone());
}
- }
// now the interfaces
for (Entry<Class<? extends Attribute>, AttributeImpl> entry : this.attributes.entrySet()) {
clone.attributes.put(entry.getKey(), clone.attributeImpls.get(entry.getValue().getClass()));
}
+ }
return clone;
}
+
+ /**
+ * Copies the contents of this {@code AttributeSource} to the given target {@code AttributeSource}.
+ * The given instance has to provide all {@link Attribute}s this instance contains.
+ * The actual attribute implementations must be identical in both {@code AttributeSource} instances;
+ * ideally both AttributeSource instances should use the same {@link AttributeFactory}.
+ * You can use this method as a replacement for {@link #restoreState}, if you use
+ * {@link #cloneAttributes} instead of {@link #captureState}.
+ */
+ public final void copyTo(AttributeSource target) {
+ if (hasAttributes()) {
+ if (currentState == null) {
+ computeCurrentState();
+ }
+ for (State state = currentState; state != null; state = state.next) {
+ final AttributeImpl targetImpl = target.attributeImpls.get(state.attribute.getClass());
+ if (targetImpl == null) {
+ throw new IllegalArgumentException("This AttributeSource contains AttributeImpl of type " +
+ state.attribute.getClass().getName() + " that is not in the target");
+ }
+ state.attribute.copyTo(targetImpl);
+ }
+ }
+ }
}
Modified: lucene/java/branches/flex_1458/src/site/src/documentation/content/xdocs/fileformats.xml
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/site/src/documentation/content/xdocs/fileformats.xml?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/site/src/documentation/content/xdocs/fileformats.xml (original)
+++ lucene/java/branches/flex_1458/src/site/src/documentation/content/xdocs/fileformats.xml Wed Mar 17 12:06:27 2010
@@ -63,6 +63,30 @@
change in 2.1).
</p>
+ <p>
+ In version 2.4, Strings are now written as true UTF-8
+ byte sequence, not Java's modified UTF-8. See issue
+ LUCENE-510 for details.
+ </p>
+
+ <p>
+ In version 2.9, an optional opaque Map<String,String>
+ CommitUserData may be passed to IndexWriter's commit
+ methods (and later retrieved), which is recorded in
+ the segments_N file. See issue LUCENE-1382 for
+ details. Also, diagnostics were added to each segment
+ written recording details about why it was written
+ (due to flush, merge; which OS/JRE was used; etc.).
+ See issue LUCENE-1654 for details.
+ </p>
+
+ <p>
+ In version 3.0, compressed fields are no longer
+ written to the index (they can still be read, but on
+ merge the new segment will write them,
+ uncompressed). See issue LUCENE-1960 for details.
+ </p>
+
</section>
<section id="Definitions"><title>Definitions</title>
Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 17 12:06:27 2010
@@ -1,4 +1,4 @@
/lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:748824
/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:829134,829881,831036,896850,909334
/lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:880793,896906
-/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499
+/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499,922013,922277,922525,922528,922602,922624,922797,922799,922886-922887,923112,924151,924207
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestPorterStemFilter.java Wed Mar 17 12:06:27 2010
@@ -36,8 +36,7 @@ public class TestPorterStemFilter extend
public void testPorterStemFilter() throws Exception {
Tokenizer tokenizer = new KeywordTokenizer(new StringReader(""));
TokenStream filter = new PorterStemFilter(tokenizer);
- ZipFile zipFile = new ZipFile(
- new File(getClass().getResource("porterTestData.zip").toURI()));
+ ZipFile zipFile = new ZipFile(getDataFile("porterTestData.zip"));
InputStream voc = zipFile.getInputStream(zipFile.getEntry("voc.txt"));
InputStream out = zipFile.getInputStream(zipFile.getEntry("output.txt"));
BufferedReader vocReader = new BufferedReader(new InputStreamReader(
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestStopFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestStopFilter.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestStopFilter.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestStopFilter.java Wed Mar 17 12:06:27 2010
@@ -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
Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 17 12:06:27 2010
@@ -1,4 +1,4 @@
/lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestDateTools.java:748824
/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java:829134,829881,831036,896850,909334
/lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java:880793,896906
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499,922013,922277,922525,922528,922602,922624,922797,922799,922886-922887,923112,924151,924207
Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 17 12:06:27 2010
@@ -1,4 +1,4 @@
/lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestNumberTools.java:748824
/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java:829134,829881,831036,896850,909334
/lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java:880793,896906
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499,922013,922277,922525,922528,922602,922624,922797,922799,922886-922887,923112,924151,924207
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Wed Mar 17 12:06:27 2010
@@ -631,7 +631,7 @@ public class TestBackwardsCompatibility
}
public static String fullDir(String dirName) throws IOException {
- return new File(System.getProperty("tempDir"), dirName).getCanonicalPath();
+ return new File(TEMP_DIR, dirName).getCanonicalPath();
}
static final String TEXT_TO_COMPRESS = "this is a compressed field and should appear in 3.0 as an uncompressed field after merge";
Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 17 12:06:27 2010
@@ -1,4 +1,4 @@
/lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:748824
/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:829134,829881,831036,896850,909334
/lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:880793,896906
-/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499
+/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499,922013,922277,922525,922528,922602,922624,922797,922799,922886-922887,923112,924151,924207
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestByteSlices.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestByteSlices.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestByteSlices.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestByteSlices.java Wed Mar 17 12:06:27 2010
@@ -65,36 +65,34 @@ public class TestByteSlices extends Luce
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]) {
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCheckIndex.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCheckIndex.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCheckIndex.java Wed Mar 17 12:06:27 2010
@@ -50,7 +50,7 @@ public class TestCheckIndex extends Luce
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");
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCompoundFile.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCompoundFile.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCompoundFile.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestCompoundFile.java Wed Mar 17 12:06:27 2010
@@ -57,7 +57,7 @@ public class TestCompoundFile extends Lu
@Override
protected void setUp() throws Exception {
super.setUp();
- File file = new File(System.getProperty("tempDir"), "testIndex");
+ File file = new File(TEMP_DIR, "testIndex");
_TestUtil.rmDir(file);
// use a simple FSDir here, to be sure to have SimpleFSInputs
dir = new SimpleFSDirectory(file,null);
@@ -66,6 +66,7 @@ public class TestCompoundFile extends Lu
@Override
protected void tearDown() throws Exception {
dir.close();
+ _TestUtil.rmDir(new File(TEMP_DIR, "testIndex"));
super.tearDown();
}
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java Wed Mar 17 12:06:27 2010
@@ -52,7 +52,6 @@ public class TestConcurrentMergeSchedule
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");
}
}
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestDoc.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestDoc.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestDoc.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestDoc.java Wed Mar 17 12:06:27 2010
@@ -58,7 +58,7 @@ public class TestDoc extends LuceneTestC
@Override
protected void setUp() throws Exception {
super.setUp();
- workDir = new File(System.getProperty("tempDir"),"TestDoc");
+ workDir = new File(TEMP_DIR,"TestDoc");
workDir.mkdirs();
indexDir = new File(workDir, "testIndex");
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFieldsReader.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFieldsReader.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFieldsReader.java Wed Mar 17 12:06:27 2010
@@ -199,10 +199,8 @@ public class TestFieldsReader extends Lu
* @throws Exception
*/
public void testLazyPerformance() throws Exception {
- String tmpIODir = System.getProperty("tempDir");
String userName = System.getProperty("user.name");
- String path = tmpIODir + File.separator + "lazyDir" + userName;
- File file = new File(path);
+ File file = new File(TEMP_DIR, "lazyDir" + userName);
_TestUtil.rmDir(file);
FSDirectory tmpDir = FSDirectory.open(file);
assertTrue(tmpDir != null);
@@ -258,9 +256,11 @@ public class TestFieldsReader extends Lu
reader.close();
}
+ 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 {
FieldsReader reader = new FieldsReader(dir, TEST_SEGMENT_NAME, fieldInfos);
@@ -380,10 +380,7 @@ public class TestFieldsReader extends Lu
// LUCENE-1262
public void testExceptions() throws Throwable {
- String tempDir = System.getProperty("java.io.tmpdir");
- if (tempDir == null)
- throw new IOException("java.io.tmpdir undefined, cannot run test");
- File indexDir = new File(tempDir, "testfieldswriterexceptions");
+ File indexDir = new File(TEMP_DIR, "testfieldswriterexceptions");
try {
Directory dir = new FaultyFSDirectory(indexDir);
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReader.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReader.java Wed Mar 17 12:06:27 2010
@@ -269,7 +269,7 @@ public class TestIndexReader extends Luc
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);
}
@@ -512,9 +512,7 @@ public class TestIndexReader extends Luc
// Make sure you can set norms & commit even if a reader
// is open against the index:
public void testWritingNorms() throws IOException {
- String tempDir = "target/test";
-
- File indexDir = new File(tempDir, "lucenetestnormwriter");
+ File indexDir = new File(TEMP_DIR, "lucenetestnormwriter");
Directory dir = FSDirectory.open(indexDir);
IndexWriter writer;
IndexReader reader;
@@ -695,13 +693,13 @@ public class TestIndexReader extends Luc
}
private Directory getDirectory() throws IOException {
- return FSDirectory.open(new File(System.getProperty("tempDir"), "testIndex"));
+ return FSDirectory.open(new File(TEMP_DIR, "testIndex"));
}
public void testFilesOpenClose() throws IOException
{
// Create initial data set
- File dirFile = new File(System.getProperty("tempDir"), "testIndex");
+ File dirFile = new File(TEMP_DIR, "testIndex");
Directory dir = getDirectory();
IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
addDoc(writer, "test");
@@ -730,7 +728,7 @@ public class TestIndexReader extends Luc
}
public void testLastModified() throws Exception {
- final File fileDir = new File(System.getProperty("tempDir"), "testIndex");
+ final File fileDir = new File(TEMP_DIR, "testIndex");
for(int i=0;i<2;i++) {
try {
final Directory dir;
@@ -880,7 +878,6 @@ public class TestIndexReader extends Luc
*/
public void testDiskFull() throws IOException {
- boolean debug = false;
Term searchTerm = new Term("content", "aaa");
int START_COUNT = 157;
int END_COUNT = 144;
@@ -940,14 +937,14 @@ public class TestIndexReader extends Luc
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";
@@ -971,7 +968,7 @@ public class TestIndexReader extends Luc
done = true;
}
} catch (IOException e) {
- if (debug) {
+ if (VERBOSE) {
System.out.println(" hit IOException: " + e);
e.printStackTrace(System.out);
}
@@ -1132,8 +1129,7 @@ public class TestIndexReader extends Luc
}
public void testOpenReaderAfterDelete() throws IOException {
- File dirFile = new File(System.getProperty("tempDir"),
- "deletetest");
+ File dirFile = new File(TEMP_DIR, "deletetest");
Directory dir = FSDirectory.open(dirFile);
try {
IndexReader.open(dir, false);
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java Wed Mar 17 12:06:27 2010
@@ -81,14 +81,8 @@ public class TestIndexReaderCloneNorms e
* optimize.
*/
public void testNorms() throws IOException {
- // tmp dir
- String tempDir = System.getProperty("java.io.tmpdir");
- if (tempDir == null) {
- throw new IOException("java.io.tmpdir undefined, cannot run test");
- }
-
// test with a single index: index1
- File indexDir1 = new File(tempDir, "lucenetestindex1");
+ File indexDir1 = new File(TEMP_DIR, "lucenetestindex1");
Directory dir1 = FSDirectory.open(indexDir1);
IndexWriter.unlock(dir1);
@@ -107,14 +101,14 @@ public class TestIndexReaderCloneNorms e
modifiedNorms = new ArrayList<Float>();
numDocNorms = 0;
- File indexDir2 = new File(tempDir, "lucenetestindex2");
+ File indexDir2 = new File(TEMP_DIR, "lucenetestindex2");
Directory dir2 = FSDirectory.open(indexDir2);
createIndex(dir2);
doTestNorms(dir2);
// add index1 and index2 to a third index: index3
- File indexDir3 = new File(tempDir, "lucenetestindex3");
+ File indexDir3 = new File(TEMP_DIR, "lucenetestindex3");
Directory dir3 = FSDirectory.open(indexDir3);
createIndex(dir3);
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderReopen.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderReopen.java Wed Mar 17 12:06:27 2010
@@ -1096,10 +1096,7 @@ public class TestIndexReaderReopen exten
@Override
protected void setUp() throws Exception {
super.setUp();
- String tempDir = System.getProperty("java.io.tmpdir");
- if (tempDir == null)
- throw new IOException("java.io.tmpdir undefined, cannot run test");
- indexDir = new File(tempDir, "IndexReaderReopen");
+ indexDir = new File(TEMP_DIR, "IndexReaderReopen");
}
public void testCloseOrig() throws Throwable {
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java Wed Mar 17 12:06:27 2010
@@ -173,8 +173,6 @@ public class TestIndexWriter extends Luc
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];
@@ -234,7 +232,7 @@ public class TestIndexWriter extends Luc
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:
@@ -293,16 +291,16 @@ public class TestIndexWriter extends Luc
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);
@@ -330,7 +328,7 @@ public class TestIndexWriter extends Luc
}
success = true;
- if (debug) {
+ if (VERBOSE) {
System.out.println(" success!");
}
@@ -341,7 +339,7 @@ public class TestIndexWriter extends Luc
} catch (IOException e) {
success = false;
err = e;
- if (debug) {
+ if (VERBOSE) {
System.out.println(" hit IOException: " + e);
e.printStackTrace(System.out);
}
@@ -356,7 +354,7 @@ public class TestIndexWriter extends Luc
// ConcurrentMergeScheduler are done
_TestUtil.syncConcurrentMerges(writer);
- if (debug) {
+ if (VERBOSE) {
System.out.println(" now test readers");
}
@@ -407,7 +405,7 @@ public class TestIndexWriter extends Luc
searcher.close();
reader.close();
- if (debug) {
+ if (VERBOSE) {
System.out.println(" count is " + result);
}
@@ -416,7 +414,7 @@ public class TestIndexWriter extends Luc
}
}
- if (debug) {
+ if (VERBOSE) {
System.out.println(" start disk = " + startDiskUsage + "; input disk = " + inputDiskUsage + "; max used = " + dir.getMaxUsedSizeInBytes());
}
@@ -458,15 +456,13 @@ public class TestIndexWriter extends Luc
*/
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);
@@ -485,7 +481,7 @@ public class TestIndexWriter extends Luc
addDoc(writer);
}
} catch (IOException e) {
- if (debug) {
+ if (VERBOSE) {
System.out.println("TEST: exception on addDoc");
e.printStackTrace(System.out);
}
@@ -499,7 +495,7 @@ public class TestIndexWriter extends Luc
try {
writer.close();
} catch (IOException e) {
- if (debug) {
+ if (VERBOSE) {
System.out.println("TEST: exception on close");
e.printStackTrace(System.out);
}
@@ -4329,7 +4325,7 @@ public class TestIndexWriter extends Luc
// create=true does not remove non-index files
public void testOtherFiles() throws Throwable {
- File indexDir = new File(System.getProperty("tempDir"), "otherfiles");
+ File indexDir = new File(TEMP_DIR, "otherfiles");
Directory dir = FSDirectory.open(indexDir);
try {
// Create my own random file:
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterDelete.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterDelete.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterDelete.java Wed Mar 17 12:06:27 2010
@@ -416,7 +416,6 @@ public class TestIndexWriterDelete exten
*/
private void testOperationsOnDiskFull(boolean updates) throws IOException {
- boolean debug = false;
Term searchTerm = new Term("content", "aaa");
int START_COUNT = 157;
int END_COUNT = 144;
@@ -476,7 +475,7 @@ public class TestIndexWriterDelete exten
if (diskRatio >= 6.0) {
rate = 0.0;
}
- if (debug) {
+ if (VERBOSE) {
System.out.println("\ncycle: " + diskFree + " bytes");
}
testName = "disk full during reader.close() @ " + thisDiskFree
@@ -484,7 +483,7 @@ public class TestIndexWriterDelete exten
} 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";
@@ -518,7 +517,7 @@ public class TestIndexWriterDelete exten
}
}
catch (IOException e) {
- if (debug) {
+ if (VERBOSE) {
System.out.println(" hit IOException: " + e);
e.printStackTrace(System.out);
}
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Wed Mar 17 12:06:27 2010
@@ -31,8 +31,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;
@@ -73,7 +71,7 @@ public class TestIndexWriterExceptions e
try {
writer.updateDocument(idTerm, doc);
} catch (RuntimeException re) {
- if (DEBUG) {
+ if (VERBOSE) {
System.out.println("EXC: ");
re.printStackTrace(System.out);
}
@@ -121,7 +119,7 @@ public class TestIndexWriterExceptions e
@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);
}
@@ -139,7 +137,7 @@ public class TestIndexWriterExceptions e
//writer.setMaxBufferedDocs(10);
writer.setRAMBufferSizeMB(0.1);
- if (DEBUG)
+ if (VERBOSE)
writer.setInfoStream(System.out);
IndexerThread thread = new IndexerThread(0, writer);
@@ -177,7 +175,7 @@ public class TestIndexWriterExceptions e
//writer.setMaxBufferedDocs(10);
writer.setRAMBufferSizeMB(0.2);
- if (DEBUG)
+ if (VERBOSE)
writer.setInfoStream(System.out);
final int NUM_THREADS = 4;
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java Wed Mar 17 12:06:27 2010
@@ -37,8 +37,7 @@ public class TestIndexWriterLockRelease
protected void setUp() throws Exception {
super.setUp();
if (this.__test_dir == null) {
- String tmp_dir = System.getProperty("java.io.tmpdir", "tmp");
- this.__test_dir = new File(tmp_dir, "testIndexWriter");
+ this.__test_dir = new File(TEMP_DIR, "testIndexWriter");
if (this.__test_dir.exists()) {
throw new IOException("test directory \"" + this.__test_dir.getPath() + "\" already exists (please remove by hand)");
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java Wed Mar 17 12:06:27 2010
@@ -466,12 +466,7 @@ public class TestStressIndexing2 extends
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);
@@ -482,15 +477,10 @@ public class TestStressIndexing2 extends
} 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);
}
}
}
- }
public static void verifyEquals(TermFreqVector[] d1, TermFreqVector[] d2) {
if (d1 == null) {
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTermdocPerf.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTermdocPerf.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTermdocPerf.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTermdocPerf.java Wed Mar 17 12:06:27 2010
@@ -89,7 +89,7 @@ public class TestTermdocPerf extends Luc
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"));
@@ -106,7 +106,7 @@ public class TestTermdocPerf extends Luc
}
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;
}
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestThreadedOptimize.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestThreadedOptimize.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestThreadedOptimize.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestThreadedOptimize.java Wed Mar 17 12:06:27 2010
@@ -139,12 +139,8 @@ public class TestThreadedOptimize extend
runTest(directory, new ConcurrentMergeScheduler());
directory.close();
- String tempDir = System.getProperty("tempDir");
- if (tempDir == null)
- throw new IOException("tempDir undefined, cannot run test");
-
- String dirName = tempDir + "/luceneTestThreadedOptimize";
- directory = FSDirectory.open(new File(dirName));
+ File dirName = new File(TEMP_DIR, "luceneTestThreadedOptimize");
+ directory = FSDirectory.open(dirName);
runTest(directory, new SerialMergeScheduler());
runTest(directory, new ConcurrentMergeScheduler());
directory.close();
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestQueryParser.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestQueryParser.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestQueryParser.java Wed Mar 17 12:06:27 2010
@@ -968,7 +968,7 @@ public class TestQueryParser extends Loc
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);
}
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestCustomSearcherSort.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestCustomSearcherSort.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestCustomSearcherSort.java Wed Mar 17 12:06:27 2010
@@ -213,7 +213,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 {
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java Wed Mar 17 12:06:27 2010
@@ -35,7 +35,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;
@@ -85,7 +84,7 @@ public class TestMultiSearcherRanking ex
*/
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;
@@ -94,15 +93,15 @@ public class TestMultiSearcherRanking ex
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();
}
/**
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java Wed Mar 17 12:06:27 2010
@@ -139,7 +139,7 @@ public class TestNumericRangeQuery32 ext
default:
return;
}
- System.out.println("Found "+terms+" distinct terms in range for field '"+field+"'"+type+".");
+ if (VERBOSE) System.out.println("Found "+terms+" distinct terms in range for field '"+field+"'"+type+".");
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count"+type, count, sd.length );
@@ -197,7 +197,7 @@ public class TestNumericRangeQuery32 ext
int upper=(count-1)*distance + (distance/3) + startOffset;
NumericRangeQuery<Integer> q=NumericRangeQuery.newIntRange(field, precisionStep, null, upper, true, true);
TopDocs topDocs = searcher.search(q, null, noDocs, Sort.INDEXORDER);
- System.out.println("Found "+q.getTotalNumberOfTerms()+" distinct terms in left open range for field '"+field+"'.");
+ if (VERBOSE) System.out.println("Found "+q.getTotalNumberOfTerms()+" distinct terms in left open range for field '"+field+"'.");
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count", count, sd.length );
@@ -238,7 +238,7 @@ public class TestNumericRangeQuery32 ext
int lower=(count-1)*distance + (distance/3) +startOffset;
NumericRangeQuery<Integer> q=NumericRangeQuery.newIntRange(field, precisionStep, lower, null, true, true);
TopDocs topDocs = searcher.search(q, null, noDocs, Sort.INDEXORDER);
- System.out.println("Found "+q.getTotalNumberOfTerms()+" distinct terms in right open range for field '"+field+"'.");
+ if (VERBOSE) System.out.println("Found "+q.getTotalNumberOfTerms()+" distinct terms in right open range for field '"+field+"'.");
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count", noDocs-count, sd.length );
@@ -369,7 +369,7 @@ public class TestNumericRangeQuery32 ext
}
if (precisionStep == Integer.MAX_VALUE) {
assertEquals("Total number of terms should be equal for unlimited precStep", termCountT, termCountC);
- } else {
+ } else if (VERBOSE) {
System.out.println("Average number of terms during random search on '" + field + "':");
System.out.println(" Trie query: " + (((double)termCountT)/(10*4)));
System.out.println(" Classical query: " + (((double)termCountC)/(10*4)));
@@ -567,7 +567,7 @@ public class TestNumericRangeQuery32 ext
break;
}
assertNull(termEnum.next());
- System.out.println("TermEnum on 'field4' for range [" + lower + "," + upper
+ if (VERBOSE) System.out.println("TermEnum on 'field4' for range [" + lower + "," + upper
+ "] contained " + count + " terms.");
}
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java Wed Mar 17 12:06:27 2010
@@ -141,7 +141,7 @@ public class TestNumericRangeQuery64 ext
default:
return;
}
- System.out.println("Found "+terms+" distinct terms in range for field '"+field+"'"+type+".");
+ if (VERBOSE) System.out.println("Found "+terms+" distinct terms in range for field '"+field+"'"+type+".");
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count"+type, count, sd.length );
@@ -204,7 +204,7 @@ public class TestNumericRangeQuery64 ext
long upper=(count-1)*distance + (distance/3) + startOffset;
NumericRangeQuery<Long> q=NumericRangeQuery.newLongRange(field, precisionStep, null, upper, true, true);
TopDocs topDocs = searcher.search(q, null, noDocs, Sort.INDEXORDER);
- System.out.println("Found "+q.getTotalNumberOfTerms()+" distinct terms in left open range for field '"+field+"'.");
+ if (VERBOSE) System.out.println("Found "+q.getTotalNumberOfTerms()+" distinct terms in left open range for field '"+field+"'.");
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count", count, sd.length );
@@ -250,7 +250,7 @@ public class TestNumericRangeQuery64 ext
long lower=(count-1)*distance + (distance/3) +startOffset;
NumericRangeQuery<Long> q=NumericRangeQuery.newLongRange(field, precisionStep, lower, null, true, true);
TopDocs topDocs = searcher.search(q, null, noDocs, Sort.INDEXORDER);
- System.out.println("Found "+q.getTotalNumberOfTerms()+" distinct terms in right open range for field '"+field+"'.");
+ if (VERBOSE) System.out.println("Found "+q.getTotalNumberOfTerms()+" distinct terms in right open range for field '"+field+"'.");
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count", noDocs-count, sd.length );
@@ -386,7 +386,7 @@ public class TestNumericRangeQuery64 ext
}
if (precisionStep == Integer.MAX_VALUE) {
assertEquals("Total number of terms should be equal for unlimited precStep", termCountT, termCountC);
- } else {
+ } else if (VERBOSE) {
System.out.println("Average number of terms during random search on '" + field + "':");
System.out.println(" Trie query: " + (((double)termCountT)/(10*4)));
System.out.println(" Classical query: " + (((double)termCountC)/(10*4)));
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestScorerPerf.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestScorerPerf.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestScorerPerf.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestScorerPerf.java Wed Mar 17 12:06:27 2010
@@ -205,7 +205,7 @@ public class TestScorerPerf extends Luce
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;
}
@@ -238,7 +238,7 @@ public class TestScorerPerf extends Luce
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;
}
@@ -280,7 +280,7 @@ public class TestScorerPerf extends Luce
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;
}
@@ -333,7 +333,7 @@ public class TestScorerPerf extends Luce
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();
}
@@ -347,7 +347,7 @@ public class TestScorerPerf extends Luce
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();
}
@@ -357,15 +357,15 @@ public class TestScorerPerf extends Luce
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();
}
@@ -374,15 +374,15 @@ public class TestScorerPerf extends Luce
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();
}
@@ -392,15 +392,15 @@ public class TestScorerPerf extends Luce
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();
}
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestWildcard.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestWildcard.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestWildcard.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestWildcard.java Wed Mar 17 12:06:27 2010
@@ -221,7 +221,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[] = {
@@ -266,7 +265,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);
}
@@ -275,7 +274,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);
}
@@ -285,7 +284,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);
@@ -298,7 +297,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);
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java Wed Mar 17 12:06:27 2010
@@ -42,8 +42,6 @@ public class FunctionTestSetup extends L
*/
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 L
// debug messages (change DBG to true for anything to print)
protected void log(Object o) {
- if (DBG) {
+ if (VERBOSE) {
System.out.println(o.toString());
}
}
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/PayloadHelper.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/PayloadHelper.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/payloads/PayloadHelper.java Wed Mar 17 12:06:27 2010
@@ -108,7 +108,7 @@ public class PayloadHelper {
IndexWriter writer
= new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
writer.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));
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java Wed Mar 17 12:06:27 2010
@@ -49,7 +49,6 @@ import org.apache.lucene.store.RAMDirect
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;
@@ -348,7 +347,7 @@ public class TestPayloadSpans extends Lu
}
}
assertEquals(2, payloadSet.size());
- if(DEBUG) {
+ if(VERBOSE) {
for (final String payload : payloadSet)
System.out.println("match:" + payload);
@@ -374,10 +373,10 @@ public class TestPayloadSpans extends Lu
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));
}
@@ -442,14 +441,14 @@ public class TestPayloadSpans extends Lu
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));
}
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestBufferedIndexInput.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestBufferedIndexInput.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestBufferedIndexInput.java Wed Mar 17 12:06:27 2010
@@ -239,7 +239,7 @@ public class TestBufferedIndexInput exte
}
public void testSetBufferSize() throws IOException {
- File indexDir = new File(System.getProperty("tempDir"), "testSetBufferSize");
+ File indexDir = new File(TEMP_DIR, "testSetBufferSize");
MockFSDirectory dir = new MockFSDirectory(indexDir, newRandom());
try {
IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestDirectory.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestDirectory.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestDirectory.java Wed Mar 17 12:06:27 2010
@@ -35,7 +35,7 @@ public class TestDirectory extends Lucen
} catch (AlreadyClosedException ace) {
}
- dir = FSDirectory.open(new File(System.getProperty("tempDir")));
+ dir = FSDirectory.open(TEMP_DIR);
dir.close();
try {
dir.createOutput("test");
@@ -48,7 +48,7 @@ public class TestDirectory extends Lucen
// Test that different instances of FSDirectory can coexist on the same
// path, can read, write, and lock files.
public void testDirectInstantiation() throws Exception {
- File path = new File(System.getProperty("tempDir"));
+ File path = new File(TEMP_DIR, "testDirectInstantiation");
int sz = 3;
Directory[] dirs = new Directory[sz];
@@ -116,11 +116,13 @@ public class TestDirectory extends Lucen
dir.close();
assertFalse(dir.isOpen);
}
+
+ _TestUtil.rmDir(path);
}
// LUCENE-1464
public void testDontCreate() throws Throwable {
- File path = new File(System.getProperty("tempDir"), "doesnotexist");
+ File path = new File(TEMP_DIR, "doesnotexist");
try {
assertTrue(!path.exists());
Directory dir = new SimpleFSDirectory(path, null);
@@ -138,7 +140,7 @@ public class TestDirectory extends Lucen
// LUCENE-1468
public void testFSDirectoryFilter() throws IOException {
- checkDirectoryFilter(FSDirectory.open(new File("test")));
+ checkDirectoryFilter(FSDirectory.open(new File(TEMP_DIR,"test")));
}
// LUCENE-1468
@@ -155,7 +157,7 @@ public class TestDirectory extends Lucen
// LUCENE-1468
public void testCopySubdir() throws Throwable {
- File path = new File(System.getProperty("tempDir"), "testsubdir");
+ File path = new File(TEMP_DIR, "testsubdir");
try {
path.mkdirs();
new File(path, "subdir").mkdirs();
@@ -168,7 +170,7 @@ public class TestDirectory extends Lucen
// LUCENE-1468
public void testNotDirectory() throws Throwable {
- File path = new File(System.getProperty("tempDir"), "testnotdir");
+ File path = new File(TEMP_DIR, "testnotdir");
Directory fsDir = new SimpleFSDirectory(path, null);
try {
IndexOutput out = fsDir.createOutput("afile");
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestLockFactory.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestLockFactory.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestLockFactory.java Wed Mar 17 12:06:27 2010
@@ -175,7 +175,7 @@ public class TestLockFactory extends Luc
// Verify: NativeFSLockFactory works correctly
public void testNativeFSLockFactory() throws IOException {
- NativeFSLockFactory f = new NativeFSLockFactory(System.getProperty("tempDir"));
+ NativeFSLockFactory f = new NativeFSLockFactory(TEMP_DIR);
f.setLockPrefix("test");
Lock l = f.makeLock("commit");
@@ -199,7 +199,7 @@ public class TestLockFactory extends Luc
public void testNativeFSLockReleaseByOtherLock() throws IOException {
- NativeFSLockFactory f = new NativeFSLockFactory(System.getProperty("tempDir"));
+ NativeFSLockFactory f = new NativeFSLockFactory(TEMP_DIR);
f.setLockPrefix("test");
Lock l = f.makeLock("commit");
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestRAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestRAMDirectory.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestRAMDirectory.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestRAMDirectory.java Wed Mar 17 12:06:27 2010
@@ -48,10 +48,7 @@ public class TestRAMDirectory extends Lu
@Override
protected void setUp () throws Exception {
super.setUp();
- String tempDir = System.getProperty("java.io.tmpdir");
- if (tempDir == null)
- throw new IOException("java.io.tmpdir undefined, cannot run test");
- indexDir = new File(tempDir, "RAMDirIndex");
+ indexDir = new File(TEMP_DIR, "RAMDirIndex");
Directory dir = FSDirectory.open(indexDir);
IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestWindowsMMap.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestWindowsMMap.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestWindowsMMap.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestWindowsMMap.java Wed Mar 17 12:06:27 2010
@@ -61,7 +61,7 @@ public class TestWindowsMMap extends Luc
}
private final static String storePathname =
- new File(System.getProperty("tempDir"),"testLuceneMmap").getAbsolutePath();
+ new File(TEMP_DIR,"testLuceneMmap").getAbsolutePath();
public void testMmapIndex() throws Exception {
FSDirectory storeDirectory;
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCase.java Wed Mar 17 12:06:27 2010
@@ -17,7 +17,9 @@ package org.apache.lucene.util;
* limitations under the License.
*/
+import java.io.File;
import java.io.PrintStream;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Random;
@@ -54,8 +56,18 @@ import org.apache.lucene.util.FieldCache
*/
public abstract class LuceneTestCase extends TestCase {
+ /**
+ * true iff tests are run in verbose mode. Note: if it is false, tests are not
+ * expected to print any messages.
+ */
+ public static final boolean VERBOSE = LuceneTestCaseJ4.VERBOSE;
+
+ /** Use this constant when creating Analyzers and any other version-dependent stuff. */
public static final Version TEST_VERSION_CURRENT = LuceneTestCaseJ4.TEST_VERSION_CURRENT;
+ /** Create indexes in this directory, optimally use a subdir, named after the test */
+ public static final File TEMP_DIR = LuceneTestCaseJ4.TEMP_DIR;
+
private int savedBoolMaxClauseCount;
private volatile Thread.UncaughtExceptionHandler savedUncaughtExceptionHandler = null;
@@ -244,6 +256,18 @@ public abstract class LuceneTestCase ext
return new Random(seed);
}
+ /** Gets a resource from the classpath as {@link File}. This method should only be used,
+ * if a real file is needed. To get a stream, code should prefer
+ * {@link Class#getResourceAsStream} using {@code this.getClass()}.
+ */
+ protected File getDataFile(String name) throws IOException {
+ try {
+ return new File(this.getClass().getResource(name).toURI());
+ } catch (Exception e) {
+ throw new IOException("Cannot find resource: " + name);
+ }
+ }
+
@Override
public void runBare() throws Throwable {
//long t0 = System.currentTimeMillis();
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java Wed Mar 17 12:06:27 2010
@@ -25,16 +25,22 @@ import org.apache.lucene.util.FieldCache
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
+import org.junit.Test;
import org.junit.rules.TestWatchman;
import org.junit.runners.model.FrameworkMethod;
+import java.io.File;
import java.io.PrintStream;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Random;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
import java.util.Collections;
+import java.lang.reflect.Method;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -58,8 +64,7 @@ import static org.junit.Assert.fail;
* of its name
* <p>
* <p>
- * See Junit4 documentation for a complete list of features at
- * http://junit.org/junit/javadoc/4.7/
+ * See Junit4 <a href="http://junit.org/junit/javadoc/4.7/">documentation</a> for a complete list of features.
* <p>
* Import from org.junit rather than junit.framework.
* <p>
@@ -77,8 +82,25 @@ import static org.junit.Assert.fail;
//@RunWith(RunBareWrapper.class)
public class LuceneTestCaseJ4 {
- /** Change this when development starts for new Lucene version: */
+ /**
+ * true iff tests are run in verbose mode. Note: if it is false, tests are not
+ * expected to print any messages.
+ */
+ public static final boolean VERBOSE = Boolean.getBoolean("tests.verbose");
+
+ /** Use this constant when creating Analyzers and any other version-dependent stuff.
+ * <p><b>NOTE:</b> Change this when development starts for new Lucene version:
+ */
public static final Version TEST_VERSION_CURRENT = Version.LUCENE_31;
+
+ /** Create indexes in this directory, optimally use a subdir, named after the test */
+ public static final File TEMP_DIR;
+ static {
+ String s = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
+ if (s == null)
+ throw new RuntimeException("To run tests, you need to define system property 'tempDir' or 'java.io.tmpdir'.");
+ TEMP_DIR = new File(s);
+ }
private int savedBoolMaxClauseCount;
@@ -94,7 +116,12 @@ public class LuceneTestCaseJ4 {
}
}
private List<UncaughtExceptionEntry> uncaughtExceptions = Collections.synchronizedList(new ArrayList<UncaughtExceptionEntry>());
-
+
+ // checks if class correctly annotated
+ private static final Object PLACEHOLDER = new Object();
+ private static final Map<Class<? extends LuceneTestCaseJ4>,Object> checkedClasses =
+ Collections.synchronizedMap(new WeakHashMap<Class<? extends LuceneTestCaseJ4>,Object>());
+
// This is how we get control when errors occur.
// Think of this as start/end/success/failed
// events.
@@ -109,7 +136,18 @@ public class LuceneTestCaseJ4 {
@Override
public void starting(FrameworkMethod method) {
+ // set current method name for logging
LuceneTestCaseJ4.this.name = method.getName();
+ // check if the current test's class annotated all test* methods with @Test
+ final Class<? extends LuceneTestCaseJ4> clazz = LuceneTestCaseJ4.this.getClass();
+ if (!checkedClasses.containsKey(clazz)) {
+ checkedClasses.put(clazz, PLACEHOLDER);
+ for (Method m : clazz.getMethods()) {
+ if (m.getName().startsWith("test") && m.getAnnotation(Test.class) == null) {
+ fail("In class '" + clazz.getName() + "' the method '" + m.getName() + "' is not annotated with @Test.");
+ }
+ }
+ }
super.starting(method);
}
@@ -285,6 +323,18 @@ public class LuceneTestCaseJ4 {
public String getName() {
return this.name;
}
+
+ /** Gets a resource from the classpath as {@link File}. This method should only be used,
+ * if a real file is needed. To get a stream, code should prefer
+ * {@link Class#getResourceAsStream} using {@code this.getClass()}.
+ */
+ protected File getDataFile(String name) throws IOException {
+ try {
+ return new File(this.getClass().getResource(name).toURI());
+ } catch (Exception e) {
+ throw new IOException("Cannot find resource: " + name);
+ }
+ }
// We get here from InterceptTestCaseEvents on the 'failed' event....
public void reportAdditionalFailureInfo() {
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java Wed Mar 17 12:06:27 2010
@@ -95,6 +95,18 @@ public class TestAttributeSource extends
assertNotSame("TypeAttribute of original and clone must be different instances", typeAtt2, typeAtt);
assertEquals("TermAttribute of original and clone must be equal", termAtt2, termAtt);
assertEquals("TypeAttribute of original and clone must be equal", typeAtt2, typeAtt);
+
+ // test copy back
+ termAtt2.setTermBuffer("OtherTerm");
+ typeAtt2.setType("OtherType");
+ clone.copyTo(src);
+ assertEquals("TermAttribute of original must now contain updated term", "OtherTerm", termAtt.term());
+ assertEquals("TypeAttribute of original must now contain updated type", "OtherType", typeAtt.type());
+ // verify again:
+ assertNotSame("TermAttribute of original and clone must be different instances", termAtt2, termAtt);
+ assertNotSame("TypeAttribute of original and clone must be different instances", typeAtt2, typeAtt);
+ assertEquals("TermAttribute of original and clone must be equal", termAtt2, termAtt);
+ assertEquals("TypeAttribute of original and clone must be equal", typeAtt2, typeAtt);
}
public void testToStringAndMultiAttributeImplementations() {
Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 17 12:06:27 2010
@@ -1,2 +1,2 @@
/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/util/TestAttributeSource.java:909334
-/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499
+/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:916596,916685,916755,916769,917019,917148,917154,917161,917203-917204,919060,919119,919718,919731,919869,920237-920499,922013,922277,922525,922528,922602,922624,922797,922799,922886-922887,923112,924151,924207
Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/_TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/_TestUtil.java?rev=924247&r1=924246&r2=924247&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/_TestUtil.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/_TestUtil.java Wed Mar 17 12:06:27 2010
@@ -33,10 +33,7 @@ public class _TestUtil {
/** Returns temp dir, containing String arg in its name;
* does not create the directory. */
public static File getTempDir(String desc) {
- String tempDir = System.getProperty("java.io.tmpdir");
- if (tempDir == null)
- throw new RuntimeException("java.io.tmpdir undefined, cannot run test");
- return new File(tempDir, desc + "." + new Random().nextLong());
+ return new File(LuceneTestCaseJ4.TEMP_DIR, desc + "." + new Random().nextLong());
}
public static void rmDir(File dir) throws IOException {