lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [15/20] lucenenet git commit: Lucene.Net.TestFramework.Util.TestRuleSetupAndRestoreClassEnv: Added randomization of Culture, TimeZone, and InfoStream.
Date Tue, 28 Feb 2017 12:30:06 GMT
Lucene.Net.TestFramework.Util.TestRuleSetupAndRestoreClassEnv: Added randomization of Culture,
TimeZone, and InfoStream.


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

Branch: refs/heads/api-work
Commit: e9ec2abf12feec9fd5608b104f4753ac90f515ab
Parents: 9b9cd81
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Tue Feb 28 17:17:01 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Tue Feb 28 17:17:01 2017 +0700

----------------------------------------------------------------------
 .../JavaCompatibility/LuceneTestCase.cs         |  10 -
 .../Util/LuceneTestCase.cs                      |  69 ++--
 .../Util/TestRuleSetupAndRestoreClassEnv.cs     | 344 +++++--------------
 .../Flexible/Standard/TestNumericQueryParser.cs |   4 +-
 4 files changed, 119 insertions(+), 308 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e9ec2abf/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 913f94b..e417c4f 100644
--- a/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
@@ -244,15 +244,5 @@ namespace Lucene.Net.Util
                 return v1 * multiplier;
             }
         }
-
-        protected virtual CultureInfo randomLocale(Random random)
-        {
-            return RandomInts.RandomFrom(random, CultureInfoSupport.GetNeutralAndSpecificCultures());
-        }
-
-        protected virtual TimeZoneInfo randomTimeZone(Random random)
-        {
-            return RandomInts.RandomFrom(random, TimeZoneInfo.GetSystemTimeZones());
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e9ec2abf/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 812e273..47f8dca 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -1433,46 +1433,45 @@ namespace Lucene.Net.Util
             return new Field(name, value, newType);
         }
 
