Lucene.Net.TestFramework: Refactored LuceneTestCase and test codecs back to their original implementation of using a static variable to determine if impersonation is active.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/4b0fa137 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/4b0fa137 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/4b0fa137 Branch: refs/heads/api-work Commit: 4b0fa1374d9c30974d9ec68c29aeb2b4fad84e19 Parents: 3437f3b Author: Shad Storhaug <[email protected]> Authored: Mon Feb 27 06:10:19 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Mon Feb 27 06:18:03 2017 +0700 ---------------------------------------------------------------------- .../Codecs/Lucene3x/PreFlexRWCodec.cs | 60 ++++++-------------- .../Codecs/Lucene40/Lucene40RWCodec.cs | 46 ++------------- .../Lucene40/Lucene40RWDocValuesFormat.cs | 25 +------- .../Codecs/Lucene40/Lucene40RWNormsFormat.cs | 25 +------- .../Codecs/Lucene40/Lucene40RWPostingsFormat.cs | 25 +------- .../Codecs/Lucene41/Lucene41RWCodec.cs | 55 ++++-------------- .../Codecs/Lucene42/Lucene42RWCodec.cs | 38 +------------ .../Lucene42/Lucene42RWDocValuesFormat.cs | 25 +------- .../Codecs/Lucene45/Lucene45RWCodec.cs | 36 +----------- .../Util/LuceneTestCase.cs | 30 ++++------ .../Lucene3x/TestLucene3xPostingsFormat.cs | 14 +++-- .../Lucene3x/TestLucene3xStoredFieldsFormat.cs | 16 +++--- .../Lucene3x/TestLucene3xTermVectorsFormat.cs | 3 +- .../Codecs/Lucene3x/TestSurrogates.cs | 8 +-- .../Codecs/Lucene3x/TestTermInfosReaderIndex.cs | 9 +-- .../Lucene40/TestLucene40DocValuesFormat.cs | 12 ++-- .../Lucene40/TestLucene40PostingsFormat.cs | 12 ++-- .../Lucene40/TestLucene40PostingsReader.cs | 7 +-- .../Lucene40/TestLucene40StoredFieldsFormat.cs | 10 +--- .../Lucene40/TestLucene40TermVectorsFormat.cs | 10 +--- .../Codecs/Lucene40/TestReuseDocsEnum.cs | 13 ++--- .../Lucene41/TestLucene41StoredFieldsFormat.cs | 9 +-- .../Lucene42/TestLucene42DocValuesFormat.cs | 12 ++-- .../Index/TestBackwardsCompatibility.cs | 2 +- .../Index/TestBackwardsCompatibility3x.cs | 14 ++--- .../Index/TestBinaryDocValuesUpdates.cs | 24 +++----- src/Lucene.Net.Tests/Index/TestCodecs.cs | 5 +- .../Index/TestNumericDocValuesUpdates.cs | 5 +- 28 files changed, 129 insertions(+), 421 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.TestFramework/Codecs/Lucene3x/PreFlexRWCodec.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene3x/PreFlexRWCodec.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene3x/PreFlexRWCodec.cs index 4d265d9..642d33f 100644 --- a/src/Lucene.Net.TestFramework/Codecs/Lucene3x/PreFlexRWCodec.cs +++ b/src/Lucene.Net.TestFramework/Codecs/Lucene3x/PreFlexRWCodec.cs @@ -26,44 +26,20 @@ namespace Lucene.Net.Codecs.Lucene3x #pragma warning disable 612, 618 public class PreFlexRWCodec : Lucene3xCodec { - private readonly PostingsFormat Postings = new PreFlexRWPostingsFormat(); - private readonly Lucene3xNormsFormat Norms = new PreFlexRWNormsFormat(); - private readonly FieldInfosFormat FieldInfos = new PreFlexRWFieldInfosFormat(); - private readonly TermVectorsFormat TermVectors = new PreFlexRWTermVectorsFormat(); - private readonly SegmentInfoFormat SegmentInfos = new PreFlexRWSegmentInfoFormat(); - private readonly StoredFieldsFormat StoredFields = new PreFlexRWStoredFieldsFormat(); - private readonly bool _oldFormatImpersonationIsActive; - - /// <summary> - /// LUCENENET specific - /// Creates the codec with OldFormatImpersonationIsActive = true. - /// </summary> - /// <remarks> - /// Added so that SPIClassIterator can locate this Codec. The iterator - /// only recognises classes that have empty constructors. - /// </remarks> - public PreFlexRWCodec() - : this(true) - { } - - /// <summary> - /// </summary> - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public PreFlexRWCodec(bool oldFormatImpersonationIsActive) : base() - { - _oldFormatImpersonationIsActive = oldFormatImpersonationIsActive; - } + private readonly PostingsFormat postings = new PreFlexRWPostingsFormat(); + private readonly Lucene3xNormsFormat norms = new PreFlexRWNormsFormat(); + private readonly FieldInfosFormat fieldInfos = new PreFlexRWFieldInfosFormat(); + private readonly TermVectorsFormat termVectors = new PreFlexRWTermVectorsFormat(); + private readonly SegmentInfoFormat segmentInfos = new PreFlexRWSegmentInfoFormat(); + private readonly StoredFieldsFormat storedFields = new PreFlexRWStoredFieldsFormat(); public override PostingsFormat PostingsFormat { get { - if (_oldFormatImpersonationIsActive) + if (LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { - return Postings; + return postings; } else { @@ -76,9 +52,9 @@ namespace Lucene.Net.Codecs.Lucene3x { get { - if (_oldFormatImpersonationIsActive) + if (LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { - return Norms; + return norms; } else { @@ -91,9 +67,9 @@ namespace Lucene.Net.Codecs.Lucene3x { get { - if (_oldFormatImpersonationIsActive) + if (LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { - return SegmentInfos; + return segmentInfos; } else { @@ -106,9 +82,9 @@ namespace Lucene.Net.Codecs.Lucene3x { get { - if (_oldFormatImpersonationIsActive) + if (LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { - return FieldInfos; + return fieldInfos; } else { @@ -121,9 +97,9 @@ namespace Lucene.Net.Codecs.Lucene3x { get { - if (_oldFormatImpersonationIsActive) + if (LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { - return TermVectors; + return termVectors; } else { @@ -136,9 +112,9 @@ namespace Lucene.Net.Codecs.Lucene3x { get { - if (_oldFormatImpersonationIsActive) + if (LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { - return StoredFields; + return storedFields; } else { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWCodec.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWCodec.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWCodec.cs index 79fbb42..7c69b61 100644 --- a/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWCodec.cs +++ b/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWCodec.cs @@ -24,49 +24,15 @@ namespace Lucene.Net.Codecs.Lucene40 #pragma warning disable 612, 618 public sealed class Lucene40RWCodec : Lucene40Codec { - private readonly FieldInfosFormat fieldInfos; - - /// <summary> - /// LUCENENET specific - /// Creates the codec with OldFormatImpersonationIsActive = true. - /// </summary> - /// <remarks> - /// Added so that SPIClassIterator can locate this Codec. The iterator - /// only recognises classes that have empty constructors. - /// </remarks> - public Lucene40RWCodec() - : this(true) - { } - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene40RWCodec(bool oldFormatImpersonationIsActive) : base() - { - fieldInfos = new Lucene40FieldInfosFormatAnonymousInnerClassHelper(oldFormatImpersonationIsActive); - DocValues = new Lucene40RWDocValuesFormat(oldFormatImpersonationIsActive); - Norms = new Lucene40RWNormsFormat(oldFormatImpersonationIsActive); - } + private readonly FieldInfosFormat fieldInfos = new Lucene40FieldInfosFormatAnonymousInnerClassHelper(); private class Lucene40FieldInfosFormatAnonymousInnerClassHelper : Lucene40FieldInfosFormat { - private readonly bool _oldFormatImpersonationIsActive; - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene40FieldInfosFormatAnonymousInnerClassHelper(bool oldFormatImpersonationIsActive) : base() - { - _oldFormatImpersonationIsActive = oldFormatImpersonationIsActive; - } - public override FieldInfosWriter FieldInfosWriter { get { - if (!_oldFormatImpersonationIsActive) + if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { return base.FieldInfosWriter; } @@ -78,8 +44,8 @@ namespace Lucene.Net.Codecs.Lucene40 } } - private readonly DocValuesFormat DocValues; - private readonly NormsFormat Norms; + private readonly DocValuesFormat docValues = new Lucene40RWDocValuesFormat(); + private readonly NormsFormat norms = new Lucene40RWNormsFormat(); public override FieldInfosFormat FieldInfosFormat { @@ -88,12 +54,12 @@ namespace Lucene.Net.Codecs.Lucene40 public override DocValuesFormat DocValuesFormat { - get { return DocValues; } + get { return docValues; } } public override NormsFormat NormsFormat { - get { return Norms; } + get { return norms; } } } #pragma warning restore 612, 618 http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWDocValuesFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWDocValuesFormat.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWDocValuesFormat.cs index 2281475..20c641a 100644 --- a/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWDocValuesFormat.cs +++ b/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWDocValuesFormat.cs @@ -26,32 +26,9 @@ namespace Lucene.Net.Codecs.Lucene40 #pragma warning disable 612, 618 public class Lucene40RWDocValuesFormat : Lucene40DocValuesFormat { - private readonly bool _oldFormatImpersonationIsActive; - - /// <summary> - /// LUCENENET specific - /// Creates the codec with OldFormatImpersonationIsActive = true. - /// </summary> - /// <remarks> - /// Added so that SPIClassIterator can locate this Codec. The iterator - /// only recognises classes that have empty constructors. - /// </remarks> - public Lucene40RWDocValuesFormat() - : this(true) - { } - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene40RWDocValuesFormat(bool oldFormatImpersonationIsActive) : base() - { - _oldFormatImpersonationIsActive = oldFormatImpersonationIsActive; - } - public override DocValuesConsumer FieldsConsumer(SegmentWriteState state) { - if (!_oldFormatImpersonationIsActive) + if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { return base.FieldsConsumer(state); } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWNormsFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWNormsFormat.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWNormsFormat.cs index 0830c86..12e5cf6 100644 --- a/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWNormsFormat.cs +++ b/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWNormsFormat.cs @@ -26,32 +26,9 @@ namespace Lucene.Net.Codecs.Lucene40 #pragma warning disable 612, 618 public class Lucene40RWNormsFormat : Lucene40NormsFormat { - private readonly bool _oldFormatImpersonationIsActive; - - /// <summary> - /// LUCENENET specific - /// Creates the codec with OldFormatImpersonationIsActive = true. - /// </summary> - /// <remarks> - /// Added so that SPIClassIterator can locate this Codec. The iterator - /// only recognises classes that have empty constructors. - /// </remarks> - public Lucene40RWNormsFormat() - : this(true) - { } - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene40RWNormsFormat(bool oldFormatImpersonationIsActive) : base() - { - _oldFormatImpersonationIsActive = oldFormatImpersonationIsActive; - } - public override DocValuesConsumer NormsConsumer(SegmentWriteState state) { - if (!_oldFormatImpersonationIsActive) + if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { return base.NormsConsumer(state); } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWPostingsFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWPostingsFormat.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWPostingsFormat.cs index 7a2c9cf..aff3425 100644 --- a/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWPostingsFormat.cs +++ b/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40RWPostingsFormat.cs @@ -26,32 +26,9 @@ namespace Lucene.Net.Codecs.Lucene40 #pragma warning disable 612, 618 public class Lucene40RWPostingsFormat : Lucene40PostingsFormat { - private readonly bool _oldFormatImpersonationIsActive; - - /// <summary> - /// LUCENENET specific - /// Creates the codec with OldFormatImpersonationIsActive = true. - /// </summary> - /// <remarks> - /// Added so that SPIClassIterator can locate this Codec. The iterator - /// only recognises classes that have empty constructors. - /// </remarks> - public Lucene40RWPostingsFormat() - : this(true) - { } - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene40RWPostingsFormat(bool oldFormatImpersonationIsActive) : base() - { - _oldFormatImpersonationIsActive = oldFormatImpersonationIsActive; - } - public override FieldsConsumer FieldsConsumer(SegmentWriteState state) { - if (!_oldFormatImpersonationIsActive) + if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { return base.FieldsConsumer(state); } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.TestFramework/Codecs/Lucene41/Lucene41RWCodec.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene41/Lucene41RWCodec.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene41/Lucene41RWCodec.cs index 2c6edef..a51a514 100644 --- a/src/Lucene.Net.TestFramework/Codecs/Lucene41/Lucene41RWCodec.cs +++ b/src/Lucene.Net.TestFramework/Codecs/Lucene41/Lucene41RWCodec.cs @@ -29,55 +29,16 @@ namespace Lucene.Net.Codecs.Lucene41 #pragma warning disable 612, 618 public class Lucene41RWCodec : Lucene41Codec { - private readonly StoredFieldsFormat FieldsFormat = new Lucene41StoredFieldsFormat(); - private readonly FieldInfosFormat fieldInfos; - private readonly DocValuesFormat DocValues; - private readonly NormsFormat Norms; - private readonly bool _oldFormatImpersonationIsActive; - - /// <summary> - /// LUCENENET specific - /// Creates the codec with OldFormatImpersonationIsActive = true. - /// </summary> - /// <remarks> - /// Added so that SPIClassIterator can locate this Codec. The iterator - /// only recognises classes that have empty constructors. - /// </remarks> - public Lucene41RWCodec() - : this(true) - { } - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene41RWCodec(bool oldFormatImpersonationIsActive) : base() - { - _oldFormatImpersonationIsActive = oldFormatImpersonationIsActive; - - Norms = new Lucene40RWNormsFormat(oldFormatImpersonationIsActive); - fieldInfos = new Lucene40FieldInfosFormatAnonymousInnerClassHelper(oldFormatImpersonationIsActive); - DocValues = new Lucene40RWDocValuesFormat(oldFormatImpersonationIsActive); - } + private readonly StoredFieldsFormat fieldsFormat = new Lucene41StoredFieldsFormat(); + private readonly FieldInfosFormat fieldInfos = new Lucene40FieldInfosFormatAnonymousInnerClassHelper(); private class Lucene40FieldInfosFormatAnonymousInnerClassHelper : Lucene40FieldInfosFormat { - private readonly bool _oldFormatImpersonationIsActive; - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene40FieldInfosFormatAnonymousInnerClassHelper(bool oldFormatImpersonationIsActive) : base() - { - _oldFormatImpersonationIsActive = oldFormatImpersonationIsActive; - } - public override FieldInfosWriter FieldInfosWriter { get { - if (!_oldFormatImpersonationIsActive) + if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { return base.FieldInfosWriter; } @@ -89,6 +50,10 @@ namespace Lucene.Net.Codecs.Lucene41 } } + private readonly DocValuesFormat docValues = new Lucene40RWDocValuesFormat(); + private readonly NormsFormat norms = new Lucene40RWNormsFormat(); + + public override FieldInfosFormat FieldInfosFormat { get { return fieldInfos; } @@ -96,17 +61,17 @@ namespace Lucene.Net.Codecs.Lucene41 public override StoredFieldsFormat StoredFieldsFormat { - get { return FieldsFormat; } + get { return fieldsFormat; } } public override DocValuesFormat DocValuesFormat { - get { return DocValues; } + get { return docValues; } } public override NormsFormat NormsFormat { - get { return Norms; } + get { return norms; } } } #pragma warning restore 612, 618 http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.TestFramework/Codecs/Lucene42/Lucene42RWCodec.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene42/Lucene42RWCodec.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene42/Lucene42RWCodec.cs index 39e3b66..f117744 100644 --- a/src/Lucene.Net.TestFramework/Codecs/Lucene42/Lucene42RWCodec.cs +++ b/src/Lucene.Net.TestFramework/Codecs/Lucene42/Lucene42RWCodec.cs @@ -25,50 +25,18 @@ namespace Lucene.Net.Codecs.Lucene42 #pragma warning disable 612, 618 public class Lucene42RWCodec : Lucene42Codec { - private readonly DocValuesFormat Dv; + private readonly DocValuesFormat Dv = new Lucene42RWDocValuesFormat(); private readonly NormsFormat Norms = new Lucene42NormsFormat(); - private readonly FieldInfosFormat fieldInfosFormat; - /// <summary> - /// LUCENENET specific - /// Creates the codec with OldFormatImpersonationIsActive = true. - /// </summary> - /// <remarks> - /// Added so that SPIClassIterator can locate this Codec. The iterator - /// only recognises classes that have empty constructors. - /// </remarks> - public Lucene42RWCodec() - : this(true) - { } - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene42RWCodec(bool oldFormatImpersonationIsActive) : base() - { - Dv = new Lucene42RWDocValuesFormat(oldFormatImpersonationIsActive); - fieldInfosFormat = new Lucene42FieldInfosFormatAnonymousInnerClassHelper(oldFormatImpersonationIsActive); - } + private readonly FieldInfosFormat fieldInfosFormat = new Lucene42FieldInfosFormatAnonymousInnerClassHelper(); private class Lucene42FieldInfosFormatAnonymousInnerClassHelper : Lucene42FieldInfosFormat { - private readonly bool _oldFormatImpersonationIsActive; - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene42FieldInfosFormatAnonymousInnerClassHelper(bool oldFormatImpersonationIsActive) : base() - { - _oldFormatImpersonationIsActive = oldFormatImpersonationIsActive; - } - public override FieldInfosWriter FieldInfosWriter { get { - if (!_oldFormatImpersonationIsActive) + if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { return base.FieldInfosWriter; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.TestFramework/Codecs/Lucene42/Lucene42RWDocValuesFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene42/Lucene42RWDocValuesFormat.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene42/Lucene42RWDocValuesFormat.cs index 1a29fe6..a7ea4fb 100644 --- a/src/Lucene.Net.TestFramework/Codecs/Lucene42/Lucene42RWDocValuesFormat.cs +++ b/src/Lucene.Net.TestFramework/Codecs/Lucene42/Lucene42RWDocValuesFormat.cs @@ -27,32 +27,9 @@ namespace Lucene.Net.Codecs.Lucene42 #pragma warning disable 612, 618 public class Lucene42RWDocValuesFormat : Lucene42DocValuesFormat { - private readonly bool _oldFormatImpersonationIsActive; - - /// <summary> - /// LUCENENET specific - /// Creates the codec with OldFormatImpersonationIsActive = true. - /// </summary> - /// <remarks> - /// Added so that SPIClassIterator can locate this Codec. The iterator - /// only recognises classes that have empty constructors. - /// </remarks> - public Lucene42RWDocValuesFormat() - : this(true) - { } - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene42RWDocValuesFormat(bool oldFormatImpersonationIsActive) : base() - { - _oldFormatImpersonationIsActive = oldFormatImpersonationIsActive; - } - public override DocValuesConsumer FieldsConsumer(SegmentWriteState state) { - if (!_oldFormatImpersonationIsActive) + if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { return base.FieldsConsumer(state); } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.TestFramework/Codecs/Lucene45/Lucene45RWCodec.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene45/Lucene45RWCodec.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene45/Lucene45RWCodec.cs index c610ca9..6ddcf84 100644 --- a/src/Lucene.Net.TestFramework/Codecs/Lucene45/Lucene45RWCodec.cs +++ b/src/Lucene.Net.TestFramework/Codecs/Lucene45/Lucene45RWCodec.cs @@ -27,47 +27,15 @@ namespace Lucene.Net.Codecs.Lucene45 #pragma warning disable 612, 618 public class Lucene45RWCodec : Lucene45Codec { - private readonly FieldInfosFormat fieldInfosFormat; - - /// <summary> - /// LUCENENET specific - /// Creates the codec with OldFormatImpersonationIsActive = true. - /// </summary> - /// <remarks> - /// Added so that SPIClassIterator can locate this Codec. The iterator - /// only recognises classes that have empty constructors. - /// </remarks> - public Lucene45RWCodec() - : this(true) - { } - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene45RWCodec(bool oldFormatImpersonationIsActive) : base() - { - fieldInfosFormat = new Lucene42FieldInfosFormatAnonymousInnerClassHelper(oldFormatImpersonationIsActive); - } + private readonly FieldInfosFormat fieldInfosFormat = new Lucene42FieldInfosFormatAnonymousInnerClassHelper(); private class Lucene42FieldInfosFormatAnonymousInnerClassHelper : Lucene42FieldInfosFormat { - private readonly bool _oldFormatImpersonationIsActive; - - /// <param name="oldFormatImpersonationIsActive"> - /// LUCENENET specific - /// Added to remove dependency on then-static <see cref="LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// </param> - public Lucene42FieldInfosFormatAnonymousInnerClassHelper(bool oldFormatImpersonationIsActive) : base() - { - _oldFormatImpersonationIsActive = oldFormatImpersonationIsActive; - } - public override FieldInfosWriter FieldInfosWriter { get { - if (!_oldFormatImpersonationIsActive) + if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) { return base.FieldInfosWriter; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/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 e83704d..5dd3542 100644 --- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs +++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs @@ -204,7 +204,6 @@ 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); @@ -428,11 +427,8 @@ namespace Lucene.Net.Util /// specific tests on demand. /// /// @lucene.internal - /// - /// LUCENENET specific - /// Is non-static to remove inter-class dependencies on this variable /// </summary> - public bool OLD_FORMAT_IMPERSONATION_IS_ACTIVE { get; protected set; } + public static bool OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false; // ----------------------------------------------------------------- // Class level (suite) rules. @@ -596,8 +592,6 @@ namespace Lucene.Net.Util { // LUCENENET TODO: Not sure how to convert these //ParentChainCallRule.SetupCalled = true; - - } /// <summary> @@ -620,8 +614,10 @@ namespace Lucene.Net.Util // LUCENENET specific method for setting up dependency injection of test classes. [OneTimeSetUp] - public virtual void OneTimeSetUp() + public virtual void BeforeClass() { + OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false; + // Setup the factories Codec.SetCodecFactory(TEST_CODEC_FACTORY); DocValuesFormat.SetDocValuesFormatFactory(TEST_DOCVALUES_FORMAT_FACTORY); @@ -1333,8 +1329,7 @@ namespace Lucene.Net.Util /// <summary> /// LUCENENET specific - /// Is non-static because <see cref="OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// is now non-static. + /// Is non-static. /// </summary> public Field NewStringField(string name, string value, Field.Store stored) { @@ -1343,8 +1338,7 @@ namespace Lucene.Net.Util /// <summary> /// LUCENENET specific - /// Is non-static because <see cref="OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// is now non-static. + /// Is non-static. /// </summary> public Field NewTextField(string name, string value, Field.Store stored) { @@ -1353,8 +1347,7 @@ namespace Lucene.Net.Util /// <summary> /// LUCENENET specific - /// Is non-static because <see cref="OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// is now non-static. + /// Is non-static. /// </summary> public Field NewStringField(Random random, string name, string value, Field.Store stored) { @@ -1363,8 +1356,7 @@ namespace Lucene.Net.Util /// <summary> /// LUCENENET specific - /// Is non-static because <see cref="OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// is also non-static to reduce hidden dependencies on this variable. + /// Is non-static. /// </summary> public Field NewTextField(Random random, string name, string value, Field.Store stored) { @@ -1373,8 +1365,7 @@ namespace Lucene.Net.Util /// <summary> /// LUCENENET specific - /// Is non-static because <see cref="OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// is now non-static. + /// Is non-static. /// </summary> public Field NewField(string name, string value, FieldType type) { @@ -1383,8 +1374,7 @@ namespace Lucene.Net.Util /// <summary> /// LUCENENET specific - /// Is non-static because <see cref="OLD_FORMAT_IMPERSONATION_IS_ACTIVE"/> - /// is now non-static. + /// Is non-static. /// </summary> public Field NewField(Random random, string name, string value, FieldType type) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xPostingsFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xPostingsFormat.cs b/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xPostingsFormat.cs index 0ab9a7b..365ab52 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xPostingsFormat.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xPostingsFormat.cs @@ -27,19 +27,23 @@ namespace Lucene.Net.Codecs.Lucene3x /// </summary> public class TestLucene3xPostingsFormat : BasePostingsFormatTestCase { - private readonly Codec Codec_Renamed; + private readonly Codec codec = new PreFlexRWCodec(); - public TestLucene3xPostingsFormat() : base() + /// <summary> + /// we will manually instantiate preflex-rw here + /// </summary> + public override void SetUp() { - OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient codec - Codec_Renamed = new PreFlexRWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE); + base.SetUp(); + LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; } + protected override Codec Codec { get { - return Codec_Renamed; + return codec; } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xStoredFieldsFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xStoredFieldsFormat.cs b/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xStoredFieldsFormat.cs index e78db47..3682335 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xStoredFieldsFormat.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xStoredFieldsFormat.cs @@ -26,13 +26,10 @@ namespace Lucene.Net.Codecs.Lucene3x [TestFixture] public class TestLucene3xStoredFieldsFormat : BaseStoredFieldsFormatTestCase { - /// <summary> - /// LUCENENET specific - /// Is non-static because OLD_FORMAT_IMPERSONATION_IS_ACTIVE is no longer static. - /// </summary> [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { + base.BeforeClass(); OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient codec } @@ -40,8 +37,7 @@ namespace Lucene.Net.Codecs.Lucene3x { get { - Assert.IsTrue(OLD_FORMAT_IMPERSONATION_IS_ACTIVE, "This should have been set up in the test fixture"); - return new PreFlexRWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE); + return new PreFlexRWCodec(); } } @@ -105,7 +101,11 @@ namespace Lucene.Net.Codecs.Lucene3x base.TestEmptyDocs(); } - [Test] +#if !NETSTANDARD + // LUCENENET: There is no Timeout on NUnit for .NET Core. + [Timeout(40000)] +#endif + [Test, HasTimeout] public override void TestConcurrentReads() { base.TestConcurrentReads(); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xTermVectorsFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xTermVectorsFormat.cs b/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xTermVectorsFormat.cs index cbd59ed..7b7ed3a 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xTermVectorsFormat.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene3x/TestLucene3xTermVectorsFormat.cs @@ -38,8 +38,7 @@ namespace Lucene.Net.Codecs.Lucene3x { get { - Assert.IsTrue(OLD_FORMAT_IMPERSONATION_IS_ACTIVE, "This should have been set up in the test fixture"); - return new PreFlexRWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE); + return new PreFlexRWCodec(); } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene3x/TestSurrogates.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene3x/TestSurrogates.cs b/src/Lucene.Net.Tests/Codecs/Lucene3x/TestSurrogates.cs index d4b1b63..8a9134d 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene3x/TestSurrogates.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene3x/TestSurrogates.cs @@ -34,13 +34,11 @@ namespace Lucene.Net.Codecs.Lucene3x { /// <summary> /// we will manually instantiate preflex-rw here - /// - /// LUCENENET specific - /// Is non-static because OLD_FORMAT_IMPERSONATION_IS_ACTIVE is no longer static. /// </summary> [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { + base.BeforeClass(); OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; } @@ -351,7 +349,7 @@ namespace Lucene.Net.Codecs.Lucene3x { Directory dir = NewDirectory(); RandomIndexWriter w = new RandomIndexWriter(Random(), dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())) - .SetCodec(new PreFlexRWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE))); + .SetCodec(new PreFlexRWCodec())); int numField = TestUtil.NextInt(Random(), 2, 5); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene3x/TestTermInfosReaderIndex.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene3x/TestTermInfosReaderIndex.cs b/src/Lucene.Net.Tests/Codecs/Lucene3x/TestTermInfosReaderIndex.cs index 2d9dd05..246a3ec 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene3x/TestTermInfosReaderIndex.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene3x/TestTermInfosReaderIndex.cs @@ -66,12 +66,9 @@ namespace Lucene.Net.Codecs.Lucene3x /// <summary> /// we will manually instantiate preflex-rw here - /// - /// LUCENENET specific - /// Is non-static because OLD_FORMAT_IMPERSONATION_IS_ACTIVE is no longer static. /// </summary> [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { // NOTE: turn off compound file, this test will open some index files directly. OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; @@ -84,7 +81,7 @@ namespace Lucene.Net.Codecs.Lucene3x Directory = NewDirectory(); - config.SetCodec(new PreFlexRWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE)); + config.SetCodec(new PreFlexRWCodec()); LogMergePolicy mp = NewLogMergePolicy(); // NOTE: turn off compound file, this test will open some index files directly. mp.NoCFSRatio = 0.0; @@ -97,7 +94,7 @@ namespace Lucene.Net.Codecs.Lucene3x string segment = r.SegmentName; r.Dispose(); - FieldInfosReader infosReader = (new PreFlexRWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE)).FieldInfosFormat.FieldInfosReader; + FieldInfosReader infosReader = (new PreFlexRWCodec()).FieldInfosFormat.FieldInfosReader; FieldInfos fieldInfos = infosReader.Read(Directory, segment, "", IOContext.READ_ONCE); string segmentFileName = IndexFileNames.SegmentFileName(segment, "", Lucene3xPostingsFormat.TERMS_INDEX_EXTENSION); long tiiFileLength = Directory.FileLength(segmentFileName); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40DocValuesFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40DocValuesFormat.cs b/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40DocValuesFormat.cs index d63a6b3..0f979c2 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40DocValuesFormat.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40DocValuesFormat.cs @@ -26,13 +26,12 @@ namespace Lucene.Net.Codecs.Lucene40 /// </summary> public class TestLucene40DocValuesFormat : BaseDocValuesFormatTestCase { - /// <summary> - /// LUCENENET specific - /// Is non-static because OLD_FORMAT_IMPERSONATION_IS_ACTIVE is no longer static. - /// </summary> + private readonly Codec codec = new Lucene40RWCodec(); + [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { + base.BeforeClass(); OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient codec } @@ -40,8 +39,7 @@ namespace Lucene.Net.Codecs.Lucene40 { get { - Assert.True(OLD_FORMAT_IMPERSONATION_IS_ACTIVE, "Expecting that this is true"); - return new Lucene40RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE); + return codec; } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40PostingsFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40PostingsFormat.cs b/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40PostingsFormat.cs index 2d2b5f1..8e8320d 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40PostingsFormat.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40PostingsFormat.cs @@ -26,13 +26,12 @@ namespace Lucene.Net.Codecs.Lucene40 /// </summary> public class TestLucene40PostingsFormat : BasePostingsFormatTestCase { - /// <summary> - /// LUCENENET specific - /// Is non-static because OLD_FORMAT_IMPERSONATION_IS_ACTIVE is no longer static. - /// </summary> + private readonly Codec codec = new Lucene40RWCodec(); + [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { + base.BeforeClass(); OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient codec } @@ -40,8 +39,7 @@ namespace Lucene.Net.Codecs.Lucene40 { get { - Assert.True(OLD_FORMAT_IMPERSONATION_IS_ACTIVE, "Expecting this to be set already before creating codec"); - return new Lucene40RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE); + return codec; } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40PostingsReader.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40PostingsReader.cs b/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40PostingsReader.cs index aea5ce0..cfd9a3f 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40PostingsReader.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40PostingsReader.cs @@ -53,13 +53,10 @@ namespace Lucene.Net.Codecs.Lucene40 } } - /// <summary> - /// LUCENENET specific - /// Is non-static because OLD_FORMAT_IMPERSONATION_IS_ACTIVE is no longer static. - /// </summary> [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { + base.BeforeClass(); OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient codec } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40StoredFieldsFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40StoredFieldsFormat.cs b/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40StoredFieldsFormat.cs index c78b1b4..3ae63f7 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40StoredFieldsFormat.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40StoredFieldsFormat.cs @@ -24,13 +24,10 @@ namespace Lucene.Net.Codecs.Lucene40 public class TestLucene40StoredFieldsFormat : BaseStoredFieldsFormatTestCase { - /// <summary> - /// LUCENENET specific - /// Is non-static because OLD_FORMAT_IMPERSONATION_IS_ACTIVE is no longer static. - /// </summary> [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { + base.BeforeClass(); OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient codec } @@ -38,8 +35,7 @@ namespace Lucene.Net.Codecs.Lucene40 { get { - Assert.True(OLD_FORMAT_IMPERSONATION_IS_ACTIVE, "Expecting this to be set already"); - return new Lucene40RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE); + return new Lucene40RWCodec(); } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40TermVectorsFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40TermVectorsFormat.cs b/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40TermVectorsFormat.cs index d7541eb..4370228 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40TermVectorsFormat.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene40/TestLucene40TermVectorsFormat.cs @@ -24,13 +24,10 @@ namespace Lucene.Net.Codecs.Lucene40 public class TestLucene40TermVectorsFormat : BaseTermVectorsFormatTestCase { - /// <summary> - /// LUCENENET specific - /// Is non-static because OLD_FORMAT_IMPERSONATION_IS_ACTIVE is no longer static. - /// </summary> [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { + base.BeforeClass(); OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient codec } @@ -38,8 +35,7 @@ namespace Lucene.Net.Codecs.Lucene40 { get { - Assert.True(OLD_FORMAT_IMPERSONATION_IS_ACTIVE, "Expecting this to be set already"); - return new Lucene40RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE); + return new Lucene40RWCodec(); } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene40/TestReuseDocsEnum.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene40/TestReuseDocsEnum.cs b/src/Lucene.Net.Tests/Codecs/Lucene40/TestReuseDocsEnum.cs index c2bdadf..c8b7600 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene40/TestReuseDocsEnum.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene40/TestReuseDocsEnum.cs @@ -46,13 +46,10 @@ namespace Lucene.Net.Codecs.Lucene40 [TestFixture] public class TestReuseDocsEnum : LuceneTestCase { - /// <summary> - /// LUCENENET specific - /// Is non-static because OLD_FORMAT_IMPERSONATION_IS_ACTIVE is no longer static. - /// </summary> [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { + base.BeforeClass(); OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient codec } @@ -60,7 +57,7 @@ namespace Lucene.Net.Codecs.Lucene40 public virtual void TestReuseDocsEnumNoReuse() { Directory dir = NewDirectory(); - Codec cp = TestUtil.AlwaysPostingsFormat(new Lucene40RWPostingsFormat(OLD_FORMAT_IMPERSONATION_IS_ACTIVE)); + Codec cp = TestUtil.AlwaysPostingsFormat(new Lucene40RWPostingsFormat()); RandomIndexWriter writer = new RandomIndexWriter(Random(), dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetCodec(cp)); int numdocs = AtLeast(20); CreateRandomIndex(numdocs, writer, Random()); @@ -90,7 +87,7 @@ namespace Lucene.Net.Codecs.Lucene40 public virtual void TestReuseDocsEnumSameBitsOrNull() { Directory dir = NewDirectory(); - Codec cp = TestUtil.AlwaysPostingsFormat(new Lucene40RWPostingsFormat(OLD_FORMAT_IMPERSONATION_IS_ACTIVE)); + Codec cp = TestUtil.AlwaysPostingsFormat(new Lucene40RWPostingsFormat()); RandomIndexWriter writer = new RandomIndexWriter(Random(), dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetCodec(cp)); int numdocs = AtLeast(20); CreateRandomIndex(numdocs, writer, Random()); @@ -139,7 +136,7 @@ namespace Lucene.Net.Codecs.Lucene40 public virtual void TestReuseDocsEnumDifferentReader() { Directory dir = NewDirectory(); - Codec cp = TestUtil.AlwaysPostingsFormat(new Lucene40RWPostingsFormat(OLD_FORMAT_IMPERSONATION_IS_ACTIVE)); + Codec cp = TestUtil.AlwaysPostingsFormat(new Lucene40RWPostingsFormat()); MockAnalyzer analyzer = new MockAnalyzer(Random()); analyzer.MaxTokenLength = TestUtil.NextInt(Random(), 1, IndexWriter.MAX_TERM_LENGTH); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene41/TestLucene41StoredFieldsFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene41/TestLucene41StoredFieldsFormat.cs b/src/Lucene.Net.Tests/Codecs/Lucene41/TestLucene41StoredFieldsFormat.cs index 0cbb28b..3f1b59d 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene41/TestLucene41StoredFieldsFormat.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene41/TestLucene41StoredFieldsFormat.cs @@ -24,13 +24,10 @@ namespace Lucene.Net.Codecs.Lucene41 public class TestLucene41StoredFieldsFormat : BaseStoredFieldsFormatTestCase { - /// <summary> - /// LUCENENET specific - /// Is non-static because OLD_FORMAT_IMPERSONATION_IS_ACTIVE is no longer static. - /// </summary> [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { + base.BeforeClass(); OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient codec } @@ -38,7 +35,7 @@ namespace Lucene.Net.Codecs.Lucene41 { get { - return new Lucene41RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE); + return new Lucene41RWCodec(); } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Codecs/Lucene42/TestLucene42DocValuesFormat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Codecs/Lucene42/TestLucene42DocValuesFormat.cs b/src/Lucene.Net.Tests/Codecs/Lucene42/TestLucene42DocValuesFormat.cs index f9c47ce..c147cc4 100644 --- a/src/Lucene.Net.Tests/Codecs/Lucene42/TestLucene42DocValuesFormat.cs +++ b/src/Lucene.Net.Tests/Codecs/Lucene42/TestLucene42DocValuesFormat.cs @@ -26,24 +26,20 @@ namespace Lucene.Net.Codecs.Lucene42 /// </summary> public class TestLucene42DocValuesFormat : BaseCompressingDocValuesFormatTestCase { - private Codec Codec_Renamed; + private readonly Codec codec = new Lucene42RWCodec(); - /// <summary> - /// LUCENENET specific - /// Is non-static because OLD_FORMAT_IMPERSONATION_IS_ACTIVE is no longer static. - /// </summary> [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { + base.BeforeClass(); OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true; // explicitly instantiates ancient codec - Codec_Renamed = new Lucene42RWCodec(OLD_FORMAT_IMPERSONATION_IS_ACTIVE); } protected override Codec Codec { get { - return Codec_Renamed; + return codec; } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility.cs b/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility.cs index 2983ae5..8b6f78d 100644 --- a/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility.cs +++ b/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility.cs @@ -201,7 +201,7 @@ namespace Lucene.Net.Index } [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { Assert.IsFalse(OLD_FORMAT_IMPERSONATION_IS_ACTIVE, "test infra is broken!"); IList<string> names = new List<string>(OldNames.Length + OldSingleSegmentNames.Length); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility3x.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility3x.cs b/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility3x.cs index c5de1e4..9ee601f 100644 --- a/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility3x.cs +++ b/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility3x.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Text; namespace Lucene.Net.Index { @@ -129,9 +130,9 @@ namespace Lucene.Net.Index internal static IDictionary<string, Directory> OldIndexDirs; [OneTimeSetUp] - public void BeforeClass() + public override void BeforeClass() { - Assert.IsFalse(OLD_FORMAT_IMPERSONATION_IS_ACTIVE, "test infra is broken!"); + assertFalse("test infra is broken!", OLD_FORMAT_IMPERSONATION_IS_ACTIVE); IList<string> names = new List<string>(OldNames.Length + OldSingleSegmentNames.Length); names.AddRange(Arrays.AsList(OldNames)); names.AddRange(Arrays.AsList(OldSingleSegmentNames)); @@ -237,13 +238,12 @@ namespace Lucene.Net.Index writer = null; } - MemoryStream bos = new MemoryStream(1024); + StringBuilder bos = new StringBuilder(); CheckIndex checker = new CheckIndex(dir); -#pragma warning disable 612, 618 - checker.InfoStream = new StreamWriter(bos.ToString(), false, IOUtils.CHARSET_UTF_8); -#pragma warning restore 612, 618 + checker.InfoStream = new StringWriter(bos); CheckIndex.Status indexStatus = checker.DoCheckIndex(); Assert.IsFalse(indexStatus.Clean); + checker.InfoStream.Flush(); Assert.IsTrue(bos.ToString().Contains(typeof(IndexFormatTooOldException).Name)); dir.Dispose(); @@ -585,7 +585,7 @@ namespace Lucene.Net.Index Assert.AreEqual(44, hits.Length, "wrong number of hits"); d = searcher.Doc(hits[0].Doc); DoTestHits(hits, 44, searcher.IndexReader); - Assert.AreEqual("wrong first document", "21", d.Get("id")); + assertEquals("wrong first document", "21", d.Get("id")); reader.Dispose(); } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Index/TestBinaryDocValuesUpdates.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Index/TestBinaryDocValuesUpdates.cs b/src/Lucene.Net.Tests/Index/TestBinaryDocValuesUpdates.cs index 19351fd..151237b 100644 --- a/src/Lucene.Net.Tests/Index/TestBinaryDocValuesUpdates.cs +++ b/src/Lucene.Net.Tests/Index/TestBinaryDocValuesUpdates.cs @@ -1116,19 +1116,18 @@ namespace Lucene.Net.Index [Test] public virtual void TestUpdateOldSegments() { - 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) + new Lucene40RWCodec(), + new Lucene41RWCodec(), + new Lucene42RWCodec(), + new Lucene45RWCodec() }; Directory dir = NewDirectory(); // 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)); @@ -1138,11 +1137,6 @@ namespace Lucene.Net.Index dir.Dispose(); } - /// <summary> - /// LUCENENET specific - /// Split from <see cref="TestUpdateOldSegments"/> because OLD_FORMAT_IMPERSONATION_IS_ACTIVE - /// is no longer static and the existing codecs have to be remade. - /// </summary> [Test, LuceneNetSpecific] public virtual void TestUpdateOldSegments_OldFormatNotActive() { @@ -1151,10 +1145,10 @@ namespace Lucene.Net.Index 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) + new Lucene40RWCodec(), + new Lucene41RWCodec(), + new Lucene42RWCodec(), + new Lucene45RWCodec() }; Directory dir = NewDirectory(); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Index/TestCodecs.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Index/TestCodecs.cs b/src/Lucene.Net.Tests/Index/TestCodecs.cs index e798da9..58d5aa9 100644 --- a/src/Lucene.Net.Tests/Index/TestCodecs.cs +++ b/src/Lucene.Net.Tests/Index/TestCodecs.cs @@ -89,8 +89,9 @@ namespace Lucene.Net.Index private const int TERM_DOC_FREQ_RAND = 20; [OneTimeSetUp] - public static void BeforeClass() + public override void BeforeClass() { + base.BeforeClass(); NUM_TEST_ITER = AtLeast(20); } @@ -899,7 +900,7 @@ namespace Lucene.Net.Index [Test] public virtual void TestDisableImpersonation() { - 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) }; + Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec() }; Directory dir = NewDirectory(); IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())); conf.SetCodec(oldCodecs[Random().Next(oldCodecs.Length)]); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b0fa137/src/Lucene.Net.Tests/Index/TestNumericDocValuesUpdates.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Index/TestNumericDocValuesUpdates.cs b/src/Lucene.Net.Tests/Index/TestNumericDocValuesUpdates.cs index 25b8b44..eb02fac 100644 --- a/src/Lucene.Net.Tests/Index/TestNumericDocValuesUpdates.cs +++ b/src/Lucene.Net.Tests/Index/TestNumericDocValuesUpdates.cs @@ -1068,15 +1068,14 @@ namespace Lucene.Net.Index [Test] public virtual void TestUpdateOldSegments() { - 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) }; + Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec(), new Lucene45RWCodec() }; 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));
