You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by cb...@apache.org on 2005/06/25 07:13:49 UTC

svn commit: r201726 - /ibatis/trunk/java/mapper/mapper2/test/com/ibatis/sqlmap/CacheStatementTest.java

Author: cbegin
Date: Fri Jun 24 22:13:47 2005
New Revision: 201726

URL: http://svn.apache.org/viewcvs?rev=201726&view=rev
Log:
Added unit tests to verify correct operation of IBATIS-93

Modified:
    ibatis/trunk/java/mapper/mapper2/test/com/ibatis/sqlmap/CacheStatementTest.java

Modified: ibatis/trunk/java/mapper/mapper2/test/com/ibatis/sqlmap/CacheStatementTest.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/mapper/mapper2/test/com/ibatis/sqlmap/CacheStatementTest.java?rev=201726&r1=201725&r2=201726&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/test/com/ibatis/sqlmap/CacheStatementTest.java (original)
+++ ibatis/trunk/java/mapper/mapper2/test/com/ibatis/sqlmap/CacheStatementTest.java Fri Jun 24 22:13:47 2005
@@ -48,23 +48,60 @@
 
   public void testFlushDataCache() throws SQLException {
     List list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
-
     int firstId = System.identityHashCode(list);
-
     list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
-
     int secondId = System.identityHashCode(list);
-
     assertEquals(firstId, secondId);
-
     sqlMap.flushDataCache();
-
     list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
+    int thirdId = System.identityHashCode(list);
+    assertTrue(firstId != thirdId);
+  }
 
+  public void testFlushDataCacheOnExecute() throws SQLException {
+    List list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
+    int firstId = System.identityHashCode(list);
+    list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
+    int secondId = System.identityHashCode(list);
+    assertEquals(firstId, secondId);
+    sqlMap.update("updateAccountViaInlineParameters", list.get(0));
+    list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
     int thirdId = System.identityHashCode(list);
+    assertTrue(firstId != thirdId);
+  }
 
+  public void testFlushDataCacheOnExecuteInBatch() throws SQLException {
+    List list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
+    int firstId = System.identityHashCode(list);
+    list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
+    int secondId = System.identityHashCode(list);
+    assertEquals(firstId, secondId);
+    sqlMap.startBatch();
+    sqlMap.update("updateAccountViaInlineParameters", list.get(0));
+    sqlMap.executeBatch();
+    list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
+    int thirdId = System.identityHashCode(list);
     assertTrue(firstId != thirdId);
+  }
 
+  public void testFlushDataCacheOnExecuteInBatchWithTx() throws SQLException {
+    List list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
+    int firstId = System.identityHashCode(list);
+    list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
+    int secondId = System.identityHashCode(list);
+    assertEquals(firstId, secondId);
+    try {
+      sqlMap.startTransaction();
+      sqlMap.startBatch();
+      sqlMap.update("updateAccountViaInlineParameters", list.get(0));
+      sqlMap.executeBatch();
+      sqlMap.commitTransaction();
+    } finally {
+      sqlMap.endTransaction();
+    }
+    list = sqlMap.queryForList("getCachedAccountsViaResultMap", null);
+    int thirdId = System.identityHashCode(list);
+    assertTrue(firstId != thirdId);
   }
 
   public void testMappedStatementQueryWithThreadedCache() throws SQLException {