提交 a5046b58 authored 作者: Thomas Mueller's avatar Thomas Mueller

To test recovery, append ;RECOVER_TEST=64 to the database URL.

上级 df754bec
...@@ -26,7 +26,7 @@ import org.h2.tools.Recover; ...@@ -26,7 +26,7 @@ import org.h2.tools.Recover;
*/ */
public class RecoverTester implements Recorder { public class RecoverTester implements Recorder {
private static final RecoverTester INSTANCE = new RecoverTester(); private static RecoverTester instance;
private String testDatabase = "memFS:reopen"; private String testDatabase = "memFS:reopen";
private int writeCount = Utils.getProperty("h2.recoverTestOffset", 0); private int writeCount = Utils.getProperty("h2.recoverTestOffset", 0);
...@@ -36,8 +36,11 @@ public class RecoverTester implements Recorder { ...@@ -36,8 +36,11 @@ public class RecoverTester implements Recorder {
private HashSet<String> knownErrors = New.hashSet(); private HashSet<String> knownErrors = New.hashSet();
private volatile boolean testing; private volatile boolean testing;
public static RecoverTester getInstance() { public static synchronized RecoverTester getInstance() {
return INSTANCE; if (instance == null) {
instance = new RecoverTester();
}
return instance;
} }
public void log(int op, String fileName, byte[] data, long x) { public void log(int op, String fileName, byte[] data, long x) {
...@@ -85,6 +88,7 @@ public class RecoverTester implements Recorder { ...@@ -85,6 +88,7 @@ public class RecoverTester implements Recorder {
Database database = new Database(ci, null); Database database = new Database(ci, null);
// close the database // close the database
Session session = database.getSystemSession(); Session session = database.getSystemSession();
session.prepare("script to '" + testDatabase + ".sql'").query(0);
session.prepare("shutdown immediately").update(); session.prepare("shutdown immediately").update();
database.removeSession(null); database.removeSession(null);
// everything OK - return // everything OK - return
......
...@@ -35,6 +35,7 @@ public class TestClearReferences extends TestBase { ...@@ -35,6 +35,7 @@ public class TestClearReferences extends TestBase {
"org.h2.util.DateTimeUtils.cachedCalendar", "org.h2.util.DateTimeUtils.cachedCalendar",
"org.h2.util.MathUtils.cachedSecureRandom", "org.h2.util.MathUtils.cachedSecureRandom",
"org.h2.util.NetUtils.cachedLocalAddress", "org.h2.util.NetUtils.cachedLocalAddress",
"org.h2.util.RecoverTester.instance",
"org.h2.util.StringUtils.softCache", "org.h2.util.StringUtils.softCache",
"org.h2.util.Utils.allowedClassNames", "org.h2.util.Utils.allowedClassNames",
"org.h2.util.Utils.allowedClassNamePrefixes", "org.h2.util.Utils.allowedClassNamePrefixes",
......
...@@ -106,6 +106,7 @@ public class TestReopen extends TestBase implements Recorder { ...@@ -106,6 +106,7 @@ public class TestReopen extends TestBase implements Recorder {
Database database = new Database(ci, null); Database database = new Database(ci, null);
// close the database // close the database
Session session = database.getSystemSession(); Session session = database.getSystemSession();
session.prepare("script to '" + testDatabase + ".sql'").query(0);
session.prepare("shutdown immediately").update(); session.prepare("shutdown immediately").update();
database.removeSession(null); database.removeSession(null);
// everything OK - return // everything OK - return
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论