You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2015/01/07 02:23:08 UTC

[1/3] lucenenet git commit: Another confirmed long running test

Repository: lucenenet
Updated Branches:
  refs/heads/master e3558b84b -> a9585694a


Another confirmed long running test


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

Branch: refs/heads/master
Commit: f79148cfb9e02c155a2998c66b9277b914203209
Parents: e3558b8
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Wed Jan 7 02:57:15 2015 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Wed Jan 7 02:57:15 2015 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Tests/core/Index/TestDocTermOrds.cs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f79148cf/src/Lucene.Net.Tests/core/Index/TestDocTermOrds.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestDocTermOrds.cs b/src/Lucene.Net.Tests/core/Index/TestDocTermOrds.cs
index 54ef5eb..0042286 100644
--- a/src/Lucene.Net.Tests/core/Index/TestDocTermOrds.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestDocTermOrds.cs
@@ -194,7 +194,7 @@ namespace Lucene.Net.Index
             dir.Dispose();
         }
 
-        [Test]
+        [Test, Timeout(300000)]
         public virtual void TestRandomWithPrefix()
         {
             Directory dir = NewDirectory();
@@ -223,7 +223,7 @@ namespace Lucene.Net.Index
                     terms.Add(new BytesRef(s));
                 }
             }
-            BytesRef[] termsArray = terms.ToArray(/*new BytesRef[terms.Size()]*/);
+            BytesRef[] termsArray = terms.ToArray();
             Array.Sort(termsArray);
 
             int NUM_DOCS = AtLeast(100);


Re: [2/3] lucenenet git commit: Fixing some more tests by asserting on the right things

Posted by Itamar Syn-Hershko <it...@code972.com>.
To all committers - notice this change

>From now on lets try using the Java style asserts and bring new variants as
needed, this will greatly improve the speed of which we work as well as
stability

Complete list of methods I added is here
https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs

--

Itamar Syn-Hershko
http://code972.com | @synhershko <https://twitter.com/synhershko>
Freelance Developer & Consultant
Author of RavenDB in Action <http://manning.com/synhershko/>

On Wed, Jan 7, 2015 at 3:23 AM, <sy...@apache.org> wrote:

