You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by rg...@apache.org on 2009/06/28 00:51:22 UTC
svn commit: r789023 - in
/ibatis/branches/MappedStatementRefactor/Apache.Ibatis.DataMapper.SqlClient.Test/Fixtures:
BaseTest.cs Mapping/ThreadTest.cs
Author: rgrabowski
Date: Sat Jun 27 22:51:22 2009
New Revision: 789023
URL: http://svn.apache.org/viewvc?rev=789023&view=rev
Log:
Made the thread test slightly more exciting by not passing in parameter=1 each time. The parameter is either 1 or 2 depending on the parity of the thread index.
Modified:
ibatis/branches/MappedStatementRefactor/Apache.Ibatis.DataMapper.SqlClient.Test/Fixtures/BaseTest.cs
ibatis/branches/MappedStatementRefactor/Apache.Ibatis.DataMapper.SqlClient.Test/Fixtures/Mapping/ThreadTest.cs
Modified: ibatis/branches/MappedStatementRefactor/Apache.Ibatis.DataMapper.SqlClient.Test/Fixtures/BaseTest.cs
URL: http://svn.apache.org/viewvc/ibatis/branches/MappedStatementRefactor/Apache.Ibatis.DataMapper.SqlClient.Test/Fixtures/BaseTest.cs?rev=789023&r1=789022&r2=789023&view=diff
==============================================================================
--- ibatis/branches/MappedStatementRefactor/Apache.Ibatis.DataMapper.SqlClient.Test/Fixtures/BaseTest.cs (original)
+++ ibatis/branches/MappedStatementRefactor/Apache.Ibatis.DataMapper.SqlClient.Test/Fixtures/BaseTest.cs Sat Jun 27 22:51:22 2009
@@ -189,6 +189,14 @@
Assert.AreEqual("Joe.Dalton@somewhere.com", account.EmailAddress, "account.EmailAddress");
}
+ protected void AssertAccount2(Account account)
+ {
+ Assert.AreEqual(2, account.Id, "account.Id");
+ Assert.AreEqual("Averel", account.FirstName, "account.FirstName");
+ Assert.AreEqual("Dalton", account.LastName, "account.LastName");
+ Assert.AreEqual("Averel.Dalton@somewhere.com", account.EmailAddress, "account.EmailAddress");
+ }
+
/// <summary>
/// Verify that the input account is equal to the account(id=1).
/// </summary>
Modified: ibatis/branches/MappedStatementRefactor/Apache.Ibatis.DataMapper.SqlClient.Test/Fixtures/Mapping/ThreadTest.cs
URL: http://svn.apache.org/viewvc/ibatis/branches/MappedStatementRefactor/Apache.Ibatis.DataMapper.SqlClient.Test/Fixtures/Mapping/ThreadTest.cs?rev=789023&r1=789022&r2=789023&view=diff
==============================================================================
--- ibatis/branches/MappedStatementRefactor/Apache.Ibatis.DataMapper.SqlClient.Test/Fixtures/Mapping/ThreadTest.cs (original)
+++ ibatis/branches/MappedStatementRefactor/Apache.Ibatis.DataMapper.SqlClient.Test/Fixtures/Mapping/ThreadTest.cs Sat Jun 27 22:51:22 2009
@@ -15,8 +15,6 @@
[TestFixture]
public class ThreadTest: BaseTest
{
- private static readonly ILog _logger = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType );
-
private static readonly int numberOfThreads = 10;
private readonly ManualResetEvent startEvent = new ManualResetEvent(false);
private readonly ManualResetEvent stopEvent = new ManualResetEvent(false);
@@ -52,8 +50,10 @@
for(int i = 0; i < threadCount; i++)
{
- threads[i] = new Thread(new ThreadStart(ExecuteMethodUntilSignal));
- threads[i].Start();
+ bool isEventAccountId = i % 2 == 0 ? true : false;
+
+ threads[i] = new Thread(ExecuteMethodUntilSignal);
+ threads[i].Start(isEventAccountId);
}
startEvent.Set();
@@ -63,8 +63,10 @@
stopEvent.Set();
}
- public void ExecuteMethodUntilSignal()
+ public void ExecuteMethodUntilSignal(object state)
{
+ bool isEventAccountId = (bool)state;
+
startEvent.WaitOne(int.MaxValue, false);
while (!stopEvent.WaitOne(1, false))
@@ -73,13 +75,20 @@
Console.WriteLine("Begin Thread : " + Thread.CurrentThread.GetHashCode());
- Account account = (Account)dataMapper.QueryForObject("GetAccountViaColumnIndex", 1);
+ int parameter = isEventAccountId ? 2 : 1;
+
+ Account account = (Account)dataMapper.QueryForObject("GetAccountViaColumnIndex", parameter);
Assert.IsNull(sessionStore.CurrentSession);
- Assert.AreEqual(1, account.Id, "account.Id");
- Assert.AreEqual("Joe", account.FirstName, "account.FirstName");
- Assert.AreEqual("Dalton", account.LastName, "account.LastName");
+ if (parameter == 1)
+ {
+ AssertAccount1(account);
+ }
+ else
+ {
+ AssertAccount2(account);
+ }
Console.WriteLine("End Thread : " + Thread.CurrentThread.GetHashCode());
}