-        /* LUCENE TODO: removing until use is shown
+        /// <summary>
+        /// Return a random Locale from the available locales on the system. </summary>
+        /// <seealso cref= "https://issues.apache.org/jira/browse/LUCENE-4020" </seealso>
+        public static CultureInfo RandomLocale(Random random)
+        {
+            return RandomInts.RandomFrom(random, CultureInfoSupport.GetNeutralAndSpecificCultures());
+        }
 
-            /// <summary>
-            /// Return a random Locale from the available locales on the system. </summary>
-            /// <seealso cref= "https://issues.apache.org/jira/browse/LUCENE-4020" </seealso>
-            public static CultureInfo RandomLocale(Random random)
-            {
-                CultureInfo[] locales = CultureInfo.GetCultures();
-                return locales[random.Next(locales.Length)];
-            }
-            /// <summary>
-            /// Return a random TimeZone from the available timezones on the system </summary>
-            /// <seealso cref= "https://issues.apache.org/jira/browse/LUCENE-4020"  </seealso>
-            public static TimeZone RandomTimeZone(Random random)
-            {
-                string[] tzIds = TimeZone.AvailableIDs;
-                return TimeZone.getTimeZone(tzIds[random.Next(tzIds.Length)]);
-            }
+        /// <summary>
+        /// Return a random TimeZone from the available timezones on the system </summary>
+        /// <seealso cref= "https://issues.apache.org/jira/browse/LUCENE-4020"  </seealso>
+        public static TimeZoneInfo RandomTimeZone(Random random)
+        {
+            return RandomInts.RandomFrom(random, TimeZoneInfo.GetSystemTimeZones());
+        }
 
-            /// <summary>
-            /// return a Locale object equivalent to its programmatic name </summary>
-            public static Locale LocaleForName(string localeName)
-            {
-                string[] elements = localeName.Split("\\_");
-                switch (elements.Length)
-                {
-                    case 4: // fallthrough for special cases
-                    case 3:
-                    return new Locale(elements[0], elements[1], elements[2]);
+        /// <summary>
+        /// return a Locale object equivalent to its programmatic name </summary>
+        public static CultureInfo LocaleForName(string localeName)
+        {
+            return new CultureInfo(localeName);
 
-                    case 2:
-                    return new Locale(elements[0], elements[1]);
+            //string[] elements = Regex.Split(localeName, "\\_", RegexOptions.Compiled);
+            //switch (elements.Length)
+            //{
+            //    case 4: // fallthrough for special cases
+            //    case 3:
+            //    return new Locale(elements[0], elements[1], elements[2]);
 
-                    case 1:
-                    return new Locale(elements[0]);
+            //    case 2:
+            //    return new Locale(elements[0], elements[1]);
 
-                    default:
-                    throw new System.ArgumentException("Invalid Locale: " + localeName);
-                }
-            }*/
+            //    case 1:
+            //    return new Locale(elements[0]);
+
+            //    default:
+            //    throw new System.ArgumentException("Invalid Locale: " + localeName);
+            //}
+        }
 
         public static bool DefaultCodecSupportsDocValues()
         {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e9ec2abf/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs b/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
index ba4be2c..9f34248 100644
--- a/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
+++ b/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
@@ -1,46 +1,41 @@
+using Lucene.Net.Codecs.Asserting;
+using Lucene.Net.Codecs.Compressing;
+using Lucene.Net.Codecs.Lucene3x;
+using Lucene.Net.Codecs.Lucene40;
+using Lucene.Net.Codecs.Lucene41;
+using Lucene.Net.Codecs.Lucene42;
+using Lucene.Net.Codecs.Lucene45;
+using Lucene.Net.JavaCompatibility;
+using Lucene.Net.Randomized.Generators;
+using Lucene.Net.Support;
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Globalization;
 using System.IO;
+using System.Linq;
+using System.Reflection;
 using System.Threading;
 
 namespace Lucene.Net.Util
 {
-    using Codecs;
-    using Codecs.Asserting;
-    using Codecs.CheapBastard;
-    using Codecs.Compressing;
-    using Codecs.Lucene3x;
-    using Codecs.Lucene40;
-    using Codecs.Lucene41;
-    using Codecs.Lucene42;
-    using Codecs.Lucene45;
-    using Codecs.MockRandom;
-    using Codecs.SimpleText;
-    using JavaCompatibility;
-    //using AssumptionViolatedException = org.junit.@internal.AssumptionViolatedException;
-    using Lucene.Net.Randomized.Generators;
-    using Support;
-    using System.Diagnostics;
-    using System.Linq;
-    using System.Reflection;
-
     /*
-         * 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.
-         * The ASF licenses this file to You under the Apache License, Version 2.0
-         * (the "License"); you may not use this file except in compliance with
-         * the License.  You may obtain a copy of the License at
-         *
-         *     http://www.apache.org/licenses/LICENSE-2.0
-         *
-         * Unless required by applicable law or agreed to in writing, software
-         * distributed under the License is distributed on an "AS IS" BASIS,
-         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-         * See the License for the specific language governing permissions and
-         * limitations under the License.
-         */
+    * 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.
+    * The ASF licenses this file to You under the Apache License, Version 2.0
+    * (the "License"); you may not use this file except in compliance with
+    * the License.  You may obtain a copy of the License at
+    *
+    *     http://www.apache.org/licenses/LICENSE-2.0
+    *
+    * Unless required by applicable law or agreed to in writing, software
+    * distributed under the License is distributed on an "AS IS" BASIS,
+    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    * See the License for the specific language governing permissions and
+    * limitations under the License.
+    */
+
     /*
 	import static Lucene.Net.Util.LuceneTestCase.INFOSTREAM;
 	import static Lucene.Net.Util.LuceneTestCase.TEST_CODEC;
@@ -53,19 +48,17 @@ namespace Lucene.Net.Util
 	import static Lucene.Net.Util.LuceneTestCase.randomLocale;
 	import static Lucene.Net.Util.LuceneTestCase.randomTimeZone;*/
 
+    using CheapBastardCodec = Lucene.Net.Codecs.CheapBastard.CheapBastardCodec;
     using Codec = Lucene.Net.Codecs.Codec;
     using DefaultSimilarity = Lucene.Net.Search.Similarities.DefaultSimilarity;
     using DocValuesFormat = Lucene.Net.Codecs.DocValuesFormat;
-
-    //using CheapBastardCodec = Lucene.Net.Codecs.cheapbastard.CheapBastardCodec;
-    //using MockRandomPostingsFormat = Lucene.Net.Codecs.mockrandom.MockRandomPostingsFormat;
     using Lucene46Codec = Lucene.Net.Codecs.Lucene46.Lucene46Codec;
+    using MockRandomPostingsFormat = Lucene.Net.Codecs.MockRandom.MockRandomPostingsFormat;
     using PostingsFormat = Lucene.Net.Codecs.PostingsFormat;
-
-    //using SimpleTextCodec = Lucene.Net.Codecs.simpletext.SimpleTextCodec;
     using RandomCodec = Lucene.Net.Index.RandomCodec;
     using RandomSimilarityProvider = Lucene.Net.Search.RandomSimilarityProvider;
     using Similarity = Lucene.Net.Search.Similarities.Similarity;
+    using SimpleTextCodec = Lucene.Net.Codecs.SimpleText.SimpleTextCodec;
 
     //using RandomizedContext = com.carrotsearch.randomizedtesting.RandomizedContext;
 
@@ -81,9 +74,9 @@ namespace Lucene.Net.Util
         private Dictionary<string, string> restoreProperties = new Dictionary<string,
string>();
 
         private Codec savedCodec;
-        //private CultureInfo SavedLocale;
-        //private InfoStream SavedInfoStream;
-        //private TimeZoneInfo SavedTimeZone;
+        private CultureInfo savedLocale;
+        private InfoStream savedInfoStream;
+        private TimeZoneInfo savedTimeZone;
 
         internal CultureInfo locale;
         internal TimeZoneInfo timeZone;
@@ -111,18 +104,17 @@ namespace Lucene.Net.Util
                 }
             }
 
