1 24 25 package org.objectweb.cjdbc.scenario.raidb1.recovery; 26 27 import java.sql.Connection ; 28 import java.sql.ResultSet ; 29 import java.util.ArrayList ; 30 31 import org.objectweb.cjdbc.scenario.templates.Raidb1RecoveryTemplate; 32 import org.objectweb.cjdbc.scenario.tools.ScenarioUtility; 33 34 42 public class Raidb1BackupScenario extends Raidb1RecoveryTemplate 43 { 44 private static final String BACKUP_LOGIN = "user"; 45 private static final String BACKUP_PASSWORD = ""; 46 private static final String BACKUPER = "Octopus"; 47 private static final String BACKUP_PATH = "../backup"; 48 49 54 public void testBasicRecoveryScenario() throws Exception 55 { 56 Connection con = getCJDBCConnection(); 57 ResultSet rs = con.createStatement().executeQuery("select * from document"); 58 ArrayList list1 = ScenarioUtility.convertResultSet(rs); 59 System.out.println(list1); 60 rs.close(); 61 String dump = "dump" + System.currentTimeMillis(); 62 mainVdb.backupBackend("localhost", BACKUP_LOGIN, BACKUP_PASSWORD, dump, 63 BACKUPER, BACKUP_PATH, null); 64 65 rs = con.createStatement().executeQuery("select * from document"); 66 ArrayList list2 = ScenarioUtility.convertResultSet(rs); 67 rs.close(); 68 69 assertEquals("ResultSets are different", list1, list2); 70 } 72 73 79 public void testCompleteRecoveryScenario() throws Exception 80 { 81 String dump = "dump" + System.currentTimeMillis(); 82 mainVdb.backupBackend("localhost", BACKUP_LOGIN, BACKUP_PASSWORD, dump, 83 BACKUPER, BACKUP_PATH, null); 84 hm.stop(hm1); 85 Connection con = getCJDBCConnection(); 86 con.createStatement().executeQuery("select * from document"); 87 ArrayList current = null; 88 ArrayList previous = null; 89 for (int i = 0; i < 50; i++) 90 { 91 current = ScenarioUtility.convertResultSet(con.createStatement() 93 .executeQuery("select * from document")); 94 if (previous != null) 95 assertEquals("Result sets are different before recovery", previous, 96 current); 97 previous = current; 98 } 99 mainVdb.forceDisableBackend("localhost2"); 100 hm1 = hm.start("9001"); 101 hm1.loadDatabase("database-useronly.template"); 102 mainVdb.restoreDumpOnBackend("localhost", BACKUP_LOGIN, BACKUP_PASSWORD, 103 dump, null); 104 mainVdb.enableBackendFromCheckpoint("localhost"); 105 106 for (int i = 0; i < 50; i++) 107 { 108 current = ScenarioUtility.convertResultSet(con.createStatement() 110 .executeQuery("select * from document")); 111 assertEquals("Results sets are different after recovery", previous, 112 current); 113 previous = current; 114 } 115 } 116 117 } | Popular Tags |