> Fixing some more tests by asserting on the right things
>
> I've extended the test framework to support Java style asserts, and will
> bring more as needed. This will help porting tests in the future (less
> style changes), abstract away the testing framework, and most importantly
> make sure we don't assert differently than in the Java world
>
>
> Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
> Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/c9426e74
> Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/c9426e74
> Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/c9426e74
>
> Branch: refs/heads/master
> Commit: c9426e746c41c2498df6616753236c6899034d65
> Parents: f79148c
> Author: Itamar Syn-Hershko <it...@code972.com>
> Authored: Wed Jan 7 03:22:47 2015 +0200
> Committer: Itamar Syn-Hershko <it...@code972.com>
> Committed: Wed Jan 7 03:22:47 2015 +0200
>
> ----------------------------------------------------------------------
>  .../Index/BaseDocValuesFormatTestCase.cs              |  4 ++--
>  .../Index/BaseIndexFileFormatTestCase.cs              |  2 +-
>  .../JavaCompatibility/LuceneTestCase.cs               | 14 +++++++++++---
>  src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs   |  2 +-
>  4 files changed, 15 insertions(+), 7 deletions(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
> ----------------------------------------------------------------------
> diff --git
> a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
> b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
> index 4e940ee..970805c 100644
> --- a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
> +++ b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
> @@ -1477,12 +1477,12 @@ namespace Lucene.Net.Index
>
>              // compare
>              DirectoryReader ir = DirectoryReader.Open(dir);
> -            foreach (AtomicReaderContext context in ir.Leaves)
> +            foreach (var context in ir.Leaves)
>              {
>                  AtomicReader r = context.AtomicReader;
>                  Bits expected = FieldCache.DEFAULT.GetDocsWithField(r,
> "indexed");
>                  Bits actual = FieldCache.DEFAULT.GetDocsWithField(r,
> "dv");
> -                Assert.AreEqual(expected, actual);
> +                AssertEquals(expected, actual);
>              }
>              ir.Dispose();
>              dir.Dispose();
>
>
> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
> ----------------------------------------------------------------------
> diff --git
> a/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
> b/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
> index 67e606c..2ce7711 100644
> --- a/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
> +++ b/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
> @@ -120,7 +120,7 @@ namespace Lucene.Net.Index
>              w.Commit();
>              w.Dispose();
>
> -            Assert.AreEqual(BytesUsedByExtension(dir),
> BytesUsedByExtension(dir2));
> +            assertEquals(BytesUsedByExtension(dir),
> BytesUsedByExtension(dir2));
>
>              reader.Dispose();
>              dir.Dispose();
>
>
> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
> ----------------------------------------------------------------------
> diff --git
> a/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
> b/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
> index b2c23f5..9f8c484 100644
> --- a/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
> +++ b/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
> @@ -1,9 +1,8 @@
> -using System;
> -using System.Collections;
> +using System.Collections;
>  using System.Collections.Generic;
>  using NUnit.Framework;
>
> -namespace Lucene.Net
> +namespace Lucene.Net.Util
>  {
>      public abstract partial class LuceneTestCase
>      {
> @@ -57,6 +56,15 @@ namespace Lucene.Net
>              Assert.True(expected.SetEquals(actual), message);
>          }
>
> +        public static void assertEquals<T, S>(IDictionary<T, S> expected,
> IDictionary<T, S> actual)
> +        {
> +            Assert.AreEqual(expected.Count, actual.Count);
> +            foreach (var key in expected.Keys)
> +            {
> +                Assert.AreEqual(expected[key], actual[key]);
> +            }
> +        }
> +
>          public static void assertNotSame(object unexpected, object actual)
>          {
>              Assert.AreNotSame(unexpected, actual);
>
>
> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
> ----------------------------------------------------------------------
> diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
> b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
> index 66bf0ca..564b30a 100644
> --- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
> +++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
> @@ -190,7 +190,7 @@ namespace Lucene.Net.Util
>      /// </ul>
>      /// </summary>
>      [TestFixture]
> -    public abstract class LuceneTestCase : Assert // Wait long for leaked
> threads to complete before failure. zk needs this. -  See LUCENE-3995 for
> rationale.
> +    public abstract partial class LuceneTestCase : Assert // Wait long
> for leaked threads to complete before failure. zk needs this. -  See
> LUCENE-3995 for rationale.
>      {
>          public static System.IO.FileInfo TEMP_DIR;
>
>
>

[2/3] lucenenet git commit: Fixing some more tests by asserting on the right things

Posted by sy...@apache.org.
Fixing some more tests by asserting on the right things

I've extended the test framework to support Java style asserts, and will bring more as needed. This will help porting tests in the future (less style changes), abstract away the testing framework, and most importantly make sure we don't assert differently than in the Java world


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

Branch: refs/heads/master
Commit: c9426e746c41c2498df6616753236c6899034d65
Parents: f79148c
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Wed Jan 7 03:22:47 2015 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Wed Jan 7 03:22:47 2015 +0200

----------------------------------------------------------------------
 .../Index/BaseDocValuesFormatTestCase.cs              |  4 ++--
 .../Index/BaseIndexFileFormatTestCase.cs              |  2 +-
 .../JavaCompatibility/LuceneTestCase.cs               | 14 +++++++++++---
 src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs   |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
index 4e940ee..970805c 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
@@ -1477,12 +1477,12 @@ namespace Lucene.Net.Index
 
             // compare
             DirectoryReader ir = DirectoryReader.Open(dir);
-            foreach (AtomicReaderContext context in ir.Leaves)
+            foreach (var context in ir.Leaves)
             {
                 AtomicReader r = context.AtomicReader;
                 Bits expected = FieldCache.DEFAULT.GetDocsWithField(r, "indexed");
                 Bits actual = FieldCache.DEFAULT.GetDocsWithField(r, "dv");
-                Assert.AreEqual(expected, actual);
+                AssertEquals(expected, actual);
             }
             ir.Dispose();
             dir.Dispose();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
index 67e606c..2ce7711 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
@@ -120,7 +120,7 @@ namespace Lucene.Net.Index
             w.Commit();
             w.Dispose();
 
-            Assert.AreEqual(BytesUsedByExtension(dir), BytesUsedByExtension(dir2));
+            assertEquals(BytesUsedByExtension(dir), BytesUsedByExtension(dir2));
 
             reader.Dispose();
             dir.Dispose();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
index b2c23f5..9f8c484 100644
--- a/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
@@ -1,9 +1,8 @@
-using System;
-using System.Collections;
+using System.Collections;
 using System.Collections.Generic;
 using NUnit.Framework;
 
-namespace Lucene.Net
+namespace Lucene.Net.Util
 {
     public abstract partial class LuceneTestCase
     {
@@ -57,6 +56,15 @@ namespace Lucene.Net
             Assert.True(expected.SetEquals(actual), message);
         }
 
+        public static void assertEquals<T, S>(IDictionary<T, S> expected, IDictionary<T, S> actual)
+        {
+            Assert.AreEqual(expected.Count, actual.Count);
+            foreach (var key in expected.Keys)
+            {
+                Assert.AreEqual(expected[key], actual[key]);
+            }
+        }
+
         public static void assertNotSame(object unexpected, object actual)
         {
             Assert.AreNotSame(unexpected, actual);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
index 66bf0ca..564b30a 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -190,7 +190,7 @@ namespace Lucene.Net.Util
     /// </ul>
     /// </summary>
     [TestFixture]
-    public abstract class LuceneTestCase : Assert // Wait long for leaked threads to complete before failure. zk needs this. -  See LUCENE-3995 for rationale.
+    public abstract partial class LuceneTestCase : Assert // Wait long for leaked threads to complete before failure. zk needs this. -  See LUCENE-3995 for rationale.
     {
         public static System.IO.FileInfo TEMP_DIR;
 


[3/3] lucenenet git commit: Minor

Posted by sy...@apache.org.
Minor


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

Branch: refs/heads/master
Commit: a9585694a7968148f9910c65e3c89cd3b5aae5d4
Parents: c9426e7
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Wed Jan 7 03:22:58 2015 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Wed Jan 7 03:22:58 2015 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Core/Util/Bits.cs        | 42 +++++++++++++++++-----------
 src/Lucene.Net.Core/Util/FixedBitSet.cs |  2 +-
 2 files changed, 26 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a9585694/src/Lucene.Net.Core/Util/Bits.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Bits.cs b/src/Lucene.Net.Core/Util/Bits.cs
index 0e9effd..ac60e78 100644
--- a/src/Lucene.Net.Core/Util/Bits.cs
+++ b/src/Lucene.Net.Core/Util/Bits.cs
@@ -21,11 +21,11 @@ namespace Lucene.Net.Util
     /// Interface for Bitset-like structures.
     /// @lucene.experimental
     /// </summary>
-
     public interface Bits
     {
         /// <summary>
-        /// Returns the value of the bit with the specified <code>index</code>. </summary>
+        /// Returns the value of the bit with the specified <code>index</code>.
+        /// </summary>
         /// <param name="index"> index, should be non-negative and &lt; <seealso cref="#length()"/>.
         ///        The result of passing negative or out of bounds values is undefined
         ///        by this interface, <b>just don't do it!</b> </param>
@@ -35,28 +35,23 @@ namespace Lucene.Net.Util
         /// <summary>
         /// Returns the number of bits in this set </summary>
         int Length();
-
-        /// <summary>
-        /// Bits impl of the specified length with all bits set.
-        /// </summary>
-
-        /// <summary>
-        /// Bits impl of the specified length with no bits set.
-        /// </summary>
     }
 
-    public static class Bits_Fields
+    public static class BitsHelpers
     {
         public static readonly Bits[] EMPTY_ARRAY = new Bits[0];
     }
 
+    /// <summary>
+    /// Bits impl of the specified length with all bits set.
+    /// </summary>
     public class Bits_MatchAllBits : Bits
     {
-        internal readonly int Len;
+        private readonly int _len;
 
         public Bits_MatchAllBits(int len)
         {
-            this.Len = len;
+            _len = len;
         }
 
         public bool Get(int index)
@@ -66,17 +61,25 @@ namespace Lucene.Net.Util
 
         public int Length()
         {
-            return Len;
+            return _len;
+        }
+
+        public override int GetHashCode()
+        {
+            return ("MatchAllBits" + _len).GetHashCode();
         }
     }
 
+    /// <summary>
+    /// Bits impl of the specified length with no bits set.
+    /// </summary>
     public class Bits_MatchNoBits : Bits
     {
-        internal readonly int Len;
+        private readonly int _len;
 
         public Bits_MatchNoBits(int len)
         {
-            this.Len = len;
+            _len = len;
         }
 
         public bool Get(int index)
@@ -86,7 +89,12 @@ namespace Lucene.Net.Util
 
         public int Length()
         {
-            return Len;
+            return _len;
+        }
+
+        public override int GetHashCode()
+        {
+            return ("MatchNoBits" + _len).GetHashCode();
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a9585694/src/Lucene.Net.Core/Util/FixedBitSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/FixedBitSet.cs b/src/Lucene.Net.Core/Util/FixedBitSet.cs
index 1a5e253..99858af 100644
--- a/src/Lucene.Net.Core/Util/FixedBitSet.cs
+++ b/src/Lucene.Net.Core/Util/FixedBitSet.cs
@@ -718,7 +718,7 @@ namespace Lucene.Net.Util
             {
                 return false;
             }
-            FixedBitSet other = (FixedBitSet)o;
+            var other = (FixedBitSet)o;
             if (NumBits != other.Length())
             {
                 return false;