lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [04/32] lucenenet git commit: Fixing test errors with teardown/setup
Date Fri, 12 Aug 2016 13:25:17 GMT
Fixing test errors with teardown/setup


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

Branch: refs/heads/master
Commit: 4b52ddfdefed3c7cf91c6d9c7b5aad18014732dd
Parents: ae41663
Author: Connie Yau <conniey@microsoft.com>
Authored: Fri Jul 15 09:20:45 2016 -0700
Committer: Connie Yau <conniey@microsoft.com>
Committed: Fri Jul 22 12:17:30 2016 -0700

----------------------------------------------------------------------
 .../Util/LuceneTestCase.cs                      |  2 +-
 .../Lucene41/TestLucene41StoredFieldsFormat.cs  |  2 +-
 .../Lucene42/TestLucene42DocValuesFormat.cs     |  2 +-
 .../core/Index/TestBinaryDocValuesUpdates.cs    | 44 ++++++++++++++++----
 .../core/Index/TestNumericDocValuesUpdates.cs   |  5 ++-
 .../core/Index/TestStressIndexing.cs            |  6 ++-
 6 files changed, 48 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b52ddfd/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 6065280..0b63bd8 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -197,6 +197,7 @@ namespace Lucene.Net.Util
         public LuceneTestCase()
         {
             OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
+            ClassEnvRule = new TestRuleSetupAndRestoreClassEnv();
             String directory = Paths.TempDirectory;
             TEMP_DIR = new System.IO.FileInfo(directory);
         }
@@ -564,7 +565,6 @@ namespace Lucene.Net.Util
         {
             // LUCENENET TODO: Not sure how to convert these
             //ParentChainCallRule.SetupCalled = true;
-            ClassEnvRule = new TestRuleSetupAndRestoreClassEnv();
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b52ddfd/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestLucene41StoredFieldsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestLucene41StoredFieldsFormat.cs b/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestLucene41StoredFieldsFormat.cs
index d48f83c..0111163 100644
--- a/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestLucene41StoredFieldsFormat.cs
+++ b/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestLucene41StoredFieldsFormat.cs
@@ -24,7 +24,7 @@ namespace Lucene.Net.Codecs.Lucene41
     public class TestLucene41StoredFieldsFormat : BaseStoredFieldsFormatTestCase
     {
         [TestFixtureSetUp]
-        public static void BeforeClass()
+        public void BeforeClass()
         {
             OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient
codec
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b52ddfd/src/Lucene.Net.Tests/core/Codecs/Lucene42/TestLucene42DocValuesFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Codecs/Lucene42/TestLucene42DocValuesFormat.cs b/src/Lucene.Net.Tests/core/Codecs/Lucene42/TestLucene42DocValuesFormat.cs
index 2cb0e4b..19416f2 100644
--- a/src/Lucene.Net.Tests/core/Codecs/Lucene42/TestLucene42DocValuesFormat.cs
+++ b/src/Lucene.Net.Tests/core/Codecs/Lucene42/TestLucene42DocValuesFormat.cs
@@ -29,7 +29,7 @@ namespace Lucene.Net.Codecs.Lucene42
         private readonly Codec Codec_Renamed = new Lucene42RWCodec();
 
         [TestFixtureSetUp]
-        public static void BeforeClass()
+        public void BeforeClass()
         {
             OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient
codec
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b52ddfd/src/Lucene.Net.Tests/core/Index/TestBinaryDocValuesUpdates.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestBinaryDocValuesUpdates.cs b/src/Lucene.Net.Tests/core/Index/TestBinaryDocValuesUpdates.cs
index 23324b5..2caa695 100644
--- a/src/Lucene.Net.Tests/core/Index/TestBinaryDocValuesUpdates.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestBinaryDocValuesUpdates.cs
@@ -1,6 +1,6 @@
 using System;
 using System.Collections.Generic;
-    using System.Threading;
+using System.Threading;
 using Lucene.Net.Attributes;
 using Lucene.Net.Documents;
 
@@ -1109,25 +1109,55 @@ namespace Lucene.Net.Index
         [Test]
         public virtual void TestUpdateOldSegments()
         {
-            Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(),
new Lucene42RWCodec(), new Lucene45RWCodec() };
+            OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
+            Codec[] oldCodecs = new Codec[] {
+                new Lucene40RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE),
+                new Lucene41RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE),
+                new Lucene42RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE),
+                new Lucene45RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE)
+            };
             Directory dir = NewDirectory();
 
