lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject lucenenet git commit: Remove endless iterations, Repeat(10) should be enough
Date Wed, 07 Jan 2015 01:29:23 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master a9585694a -> e6f76bb95


Remove endless iterations, Repeat(10) should be enough

The iterations have been removed from the test in later versions of Java Lucene too


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/e6f76bb9
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/e6f76bb9
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/e6f76bb9

Branch: refs/heads/master
Commit: e6f76bb95a4b6dc5ae6b9082d84f38ed3a4160d7
Parents: a958569
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Wed Jan 7 03:29:16 2015 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Wed Jan 7 03:29:16 2015 +0200

----------------------------------------------------------------------
 .../core/Index/TestIndexReaderClose.cs          | 107 +++++++++----------
 1 file changed, 52 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e6f76bb9/src/Lucene.Net.Tests/core/Index/TestIndexReaderClose.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexReaderClose.cs b/src/Lucene.Net.Tests/core/Index/TestIndexReaderClose.cs
index e1d0bef..1d4b7fc 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexReaderClose.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexReaderClose.cs
@@ -32,75 +32,72 @@ namespace Lucene.Net.Index
     [TestFixture]
     public class TestIndexReaderClose : LuceneTestCase
     {
-        [Test]
+        [Test, Repeat(10)]
         public virtual void TestCloseUnderException()
         {
-            int iters = 1000 + 1 + Random().Next(20); // LUCENENET TODO why so many times?
maybe switch to nightly?
-            for (int j = 0; j < iters; j++)
+            Directory dir = NewDirectory();
+            IndexWriter writer = new IndexWriter(dir,
+                NewIndexWriterConfig(Random(), TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
+            writer.Commit();
+            writer.Dispose();
+            DirectoryReader open = DirectoryReader.Open(dir);
+            bool throwOnClose = !Rarely();
+            AtomicReader wrap = SlowCompositeReaderWrapper.Wrap(open);
+            FilterAtomicReader reader = new FilterAtomicReaderAnonymousInnerClassHelper(this,
wrap, throwOnClose);
+            IList<IndexReader.ReaderClosedListener> listeners = new List<IndexReader.ReaderClosedListener>();
+            int listenerCount = Random().Next(20);
+            AtomicInteger count = new AtomicInteger();
+            bool faultySet = false;
+            for (int i = 0; i < listenerCount; i++)
             {
-                Directory dir = NewDirectory();
-                IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(Random(),
TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
-                writer.Commit();
-                writer.Dispose();
-                DirectoryReader open = DirectoryReader.Open(dir);
-                bool throwOnClose = !Rarely();
-                AtomicReader wrap = SlowCompositeReaderWrapper.Wrap(open);
-                FilterAtomicReader reader = new FilterAtomicReaderAnonymousInnerClassHelper(this,
wrap, throwOnClose);
-                IList<IndexReader.ReaderClosedListener> listeners = new List<IndexReader.ReaderClosedListener>();
-                int listenerCount = Random().Next(20);
-                AtomicInteger count = new AtomicInteger();
-                bool faultySet = false;
-                for (int i = 0; i < listenerCount; i++)
-                {
-                    if (Rarely())
-                    {
-                        faultySet = true;
-                        reader.AddReaderClosedListener(new FaultyListener());
-                    }
-                    else
-                    {
-                        count.IncrementAndGet();
-                        reader.AddReaderClosedListener(new CountListener(count));
-                    }
-                }
-                if (!faultySet && !throwOnClose)
+                if (Rarely())
                 {
+                    faultySet = true;
                     reader.AddReaderClosedListener(new FaultyListener());
                 }
-                try
+                else
                 {
-                    reader.Dispose();
-                    Assert.Fail("expected Exception");
+                    count.IncrementAndGet();
+                    reader.AddReaderClosedListener(new CountListener(count));
                 }
-                catch (InvalidOperationException ex)
-                {
-                    if (throwOnClose)
-                    {
-                        Assert.AreEqual("BOOM!", ex.Message);
-                    }
-                    else
-                    {
-                        Assert.AreEqual("GRRRRRRRRRRRR!", ex.Message);
-                    }
-                }
-
-                try
+            }
+            if (!faultySet && !throwOnClose)
+            {
+                reader.AddReaderClosedListener(new FaultyListener());
+            }
+            try
+            {
+                reader.Dispose();
+                Assert.Fail("expected Exception");
+            }
+            catch (InvalidOperationException ex)
+            {
+                if (throwOnClose)
                 {
-                    var aaa = reader.Fields;
-                    Assert.Fail("we are closed");
+                    Assert.AreEqual("BOOM!", ex.Message);
                 }
-                catch (AlreadyClosedException ex)
+                else
                 {
+                    Assert.AreEqual("GRRRRRRRRRRRR!", ex.Message);
                 }
+            }
 
-                if (Random().NextBoolean())
-                {
-                    reader.Dispose(); // call it again
-                }
-                Assert.AreEqual(0, count.Get());
-                wrap.Dispose();
-                dir.Dispose();
+            try
+            {
+                var aaa = reader.Fields;
+                Assert.Fail("we are closed");
+            }
+            catch (AlreadyClosedException ex)
+            {
+            }
+
+            if (Random().NextBoolean())
+            {
+                reader.Dispose(); // call it again
             }
+            Assert.AreEqual(0, count.Get());
+            wrap.Dispose();
+            dir.Dispose();
         }
 
         private class FilterAtomicReaderAnonymousInnerClassHelper : FilterAtomicReader


Mime
View raw message