1 24 25 package org.objectweb.cjdbc.scenario.horizontal; 26 27 import java.sql.Connection ; 28 import java.sql.PreparedStatement ; 29 30 import org.objectweb.cjdbc.driver.ControllerInfo; 31 import org.objectweb.cjdbc.scenario.templates.HorizontalTemplate; 32 import org.objectweb.cjdbc.scenario.tools.ScenarioUtility; 33 34 41 public class ControllerHasLostAllBackendsFailoverScenario 42 extends HorizontalTemplate 43 { 44 50 public void testReadFailover() throws Exception 51 { 52 Connection con = getCJDBCConnection(new ControllerInfo[]{ 53 new ControllerInfo("localhost", 25322), 54 new ControllerInfo("localhost", 25323)}); 55 hm.stop(hm1); 56 hm.stop(hm2); 57 String query = "Select * from document"; 58 ScenarioUtility.displaySingleQueryResult(query, con); 59 } 60 61 67 public void testWriteFailover() throws Exception 68 { 69 Connection con = getCJDBCConnection(new ControllerInfo[]{ 70 new ControllerInfo("localhost", 25322), 71 new ControllerInfo("localhost", 25323)}); 72 hm.stop(hm1); 73 hm.stop(hm2); 74 String query = "update document set total=?"; 75 PreparedStatement ps = con.prepareStatement(query); 76 ps.setDouble(1, 0.0); 77 int updateC = ps.executeUpdate(); 78 logger.warn("Number of updates:" + updateC); 79 assertTrue(updateC > 1); 80 } 81 } | Popular Tags |