Author: gbayon
Date: Tue May 13 11:55:56 2008
New Revision: 655972

URL: http://svn.apache.org/viewvc?rev=655972&view=rev
Log:
Add LRU cache test

Modified:
    
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/App.config
    
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/CacheTest.cs
    
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml

Modified: 
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/App.config
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/App.config?rev=655972&r1=655971&r2=655972&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/App.config 
(original)
+++ 
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/App.config 
Tue May 13 11:55:56 2008
@@ -30,21 +30,21 @@
 
   <iBATIS>
     <logging>
-      <!--
+      
        <logFactoryAdapter 
type="Apache.Ibatis.Common.Logging.Impl.ConsoleOutLoggerFA, 
Apache.Ibatis.Common">
                                <arg key="showLogName" value="true" />
                                <arg key="showDataTime" value="true" />
                                <arg key="level" value="ALL" />
                                <arg key="dateTimeFormat" value="yyyy/MM/dd 
HH:mm:ss:SSS" />
-                       </logFactoryAdapter>    -->
+                       </logFactoryAdapter>    
       <!--      <logFactoryAdapter 
type="Apache.Ibatis.Common.Logging.Impl.Log4NetLoggerFA, 
Apache.Ibatis.Common.Logging.Log4Net">
         <arg key="configType" value="inline" />
       </logFactoryAdapter> 
 -->
 
-
+<!--
       <logFactoryAdapter type="Apache.Ibatis.Common.Logging.Impl.NoOpLoggerFA, 
Apache.Ibatis.Common" />
-
+-->
 
     </logging>
   </iBATIS>

Modified: 
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/CacheTest.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/CacheTest.cs?rev=655972&r1=655971&r2=655972&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/CacheTest.cs
 (original)
+++ 
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/CacheTest.cs
 Tue May 13 11:55:56 2008
@@ -102,6 +102,26 @@
             Assert.AreEqual(firstId, secondId);
         }
 
+        [Test]
+        public void LRU_cache_should_work()
+        {
+            IList list = 
dataMapper.QueryForList("GetLruCachedAccountsViaResultMap", null);
+
+            int firstId = HashCodeProvider.GetIdentityHashCode(list);
+
+            list = dataMapper.QueryForList("GetLruCachedAccountsViaResultMap", 
null);
+
+            int secondId = HashCodeProvider.GetIdentityHashCode(list);
+
+            Assert.AreEqual(firstId, secondId);
+
+            list = dataMapper.QueryForList("GetLruCachedAccountsViaResultMap", 
null);
+
+            int thirdId = HashCodeProvider.GetIdentityHashCode(list);
+
+            Assert.AreEqual(firstId, thirdId);
+        }
+
         /// <summary>
         /// Test Cache query
         /// </summary>

Modified: 
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml?rev=655972&r1=655971&r2=655972&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml
 (original)
+++ 
ibatis/trunk/cs/V2/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml
 Tue May 13 11:55:56 2008
@@ -22,12 +22,10 @@
                        <flushOnExecute 
statement="UpdateAccountViaInlineParameters"/>
                </cacheModel>
   
-               <!-- <cacheModel name="account-cache" implementation="LRU" >
-                       <flushInterval hours="24"/>
-                       <flushOnExecute 
statement="UpdateAccountViaInlineParameters"/>
-                       <flushOnExecute 
statement="UpdateAccountViaParameterMap"/>
-                       <property name="CacheSize" value="50"/>
-               </cacheModel> -->
+               <cacheModel id="lru-account-cache" implementation="LRU" >
+      <flushInterval minutes="5"/>
+                       <property name="CacheSize" value="2"/>
+               </cacheModel>
                
     </cacheModels>
 
@@ -282,6 +280,14 @@
                        from Accounts
                        order by Account_ID
                </select>
+
+    <select id="GetLruCachedAccountsViaResultMap"
+      resultMap="account-result"
+      cacheModel="lru-account-cache" >
+      select *
+      from Accounts
+      order by Account_ID
+    </select>
   
                <select id="GetRWCachedAccountsViaResultMap"
                                resultMap="account-result"


Reply via email to