1 24 25 package org.objectweb.cjdbc.scenario.raidb1.cache; 26 27 import java.sql.Connection ; 28 import java.util.ArrayList ; 29 30 import org.objectweb.cjdbc.scenario.templates.Raidb1Template; 31 import org.objectweb.cjdbc.scenario.tools.ScenarioUtility; 32 33 41 public class CacheInvalidateScenario extends Raidb1Template 42 { 43 44 49 public void testCacheInvalidate() throws Exception 50 { 51 Connection con = getCJDBCConnection(); 52 con.setAutoCommit(false); 53 String create = "CREATE TABLE TEST_TABLE ( TEST_ID VARCHAR(12) NOT NULL, TEST_VALUE VARCHAR(70) NOT NULL, CONSTRAINT TEST_PK PRIMARY KEY(TEST_ID))"; 54 String insert = "INSERT INTO TEST_TABLE VALUES('TEST', 'VVK')"; 55 String update = "UPDATE TEST_TABLE SET TEST_VALUE='VVK UPDATED' WHERE TEST_ID='TEST'"; 56 String delete = "DELETE FROM TEST_TABLE WHERE TEST_ID='TEST'"; 57 String drop = "DROP TABLE TEST_TABLE"; 58 String select = "SELECT TEST_VALUE FROM TEST_TABLE WHERE TEST_ID LIKE 'TEST'"; 59 60 con.createStatement().executeUpdate(create); 61 ArrayList set1 = ScenarioUtility.getSingleQueryResult(select,con); 62 64 con.createStatement().executeUpdate(insert); 65 ArrayList set2 = ScenarioUtility.getSingleQueryResult(select,con); 66 assertNotSame("Insert did not invalidate", set1,set2); 68 69 con.createStatement().executeUpdate(update); 70 ArrayList set3 = ScenarioUtility.getSingleQueryResult(select,con); 71 assertNotSame("Update did not invalidate", set2,set3); 73 74 con.createStatement().executeUpdate(delete); 75 ArrayList set4 = ScenarioUtility.getSingleQueryResult(select,con); 76 assertNotSame("Delete did not invalidate", set3,set4); 78 79 con.createStatement().executeUpdate(insert); 80 ArrayList set5 = ScenarioUtility.getSingleQueryResult(select,con); 81 assertNotSame("Insert2 did not invalidate", set4,set5); 83 84 con.createStatement().executeUpdate(drop); 85 try 86 { 87 con.createStatement().executeQuery(select); 88 fail("Drop did not invalidate"); 89 } 90 catch (Exception e) 91 { 92 } 94 95 con.rollback(); 96 con.setAutoCommit(true); 97 con.close(); 98 } 99 } | Popular Tags |