-            bool oldValue = OLD_FORMAT_IMPERSONATION_IS_ACTIVE;
             // create a segment with an old Codec
             IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
             conf.SetCodec(oldCodecs[Random().Next(oldCodecs.Length)]);
-            OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
             IndexWriter writer = new IndexWriter(dir, conf);
             Document doc = new Document();
             doc.Add(new StringField("id", "doc", Store.NO));
             doc.Add(new BinaryDocValuesField("f", ToBytes(5L)));
             writer.AddDocument(doc);
             writer.Dispose();
+            dir.Dispose();
+
+            OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
+        }
+
+        [Test]
+        public virtual void TestUpdateOldSegments_OldFormatNotActive()
+        {
+            bool oldValue = OLD_FORMAT_IMPERSONATION_IS_ACTIVE;
 
-            conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
-            writer = new IndexWriter(dir, conf);
-            writer.UpdateBinaryDocValue(new Term("id", "doc"), "f", ToBytes(4L));
             OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
+
+            Codec[] oldCodecs = new Codec[] {
+                new Lucene40RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE),
+                new Lucene41RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE),
+                new Lucene42RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE),
+                new Lucene45RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE)
+            };
+
+            Directory dir = NewDirectory();
+            Document doc = new Document();
+            doc.Add(new StringField("id", "doc", Store.NO));
+            doc.Add(new BinaryDocValuesField("f", ToBytes(5L)));
+
+            var conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
+            conf.SetCodec(oldCodecs[Random().Next(oldCodecs.Length)]);
+
+            var writer = new IndexWriter(dir, conf);
+            writer.AddDocument(doc);
+            writer.UpdateBinaryDocValue(new Term("id", "doc"), "f", ToBytes(4L));
+
             try
             {
                 writer.Dispose();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b52ddfd/src/Lucene.Net.Tests/core/Index/TestNumericDocValuesUpdates.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestNumericDocValuesUpdates.cs b/src/Lucene.Net.Tests/core/Index/TestNumericDocValuesUpdates.cs
index b9d592d..add43b4 100644
--- a/src/Lucene.Net.Tests/core/Index/TestNumericDocValuesUpdates.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestNumericDocValuesUpdates.cs
@@ -1062,14 +1062,15 @@ namespace Lucene.Net.Index
         [Test]
         public virtual void TestUpdateOldSegments()
         {
-            Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(),
new Lucene42RWCodec(), new Lucene45RWCodec() };
+            OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
+
+            Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE),
new Lucene41RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE), new Lucene42RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE),
new Lucene45RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE) };
             Directory dir = NewDirectory();
 
             bool oldValue = OLD_FORMAT_IMPERSONATION_IS_ACTIVE;
             // create a segment with an old Codec
             IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
             conf.SetCodec(oldCodecs[Random().Next(oldCodecs.Length)]);
-            OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
             IndexWriter writer = new IndexWriter(dir, conf);
             Document doc = new Document();
             doc.Add(new StringField("id", "doc", Store.NO));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b52ddfd/src/Lucene.Net.Tests/core/Index/TestStressIndexing.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestStressIndexing.cs b/src/Lucene.Net.Tests/core/Index/TestStressIndexing.cs
index 59a9baf..8f271f3 100644
--- a/src/Lucene.Net.Tests/core/Index/TestStressIndexing.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestStressIndexing.cs
@@ -92,10 +92,14 @@ namespace Lucene.Net.Index
             internal IndexWriter Writer;
             internal int NextID;
 
-            public IndexerThread(IndexWriter writer, TimedThread[] threads)
+            public IndexerThread(IndexWriter writer, TimedThread[] threads,
+                Func<string, string, Field.Store, Field> newStringField,
+                Func<string, string, Field.Store, Field> newTextField)
                 : base(threads)
             {
                 this.Writer = writer;
+                NewStringField = newStringField;
+                NewTextField = newTextField;
             }
 
             public override void DoWork()


Mime
View raw message