You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ar...@apache.org on 2008/08/01 00:20:50 UTC
svn commit: r681520 -
/incubator/lucene.net/trunk/C#/src/Test/Index/TestIndexWriter.cs
Author: aroush
Date: Thu Jul 31 15:20:48 2008
New Revision: 681520
URL: http://svn.apache.org/viewvc?rev=681520&view=rev
Log:
LUCENENET-131 "bugs in TestIndexWriter test cases"
Modified:
incubator/lucene.net/trunk/C#/src/Test/Index/TestIndexWriter.cs
Modified: incubator/lucene.net/trunk/C#/src/Test/Index/TestIndexWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Index/TestIndexWriter.cs?rev=681520&r1=681519&r2=681520&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Index/TestIndexWriter.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Index/TestIndexWriter.cs Thu Jul 31 15:20:48 2008
@@ -2365,7 +2365,7 @@
private class FailOnlyOnFlush : MockRAMDirectory.Failure
{
new internal bool doFail = false;
- //internal int count;
+ internal int count;
public override void SetDoFail()
{
@@ -2380,23 +2380,18 @@
{
if (doFail)
{
- // {{DOUG-2.3.1}} this code is suspect. i have preserved the original (below) for
- // comparative purposes.
- System.Exception e = new System.Exception();
- if (e.ToString().Contains("Lucene.Net.Index.DocumentsWriter") && e.StackTrace.Contains("appendPostings"))
+ System.Diagnostics.StackFrame[] frames = new System.Diagnostics.StackTrace().GetFrames();
+ for (int i = 0; i < frames.Length; i++)
{
- doFail = false;
- throw new System.IO.IOException("now failing during flush");
+ System.String methodName = frames[i].GetMethod().Name;
+ System.String className = frames[i].GetMethod().DeclaringType.ToString();
+ if ("Lucene.Net.Index.DocumentsWriter".Equals(className) &&
+ "AppendPostings".Equals(methodName) && count++ == 30)
+ {
+ doFail = false;
+ throw new System.IO.IOException("now failing during flush");
+ }
}
- //StackTraceElement[] trace = new System.Exception().getStackTrace();
- //for (int i = 0; i < trace.Length; i++)
- //{
- // if ("Lucene.Net.Index.DocumentsWriter".Equals(trace[i].getClassName()) && "appendPostings".Equals(trace[i].getMethodName()) && count++ == 30)
- // {
- // doFail = false;
- // throw new System.IO.IOException("now failing during flush");
- // }
- //}
}
}
}
@@ -3051,25 +3046,17 @@
{
if (doFail)
{
- // {{DOUG-2.3.1}} this code is suspect. i have preserved the original (below) for
- // comparative purposes.
- System.String trace = new System.Exception().StackTrace;
- if (trace.Contains("abort") || trace.Contains("flushDocument"))
+ System.Diagnostics.StackFrame[] frames = new System.Diagnostics.StackTrace().GetFrames();
+ for (int i = 0; i < frames.Length; i++)
{
- if (onlyOnce)
- doFail = false;
- throw new System.IO.IOException("now failing on purpose");
- }
- //StackTraceElement[] trace = new System.Exception().getStackTrace();
- //for (int i = 0; i < trace.Length; i++)
- //{
- // if ("abort".Equals(trace[i].getMethodName()) || "flushDocument".Equals(trace[i].getMethodName()))
- // {
- // if (onlyOnce)
- // doFail = false;
- // throw new System.IO.IOException("now failing on purpose");
- // }
- //}
+ String methodName = frames[i].GetMethod().Name;
+ if ("Abort".Equals(methodName) || "FlushDocument".Equals(methodName))
+ {
+ if (onlyOnce)
+ doFail = false;
+ throw new System.IO.IOException("now failing on purpose");
+ }
+ }
}
}
}
@@ -3235,24 +3222,17 @@
{
if (doFail)
{
- // {{DOUG-2.3.1}} this code is suspect. i have preserved the original (below) for
- // comparative purposes.
- if (new System.Exception().StackTrace.Contains("closeDocStore"))
+ System.Diagnostics.StackFrame[] frames = new System.Diagnostics.StackTrace().GetFrames();
+ for (int i = 0; i < frames.Length; i++)
{
- if (onlyOnce)
- doFail = false;
- throw new System.IO.IOException("now failing on purpose");
+ String methodName = frames[i].GetMethod().Name;
+ if ("CloseDocStore".Equals(methodName))
+ {
+ if (onlyOnce)
+ doFail = false;
+ throw new System.IO.IOException("now failing on purpose");
+ }
}
- //StackTraceElement[] trace = new System.Exception().getStackTrace();
- //for (int i = 0; i < trace.Length; i++)
- //{
- // if ("closeDocStore".Equals(trace[i].getMethodName()))
- // {
- // if (onlyOnce)
- // doFail = false;
- // throw new System.IO.IOException("now failing on purpose");
- // }
- //}
}
}
}
@@ -3297,26 +3277,17 @@
{
if (doFail)
{
- // {{DOUG-2.3.1}} this code is suspect. i have preserved the original (below) for
- // comparative purposes.
- if (new System.Exception().StackTrace.Contains("writeSegment"))
+ System.Diagnostics.StackFrame[] frames = new System.Diagnostics.StackTrace().GetFrames();
+ for (int i = 0; i < frames.Length; i++)
{
- if (onlyOnce)
- doFail = false;
- // new RuntimeException().printStackTrace(System.out);
- throw new System.IO.IOException("now failing on purpose");
+ String methodName = frames[i].GetMethod().Name;
+ if ("WriteSegment".Equals(methodName))
+ {
+ if (onlyOnce)
+ doFail = false;
+ throw new System.IO.IOException("now failing on purpose");
+ }
}
- //StackTraceElement[] trace = new System.Exception().getStackTrace();
- //for (int i = 0; i < trace.Length; i++)
- //{
- // if ("writeSegment".Equals(trace[i].getMethodName()))
- // {
- // if (onlyOnce)
- // doFail = false;
- // // new RuntimeException().printStackTrace(System.out);
- // throw new System.IO.IOException("now failing on purpose");
- // }
- //}
}
}
}