TestDbBackup.java (hsqldb-2.6.0) | : | TestDbBackup.java (hsqldb-2.6.1) | ||
---|---|---|---|---|
skipping to change at line 54 | skipping to change at line 54 | |||
import org.hsqldb.lib.tar.TarMalformatException; | import org.hsqldb.lib.tar.TarMalformatException; | |||
import junit.framework.Test; | import junit.framework.Test; | |||
import junit.framework.TestSuite; | import junit.framework.TestSuite; | |||
import junit.framework.TestCase; | import junit.framework.TestCase; | |||
public class TestDbBackup extends TestCase { | public class TestDbBackup extends TestCase { | |||
public TestDbBackup() throws IOException, SQLException {} | public TestDbBackup() throws IOException, SQLException {} | |||
static protected File baseDir = | static protected File baseDir = new File("TestDbBackup-" | |||
new File(System.getProperty("java.io.tmpdir"), | + System.currentTimeMillis()); | |||
"TestDbBackup-" + System.getProperty("user.name")); | ||||
static { | static { | |||
try { | try { | |||
Class.forName("org.hsqldb.jdbc.JDBCDriver"); | Class.forName("org.hsqldb.jdbc.JDBCDriver"); | |||
} catch (ClassNotFoundException cnfe) { | } catch (ClassNotFoundException cnfe) { | |||
throw new RuntimeException( | throw new RuntimeException( | |||
"<clinit> failed. JDBC Driver class not in CLASSPATH"); | "<clinit> failed. JDBC Driver class not in CLASSPATH"); | |||
} | } | |||
} | } | |||
skipping to change at line 126 | skipping to change at line 125 | |||
throw new IOException("Specified dir does not exist: " | throw new IOException("Specified dir does not exist: " | |||
+ dir.getAbsolutePath()); | + dir.getAbsolutePath()); | |||
} | } | |||
File[] children = dir.listFiles(); | File[] children = dir.listFiles(); | |||
for (int i = 0; i < children.length; i++) { | for (int i = 0; i < children.length; i++) { | |||
if (children[i].isDirectory()) { | if (children[i].isDirectory()) { | |||
rmR(children[i]); | rmR(children[i]); | |||
} else if (!children[i].delete()) { | } else if (!children[i].delete()) { | |||
throw new IOException("Failed to remove '" | if (!children[i].delete()) { | |||
+ children[i].getAbsolutePath() + "'"); | throw new IOException("Failed to remove '" | |||
+ children[i].getAbsolutePath() | ||||
+ "'"); | ||||
} | ||||
} | } | |||
} | } | |||
if (!dir.delete()) { | if (!dir.delete()) { | |||
throw new IOException("Failed to remove '" + dir.getAbsolutePath() | throw new IOException("Failed to remove '" + dir.getAbsolutePath() | |||
+ "'"); | + "'"); | |||
} | } | |||
} | } | |||
/** | /** | |||
skipping to change at line 384 | skipping to change at line 386 | |||
} | } | |||
} | } | |||
public void testMainAlreadyOpen() | public void testMainAlreadyOpen() | |||
throws SQLException, IOException, TarMalformatException { | throws SQLException, IOException, TarMalformatException { | |||
try { | try { | |||
setupConn("db1"); | setupConn("db1"); | |||
try { | try { | |||
DbBackupMain.main(new String[] { | String backupPath = baseDir.getAbsolutePath() | |||
"--save", baseDir.getAbsolutePath() + "/mainOpen.tar", | + "/mainOpen.tar"; | |||
baseDir.getAbsolutePath() + "/db1/dbfile" | String dbPath = baseDir.getAbsolutePath() + "/db1/dbfile"; | |||
}); | String[] args = new String[] { | |||
"--save", backupPath, dbPath | ||||
}; | ||||
DbBackupMain.main(args); | ||||
} catch (IllegalStateException ioe) { | } catch (IllegalStateException ioe) { | |||
return; | return; | |||
} | } | |||
} finally { | } finally { | |||
shutdownAndCloseConn(); | shutdownAndCloseConn(); | |||
} | } | |||
fail("Backup from main() did not throw even though DB is open"); | fail("Backup from main() did not throw even though DB is open"); | |||
} | } | |||
End of changes. 3 change blocks. | ||||
9 lines changed or deleted | 15 lines changed or added |