Author: nicko
Date: Sun Feb 25 15:46:41 2007
New Revision: 511663
URL: http://svn.apache.org/viewvc?view=rev&rev=511663
Log:
LOG4NET-114. Resolved some line ending issues in the tests. Tests were hard
coded to expect \r\n, changed to use Environment.NewLine.
Modified:
logging/log4net/trunk/tests/src/Appender/RollingFileAppenderTest.cs
logging/log4net/trunk/tests/src/Core/StringFormatTest.cs
logging/log4net/trunk/tests/src/Layout/XmlLayoutTest.cs
Modified: logging/log4net/trunk/tests/src/Appender/RollingFileAppenderTest.cs
URL:
http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Appender/RollingFileAppenderTest.cs?view=diff&rev=511663&r1=511662&r2=511663
==============================================================================
--- logging/log4net/trunk/tests/src/Appender/RollingFileAppenderTest.cs
(original)
+++ logging/log4net/trunk/tests/src/Appender/RollingFileAppenderTest.cs Sun Feb
25 15:46:41 2007
@@ -41,7 +41,8 @@
public class RollingFileAppenderTest
{
private const string c_fileName = "test_41d3d834_4320f4da.log";
- private const string c_testMessage =
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567";
+ private const string c_testMessage98Chars =
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567";
+ private const string c_testMessage99Chars =
"012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678";
private const int c_iMaximumFileSize = 450; // in bytes
private int _iMessagesLoggedThisFile = 0;
private int _iMessagesLogged = 0;
@@ -869,7 +870,8 @@
/// <summary>
/// Uses the externally defined rolling table to verify rolling
names/sizes
- ///
+ /// </summary>
+ /// <remarks>
/// Pattern is: check pre-conditions. Log messages, checking
size of current file.
/// when size exceeds limit, check post conditions. Can
determine from message the
/// number of messages N that will cause a roll to occur.
Challenge is to verify the
@@ -886,12 +888,12 @@
/// a 'roll', and the group between commas indicates the
numbers for all backup files that
/// occur as a result of the roll. It is assumed that no
backup files exist before a roll
/// occurs
- /// </summary>
+ /// </remarks>
/// <param name="table"></param>
private void VerifyRolling(RollConditions[] table)
{
ConfigureRootAppender();
- RollFromTableEntries(c_fileName, table, c_testMessage);
+ RollFromTableEntries(c_fileName, table,
GetTestMessage());
}
/// <summary>
@@ -920,7 +922,7 @@
//
int iMessagesToLog = 30;
- VerifyRolling(MakeNumericTestEntries(c_testMessage,
sBackupInfo, iMessagesToLog));
+ VerifyRolling(MakeNumericTestEntries(GetTestMessage(),
sBackupInfo, iMessagesToLog));
}
/// <summary>
@@ -954,7 +956,7 @@
//
int iMessagesToLog = 30;
- VerifyRolling(MakeNumericTestEntries(c_testMessage,
sBackupInfo, iMessagesToLog));
+ VerifyRolling(MakeNumericTestEntries(GetTestMessage(),
sBackupInfo, iMessagesToLog));
}
/// <summary>
@@ -987,7 +989,7 @@
//
int iMessagesToLog = 30;
- VerifyRolling(MakeNumericTestEntries(c_testMessage,
sBackupInfo, iMessagesToLog));
+ VerifyRolling(MakeNumericTestEntries(GetTestMessage(),
sBackupInfo, iMessagesToLog));
}
@@ -1016,7 +1018,7 @@
//
int iMessagesToLog = 30;
- VerifyRolling(MakeNumericTestEntries(c_testMessage,
sBackupInfo, iMessagesToLog));
+ VerifyRolling(MakeNumericTestEntries(GetTestMessage(),
sBackupInfo, iMessagesToLog));
}
/// <summary>
@@ -1050,7 +1052,7 @@
//
int iMessagesToLog = 30;
- VerifyRolling(MakeNumericTestEntries(c_testMessage,
sBackupInfo, iMessagesToLog));
+ VerifyRolling(MakeNumericTestEntries(GetTestMessage(),
sBackupInfo, iMessagesToLog));
}
/// <summary>
@@ -1083,7 +1085,7 @@
//
int iMessagesToLog = 30;
- VerifyRolling(MakeNumericTestEntries(c_testMessage,
sBackupInfo, iMessagesToLog));
+ VerifyRolling(MakeNumericTestEntries(GetTestMessage(),
sBackupInfo, iMessagesToLog));
}
/// <summary>
@@ -1830,6 +1832,21 @@
private static void
SetFieldMaxSizeRollBackups(RollingFileAppender appender, int val)
{
Utils.SetField(appender, "m_maxSizeRollBackups", val);
+ }
+
+ private static string GetTestMessage()
+ {
+ switch (Environment.NewLine.Length)
+ {
+ case 2:
+ return c_testMessage98Chars;
+
+ case 1:
+ return c_testMessage99Chars;
+
+ default:
+ throw new Exception("Unexpected
Environment.NewLine.Length");
+ }
}
}
Modified: logging/log4net/trunk/tests/src/Core/StringFormatTest.cs
URL:
http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Core/StringFormatTest.cs?view=diff&rev=511663&r1=511662&r2=511663
==============================================================================
--- logging/log4net/trunk/tests/src/Core/StringFormatTest.cs (original)
+++ logging/log4net/trunk/tests/src/Core/StringFormatTest.cs Sun Feb 25
15:46:41 2007
@@ -120,7 +120,7 @@
// ***
log1.Debug("TestMessage", new Exception("Exception
message"));
- Assert.AreEqual("DEBUG:TestMessageSystem.Exception:
Exception message\r\n", stringAppender.GetString(), "Test simple DEBUG event
3");
+ Assert.AreEqual("DEBUG:TestMessageSystem.Exception:
Exception message" + Environment.NewLine, stringAppender.GetString(), "Test
simple DEBUG event 3");
stringAppender.Reset();
// ***
@@ -238,7 +238,7 @@
// ***
log1.Info("TestMessage", new Exception("Exception
message"));
- Assert.AreEqual("INFO:TestMessageSystem.Exception:
Exception message\r\n", stringAppender.GetString(), "Test simple INFO event 3");
+ Assert.AreEqual("INFO:TestMessageSystem.Exception:
Exception message" + Environment.NewLine, stringAppender.GetString(), "Test
simple INFO event 3");
stringAppender.Reset();
// ***
@@ -356,7 +356,7 @@
// ***
log1.Warn("TestMessage", new Exception("Exception
message"));
- Assert.AreEqual("WARN:TestMessageSystem.Exception:
Exception message\r\n", stringAppender.GetString(), "Test simple WARN event 3");
+ Assert.AreEqual("WARN:TestMessageSystem.Exception:
Exception message" + Environment.NewLine, stringAppender.GetString(), "Test
simple WARN event 3");
stringAppender.Reset();
// ***
@@ -474,7 +474,7 @@
// ***
log1.Error("TestMessage", new Exception("Exception
message"));
- Assert.AreEqual("ERROR:TestMessageSystem.Exception:
Exception message\r\n", stringAppender.GetString(), "Test simple ERROR event
3");
+ Assert.AreEqual("ERROR:TestMessageSystem.Exception:
Exception message" + Environment.NewLine, stringAppender.GetString(), "Test
simple ERROR event 3");
stringAppender.Reset();
// ***
@@ -592,7 +592,7 @@
// ***
log1.Fatal("TestMessage", new Exception("Exception
message"));
- Assert.AreEqual("FATAL:TestMessageSystem.Exception:
Exception message\r\n", stringAppender.GetString(), "Test simple FATAL event
3");
+ Assert.AreEqual("FATAL:TestMessageSystem.Exception:
Exception message" + Environment.NewLine, stringAppender.GetString(), "Test
simple FATAL event 3");
stringAppender.Reset();
// ***
Modified: logging/log4net/trunk/tests/src/Layout/XmlLayoutTest.cs
URL:
http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Layout/XmlLayoutTest.cs?view=diff&rev=511663&r1=511662&r2=511663
==============================================================================
--- logging/log4net/trunk/tests/src/Layout/XmlLayoutTest.cs (original)
+++ logging/log4net/trunk/tests/src/Layout/XmlLayoutTest.cs Sun Feb 25 15:46:41
2007
@@ -59,7 +59,7 @@
private static string CreateEventNode(string message)
{
- return String.Format("<event logger=\"TestLogger\"
timestamp=\"{0}\" level=\"INFO\" thread=\"TestThread\" domain=\"Tests\"
identity=\"TestRunner\"
username=\"TestRunner\"><message>{1}</message></event>\r\n",
+ return String.Format("<event logger=\"TestLogger\"
timestamp=\"{0}\" level=\"INFO\" thread=\"TestThread\" domain=\"Tests\"
identity=\"TestRunner\" username=\"TestRunner\"><message>{1}</message></event>"
+ Environment.NewLine,
#if NET_2_0 || MONO_2_0
XmlConvert.ToString(DateTime.Today, XmlDateTimeSerializationMode.Local),
#else
@@ -70,7 +70,7 @@
private static string CreateEventNode(string key, string value)
{
- return String.Format("<event logger=\"TestLogger\"
timestamp=\"{0}\" level=\"INFO\" thread=\"TestThread\" domain=\"Tests\"
identity=\"TestRunner\" username=\"TestRunner\"><message>Test
message</message><properties><data name=\"{1}\" value=\"{2}\"
/></properties></event>\r\n",
+ return String.Format("<event logger=\"TestLogger\"
timestamp=\"{0}\" level=\"INFO\" thread=\"TestThread\" domain=\"Tests\"
identity=\"TestRunner\" username=\"TestRunner\"><message>Test
message</message><properties><data name=\"{1}\" value=\"{2}\"
/></properties></event>" + Environment.NewLine,
#if NET_2_0 || MONO_2_0
XmlConvert.ToString(DateTime.Today, XmlDateTimeSerializationMode.Local),
#else