logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpsen...@apache.org
Subject svn commit: r1511662 - in /logging/log4net/trunk/tests/src: Appender/RollingFileAppenderTest.cs Core/StringFormatTest.cs Layout/PatternLayoutTest.cs Layout/XmlLayoutTest.cs log4net.Tests.vs2010.csproj
Date Thu, 08 Aug 2013 10:03:05 GMT
Author: dpsenner
Date: Thu Aug  8 10:03:05 2013
New Revision: 1511662

URL: http://svn.apache.org/r1511662
Log:
LOG4NET-218 fixed some tests to work again because of culture trouble

Modified:
    logging/log4net/trunk/tests/src/Appender/RollingFileAppenderTest.cs
    logging/log4net/trunk/tests/src/Core/StringFormatTest.cs
    logging/log4net/trunk/tests/src/Layout/PatternLayoutTest.cs
    logging/log4net/trunk/tests/src/Layout/XmlLayoutTest.cs
    logging/log4net/trunk/tests/src/log4net.Tests.vs2010.csproj

Modified: logging/log4net/trunk/tests/src/Appender/RollingFileAppenderTest.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Appender/RollingFileAppenderTest.cs?rev=1511662&r1=1511661&r2=1511662&view=diff
==============================================================================
--- logging/log4net/trunk/tests/src/Appender/RollingFileAppenderTest.cs (original)
+++ logging/log4net/trunk/tests/src/Appender/RollingFileAppenderTest.cs Thu Aug  8 10:03:05
2013
@@ -31,6 +31,7 @@ using log4net.Repository.Hierarchy;
 using log4net.Util;
 
 using NUnit.Framework;
