1 24 25 package org.objectweb.cjdbc.scenario.raidb1; 26 27 import java.sql.Connection ; 28 import java.sql.Statement ; 29 30 import org.objectweb.cjdbc.scenario.templates.SimpleRaidb1Template; 31 32 39 public class Raidb1WaitForAllCompletionPolicyScenario extends SimpleRaidb1Template 40 { 41 42 45 public void testWriteTransactionFailOverWithVariablePool() 46 { 47 try 48 { 49 cm.loadVirtualDatabases(controller, "myDB", 51 "hsqldb-raidb1-variablepool-waitforall.xml"); 52 mainVdb = controller.getVirtualDatabase("myDB"); 53 mainVdb.enableAllBackends(); 54 55 hm.stop(hm1); 57 58 Connection con = getCJDBCConnection(); 60 assertNotNull("Connection is null", con); 61 62 con.setAutoCommit(false); 64 65 Statement stmt1 = con.createStatement(); 67 stmt1.executeUpdate("update product set name='horizontalTest1'"); 68 stmt1.close(); 69 70 Statement stmt2 = con.createStatement(); 72 stmt2.executeUpdate("update product set name='horizontalTest2'"); 73 stmt2.close(); 74 75 con.rollback(); 77 con.close(); 78 } 79 catch (Exception e) 80 { 81 e.printStackTrace(); 82 fail("failed to test c-jdbc transaction failover in variable pool connection manager"); 83 } 84 } 85 86 89 public void testWriteFailOverWithVariablePool() 90 { 91 try 92 { 93 cm.loadVirtualDatabases(controller, "myDB", 95 "hsqldb-raidb1-variablepool-waitforall.xml"); 96 mainVdb = controller.getVirtualDatabase("myDB"); 97 mainVdb.enableAllBackends(); 98 99 hm.stop(hm1); 101 102 Connection con = getCJDBCConnection(); 104 assertNotNull("Connection is null", con); 105 106 Statement stmt1 = con.createStatement(); 108 stmt1.executeUpdate("update product set name='horizontalTest1'"); 109 stmt1.close(); 110 111 Statement stmt2 = con.createStatement(); 113 stmt2.executeUpdate("update product set name='horizontalTest2'"); 114 stmt2.close(); 115 116 con.close(); 118 } 119 catch (Exception e) 120 { 121 e.printStackTrace(); 122 fail("failed to test c-jdbc transaction failover in variable pool connection manager"); 123 } 124 } 125 126 129 public void testWriteTransactionFailOverWithNoPool() 130 { 131 try 132 { 133 cm.loadVirtualDatabases(controller, "myDB", 135 "hsqldb-raidb1-nopool-waitforall.xml"); 136 mainVdb = controller.getVirtualDatabase("myDB"); 137 mainVdb.enableAllBackends(); 138 139 hm.stop(hm1); 141 142 Connection con = getCJDBCConnection(); 144 assertNotNull("Connection is null", con); 145 146 con.setAutoCommit(false); 148 149 Statement stmt1 = con.createStatement(); 151 stmt1.executeUpdate("update product set name='horizontalTest1'"); 152 stmt1.close(); 153 154 Statement stmt2 = con.createStatement(); 156 stmt2.executeUpdate("update product set name='horizontalTest2'"); 157 stmt2.close(); 158 159 con.rollback(); 161 con.close(); 162 } 163 catch (Exception e) 164 { 165 e.printStackTrace(); 166 fail("failed to test c-jdbc transaction failover in simple connection manager"); 167 } 168 } 169 170 173 public void testWriteFailOverWithNoPool() 174 { 175 try 176 { 177 cm.loadVirtualDatabases(controller, "myDB", 179 "hsqldb-raidb1-nopool-waitforall.xml"); 180 mainVdb = controller.getVirtualDatabase("myDB"); 181 mainVdb.enableAllBackends(); 182 183 hm.stop(hm1); 185 186 Connection con = getCJDBCConnection(); 188 assertNotNull("Connection is null", con); 189 190 Statement stmt1 = con.createStatement(); 192 stmt1.executeUpdate("update product set name='horizontalTest1'"); 193 stmt1.close(); 194 195 Statement stmt2 = con.createStatement(); 197 stmt2.executeUpdate("update product set name='horizontalTest2'"); 198 stmt2.close(); 199 200 con.close(); 202 } 203 catch (Exception e) 204 { 205 e.printStackTrace(); 206 fail("failed to test c-jdbc transaction failover in simple connection manager"); 207 } 208 } 209 210 211 } 212 | Popular Tags |