Lucene.Net.TestFramework.Util.TestRuleSetupAndRestoreClassEnv: Fixed implementation to swap and restore user.timezone (and setup for other environment variables as well)
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/f6c6f8ad Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/f6c6f8ad Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/f6c6f8ad Branch: refs/heads/api-work Commit: f6c6f8ad51d794a7c11dadfb07f482869fb3e468 Parents: 2efad4f Author: Shad Storhaug <[email protected]> Authored: Fri Mar 3 14:51:11 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Sun Mar 5 17:08:41 2017 +0700 ---------------------------------------------------------------------- .../Util/TestRuleSetupAndRestoreClassEnv.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f6c6f8ad/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 9f34248..34ad216 100644 --- a/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs +++ b/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs @@ -257,7 +257,7 @@ namespace Lucene.Net.Util // 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"); + restoreProperties["user.timezone"] = SystemProperties.GetProperty("user.timezone"); savedTimeZone = testInstance.TimeZone; TimeZoneInfo randomTimeZone = LuceneTestCase.RandomTimeZone(random); timeZone = testTimeZone.Equals("random") ? randomTimeZone : TimeZoneInfo.FindSystemTimeZoneById(testTimeZone); @@ -364,17 +364,10 @@ namespace Lucene.Net.Util /// </summary> public override void After(LuceneTestCase testInstance) { - //foreach (KeyValuePair<string, string> e in restoreProperties) - //{ - // if (e.Value == null) - // { - // System.ClearProperty(e.Key); - // } - // else - // { - // System.setProperty(e.Key, e.Value); - // } - //} + foreach (KeyValuePair<string, string> e in restoreProperties) + { + SystemProperties.SetProperty(e.Key, e.Value); + } restoreProperties.Clear(); Codec.Default = savedCodec;