-            // LUCENENET TODO: Finish implementation ?
-            //SavedInfoStream = InfoStream.Default;
-            Random random = LuceneTestCase.Random(); //RandomizedContext.Current.Random;
-            //bool v = random.NextBoolean();
-            //if (LuceneTestCase.INFOSTREAM)
-            //{
-            //    InfoStream.Default = new ThreadNameFixingPrintStreamInfoStream(Console.Out);
-            //}
-            //else if (v)
-            //{
-            //    InfoStream.Default = new NullInfoStream();
-            //}
+            savedInfoStream = InfoStream.Default;
+            Random random = LuceneTestCase.Random(); 
+            bool v = random.NextBoolean();
+            if (LuceneTestCase.INFOSTREAM)
+            {
+                InfoStream.Default = new ThreadNameFixingPrintStreamInfoStream(Console.Out);
+            }
+            else if (v)
+            {
+                InfoStream.Default = new NullInfoStream();
+            }
 
             Type targetClass = testInstance.GetType();
             avoidCodecs = new HashSet<string>();
@@ -249,24 +241,29 @@ namespace Lucene.Net.Util
             }
             Codec.Default = codec;
 
-            // LUCENENET TODO: Locale/time zone
-            //// Initialize locale/ timezone.
-            //string testLocale = System.getProperty("tests.locale", "random");
-            //string testTimeZone = System.getProperty("tests.timezone", "random");
-
-            //// Always pick a random one for consistency (whether tests.locale was specified
or not).
-            //SavedLocale = Locale.Default;
-            //Locale randomLocale = RandomLocale(random);
-            //Locale = testLocale.Equals("random") ? randomLocale : localeForName(testLocale);
-            //Locale.Default = Locale;
-
-            //// TimeZone.getDefault will set user.timezone to the default timezone of the
user's locale.
-            //// So store the original property value and restore it at end.
-            //RestoreProperties["user.timezone"] = System.getProperty("user.timezone");
-            //SavedTimeZone = TimeZone.Default;
-            //TimeZone randomTimeZone = RandomTimeZone(random);
-            //TimeZone = testTimeZone.Equals("random") ? randomTimeZone : TimeZone.getTimeZone(testTimeZone);
-            //TimeZone.Default = TimeZone;
+            // Initialize locale/ timezone.
+            string testLocale = System.Environment.GetEnvironmentVariable("tests.locale")
?? "random";
+            string testTimeZone = System.Environment.GetEnvironmentVariable("tests.timezone")
?? "random";
+
+            // Always pick a random one for consistency (whether tests.locale was specified
or not).
+            savedLocale = CultureInfo.CurrentCulture;
+            CultureInfo randomLocale = LuceneTestCase.RandomLocale(random);
+            locale = testLocale.Equals("random") ? randomLocale : LuceneTestCase.LocaleForName(testLocale);
+#if NETSTANDARD
+            CultureInfo.CurrentCulture = locale;
+#else
+            Thread.CurrentThread.CurrentCulture = locale;
+#endif
+
+            // TimeZone.getDefault will set user.timezone to the default timezone of the
user's locale.
+            // So store the original property value and restore it at end.
+            restoreProperties["user.timezone"] = System.Environment.GetEnvironmentVariable("user.timezone");
+            savedTimeZone = testInstance.TimeZone;
+            TimeZoneInfo randomTimeZone = LuceneTestCase.RandomTimeZone(random);
+            timeZone = testTimeZone.Equals("random") ? randomTimeZone : TimeZoneInfo.FindSystemTimeZoneById(testTimeZone);
+            //TimeZone.Default = TimeZone; // LUCENENET NOTE: There doesn't seem to be an
equivalent to this, but I don't think we need it.
+
+            //TimeZoneInfo.ConvertTime() // LUCENENET TODO: Everywhere TimeZoneInfo is supposed
to be used, use this method to convert a dateTime object to the time zone
 
             similarity = random.NextBoolean() ? (Similarity)new DefaultSimilarity() : new
