提交 43fde846 authored 作者: Thomas Mueller's avatar Thomas Mueller

Test need to clean up the file system after running.

上级 30107279
......@@ -14,6 +14,7 @@ import java.sql.Statement;
import org.h2.tools.Script;
import org.h2.tools.DeleteDbFiles;
import org.h2.tools.RunScript;
import org.h2.util.IOUtils;
/**
* This sample application shows how to compact the database files.
......@@ -56,5 +57,6 @@ public class Compact {
Script.execute(url, user, password, file);
DeleteDbFiles.execute(dir, dbName, true);
RunScript.execute(url, user, password, file, null, false);
IOUtils.delete(file);
}
}
......@@ -13,6 +13,7 @@ import java.sql.Types;
import org.h2.tools.Csv;
import org.h2.tools.SimpleResultSet;
import org.h2.util.IOUtils;
/**
* This sample application shows how to use the CSV tool
......@@ -31,6 +32,7 @@ public class CsvSample {
public static void main(String... args) throws SQLException {
CsvSample.write();
CsvSample.read();
IOUtils.delete("data/test.csv");
}
/**
......
......@@ -37,6 +37,7 @@ public class TestBackup extends TestBase {
testBackupRestoreLob();
testBackup();
deleteDb("backup");
IOUtils.delete(getBaseDir() + "/backup.zip");
}
private void testBackupRestoreLob() throws SQLException {
......@@ -44,19 +45,19 @@ public class TestBackup extends TestBase {
Connection conn = getConnection("backup");
conn.createStatement().execute("create table test(x clob) as select space(10000)");
conn.close();
Backup.execute(getTestDir("") + "/backup.zip", getTestDir(""), "backup", true);
Backup.execute(getBaseDir() + "/backup.zip", getBaseDir(), "backup", true);
deleteDb("backup");
Restore.execute(getTestDir("") + "/backup.zip", getTestDir(""), "backup", true);
Restore.execute(getBaseDir() + "/backup.zip", getBaseDir(), "backup", true);
}
private void testBackupRestoreLobStatement() throws SQLException {
deleteDb("backup");
Connection conn = getConnection("backup");
conn.createStatement().execute("create table test(x clob) as select space(10000)");
conn.createStatement().execute("backup to '"+getTestDir("") + "/backup.zip"+"'");
conn.createStatement().execute("backup to '" +getBaseDir() + "/backup.zip"+"'");
conn.close();
deleteDb("backup");
Restore.execute(getTestDir("") + "/backup.zip", getTestDir(""), "backup", true);
Restore.execute(getBaseDir() + "/backup.zip", getBaseDir(), "backup", true);
}
private void testBackup() throws SQLException {
......@@ -77,11 +78,11 @@ public class TestBackup extends TestBase {
stat2.execute("insert into test values(4, 'fourth (uncommitted)')");
stat2.execute("insert into testlob values(2, ' ', '00')");
stat1.execute("backup to '" + baseDir + "/backup.zip'");
stat1.execute("backup to '" + getBaseDir() + "/backup.zip'");
conn2.rollback();
assertEqualDatabases(stat1, stat2);
Restore.execute(baseDir + "/backup.zip", baseDir, "restored", true);
Restore.execute(getBaseDir() + "/backup.zip", getBaseDir(), "restored", true);
conn3 = getConnection("restored");
stat3 = conn3.createStatement();
assertEqualDatabases(stat1, stat3);
......@@ -90,7 +91,6 @@ public class TestBackup extends TestBase {
conn2.close();
conn3.close();
deleteDb("restored");
IOUtils.delete(baseDir + "/backup.zip");
}
}
......@@ -89,7 +89,7 @@ public class TestBigResult extends TestBase {
// rs.close();
conn.close();
deleteDb("bigResult");
ArrayList<String> files = FileLister.getDatabaseFiles(baseDir, "bigResult", true);
ArrayList<String> files = FileLister.getDatabaseFiles(getBaseDir(), "bigResult", true);
if (files.size() > 0) {
fail("file not deleted: " + files.get(0));
}
......
......@@ -19,6 +19,7 @@ import java.sql.Timestamp;
import java.util.Random;
import org.h2.constant.ErrorCode;
import org.h2.test.TestBase;
import org.h2.util.IOUtils;
/**
* Various test cases.
......@@ -320,9 +321,10 @@ public class TestCases extends TestBase {
sql = "delete from " + table;
}
stat.execute(sql);
stat.execute("script to '" + baseDir + "/test.sql'");
stat.execute("script to '" + getBaseDir() + "/test.sql'");
}
conn.close();
IOUtils.delete(getBaseDir() + "/test.sql");
}
private void testDeleteGroup() throws SQLException {
......@@ -1022,8 +1024,8 @@ public class TestCases extends TestBase {
conn.close();
File[] files = new File(baseDir + "/cases.lobs.db").listFiles();
if (files != null && files.length > 0) {
String[] list = IOUtils.listFiles(getBaseDir() + "/cases.lobs.db");
if (list != null && list.length > 0) {
fail("Lob file was not deleted");
}
}
......
......@@ -17,6 +17,7 @@ import org.h2.test.TestBase;
import org.h2.tools.CreateCluster;
import org.h2.tools.DeleteDbFiles;
import org.h2.tools.Server;
import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils;
/**
......@@ -56,14 +57,14 @@ public class TestCluster extends TestBase {
int len = 10;
// initialize the database
Server n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port1, "-baseDir", baseDir + "/node1").start();
Server n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port1, "-baseDir", getBaseDir() + "/node1").start();
conn = DriverManager.getConnection(url1, user, password);
stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar) as " +
"select x, 'Data' || x from system_range(0, " + (len - 1) + ")");
// start the second server
Server n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2 , "-baseDir", baseDir + "/node2").start();
Server n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2 , "-baseDir", getBaseDir() + "/node2").start();
// copy the database and initialize the cluster
CreateCluster.main("-urlSource", url1, "-urlTarget", url2, "-user", user, "-password", password, "-serverList",
......@@ -87,7 +88,7 @@ public class TestCluster extends TestBase {
check(connApp, len, "''");
// re-create the cluster
n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2, "-baseDir", baseDir + "/node2").start();
n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2, "-baseDir", getBaseDir() + "/node2").start();
CreateCluster.main("-urlSource", url1, "-urlTarget", url2, "-user", user, "-password", password, "-serverList",
serverList);
......@@ -135,8 +136,8 @@ public class TestCluster extends TestBase {
serverList);
// start both servers
Server n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port1, "-baseDir", baseDir + "/node1").start();
Server n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2, "-baseDir", baseDir + "/node2").start();
Server n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port1, "-baseDir", getBaseDir() + "/node1").start();
Server n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2, "-baseDir", getBaseDir() + "/node2").start();
// try to connect in standalone mode - should fail
try {
......@@ -169,12 +170,12 @@ public class TestCluster extends TestBase {
n1.stop();
// re-create the cluster
DeleteDbFiles.main("-dir", baseDir + "/node2", "-quiet");
DeleteDbFiles.main("-dir", getBaseDir() + "/node2", "-quiet");
CreateCluster.main("-urlSource", urlNode1, "-urlTarget",
urlNode2, "-user", user, "-password", password, "-serverList",
serverList);
n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port1, "-baseDir", baseDir + "/node1").start();
n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2, "-baseDir", baseDir + "/node2").start();
n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port1, "-baseDir", getBaseDir() + "/node1").start();
n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2, "-baseDir", getBaseDir() + "/node2").start();
conn = DriverManager.getConnection("jdbc:h2:tcp://" + serverList + "/test", user, password);
stat = conn.createStatement();
......@@ -186,13 +187,13 @@ public class TestCluster extends TestBase {
conn.close();
n2.stop();
n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port1, "-baseDir", baseDir + "/node1").start();
n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port1, "-baseDir", getBaseDir() + "/node1").start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:"+port1+"/test;CLUSTER=''", user, password);
check(conn, len, "''");
conn.close();
n1.stop();
n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2, "-baseDir", baseDir + "/node2").start();
n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2, "-baseDir", getBaseDir() + "/node2").start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:" + port2 + "/test;CLUSTER=''", user, password);
check(conn, len, "''");
conn.createStatement().execute("SELECT * FROM A");
......@@ -202,8 +203,10 @@ public class TestCluster extends TestBase {
}
private void deleteFiles() throws SQLException {
DeleteDbFiles.main("-dir", baseDir + "/node1", "-quiet");
DeleteDbFiles.main("-dir", baseDir + "/node2", "-quiet");
DeleteDbFiles.main("-dir", getBaseDir() + "/node1", "-quiet");
DeleteDbFiles.main("-dir", getBaseDir() + "/node2", "-quiet");
IOUtils.delete(getBaseDir() + "/node1");
IOUtils.delete(getBaseDir() + "/node2");
}
private void check(Connection conn, int len, String expectedCluster) throws SQLException {
......
......@@ -68,7 +68,7 @@ public class TestCsv extends TestBase {
private void testSpaceSeparated() throws SQLException {
deleteDb("csv");
File f = new File(baseDir + "/testSpace.csv");
File f = new File(getBaseDir() + "/testSpace.csv");
IOUtils.delete(f.getAbsolutePath());
Connection conn = getConnection("csv");
......@@ -76,13 +76,14 @@ public class TestCsv extends TestBase {
stat.execute("create temporary table test (a int, b int, c int)");
stat.execute("insert into test values(1,2,3)");
stat.execute("insert into test values(4,null,5)");
stat.execute("call csvwrite('"+baseDir+"/test.tsv','select * from test',null,' ')");
stat.execute("call csvwrite('"+getBaseDir()+"/test.tsv','select * from test',null,' ')");
ResultSet rs1 = stat.executeQuery("select * from test");
assertResultSetOrdered(rs1, new String[][]{new String[]{"1", "2", "3"}, new String[]{"4", null, "5"}});
ResultSet rs2 = stat.executeQuery("select * from csvread('"+baseDir+"/test.tsv',null,null,' ')");
ResultSet rs2 = stat.executeQuery("select * from csvread('"+getBaseDir()+"/test.tsv',null,null,' ')");
assertResultSetOrdered(rs2, new String[][]{new String[]{"1", "2", "3"}, new String[]{"4", null, "5"}});
conn.close();
IOUtils.delete(f.getAbsolutePath());
IOUtils.delete(getBaseDir() + "/test.tsv");
}
/**
......@@ -91,7 +92,7 @@ public class TestCsv extends TestBase {
private void testNull() throws Exception {
deleteDb("csv");
String fileName = baseDir + "/testNull.csv";
String fileName = getBaseDir() + "/testNull.csv";
FileSystem fs = FileSystem.getInstance(fileName);
fs.delete(fileName);
......@@ -148,11 +149,11 @@ public class TestCsv extends TestBase {
list.add(new String[]{a, b});
prep.execute();
}
stat.execute("CALL CSVWRITE('" + baseDir + "/test.csv', 'SELECT * FROM test', 'UTF-8', '|', '#')");
stat.execute("CALL CSVWRITE('" + getBaseDir() + "/test.csv', 'SELECT * FROM test', 'UTF-8', '|', '#')");
Csv csv = Csv.getInstance();
csv.setFieldSeparatorRead('|');
csv.setFieldDelimiter('#');
ResultSet rs = csv.read(baseDir + "/test.csv", null, "UTF-8");
ResultSet rs = csv.read(getBaseDir() + "/test.csv", null, "UTF-8");
for (int i = 0; i < len; i++) {
assertTrue(rs.next());
String[] pair = list.get(i);
......@@ -161,7 +162,7 @@ public class TestCsv extends TestBase {
}
assertFalse(rs.next());
conn.close();
IOUtils.delete(baseDir + "/test.csv");
IOUtils.delete(getBaseDir() + "/test.csv");
}
private String randomData(Random random) {
......@@ -178,7 +179,7 @@ public class TestCsv extends TestBase {
}
private void testEmptyFieldDelimiter() throws Exception {
String fileName = baseDir + "/test.csv";
String fileName = getBaseDir() + "/test.csv";
IOUtils.delete(fileName);
Connection conn = getConnection("csv");
Statement stat = conn.createStatement();
......@@ -201,8 +202,8 @@ public class TestCsv extends TestBase {
}
private void testFieldDelimiter() throws Exception {
String fileName = baseDir + "/test.csv";
String fileName2 = baseDir + "/test2.csv";
String fileName = getBaseDir() + "/test.csv";
String fileName2 = getBaseDir() + "/test2.csv";
FileSystem fs = FileSystem.getInstance(fileName);
fs.delete(fileName);
FileObject file = fs.openFileObject(fileName, "rw");
......@@ -239,13 +240,13 @@ public class TestCsv extends TestBase {
deleteDb("csv");
Connection conn = getConnection("csv");
Statement stat = conn.createStatement();
stat.execute("call csvwrite('" + baseDir + "/test.csv', 'select 1 id, ''Hello'' name', 'utf-8', '|')");
ResultSet rs = stat.executeQuery("select * from csvread('" + baseDir + "/test.csv', null, 'utf-8', '|')");
stat.execute("call csvwrite('" + getBaseDir() + "/test.csv', 'select 1 id, ''Hello'' name', 'utf-8', '|')");
ResultSet rs = stat.executeQuery("select * from csvread('" + getBaseDir() + "/test.csv', null, 'utf-8', '|')");
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
assertEquals("Hello", rs.getString(2));
assertFalse(rs.next());
new File(baseDir + "/test.csv").delete();
new File(getBaseDir() + "/test.csv").delete();
// PreparedStatement prep = conn.prepareStatement("select * from
// csvread(?, null, ?, ?)");
......@@ -255,29 +256,29 @@ public class TestCsv extends TestBase {
// rs = prep.executeQuery();
conn.close();
IOUtils.delete(baseDir + "/test.csv");
IOUtils.delete(getBaseDir() + "/test.csv");
}
private void testAsTable() throws SQLException {
deleteDb("csv");
Connection conn = getConnection("csv");
Statement stat = conn.createStatement();
stat.execute("call csvwrite('" + baseDir + "/test.csv', 'select 1 id, ''Hello'' name')");
ResultSet rs = stat.executeQuery("select name from csvread('" + baseDir + "/test.csv')");
stat.execute("call csvwrite('" + getBaseDir() + "/test.csv', 'select 1 id, ''Hello'' name')");
ResultSet rs = stat.executeQuery("select name from csvread('" + getBaseDir() + "/test.csv')");
assertTrue(rs.next());
assertEquals("Hello", rs.getString(1));
assertFalse(rs.next());
rs = stat.executeQuery("call csvread('" + baseDir + "/test.csv')");
rs = stat.executeQuery("call csvread('" + getBaseDir() + "/test.csv')");
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
assertEquals("Hello", rs.getString(2));
assertFalse(rs.next());
new File(baseDir + "/test.csv").delete();
new File(getBaseDir() + "/test.csv").delete();
conn.close();
}
private void testRead() throws Exception {
String fileName = baseDir + "/test.csv";
String fileName = getBaseDir() + "/test.csv";
FileSystem fs = FileSystem.getInstance(fileName);
fs.delete(fileName);
FileObject file = fs.openFileObject(fileName, "rw");
......@@ -334,8 +335,8 @@ public class TestCsv extends TestBase {
for (int i = 0; i < len; i++) {
stat.execute("INSERT INTO TEST(NAME) VALUES('Ruebezahl')");
}
Csv.getInstance().write(conn, baseDir + "/testRW.csv", "SELECT * FROM TEST", "UTF8");
ResultSet rs = Csv.getInstance().read(baseDir + "/testRW.csv", null, "UTF8");
Csv.getInstance().write(conn, getBaseDir() + "/testRW.csv", "SELECT * FROM TEST", "UTF8");
ResultSet rs = Csv.getInstance().read(getBaseDir() + "/testRW.csv", null, "UTF8");
// stat.execute("CREATE ALIAS CSVREAD FOR \"org.h2.tools.Csv.read\"");
ResultSetMetaData meta = rs.getMetaData();
assertEquals(2, meta.getColumnCount());
......@@ -347,7 +348,7 @@ public class TestCsv extends TestBase {
assertFalse(rs.next());
rs.close();
conn.close();
IOUtils.delete(baseDir + "/testRW.csv");
IOUtils.delete(getBaseDir() + "/testRW.csv");
}
}
......@@ -70,7 +70,7 @@ public class TestFullText extends TestBase {
}
String prefix = lucene ? "FTL" : "FT";
deleteDb("fullTextTransaction");
FileSystem.getInstance(baseDir).deleteRecursive(baseDir + "/fullTextTransaction", false);
FileSystem.getInstance(getBaseDir()).deleteRecursive(getBaseDir() + "/fullTextTransaction", false);
Connection conn = getConnection("fullTextTransaction");
Statement stat = conn.createStatement();
String className = lucene ? "FullTextLucene" : "FullText";
......@@ -94,6 +94,7 @@ public class TestFullText extends TestBase {
FullText.dropAll(conn);
conn.close();
deleteDb("fullTextTransaction");
FileSystem.getInstance(getBaseDir()).deleteRecursive(getBaseDir() + "/fullTextTransaction", false);
}
private void testMultiThreaded() throws Exception {
......@@ -192,7 +193,7 @@ public class TestFullText extends TestBase {
private void testCreateDrop() throws SQLException {
deleteDb("fullText");
FileSystem.getInstance(baseDir).deleteRecursive(baseDir + "/fullText", false);
FileSystem.getInstance(getBaseDir()).deleteRecursive(getBaseDir() + "/fullText", false);
Connection conn = getConnection("fullText");
Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS IF NOT EXISTS FT_INIT FOR \"org.h2.fulltext.FullText.init\"");
......@@ -203,13 +204,13 @@ public class TestFullText extends TestBase {
}
conn.close();
deleteDb("fullText");
FileSystem.getInstance(baseDir).deleteRecursive(baseDir + "/fullText", false);
FileSystem.getInstance(getBaseDir()).deleteRecursive(getBaseDir() + "/fullText", false);
}
private void testReopen(boolean lucene) throws SQLException {
String prefix = lucene ? "FTL" : "FT";
deleteDb("fullTextReopen");
FileSystem.getInstance(baseDir).deleteRecursive(baseDir + "/fullTextReopen", false);
FileSystem.getInstance(getBaseDir()).deleteRecursive(getBaseDir() + "/fullTextReopen", false);
Connection conn = getConnection("fullTextReopen");
Statement stat = conn.createStatement();
String className = lucene ? "FullTextLucene" : "FullText";
......@@ -235,11 +236,12 @@ public class TestFullText extends TestBase {
stat = conn.createStatement();
stat.execute("INSERT INTO TEST VALUES(3, 'Hello')");
conn.close();
FileSystem.getInstance(getBaseDir()).deleteRecursive(getBaseDir() + "/fullTextReopen", false);
}
private void testPerformance(boolean lucene) throws SQLException {
deleteDb("fullText");
FileSystem.getInstance(baseDir).deleteRecursive(baseDir + "/fullText", false);
FileSystem.getInstance(getBaseDir()).deleteRecursive(getBaseDir() + "/fullText", false);
Connection conn = getConnection("fullText");
String prefix = lucene ? "FTL" : "FT";
Statement stat = conn.createStatement();
......@@ -279,6 +281,9 @@ public class TestFullText extends TestBase {
}
private void test(boolean lucene, String dataType) throws SQLException {
if (lucene && getBaseDir().indexOf(':') > 0) {
return;
}
deleteDb("fullText");
Connection conn = getConnection("fullText");
String prefix = lucene ? "FTL_" : "FT_";
......
......@@ -24,6 +24,7 @@ import java.util.Properties;
import java.util.UUID;
import org.h2.api.AggregateFunction;
import org.h2.store.fs.FileSystem;
import org.h2.test.TestBase;
import org.h2.tools.SimpleResultSet;
import org.h2.util.IOUtils;
......@@ -61,6 +62,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
testFunctions();
testFileRead();
deleteDb("functions");
FileSystem.getInstance(TEMP_DIR).deleteRecursive(TEMP_DIR, false);
}
private void testGreatest() throws SQLException {
......@@ -254,7 +256,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
private void testFileRead() throws Exception {
Connection conn = getConnection("functions");
Statement stat = conn.createStatement();
String fileName = baseDir + "/test.txt";
String fileName = getBaseDir() + "/test.txt";
Properties prop = System.getProperties();
OutputStream out = IOUtils.openFileOutputStream(fileName, false);
prop.store(out, "");
......@@ -273,8 +275,8 @@ public class TestFunctions extends TestBase implements AggregateFunction {
InputStreamReader r = new InputStreamReader(IOUtils.openFileInputStream(fileName));
String ps2 = IOUtils.readStringAndClose(r, -1);
assertEquals(ps, ps2);
IOUtils.delete(fileName);
conn.close();
IOUtils.delete(fileName);
}
/**
......@@ -487,6 +489,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
// without white space
stat.execute("CREATE ALIAS PARSE_INT2 FOR \"java.lang.Integer.parseInt(java.lang.String,int)\"");
stat.execute("DROP ALIAS PARSE_INT2");
conn.close();
}
private void testSchemaSearchPath() throws SQLException {
......
......@@ -609,7 +609,7 @@ public class TestLinkedTable extends TestBase {
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY)");
conn.close();
File[] files = new File(baseDir).listFiles();
File[] files = new File(getBaseDir()).listFiles();
for (File file : files) {
if ((file.getName().startsWith("testLinkedTableInReadOnlyDb")) && (!file.getName().endsWith(".trace.db"))) {
boolean isReadOnly = file.setReadOnly();
......
......@@ -77,6 +77,7 @@ public class TestLob extends TestBase {
testLob(true);
testJavaObject();
deleteDb("lob");
FileSystem.getInstance(TEMP_DIR).deleteRecursive(TEMP_DIR, false);
}
private void testTempFilesDeleted() throws Exception {
......@@ -145,10 +146,10 @@ public class TestLob extends TestBase {
Connection conn = getConnection("lob");
Statement stat = conn.createStatement();
stat.execute("create table test(data clob) as select space(100000) from dual");
assertEquals(1, IOUtils.listFiles(baseDir + "/lob.lobs.db").length);
assertEquals(1, IOUtils.listFiles(getBaseDir() + "/lob.lobs.db").length);
stat.execute("delete from test");
conn.close();
assertEquals(0, IOUtils.listFiles(baseDir + "/lob.lobs.db").length);
assertEquals(0, IOUtils.listFiles(getBaseDir() + "/lob.lobs.db").length);
}
private void testLobServerMemory() throws SQLException {
......@@ -172,18 +173,18 @@ public class TestLob extends TestBase {
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT, DATA CLOB)");
stat.execute("INSERT INTO TEST SELECT X, SPACE(10000) FROM SYSTEM_RANGE(1, 10)");
ArrayList<String> list = FileLister.getDatabaseFiles(baseDir, "lob", true);
ArrayList<String> list = FileLister.getDatabaseFiles(getBaseDir(), "lob", true);
stat.execute("UPDATE TEST SET DATA = SPACE(5000)");
collectAndWait();
stat.execute("CHECKPOINT");
ArrayList<String> list2 = FileLister.getDatabaseFiles(baseDir, "lob", true);
ArrayList<String> list2 = FileLister.getDatabaseFiles(getBaseDir(), "lob", true);
if (list2.size() >= list.size() + 5) {
fail("Expected not many more files, got " + list2.size() + " was " + list.size());
}
stat.execute("DELETE FROM TEST");
collectAndWait();
stat.execute("CHECKPOINT");
ArrayList<String> list3 = FileLister.getDatabaseFiles(baseDir, "lob", true);
ArrayList<String> list3 = FileLister.getDatabaseFiles(getBaseDir(), "lob", true);
if (list3.size() >= list.size()) {
fail("Expected less files, got " + list2.size() + " was " + list.size());
}
......@@ -573,7 +574,7 @@ public class TestLob extends TestBase {
trace("time: " + time + " compress: " + compress);
conn.close();
if (!config.memory && SysProperties.LOB_IN_DATABASE) {
long length = new File(baseDir + "/lob.h2.db").length();
long length = new File(getBaseDir() + "/lob.h2.db").length();
trace("len: " + length + " compress: " + compress);
}
}
......
......@@ -79,6 +79,7 @@ public class TestMultiThreadedKernel extends TestBase {
if (exception != null) {
throw exception;
}
deleteDb("multiThreadedKernel");
}
}
......@@ -70,10 +70,10 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(C CLOB)");
stat.execute("INSERT INTO TEST VALUES(SPACE(10000))");
stat.execute("BACKUP TO '" + baseDir + "/test.zip'");
stat.execute("BACKUP TO '" + getBaseDir() + "/test.zip'");
conn.close();
deleteDb("openClose");
Restore.execute(baseDir + "/test.zip", baseDir, null, true);
Restore.execute(getBaseDir() + "/test.zip", getBaseDir(), null, true);
conn = DriverManager.getConnection(url, "sa", "abc def");
stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
......@@ -81,7 +81,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
assertEquals(10000, rs.getString(1).length());
assertFalse(rs.next());
conn.close();
IOUtils.delete(baseDir + "/test.zip");
IOUtils.delete(getBaseDir() + "/test.zip");
}
private void testReconnectFast() throws SQLException {
......
......@@ -43,7 +43,7 @@ public class TestPowerOff extends TestBase {
return;
}
if (config.big || config.googleAppEngine) {
dir = baseDir;
dir = getBaseDir();
} else {
dir = "memFS:";
}
......
......@@ -15,6 +15,7 @@ import java.sql.Statement;
import java.util.ArrayList;
import org.h2.constant.ErrorCode;
import org.h2.store.FileLister;
import org.h2.store.fs.FileSystem;
import org.h2.test.TestBase;
/**
......@@ -128,10 +129,10 @@ public class TestReadOnly extends TestBase {
}
private void setReadOnly() {
ArrayList<String> list = FileLister.getDatabaseFiles(TestBase.baseDir, "readonly", true);
FileSystem fs = FileSystem.getInstance(getBaseDir());
ArrayList<String> list = FileLister.getDatabaseFiles(getBaseDir(), "readonly", true);
for (String fileName : list) {
File file = new File(fileName);
file.setReadOnly();
fs.setReadOnly(fileName);
}
}
......
......@@ -220,7 +220,7 @@ public class TestRights extends TestBase {
executeSuccess("ALTER USER TEST SET PASSWORD 'def'");
executeSuccess("CREATE USER TEST2 PASSWORD 'def' ADMIN");
executeSuccess("ALTER USER TEST ADMIN FALSE");
executeSuccess("SCRIPT TO '" + baseDir + "/rights.sql' CIPHER XTEA PASSWORD 'test'");
executeSuccess("SCRIPT TO '" + getBaseDir() + "/rights.sql' CIPHER XTEA PASSWORD 'test'");
conn.close();
try {
......@@ -288,7 +288,7 @@ public class TestRights extends TestBase {
conn.close();
conn = getConnection("rights");
conn.close();
IOUtils.delete(baseDir + "/rights.sql");
IOUtils.delete(getBaseDir() + "/rights.sql");
}
private void testTableType(Connection conn, String type) throws SQLException {
......
......@@ -54,14 +54,15 @@ public class TestRunscript extends TestBase implements Trigger {
stat.execute("create table test(id int not null, data clob) as select 1, space(4100)");
// the primary key for SYSTEM_LOB_STREAM used to be named like this
stat.execute("create primary key primary_key_e on test(id)");
stat.execute("script to '" + baseDir + "/backup.sql'");
stat.execute("script to '" + getBaseDir() + "/backup.sql'");
conn.close();
deleteDb("runscript");
conn = getConnection("runscript");
stat = conn.createStatement();
stat.execute("runscript from '" + baseDir + "/backup.sql'");
stat.execute("runscript from '" + getBaseDir() + "/backup.sql'");
conn.close();
deleteDb("runscriptRestore");
IOUtils.delete(getBaseDir() + "/backup.sql");
}
private void test(boolean password) throws SQLException {
......@@ -88,7 +89,7 @@ public class TestRunscript extends TestBase implements Trigger {
stat1.execute("grant select, insert on testSchema.parent to testRole");
stat1.execute("grant testRole to testUser");
String sql = "script to '" + baseDir + "/backup.2.sql'";
String sql = "script to '" + getBaseDir() + "/backup.2.sql'";
if (password) {
sql += " CIPHER AES PASSWORD 't1e2s3t4'";
}
......@@ -97,7 +98,7 @@ public class TestRunscript extends TestBase implements Trigger {
deleteDb("runscriptRestore");
conn2 = getConnection("runscriptRestore");
stat2 = conn2.createStatement();
sql = "runscript from '" + baseDir + "/backup.2.sql'";
sql = "runscript from '" + getBaseDir() + "/backup.2.sql'";
if (password) {
sql += " CIPHER AES PASSWORD 'wrongPassword'";
}
......@@ -109,20 +110,20 @@ public class TestRunscript extends TestBase implements Trigger {
assertKnownException(e);
}
}
sql = "runscript from '" + baseDir + "/backup.2.sql'";
sql = "runscript from '" + getBaseDir() + "/backup.2.sql'";
if (password) {
sql += " CIPHER AES PASSWORD 't1e2s3t4'";
}
stat2.execute(sql);
stat2.execute("script to '" + baseDir + "/backup.3.sql'");
stat2.execute("script to '" + getBaseDir() + "/backup.3.sql'");
assertEqualDatabases(stat1, stat2);
conn1.close();
conn2.close();
deleteDb("runscriptRestore");
IOUtils.delete(baseDir + "/backup.2.sql");
IOUtils.delete(baseDir + "/backup.3.sql");
IOUtils.delete(getBaseDir() + "/backup.2.sql");
IOUtils.delete(getBaseDir() + "/backup.3.sql");
}
......
......@@ -42,7 +42,7 @@ public class TestSpaceReuse extends TestBase {
conn = getConnection("spaceReuse");
conn.createStatement().execute("delete from t");
conn.close();
now = new File(baseDir + "/spaceReuse.data.db").length();
now = new File(getBaseDir() + "/spaceReuse.data.db").length();
if (first == 0) {
first = now;
}
......
......@@ -6,13 +6,13 @@
*/
package org.h2.test.db;
import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.engine.Constants;
import org.h2.test.TestBase;
import org.h2.util.IOUtils;
/**
* Temporary table tests.
......@@ -57,12 +57,12 @@ public class TestTempTables extends TestBase {
} catch (SQLException e) {
// expected
}
String dbName = baseDir + "/tempTables" + Constants.SUFFIX_PAGE_FILE;
long before = new File(dbName).length();
String dbName = getBaseDir() + "/tempTables" + Constants.SUFFIX_PAGE_FILE;
long before = IOUtils.length(dbName);
assertTrue(before > 0);
conn = getConnection("tempTables");
conn.close();
long after = new File(dbName).length();
long after = IOUtils.length(dbName);
assertEquals(after, before);
}
......
......@@ -30,7 +30,7 @@ public class TestCallableStatement extends TestBase {
public void test() throws SQLException {
deleteDb("callableStatement");
Connection conn = getConnection("preparedStatement");
Connection conn = getConnection("callableStatement");
testPrepare(conn);
conn.close();
deleteDb("callableStatement");
......
......@@ -56,7 +56,7 @@ public class TestStatement extends TestBase {
return;
}
Statement stat = conn.createStatement();
String fileName = baseDir + "/statement.trace.db";
String fileName = getBaseDir() + "/statement.trace.db";
stat.execute("DROP TABLE TEST IF EXISTS");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY)");
stat.execute("INSERT INTO TEST VALUES(1)");
......
......@@ -55,7 +55,7 @@ public class TestAutoServer extends TestBase {
int i = ITERATIONS;
for (; i > 0; i--) {
Thread.sleep(100);
SortedProperties prop = SortedProperties.loadProperties(baseDir + "/autoServer.lock.db");
SortedProperties prop = SortedProperties.loadProperties(getBaseDir() + "/autoServer.lock.db");
String key = prop.getProperty("id");
String server = prop.getProperty("server");
if (server != null) {
......@@ -124,7 +124,7 @@ public class TestAutoServer extends TestBase {
// Now test insert
statAutoServer2.execute("INSERT INTO T (ID) VALUES('abc')");
statAutoServer2.execute("drop table t");
connAutoServer2.close();
// this will also close the linked connection from statAutoServer1
......
......@@ -6,8 +6,9 @@
*/
package org.h2.test.server;
import java.io.FileWriter;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
......@@ -30,17 +31,21 @@ public class TestInit extends TestBase {
public void test() throws Exception {
String init1 = getBaseDir() + "/test-init-1.sql";
String init2 = getBaseDir() + "/test-init-2.sql";
// Create two scripts that we will run via "INIT"
IOUtils.createDirs(baseDir + "/test-init-1.sql");
FileWriter fw = new FileWriter(baseDir + "/test-init-1.sql");
IOUtils.createDirs(init1);
Writer w = new OutputStreamWriter(IOUtils.openFileOutputStream(init1, false));
PrintWriter writer = new PrintWriter(fw);
PrintWriter writer = new PrintWriter(w);
writer.println("create table test(id int identity, name varchar);");
writer.println("insert into test(name) values('cat');");
writer.close();
fw = new FileWriter(baseDir + "/test-init-2.sql");
writer = new PrintWriter(fw);
w = new OutputStreamWriter(IOUtils.openFileOutputStream(init2, false));
writer = new PrintWriter(w);
writer.println("insert into test(name) values('dog');");
writer.close();
......@@ -48,8 +53,8 @@ public class TestInit extends TestBase {
deleteDb("initDb");
Connection conn = getConnection("initDb;" +
"INIT=" +
"RUNSCRIPT FROM '" + baseDir + "/test-init-1.sql'\\;" +
"RUNSCRIPT FROM '" + baseDir + "/test-init-2.sql'");
"RUNSCRIPT FROM '" + init1 + "'\\;" +
"RUNSCRIPT FROM '" + init2 + "'");
Statement stat = conn.createStatement();
......@@ -67,8 +72,8 @@ public class TestInit extends TestBase {
conn.close();
deleteDb("initDb");
IOUtils.delete(baseDir + "/test-init-1.sql");
IOUtils.delete(baseDir + "/test-init-2.sql");
IOUtils.delete(init1);
IOUtils.delete(init2);
}
}
......@@ -62,13 +62,11 @@ public class TestBtreeIndex extends TestBase {
} finally {
conn.close();
}
deleteDb("index");
}
public void testCase(int seed) throws SQLException {
String old = baseDir;
baseDir = TestBase.getTestDir("index");
testOne(seed);
baseDir = old;
}
private void testOne(int seed) throws SQLException {
......@@ -96,7 +94,7 @@ public class TestBtreeIndex extends TestBase {
}
}
String prefix = buff.toString().substring(0, prefixLength);
DeleteDbFiles.execute(baseDir, null, true);
DeleteDbFiles.execute(getBaseDir() + "/index", null, true);
Connection conn = getConnection("index");
try {
Statement stat = conn.createStatement();
......@@ -181,6 +179,7 @@ public class TestBtreeIndex extends TestBase {
} finally {
conn.close();
}
deleteDb("index");
}
private void printError(int seed, String message) {
......
......@@ -129,7 +129,7 @@ public class TestCrashAPI extends TestBase {
private void deleteDb() {
try {
deleteDb(baseDir + "/" + DIR, null);
deleteDb(getBaseDir() + "/" + DIR, null);
} catch (Exception e) {
// ignore
}
......@@ -166,7 +166,7 @@ public class TestCrashAPI extends TestBase {
Connection conn = null;
String fileName = "temp/backup/db-" + uniqueId++ + ".zip";
Backup.execute(fileName, baseDir + "/" + DIR, dbName, true);
Backup.execute(fileName, getBaseDir() + "/" + DIR, dbName, true);
// close databases earlier
System.gc();
try {
......@@ -470,7 +470,6 @@ public class TestCrashAPI extends TestBase {
if (config.mvcc || config.networked) {
return this;
}
baseDir = TestBase.getTestDir("crash");
startServerIfRequired();
TestScript script = new TestScript();
ArrayList<String> add = script.getAllStatements(config);
......@@ -482,13 +481,10 @@ public class TestCrashAPI extends TestBase {
public void testCase(int i) throws SQLException {
int old = SysProperties.getMaxQueryTimeout();
String oldBaseDir = baseDir;
try {
System.setProperty(SysProperties.H2_MAX_QUERY_TIMEOUT, "" + 10000);
baseDir = TestBase.getTestDir("crash");
testOne(i);
} finally {
baseDir = oldBaseDir;
System.setProperty(SysProperties.H2_MAX_QUERY_TIMEOUT, "" + old);
}
}
......
......@@ -62,11 +62,6 @@ public abstract class TestHalt extends TestBase {
*/
protected static final int FLAG_LOBS = 2;
/**
* The test directory.
*/
static final String DIR = TestBase.getTestDir("halt");
private static final String DATABASE_NAME = "halt";
private static final String TRACE_FILE_NAME = "haltTrace.trace.db";
......@@ -140,7 +135,7 @@ public abstract class TestHalt extends TestBase {
Connection getConnection() throws SQLException {
org.h2.Driver.load();
String url = "jdbc:h2:" + baseDir + "/halt";
String url = "jdbc:h2:" + getBaseDir() + "/halt";
// String url = "jdbc:h2:" + baseDir + "/halt;TRACE_LEVEL_FILE=3";
return DriverManager.getConnection(url, "sa", "sa");
}
......@@ -193,7 +188,7 @@ public abstract class TestHalt extends TestBase {
protected void traceOperation(String s, Exception e) {
FileWriter writer = null;
try {
File f = new File(baseDir + "/" + TRACE_FILE_NAME);
File f = new File(getBaseDir() + "/" + TRACE_FILE_NAME);
f.getParentFile().mkdirs();
writer = new FileWriter(f, true);
PrintWriter w = new PrintWriter(writer);
......@@ -215,15 +210,15 @@ public abstract class TestHalt extends TestBase {
*/
void controllerTest() throws Exception {
traceOperation("delete database -----------------------------");
DeleteDbFiles.execute(baseDir, DATABASE_NAME, true);
new File(baseDir + "/" + TRACE_FILE_NAME).delete();
DeleteDbFiles.execute(getBaseDir(), DATABASE_NAME, true);
new File(getBaseDir() + "/" + TRACE_FILE_NAME).delete();
connect();
controllerInit();
disconnect();
for (int i = 0; i < 10; i++) {
traceOperation("backing up " + sequenceId);
Backup.execute(baseDir + "/haltSeq" + sequenceId + ".zip", baseDir, null, true);
Backup.execute(getBaseDir() + "/haltSeq" + sequenceId + ".zip", getBaseDir(), null, true);
sequenceId++;
// int operations = OP_INSERT;
// OP_DELETE = 1, OP_UPDATE = 2, OP_SELECT = 4;
......@@ -253,14 +248,14 @@ public abstract class TestHalt extends TestBase {
p.waitFor();
try {
traceOperation("backing up " + sequenceId);
Backup.execute(baseDir + "/haltSeq" + sequenceId + ".zip", baseDir, null, true);
Backup.execute(getBaseDir() + "/haltSeq" + sequenceId + ".zip", getBaseDir(), null, true);
// new File(BASE_DIR + "/haltSeq" + (sequenceId-20) +
// ".zip").delete();
connect();
controllerCheckAfterCrash();
} catch (Exception e) {
File zip = new File(baseDir + "/haltSeq" + sequenceId + ".zip");
File zipId = new File(baseDir + "/haltSeq" + sequenceId + "-" + errorId + ".zip");
File zip = new File(getBaseDir() + "/haltSeq" + sequenceId + ".zip");
File zipId = new File(getBaseDir() + "/haltSeq" + sequenceId + "-" + errorId + ".zip");
zip.renameTo(zipId);
printTime("ERROR: " + sequenceId + " " + errorId + " " + e.toString());
e.printStackTrace();
......@@ -350,7 +345,6 @@ public abstract class TestHalt extends TestBase {
public TestBase init(TestAll conf) throws Exception {
super.init(conf);
baseDir = DIR;
return this;
}
......
......@@ -28,7 +28,6 @@ public class TestHaltApp extends TestHalt {
*/
public static void main(String... args) throws Exception {
SelfDestructor.startCountdown(60);
baseDir = TestHalt.DIR;
TestHaltApp app = new TestHaltApp();
if (args.length == 0) {
app.controllerTest();
......
......@@ -42,10 +42,7 @@ public class TestJoin extends TestBase {
}
public void test() throws Exception {
String old = baseDir;
baseDir = TestBase.getTestDir("join");
testJoin();
baseDir = old;
}
private void testJoin() throws Exception {
......
......@@ -51,7 +51,7 @@ public class TestKill extends TestBase {
"java", selfDestruct,
"-cp", getClassPath(),
"org.h2.test.synth.TestKillProcess", url, user,
password, baseDir, "" + accounts };
password, getBaseDir(), "" + accounts };
for (int i = 0;; i++) {
printTime("TestKill " + i);
......
......@@ -26,6 +26,9 @@ public class TestKillRestart extends TestBase {
if (config.networked) {
return;
}
if (getBaseDir().indexOf(':') > 0) {
return;
}
deleteDb("killRestart");
String url = getURL("killRestart", true);
// String url = getURL(
......
......@@ -40,6 +40,9 @@ public class TestKillRestartMulti extends TestBase {
if (config.networked) {
return;
}
if (getBaseDir().indexOf(':') > 0) {
return;
}
deleteDb("killRestartMulti");
url = getURL("killRestartMulti", true);
user = getUser();
......@@ -86,9 +89,9 @@ public class TestKillRestartMulti extends TestBase {
fail("Failed: " + s);
}
}
String backup = baseDir + "/killRestartMulti-" + System.currentTimeMillis() + ".zip";
String backup = getBaseDir() + "/killRestartMulti-" + System.currentTimeMillis() + ".zip";
try {
Backup.execute(backup, baseDir, "killRestartMulti", true);
Backup.execute(backup, getBaseDir(), "killRestartMulti", true);
Connection conn = null;
for (int j = 0;; j++) {
try {
......
......@@ -13,14 +13,14 @@ import java.sql.Statement;
import org.h2.constant.ErrorCode;
import org.h2.store.fs.FileSystem;
import org.h2.test.TestBase;
import org.h2.test.utils.FileSystemDebug;
import org.h2.test.utils.DebugFileSystem;
/**
* Tests that use the debug file system to simulate power failure.
*/
public class TestPowerOffFs extends TestBase {
private FileSystemDebug fs;
private DebugFileSystem fs;
/**
* Run just this test.
......@@ -32,8 +32,8 @@ public class TestPowerOffFs extends TestBase {
}
public void test() throws Exception {
FileSystemDebug.register();
fs = (FileSystemDebug) FileSystem.getInstance("debug:/");
DebugFileSystem.register();
fs = (DebugFileSystem) FileSystem.getInstance("debug:/");
test(Integer.MAX_VALUE);
System.out.println(Integer.MAX_VALUE - fs.getPowerOffCount());
System.out.println("done");
......
......@@ -16,7 +16,7 @@ import java.util.Random;
import org.h2.constant.ErrorCode;
import org.h2.store.fs.FileSystem;
import org.h2.test.TestBase;
import org.h2.test.utils.FileSystemDebug;
import org.h2.test.utils.DebugFileSystem;
import org.h2.util.New;
/**
......@@ -25,7 +25,7 @@ import org.h2.util.New;
*/
public class TestPowerOffFs2 extends TestBase {
private FileSystemDebug fs;
private DebugFileSystem fs;
private String url;
private String user = "sa";
......@@ -44,9 +44,9 @@ public class TestPowerOffFs2 extends TestBase {
}
public void test() throws Exception {
FileSystemDebug.register();
DebugFileSystem.register();
url = "jdbc:h2:debug:memFS:powerOffFs;FILE_LOCK=NO;TRACE_LEVEL_FILE=0;WRITE_DELAY=0;CACHE_SIZE=32";
fs = (FileSystemDebug) FileSystem.getInstance("debug:/");
fs = (DebugFileSystem) FileSystem.getInstance("debug:/");
for (int i = 0;; i++) {
test(i);
}
......
......@@ -14,6 +14,7 @@ import org.h2.store.fs.FileSystemMemory;
import org.h2.test.TestAll;
import org.h2.test.TestBase;
import org.h2.tools.DeleteDbFiles;
import org.h2.util.IOUtils;
import org.h2.util.MathUtils;
/**
......@@ -57,7 +58,8 @@ public class TestRandomSQL extends TestBase {
if (name.startsWith(FileSystemMemory.PREFIX)) {
DeleteDbFiles.execute("memFS:/", name, true);
} else {
DeleteDbFiles.execute(baseDir + "/dataRandomSQL", null, true);
DeleteDbFiles.execute(getBaseDir() + "/dataRandomSQL", null, true);
IOUtils.delete(getBaseDir() + "/dataRandomSQL");
}
}
......
......@@ -35,7 +35,7 @@ public class TestTimer extends TestBase {
public void test() throws SQLException {
validateOld();
DeleteDbFiles.execute(baseDir, "timer", true);
DeleteDbFiles.execute(getBaseDir(), "timer", true);
loop();
}
......@@ -132,7 +132,7 @@ public class TestTimer extends TestBase {
continue;
}
try {
Backup.execute(s, baseDir, "timer", true);
Backup.execute(s, getBaseDir(), "timer", true);
} catch (SQLException e) {
logError("backup", e);
}
......
......@@ -46,7 +46,6 @@ public class TestSynth extends TestBase {
* A PostgreSQL database connection.
*/
static final int POSTGRESQL = 4;
private static final String DIR = "synth";
private DbState dbState = new DbState(this);
private ArrayList<DbInterface> databases;
......@@ -274,9 +273,7 @@ public class TestSynth extends TestBase {
public TestBase init(TestAll conf) throws Exception {
super.init(conf);
String old = baseDir;
baseDir = TestBase.getTestDir("synth");
deleteDb("synth");
deleteDb("synth/synth");
databases = New.arrayList();
// mode = HSQLDB;
......@@ -292,7 +289,7 @@ public class TestSynth extends TestBase {
mode = H2_MEM;
org.h2.Driver.load();
addDatabase("org.h2.Driver", "jdbc:h2:mem:synth", "sa", "", true);
addDatabase("org.h2.Driver", "jdbc:h2:" + baseDir + "/" + DIR + "/synth", "sa", "", false);
addDatabase("org.h2.Driver", "jdbc:h2:" + getBaseDir() + "/synth/synth", "sa", "", false);
// addDatabase("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test",
// "sa", "");
......@@ -319,14 +316,11 @@ public class TestSynth extends TestBase {
// original (0):
// System.exit(0);
baseDir = old;
return this;
}
public void testCase(int seed) throws Exception {
String old = baseDir;
baseDir = TestBase.getTestDir("synth");
deleteDb(baseDir, DIR + "/synth");
deleteDb("synth/synth");
try {
printTime("TestSynth " + seed);
testRun(seed);
......@@ -334,7 +328,6 @@ public class TestSynth extends TestBase {
TestBase.logError("error", e);
System.exit(0);
}
baseDir = old;
}
public void test() throws Exception {
......
......@@ -54,7 +54,7 @@ public class TestMulti extends TestBase {
}
Connection getConnection() throws SQLException {
final String url = "jdbc:h2:" + baseDir + "/openClose;LOCK_MODE=3;DB_CLOSE_DELAY=-1";
final String url = "jdbc:h2:" + getBaseDir() + "/openClose;LOCK_MODE=3;DB_CLOSE_DELAY=-1";
Connection conn = DriverManager.getConnection(url, "sa", "");
return conn;
}
......
......@@ -22,10 +22,11 @@
package org.h2.test.trace;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.HashMap;
import org.h2.util.IOUtils;
import org.h2.util.New;
/**
......@@ -101,7 +102,7 @@ public class Player {
private void runFile(String fileName) throws IOException {
LineNumberReader reader = new LineNumberReader(new BufferedReader(
new FileReader(fileName)));
new InputStreamReader(IOUtils.openFileInputStream(fileName))));
while (true) {
String line = reader.readLine();
if (line == null) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论