提交 8351b1c6 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Move TestFileSystem to testUtils() section

上级 e273bff1
......@@ -928,7 +928,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
addTest(new TestCluster());
addTest(new TestFileLockSerialized());
addTest(new TestFileLockProcess());
addTest(new TestFileSystem());
addTest(new TestDefrag());
addTest(new TestTools());
addTest(new TestSampleApps());
......@@ -973,6 +972,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
addTest(new TestDateIso8601());
addTest(new TestDbException());
addTest(new TestFile());
addTest(new TestFileSystem());
addTest(new TestFtp());
addTest(new TestGeometryUtils());
addTest(new TestInterval());
......
......@@ -16,6 +16,7 @@ import java.nio.channels.FileChannel.MapMode;
import java.nio.channels.FileLock;
import java.nio.channels.NonWritableChannelException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
......@@ -32,7 +33,6 @@ import org.h2.store.fs.FilePathEncrypt;
import org.h2.store.fs.FilePathRec;
import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase;
import org.h2.test.TestDb;
import org.h2.test.utils.AssertThrows;
import org.h2.test.utils.FilePathDebug;
import org.h2.tools.Backup;
......@@ -43,7 +43,7 @@ import org.h2.util.Task;
/**
* Tests various file system.
*/
public class TestFileSystem extends TestDb {
public class TestFileSystem extends TestBase {
/**
* Run just this test.
......@@ -251,7 +251,7 @@ public class TestFileSystem extends TestDb {
FileUtils.deleteRecursive(dir, false);
Connection conn;
Statement stat;
conn = getConnection("jdbc:h2:split:18:"+dir+"/test");
conn = DriverManager.getConnection("jdbc:h2:split:18:"+dir+"/test");
stat = conn.createStatement();
stat.execute(
"create table test(id int primary key, name varchar) " +
......@@ -260,7 +260,7 @@ public class TestFileSystem extends TestDb {
conn.close();
Backup.execute(dir + "/test.zip", dir, "", true);
DeleteDbFiles.execute("split:" + dir, "test", true);
conn = getConnection(
conn = DriverManager.getConnection(
"jdbc:h2:split:zip:"+dir+"/test.zip!/test");
conn.createStatement().execute("select * from test where id=1");
conn.close();
......@@ -269,22 +269,22 @@ public class TestFileSystem extends TestDb {
private void testDatabaseInMemFileSys() throws SQLException {
org.h2.Driver.load();
deleteDb("fsMem");
String url = "jdbc:h2:" + getBaseDir() + "/fsMem";
Connection conn = getConnection(url, "sa", "sa");
String dir = getBaseDir() + "/fsMem";
FileUtils.deleteRecursive(dir, false);
String url = "jdbc:h2:" + dir + "/fsMem";
Connection conn = DriverManager.getConnection(url, "sa", "sa");
conn.createStatement().execute(
"CREATE TABLE TEST AS SELECT * FROM DUAL");
conn.createStatement().execute(
"BACKUP TO '" + getBaseDir() + "/fsMem.zip'");
conn.close();
org.h2.tools.Restore.main("-file", getBaseDir() + "/fsMem.zip", "-dir",
"memFS:");
conn = getConnection("jdbc:h2:memFS:fsMem", "sa", "sa");
org.h2.tools.Restore.main("-file", getBaseDir() + "/fsMem.zip", "-dir", "memFS:");
conn = DriverManager.getConnection("jdbc:h2:memFS:fsMem", "sa", "sa");
ResultSet rs = conn.createStatement()
.executeQuery("SELECT * FROM TEST");
rs.close();
conn.close();
deleteDb("fsMem");
FileUtils.deleteRecursive(dir, false);
FileUtils.delete(getBaseDir() + "/fsMem.zip");
FileUtils.delete("memFS:fsMem.mv.db");
}
......@@ -297,8 +297,9 @@ public class TestFileSystem extends TestDb {
return;
}
org.h2.Driver.load();
String url = "jdbc:h2:" + getBaseDir() + "/fsJar";
Connection conn = getConnection(url, "sa", "sa");
String dir = getBaseDir() + "/fsJar";
String url = "jdbc:h2:" + dir + "/fsJar";
Connection conn = DriverManager.getConnection(url, "sa", "sa");
Statement stat = conn.createStatement();
stat.execute("create table test(id int primary key, " +
"name varchar, b blob, c clob)");
......@@ -310,12 +311,12 @@ public class TestFileSystem extends TestDb {
byte[] b1 = rs.getBytes(3);
String s1 = rs.getString(4);
conn.close();
conn = getConnection(url, "sa", "sa");
conn = DriverManager.getConnection(url, "sa", "sa");
stat = conn.createStatement();
stat.execute("backup to '" + getBaseDir() + "/fsJar.zip'");
conn.close();
deleteDb("fsJar");
FileUtils.deleteRecursive(dir, false);
for (String f : FileUtils.newDirectoryStream(
"zip:" + getBaseDir() + "/fsJar.zip")) {
assertFalse(FileUtils.isAbsolute(f));
......@@ -334,7 +335,7 @@ public class TestFileSystem extends TestDb {
testReadOnly(f);
}
String urlJar = "jdbc:h2:zip:" + getBaseDir() + "/fsJar.zip!/fsJar";
conn = getConnection(urlJar, "sa", "sa");
conn = DriverManager.getConnection(urlJar, "sa", "sa");
stat = conn.createStatement();
rs = stat.executeQuery("select * from test");
rs.next();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论