RandomSimilarityProvider(random);
             
@@ -310,186 +307,6 @@ namespace Lucene.Net.Util
             }
         }
 
-        /*protected internal override void Before()
-        {
-          // enable this by default, for IDE consistency with ant tests (as its the default
from ant)
-          // TODO: really should be in solr base classes, but some extend LTC directly.
-          // we do this in beforeClass, because some tests currently disable it
-          RestoreProperties["solr.directoryFactory"] = System.getProperty("solr.directoryFactory");
-          if (System.getProperty("solr.directoryFactory") == null)
-          {
-            System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockDirectoryFactory");
-          }
-
-          // Restore more Solr properties.
-          RestoreProperties["solr.solr.home"] = System.getProperty("solr.solr.home");
-          RestoreProperties["solr.data.dir"] = System.getProperty("solr.data.dir");
-
-          // if verbose: print some debugging stuff about which codecs are loaded.
-          if (LuceneTestCase.VERBOSE)
-          {
-            ISet<string> codecs = Codec.AvailableCodecs();
-            foreach (string codec in codecs)
-            {
-              Console.WriteLine("Loaded codec: '" + codec + "': " + Codec.ForName(codec).GetType().Name);
-            }
-
-            ISet<string> postingsFormats = PostingsFormat.AvailablePostingsFormats();
-            foreach (string postingsFormat in postingsFormats)
-            {
-              Console.WriteLine("Loaded postingsFormat: '" + postingsFormat + "': " + PostingsFormat.ForName(postingsFormat).GetType().Name);
-            }
-          }
-
-          SavedInfoStream = InfoStream.Default;
-          Random random = RandomizedContext.Current.Random;
-          bool v = random.NextBoolean();
-          if (LuceneTestCase.INFOSTREAM)
-          {
-            InfoStream.Default = new ThreadNameFixingPrintStreamInfoStream(Console.Out);
-          }
-          else if (v)
-          {
-            InfoStream.Default = new NullInfoStream();
-          }
-
-          Type targetClass = RandomizedContext.Current.GetTargetType;
-          AvoidCodecs = new HashSet<string>();
-          if (targetClass.isAnnotationPresent(typeof(SuppressCodecs)))
-          {
-            SuppressCodecs a = targetClass.getAnnotation(typeof(SuppressCodecs));
-            AvoidCodecs.AddAll(Arrays.AsList(a.Value()));
-          }
-
-          // set back to default
-          LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
-
-          SavedCodec = Codec.Default;
-          int randomVal = random.Next(10);
-          if ("Lucene3x".Equals(LuceneTestCase.TEST_CODEC) || ("random".Equals(LuceneTestCase.TEST_CODEC)
&& "random".Equals(LuceneTestCase.TEST_POSTINGSFORMAT) && "random".Equals(LuceneTestCase.TEST_DOCVALUESFORMAT)
&& randomVal == 3 && !ShouldAvoidCodec("Lucene3x"))) // preflex-only setup
-          {
-            Codec = Codec.ForName("Lucene3x");
-            Debug.Assert((Codec is PreFlexRWCodec), "fix your classpath to have tests-framework.jar
before lucene-core.jar");
-            LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
-          }
-          else if ("Lucene40".Equals(LuceneTestCase.TEST_CODEC) || ("random".Equals(LuceneTestCase.TEST_CODEC)
&& "random".Equals(LuceneTestCase.TEST_POSTINGSFORMAT) && randomVal == 0 &&
!ShouldAvoidCodec("Lucene40"))) // 4.0 setup
-          {
-            Codec = Codec.ForName("Lucene40");
-            LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
-            Debug.Assert(Codec is Lucene40RWCodec, "fix your classpath to have tests-framework.jar
before lucene-core.jar");
-            Debug.Assert((PostingsFormat.ForName("Lucene40") is Lucene40RWPostingsFormat),
"fix your classpath to have tests-framework.jar before lucene-core.jar");
-          }
-          else if ("Lucene41".Equals(LuceneTestCase.TEST_CODEC) || ("random".Equals(LuceneTestCase.TEST_CODEC)
&& "random".Equals(LuceneTestCase.TEST_POSTINGSFORMAT) && "random".Equals(LuceneTestCase.TEST_DOCVALUESFORMAT)
&& randomVal == 1 && !ShouldAvoidCodec("Lucene41")))
-          {
-            Codec = Codec.ForName("Lucene41");
-            LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
-            Debug.Assert(Codec is Lucene41RWCodec, "fix your classpath to have tests-framework.jar
before lucene-core.jar");
-          }
-          else if ("Lucene42".Equals(LuceneTestCase.TEST_CODEC) || ("random".Equals(LuceneTestCase.TEST_CODEC)
&& "random".Equals(LuceneTestCase.TEST_POSTINGSFORMAT) && "random".Equals(LuceneTestCase.TEST_DOCVALUESFORMAT)
&& randomVal == 2 && !ShouldAvoidCodec("Lucene42")))
-          {
-            Codec = Codec.ForName("Lucene42");
-            LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
-            Debug.Assert(Codec is Lucene42RWCodec, "fix your classpath to have tests-framework.jar
before lucene-core.jar");
-          }
-          else if ("Lucene45".Equals(LuceneTestCase.TEST_CODEC) || ("random".Equals(LuceneTestCase.TEST_CODEC)
&& "random".Equals(LuceneTestCase.TEST_POSTINGSFORMAT) && "random".Equals(LuceneTestCase.TEST_DOCVALUESFORMAT)
&& randomVal == 5 && !ShouldAvoidCodec("Lucene45")))
-          {
-            Codec = Codec.ForName("Lucene45");
-            LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
-            Debug.Assert(Codec is Lucene45RWCodec, "fix your classpath to have tests-framework.jar
before lucene-core.jar");
-          }
-          else if (("random".Equals(LuceneTestCase.TEST_POSTINGSFORMAT) == false) || ("random".Equals(LuceneTestCase.TEST_DOCVALUESFORMAT)
== false))
-          {
-            // the user wired postings or DV: this is messy
-            // refactor into RandomCodec....
-
-            PostingsFormat format;
-            if ("random".Equals(LuceneTestCase.TEST_POSTINGSFORMAT))
-            {
-              format = PostingsFormat.ForName("Lucene41");
-            }
-            else if ("MockRandom".Equals(LuceneTestCase.TEST_POSTINGSFORMAT))
-            {
-              format = new MockRandomPostingsFormat(new Random(random.Next()));
-            }
-            else
-            {
-                format = PostingsFormat.ForName(LuceneTestCase.TEST_POSTINGSFORMAT);
-            }
-
-            DocValuesFormat dvFormat;
-            if ("random".Equals(LuceneTestCase.TEST_DOCVALUESFORMAT))
-            {
-              dvFormat = DocValuesFormat.ForName("Lucene45");
-            }
-            else
-            {
-                dvFormat = DocValuesFormat.ForName(LuceneTestCase.TEST_DOCVALUESFORMAT);
-            }
-
-            Codec = new Lucene46CodecAnonymousInnerClassHelper(this, format, dvFormat);
-          }
-          else if ("SimpleText".Equals(LuceneTestCase.TEST_CODEC) || ("random".Equals(LuceneTestCase.TEST_CODEC)
&& randomVal == 9 && LuceneTestCase.Rarely(random) && !ShouldAvoidCodec("SimpleText")))
-          {
-            Codec = new SimpleTextCodec();
-          }
-          else if ("CheapBastard".Equals(LuceneTestCase.TEST_CODEC) || ("random".Equals(LuceneTestCase.TEST_CODEC)
&& randomVal == 8 && !ShouldAvoidCodec("CheapBastard") && !ShouldAvoidCodec("Lucene41")))
-          {
-            // we also avoid this codec if Lucene41 is avoided, since thats the postings
format it uses.
-            Codec = new CheapBastardCodec();
-          }
-          else if ("Asserting".Equals(LuceneTestCase.TEST_CODEC) || ("random".Equals(LuceneTestCase.TEST_CODEC)
&& randomVal == 6 && !ShouldAvoidCodec("Asserting")))
-          {
-            Codec = new AssertingCodec();
-          }
-          else if ("Compressing".Equals(LuceneTestCase.TEST_CODEC) || ("random".Equals(LuceneTestCase.TEST_CODEC)
&& randomVal == 5 && !ShouldAvoidCodec("Compressing")))
-          {
-            Codec = CompressingCodec.RandomInstance(random);
-          }
-          else if (!"random".Equals(LuceneTestCase.TEST_CODEC))
-          {
-              Codec = Codec.ForName(LuceneTestCase.TEST_CODEC);
-          }
-          else if ("random".Equals(LuceneTestCase.TEST_POSTINGSFORMAT))
-          {
-            Codec = new RandomCodec(random, AvoidCodecs);
-          }
-          else
-          {
-            Debug.Assert(false);
-          }
-          Codec.Default = Codec;
-
-          // Initialize locale/ timezone.
-          string testLocale = System.getProperty("tests.locale", "random");
-          string testTimeZone = System.getProperty("tests.timezone", "random");
-
-          // Always pick a random one for consistency (whether tests.locale was specified
or not).
-          SavedLocale = Locale.Default;
-          Locale randomLocale = RandomLocale(random);
-          Locale = testLocale.Equals("random") ? randomLocale : localeForName(testLocale);
-          Locale.Default = Locale;
-
-          // TimeZone.getDefault will set user.timezone to the default timezone of the user's
locale.
-          // So store the original property value and restore it at end.
-          RestoreProperties["user.timezone"] = System.getProperty("user.timezone");
-          SavedTimeZone = TimeZone.Default;
-          TimeZone randomTimeZone = RandomTimeZone(random);
-          TimeZone = testTimeZone.Equals("random") ? randomTimeZone : TimeZone.getTimeZone(testTimeZone);
-          TimeZone.Default = TimeZone;
-          Similarity = random.NextBoolean() ? (Similarity)new DefaultSimilarity() : new RandomSimilarityProvider(new
Random());
-
-          // Check codec restrictions once at class level.
-          try
-          {
-            CheckCodecRestrictions(Codec);
-          }
-          catch (Exception e)
-          {
-            Console.Error.WriteLine("NOTE: " + e.Message + " Suppressed codecs: " + Arrays.ToString(AvoidCodecs.ToArray()));
-            throw e;
-          }
-        }*/
-
         private class Lucene46CodecAnonymousInnerClassHelper : Lucene46Codec
         {
             private readonly TestRuleSetupAndRestoreClassEnv outerInstance;
@@ -561,15 +378,20 @@ namespace Lucene.Net.Util
             restoreProperties.Clear();
 
             Codec.Default = savedCodec;
-            //InfoStream.Default = savedInfoStream;
-            //if (savedLocale != null)
-            //{
-            //    locale = savedLocale;
-            //}
-            //if (savedTimeZone != null)
-            //{
-            //    timeZone = savedTimeZone;
-            //}
+            InfoStream.Default = savedInfoStream;
+            if (savedLocale != null)
+            {
+                locale = savedLocale;
+#if NETSTANDARD
+                CultureInfo.CurrentCulture = savedLocale;
+#else
+                Thread.CurrentThread.CurrentCulture = savedLocale;
+#endif
+            }
+            if (savedTimeZone != null)
+            {
+                timeZone = savedTimeZone;
+            }
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e9ec2abf/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestNumericQueryParser.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestNumericQueryParser.cs
b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestNumericQueryParser.cs
index 99ba96f..601c1d0 100644
--- a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestNumericQueryParser.cs
+++ b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestNumericQueryParser.cs
@@ -97,8 +97,8 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard
                 }
 
                 dateFormatSanityCheckPass = true;
-                LOCALE = randomLocale(Random());
-                TIMEZONE = randomTimeZone(Random());
+                LOCALE = RandomLocale(Random());
+                TIMEZONE = RandomTimeZone(Random());
                 DATE_STYLE = randomDateStyle(Random());
                 TIME_STYLE = randomDateStyle(Random());
 


Mime
View raw message