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

Simplified test cases using assertThrows(...).

上级 aa33fa97
......@@ -55,8 +55,12 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
deleteDb("openClose");
Connection conn;
conn = getConnection("jdbc:h2:" + getBaseDir() + "/openClose;FILE_LOCK=FS");
assertThrows(ErrorCode.DATABASE_ALREADY_OPEN_1, (TestBase) this).
getConnection("jdbc:h2:" + getBaseDir() + "/openClose;FILE_LOCK=FS;OPEN_NEW=TRUE");
try {
getConnection("jdbc:h2:" + getBaseDir() + "/openClose;FILE_LOCK=FS;OPEN_NEW=TRUE");
fail();
} catch (SQLException e) {
assertEquals(ErrorCode.DATABASE_ALREADY_OPEN_1, e.getErrorCode());
}
conn.close();
}
......@@ -72,8 +76,12 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
FileObject f = FileSystem.getInstance(getBaseDir()).openFileObject(getBaseDir() + "/openClose2.h2.db.1.part", "rw");
f.setFileLength(f.length() * 2);
f.close();
assertThrows(ErrorCode.IO_EXCEPTION_2, (TestBase) this).
getConnection("jdbc:h2:split:18:" + getBaseDir() + "/openClose2");
try {
getConnection("jdbc:h2:split:18:" + getBaseDir() + "/openClose2");
fail();
} catch (SQLException e) {
assertEquals(ErrorCode.IO_EXCEPTION_2, e.getErrorCode());
}
FileSystem.getInstance("split:").delete("split:" + getBaseDir() + "/openClose2.h2.db");
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论