I want to test to run mysqldump command in my function but I could not create aaadumpdb.sql file. My code is below:
@Test
public void dumpDB() {
Process p = null;
try {
Runtime runtime = Runtime.getRuntime();
p = runtime
.exec("mysqldump -u root -padmin --add-drop-database aaa_db "
+ "D:\\backupdenemeaaa " + "aaadumpdb.sql");
// change the dbpass and dbname with your dbpass and dbname
int processComplete = p.waitFor();
if (processComplete == 0) {
System.out.println("Backup created successfully!");
} else {
JOptionPane.showMessageDialog(new JDialog(),
"Could not create the backup");
}
} catch (Exception e) {
e.printStackTrace();
}
File f = new File("aaadumpdb.sql");
assertTrue(f.exists());
}
Can anybody give me some advice about it? Thank you.
Aucun commentaire:
Enregistrer un commentaire