+using System.Globalization;
 
 namespace log4net.Tests.Appender
 {
@@ -50,6 +51,8 @@ namespace log4net.Tests.Appender
 		private int _MaxSizeRollBackups = 3;
 		private CountingAppender _caRoot;
 		private Logger _root;
+		private CultureInfo _currentCulture;
+		private CultureInfo _currentUICulture;
 
 		private class SilentErrorHandler : IErrorHandler
 		{
@@ -111,6 +114,11 @@ namespace log4net.Tests.Appender
 		{
 			ResetAndDeleteTestFiles();
 			InitializeVariables();
+
+			// set correct thread culture
+			_currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
+			_currentUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
+			System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture
= System.Globalization.CultureInfo.InvariantCulture;
 		}
 
 		/// <summary>
@@ -120,6 +128,10 @@ namespace log4net.Tests.Appender
 		public void TearDown()
 		{
 			ResetAndDeleteTestFiles();
+			
+			// restore previous culture
+			System.Threading.Thread.CurrentThread.CurrentCulture = _currentCulture;
+			System.Threading.Thread.CurrentThread.CurrentUICulture = _currentUICulture;
 		}
 
 		/// <summary>

Modified: logging/log4net/trunk/tests/src/Core/StringFormatTest.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Core/StringFormatTest.cs?rev=1511662&r1=1511661&r2=1511662&view=diff
==============================================================================
--- logging/log4net/trunk/tests/src/Core/StringFormatTest.cs (original)
+++ logging/log4net/trunk/tests/src/Core/StringFormatTest.cs Thu Aug  8 10:03:05 2013
@@ -40,6 +40,26 @@ namespace log4net.Tests.Core
 	[TestFixture]
 	public class StringFormatTest
 	{
+		private CultureInfo _currentCulture;
+		private CultureInfo _currentUICulture;
+
+		[SetUp]
+		public void SetUp()
+		{
+			// set correct thread culture
+			_currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
+			_currentUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
+			System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture
= System.Globalization.CultureInfo.InvariantCulture;
+		}
+
+		[TearDown]
+		public void TearDown()
+		{
+			// restore previous culture
+			System.Threading.Thread.CurrentThread.CurrentCulture = _currentCulture;
+			System.Threading.Thread.CurrentThread.CurrentUICulture = _currentUICulture;
+		}
+
 		[Test]
 		public void TestFormatString()
 		{

Modified: logging/log4net/trunk/tests/src/Layout/PatternLayoutTest.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Layout/PatternLayoutTest.cs?rev=1511662&r1=1511661&r2=1511662&view=diff
==============================================================================
--- logging/log4net/trunk/tests/src/Layout/PatternLayoutTest.cs (original)
+++ logging/log4net/trunk/tests/src/Layout/PatternLayoutTest.cs Thu Aug  8 10:03:05 2013
@@ -29,6 +29,7 @@ using log4net.Tests.Appender;
 using log4net.Util;
 
 using NUnit.Framework;
+using System.Globalization;
 
 namespace log4net.Tests.Layout
 {
@@ -41,10 +42,25 @@ namespace log4net.Tests.Layout
 	[TestFixture]
 	public class PatternLayoutTest
 	{
+		private CultureInfo _currentCulture;
+		private CultureInfo _currentUICulture;
+
+		[SetUp]
+		public void SetUp()
+		{
+			// set correct thread culture
+			_currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
+			_currentUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
+			System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture
= System.Globalization.CultureInfo.InvariantCulture;
+		}
+
 
         [TearDown]
         public void TearDown() {
-            Utils.RemovePropertyFromAllContexts();
+			Utils.RemovePropertyFromAllContexts();
+			// restore previous culture
+			System.Threading.Thread.CurrentThread.CurrentCulture = _currentCulture;
+			System.Threading.Thread.CurrentThread.CurrentUICulture = _currentUICulture;
         }
 
         protected virtual PatternLayout NewPatternLayout() {
@@ -96,7 +112,7 @@ namespace log4net.Tests.Layout
 
             log1.Info("TestMessage");
 #if !MONO
-            Assert.AreEqual("RuntimeMethodHandle._InvokeMethodFast > PatternLayoutTest.TestStackTracePattern",
stringAppender.GetString(), "stack trace value set");
+            Assert.AreEqual("System.RuntimeMethodHandle.InvokeMethod > log4net.Tests.Layout.PatternLayoutTest.TestStackTracePattern",
stringAppender.GetString(), "stack trace value set");
 #else
             Assert.AreEqual("MonoMethod.InternalInvoke > PatternLayoutTest.TestStackTracePattern",
stringAppender.GetString(), "stack trace value set");
 #endif

Modified: logging/log4net/trunk/tests/src/Layout/XmlLayoutTest.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Layout/XmlLayoutTest.cs?rev=1511662&r1=1511661&r2=1511662&view=diff
==============================================================================
--- logging/log4net/trunk/tests/src/Layout/XmlLayoutTest.cs (original)
+++ logging/log4net/trunk/tests/src/Layout/XmlLayoutTest.cs Thu Aug  8 10:03:05 2013
@@ -29,12 +29,33 @@ using log4net.Tests.Appender;
 using log4net.Util;
 
 using NUnit.Framework;
+using System.Globalization;
 
 namespace log4net.Tests.Layout
 {
 	[TestFixture]
 	public class XmlLayoutTest
 	{
+		private CultureInfo _currentCulture;
+		private CultureInfo _currentUICulture;
+
+		[SetUp]
+		public void SetUp()
+		{
+			// set correct thread culture
+			_currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
+			_currentUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
+			System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture
= System.Globalization.CultureInfo.InvariantCulture;
+		}
+
+		[TearDown]
+		public void TearDown()
+		{
+			// restore previous culture
+			System.Threading.Thread.CurrentThread.CurrentCulture = _currentCulture;
+			System.Threading.Thread.CurrentThread.CurrentUICulture = _currentUICulture;
+		}
+
 		/// <summary>
 		/// Build a basic <see cref="LoggingEventData"/> object with some default values.
 		/// </summary>
@@ -329,7 +350,7 @@ namespace log4net.Tests.Layout
             var startOfExceptionElement = log.IndexOf("<exception>");
             var sub = log.Substring(startOfExceptionElement + 11);
             StringAssert.StartsWith("System.NullReferenceException: Object reference not
set to an instance of an object", sub);
-            StringAssert.Contains("at log4net.Tests.Layout.XmlLayoutTest.&lt;&gt;c__DisplayClass4.&lt;BracketsInStackTracesAreEscapedProperly&gt;b__3(Int32
foo) in ", sub);
+            StringAssert.Contains("at log4net.Tests.Layout.XmlLayoutTest.&lt;&gt;c__DisplayClass4.&lt;BracketsInStackTracesAreEscapedProperly&gt;b__3(Int32
foo)", sub);
         }
 #endif
 	}

Modified: logging/log4net/trunk/tests/src/log4net.Tests.vs2010.csproj
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/log4net.Tests.vs2010.csproj?rev=1511662&r1=1511661&r2=1511662&view=diff
==============================================================================
--- logging/log4net/trunk/tests/src/log4net.Tests.vs2010.csproj (original)
+++ logging/log4net/trunk/tests/src/log4net.Tests.vs2010.csproj Thu Aug  8 10:03:05 2013
@@ -212,12 +212,6 @@
     <Compile Include="Util\TransformTest.cs" />
   </ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\..\src\log4net.vs2008.csproj">
-      <Project>{181FE707-E161-4722-9F38-6AAAB6FAA106}</Project>
-      <Name>log4net.vs2008</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
     <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
       <Visible>False</Visible>
       <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
@@ -234,6 +228,12 @@
       <Install>true</Install>
     </BootstrapperPackage>
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\src\log4net.vs2010.csproj">
+      <Project>{181fe707-e161-4722-9f38-6aaab6faa106}</Project>
+      <Name>log4net.vs2010</Name>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
     <PreBuildEvent>



Mime
View raw message