You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2016/10/23 13:01:55 UTC
[09/50] [abbrv] lucenenet git commit: Added missing test
Core.TestWorstCaseBehavior
Added missing test Core.TestWorstCaseBehavior
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/fc40147e
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/fc40147e
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/fc40147e
Branch: refs/heads/master
Commit: fc40147ed85e3a81b81f0b1f276ec3f41c01d265
Parents: 7517a73
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Sun Oct 16 06:48:16 2016 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Thu Oct 20 18:20:52 2016 +0700
----------------------------------------------------------------------
src/Lucene.Net.Tests/Lucene.Net.Tests.csproj | 1 +
.../core/TestWorstCaseTestBehavior.cs | 253 +++++++++----------
2 files changed, 126 insertions(+), 128 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc40147e/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj b/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj
index 8cf8890..7d6d99f 100644
--- a/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj
+++ b/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj
@@ -484,6 +484,7 @@
</Compile>
<Compile Include="core\TestSearch.cs" />
<Compile Include="core\TestSearchForDuplicates.cs" />
+ <Compile Include="core\TestWorstCaseTestBehavior.cs" />
<Compile Include="core\Util\Automaton\TestBasicOperations.cs">
<SubType>Code</SubType>
</Compile>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc40147e/src/Lucene.Net.Tests/core/TestWorstCaseTestBehavior.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/TestWorstCaseTestBehavior.cs b/src/Lucene.Net.Tests/core/TestWorstCaseTestBehavior.cs
index ac07b2c..ee0a0b9 100644
--- a/src/Lucene.Net.Tests/core/TestWorstCaseTestBehavior.cs
+++ b/src/Lucene.Net.Tests/core/TestWorstCaseTestBehavior.cs
@@ -1,16 +1,12 @@
+using Lucene.Net.Support;
+using Lucene.Net.Util;
+using NUnit.Framework;
using System;
using System.Threading;
-namespace org.apache.lucene
+namespace Lucene.Net
{
-
- using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
- //using Ignore = org.junit.Ignore;
-
- //using RandomizedTest = com.carrotsearch.randomizedtesting.RandomizedTest;
- //using Timeout = com.carrotsearch.randomizedtesting.annotations.Timeout;
-
- /*
+ /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -27,123 +23,124 @@ namespace org.apache.lucene
* limitations under the License.
*/
- public class TestWorstCaseTestBehavior : LuceneTestCase
- {
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Ignore public void testThreadLeak()
- public virtual void TestThreadLeak()
- {
- Thread t = new ThreadAnonymousInnerClassHelper(this);
- t.Start();
-
- while (!t.IsAlive)
- {
- Thread.@Yield();
- }
-
- // once alive, leave it to run outside of the test scope.
- }
-
- private class ThreadAnonymousInnerClassHelper : Thread
- {
- private readonly TestWorstCaseTestBehavior OuterInstance;
-
- public ThreadAnonymousInnerClassHelper(TestWorstCaseTestBehavior outerInstance)
- {
- this.OuterInstance = outerInstance;
- }
-
- public override void Run()
- {
- try
- {
- Thread.Sleep(10000);
- }
- catch (InterruptedException e)
- {
- // Ignore.
- }
- }
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Ignore public void testLaaaaaargeOutput() throws Exception
- public virtual void TestLaaaaaargeOutput()
- {
- string message = "I will not OOM on large output";
- int howMuch = 250 * 1024 * 1024;
- for (int i = 0; i < howMuch; i++)
- {
- if (i > 0)
- {
- Console.Write(",\n");
- }
- Console.Write(message);
- howMuch -= message.Length; // approximately.
- }
- Console.WriteLine(".");
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Ignore public void testProgressiveOutput() throws Exception
- public virtual void TestProgressiveOutput()
- {
- for (int i = 0; i < 20; i++)
- {
- Console.WriteLine("Emitting sysout line: " + i);
- Console.Error.WriteLine("Emitting syserr line: " + i);
- System.out.flush();
- System.err.flush();
- RandomizedTest.sleep(1000);
- }
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Ignore public void testUncaughtException() throws Exception
- public virtual void TestUncaughtException()
- {
- Thread t = new ThreadAnonymousInnerClassHelper2(this);
- t.Start();
- t.Join();
- }
-
- private class ThreadAnonymousInnerClassHelper2 : System.Threading.Thread
- {
- private readonly TestWorstCaseTestBehavior OuterInstance;
-
- public ThreadAnonymousInnerClassHelper2(TestWorstCaseTestBehavior outerInstance)
- {
- this.OuterInstance = outerInstance;
- }
-
- public override void Run()
- {
- throw new Exception("foobar");
- }
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Ignore @Timeout(millis = 500) public void testTimeout() throws Exception
- public virtual void TestTimeout()
- {
- Thread.Sleep(5000);
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Ignore @Timeout(millis = 1000) public void testZombie() throws Exception
- public virtual void TestZombie()
- {
- while (true)
- {
- try
- {
- Thread.Sleep(1000);
- }
- catch (InterruptedException e)
- {
- }
- }
- }
- }
-
+ public class TestWorstCaseTestBehavior : LuceneTestCase
+ {
+ [Ignore]
+ [Test]
+ public virtual void TestThreadLeak()
+ {
+ ThreadClass t = new ThreadAnonymousInnerClassHelper(this);
+ t.Start();
+
+ while (!t.IsAlive)
+ {
+ Thread.@Yield();
+ }
+
+ // once alive, leave it to run outside of the test scope.
+ }
+
+ private class ThreadAnonymousInnerClassHelper : ThreadClass
+ {
+ private readonly TestWorstCaseTestBehavior OuterInstance;
+
+ public ThreadAnonymousInnerClassHelper(TestWorstCaseTestBehavior outerInstance)
+ {
+ this.OuterInstance = outerInstance;
+ }
+
+ public override void Run()
+ {
+ try
+ {
+ Thread.Sleep(10000);
+ }
+ catch (ThreadInterruptedException e)
+ {
+ // Ignore.
+ }
+ }
+ }
+
+ [Ignore]
+ [Test]
+ public virtual void TestLaaaaaargeOutput()
+ {
+ string message = "I will not OOM on large output";
+ int howMuch = 250 * 1024 * 1024;
+ for (int i = 0; i < howMuch; i++)
+ {
+ if (i > 0)
+ {
+ Console.Write(",\n");
+ }
+ Console.Write(message);
+ howMuch -= message.Length; // approximately.
+ }
+ Console.WriteLine(".");
+ }
+
+
+ [Ignore]
+ [Test]
+ public virtual void TestProgressiveOutput()
+ {
+ for (int i = 0; i < 20; i++)
+ {
+ Console.WriteLine("Emitting sysout line: " + i);
+ Console.Error.WriteLine("Emitting syserr line: " + i);
+ Console.Out.Flush();
+ Console.Error.Flush();
+ Thread.Sleep(1000);
+ }
+ }
+
+ [Ignore]
+ [Test]
+ public virtual void TestUncaughtException()
+ {
+ ThreadClass t = new ThreadAnonymousInnerClassHelper2(this);
+ t.Start();
+ t.Join();
+ }
+
+ private class ThreadAnonymousInnerClassHelper2 : ThreadClass
+ {
+ private readonly TestWorstCaseTestBehavior OuterInstance;
+
+ public ThreadAnonymousInnerClassHelper2(TestWorstCaseTestBehavior outerInstance)
+ {
+ this.OuterInstance = outerInstance;
+ }
+
+ public override void Run()
+ {
+ throw new Exception("foobar");
+ }
+ }
+
+ [Ignore]
+ [Test, Timeout(500)]
+ public virtual void TestTimeout()
+ {
+ Thread.Sleep(5000);
+ }
+
+
+ [Ignore]
+ [Test, Timeout(1000)]
+ public virtual void TestZombie()
+ {
+ while (true)
+ {
+ try
+ {
+ Thread.Sleep(1000);
+ }
+ catch (ThreadInterruptedException e)
+ {
+ }
+ }
+ }
+ }
}
\ No newline at end of file