提交 03fc1e6f authored 作者: Thomas Mueller's avatar Thomas Mueller

Allow to run most tests in parallel (not enabled right now)

上级 f6397d84
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
*/ */
package org.h2.test; package org.h2.test;
import java.lang.management.ManagementFactory;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
import org.h2.Driver; import org.h2.Driver;
import org.h2.engine.Constants; import org.h2.engine.Constants;
...@@ -168,6 +170,7 @@ import org.h2.test.unit.TestIntArray; ...@@ -168,6 +170,7 @@ import org.h2.test.unit.TestIntArray;
import org.h2.test.unit.TestIntIntHashMap; import org.h2.test.unit.TestIntIntHashMap;
import org.h2.test.unit.TestJmx; import org.h2.test.unit.TestJmx;
import org.h2.test.unit.TestIntPerfectHash; import org.h2.test.unit.TestIntPerfectHash;
import org.h2.test.unit.TestLocale;
import org.h2.test.unit.TestMathUtils; import org.h2.test.unit.TestMathUtils;
import org.h2.test.unit.TestModifyOnWrite; import org.h2.test.unit.TestModifyOnWrite;
import org.h2.test.unit.TestNetUtils; import org.h2.test.unit.TestNetUtils;
...@@ -201,8 +204,10 @@ import org.h2.test.utils.SelfDestructor; ...@@ -201,8 +204,10 @@ import org.h2.test.utils.SelfDestructor;
import org.h2.tools.DeleteDbFiles; import org.h2.tools.DeleteDbFiles;
import org.h2.tools.Server; import org.h2.tools.Server;
import org.h2.util.AbbaLockingDetector; import org.h2.util.AbbaLockingDetector;
import org.h2.util.New;
import org.h2.util.Profiler; import org.h2.util.Profiler;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Task;
import org.h2.util.Utils; import org.h2.util.Utils;
/** /**
...@@ -340,6 +345,11 @@ java org.h2.test.TestAll timer ...@@ -340,6 +345,11 @@ java org.h2.test.TestAll timer
*/ */
boolean endless; boolean endless;
/**
* If only fast tests should be run. If enabled, SSL is not tested.
*/
public boolean fast;
/** /**
* The THROTTLE value to use. * The THROTTLE value to use.
*/ */
...@@ -372,7 +382,7 @@ java org.h2.test.TestAll timer ...@@ -372,7 +382,7 @@ java org.h2.test.TestAll timer
private Server server; private Server server;
private boolean fast; ArrayList<TestBase> tests = New.arrayList();
/** /**
* Run all tests. * Run all tests.
...@@ -625,213 +635,262 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -625,213 +635,262 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
beforeTest(); beforeTest();
// db // db
new TestScriptSimple().runTest(this); addTest(new TestScriptSimple());
new TestScript().runTest(this); addTest(new TestScript());
new TestAlter().runTest(this); addTest(new TestAlter());
new TestAlterSchemaRename().runTest(this); addTest(new TestAlterSchemaRename());
new TestAutoRecompile().runTest(this); addTest(new TestAutoRecompile());
new TestBitField().runTest(this); addTest(new TestBackup());
new TestBackup().runTest(this); addTest(new TestBigDb());
new TestBigDb().runTest(this); addTest(new TestBigResult());
new TestBigResult().runTest(this); addTest(new TestCases());
new TestCases().runTest(this); addTest(new TestCheckpoint());
new TestCheckpoint().runTest(this); addTest(new TestCompatibility());
new TestCluster().runTest(this); addTest(new TestCompatibilityOracle());
new TestCompatibility().runTest(this); addTest(new TestCsv());
new TestCompatibilityOracle().runTest(this); addTest(new TestDeadlock());
new TestCsv().runTest(this); addTest(new TestDrop());
new TestDateStorage().runTest(this); addTest(new TestDuplicateKeyUpdate());
new TestDeadlock().runTest(this); addTest(new TestEncryptedDb());
new TestDrop().runTest(this); addTest(new TestExclusive());
new TestDuplicateKeyUpdate().runTest(this); addTest(new TestFullText());
new TestEncryptedDb().runTest(this); addTest(new TestFunctionOverload());
new TestExclusive().runTest(this); addTest(new TestFunctions());
new TestFullText().runTest(this); addTest(new TestInit());
new TestFunctionOverload().runTest(this); addTest(new TestIndex());
new TestFunctions().runTest(this); addTest(new TestLargeBlob());
new TestInit().runTest(this); addTest(new TestLinkedTable());
new TestIndex().runTest(this); addTest(new TestListener());
new TestLargeBlob().runTest(this); addTest(new TestLob());
new TestLinkedTable().runTest(this); addTest(new TestMultiConn());
new TestListener().runTest(this); addTest(new TestMultiDimension());
new TestLob().runTest(this); addTest(new TestMultiThreadedKernel());
new TestMemoryUsage().runTest(this); addTest(new TestOpenClose());
new TestMultiConn().runTest(this); addTest(new TestOptimizations());
new TestMultiDimension().runTest(this); addTest(new TestOutOfMemory());
new TestMultiThread().runTest(this); addTest(new TestReadOnly());
new TestMultiThreadedKernel().runTest(this); addTest(new TestRecursiveQueries());
new TestOpenClose().runTest(this); addTest(new TestRights());
new TestOptimizations().runTest(this); addTest(new TestRunscript());
new TestOutOfMemory().runTest(this); addTest(new TestSQLInjection());
new TestPowerOff().runTest(this); addTest(new TestSessionsLocks());
new TestQueryCache().runTest(this); addTest(new TestSelectCountNonNullColumn());
new TestReadOnly().runTest(this); addTest(new TestSequence());
new TestRecursiveQueries().runTest(this); addTest(new TestShow());
new TestRights().runTest(this); addTest(new TestSpaceReuse());
new TestRunscript().runTest(this); addTest(new TestSpatial());
new TestSQLInjection().runTest(this); addTest(new TestSpeed());
new TestSessionsLocks().runTest(this); addTest(new TestTableEngines());
new TestSelectCountNonNullColumn().runTest(this); addTest(new TestTempTables());
new TestSequence().runTest(this); addTest(new TestTransaction());
new TestShow().runTest(this); addTest(new TestTriggersConstraints());
new TestSpaceReuse().runTest(this); addTest(new TestTwoPhaseCommit());
new TestSpatial().runTest(this); addTest(new TestView());
new TestSpeed().runTest(this); addTest(new TestViewAlterTable());
new TestTableEngines().runTest(this); addTest(new TestViewDropView());
new TestTempTables().runTest(this);
new TestTransaction().runTest(this);
new TestTriggersConstraints().runTest(this);
new TestTwoPhaseCommit().runTest(this);
new TestView().runTest(this);
new TestViewAlterTable().runTest(this);
new TestViewDropView().runTest(this);
// jaqu // jaqu
new AliasMapTest().runTest(this); addTest(new AliasMapTest());
new AnnotationsTest().runTest(this); addTest(new AnnotationsTest());
new ClobTest().runTest(this); addTest(new ClobTest());
new ModelsTest().runTest(this); addTest(new ModelsTest());
new SamplesTest().runTest(this); addTest(new SamplesTest());
new UpdateTest().runTest(this); addTest(new UpdateTest());
// jdbc // jdbc
new TestBatchUpdates().runTest(this); addTest(new TestBatchUpdates());
new TestCallableStatement().runTest(this); addTest(new TestCallableStatement());
new TestCancel().runTest(this); addTest(new TestCancel());
new TestDatabaseEventListener().runTest(this); addTest(new TestDatabaseEventListener());
new TestDriver().runTest(this); addTest(new TestJavaObject());
new TestJavaObject().runTest(this); addTest(new TestLimitUpdates());
new TestJavaObjectSerializer().runTest(this); addTest(new TestLobApi());
new TestUrlJavaObjectSerializer().runTest(this); addTest(new TestManyJdbcObjects());
new TestLimitUpdates().runTest(this); addTest(new TestMetaData());
new TestLobApi().runTest(this); addTest(new TestNativeSQL());
new TestManyJdbcObjects().runTest(this); addTest(new TestPreparedStatement());
new TestMetaData().runTest(this); addTest(new TestResultSet());
new TestNativeSQL().runTest(this); addTest(new TestStatement());
new TestPreparedStatement().runTest(this); addTest(new TestTransactionIsolation());
new TestResultSet().runTest(this); addTest(new TestUpdatableResultSet());
new TestStatement().runTest(this); addTest(new TestZloty());
new TestTransactionIsolation().runTest(this);
new TestUpdatableResultSet().runTest(this);
new TestZloty().runTest(this);
// jdbcx // jdbcx
new TestConnectionPool().runTest(this); addTest(new TestConnectionPool());
new TestDataSource().runTest(this); addTest(new TestDataSource());
new TestXA().runTest(this); addTest(new TestXA());
new TestXASimple().runTest(this); addTest(new TestXASimple());
// server // server
new TestAutoServer().runTest(this); addTest(new TestAutoServer());
new TestNestedLoop().runTest(this); addTest(new TestNestedLoop());
new TestWeb().runTest(this);
// mvcc & row level locking // mvcc & row level locking
new TestMvcc1().runTest(this); addTest(new TestMvcc1());
new TestMvcc2().runTest(this); addTest(new TestMvcc2());
new TestMvcc3().runTest(this); addTest(new TestMvcc3());
new TestMvccMultiThreaded().runTest(this); addTest(new TestMvccMultiThreaded());
new TestRowLocks().runTest(this); addTest(new TestRowLocks());
// synth // synth
new TestBtreeIndex().runTest(this); addTest(new TestBtreeIndex());
new TestConcurrentUpdate().runTest(this); addTest(new TestConcurrentUpdate());
new TestDiskFull().runTest(this); addTest(new TestDiskFull());
new TestCrashAPI().runTest(this); addTest(new TestCrashAPI());
new TestFuzzOptimizations().runTest(this); addTest(new TestFuzzOptimizations());
new TestLimit().runTest(this); addTest(new TestLimit());
new TestRandomSQL().runTest(this); addTest(new TestRandomCompare());
new TestRandomCompare().runTest(this); addTest(new TestKillRestart());
new TestKillRestart().runTest(this); addTest(new TestKillRestartMulti());
new TestKillRestartMulti().runTest(this); addTest(new TestMultiThreaded());
new TestMultiThreaded().runTest(this); addTest(new TestOuterJoins());
new TestOuterJoins().runTest(this); addTest(new TestNestedJoins());
new TestNestedJoins().runTest(this);
runAddedTests();
// serial
addTest(new TestDateStorage());
addTest(new TestDriver());
addTest(new TestJavaObjectSerializer());
addTest(new TestLocale());
addTest(new TestMemoryUsage());
addTest(new TestMultiThread());
addTest(new TestPowerOff());
addTest(new TestRandomSQL());
addTest(new TestQueryCache());
addTest(new TestUrlJavaObjectSerializer());
addTest(new TestWeb());
runAddedTests(1);
afterTest(); afterTest();
} }
private void testUnit() { private void testUnit() {
// mv store // mv store
new TestCacheConcurrentLIRS().runTest(this); addTest(new TestCacheConcurrentLIRS());
new TestCacheLIRS().runTest(this); addTest(new TestCacheLIRS());
new TestCacheLongKeyLIRS().runTest(this); addTest(new TestCacheLongKeyLIRS());
new TestConcurrent().runTest(this); addTest(new TestConcurrentLinkedList());
new TestConcurrentLinkedList().runTest(this); addTest(new TestDataUtils());
new TestDataUtils().runTest(this); addTest(new TestFreeSpace());
new TestFreeSpace().runTest(this); addTest(new TestKillProcessWhileWriting());
new TestKillProcessWhileWriting().runTest(this); addTest(new TestMVRTree());
new TestMVRTree().runTest(this); addTest(new TestMVStore());
new TestMVStore().runTest(this); addTest(new TestMVStoreBenchmark());
new TestMVStoreBenchmark().runTest(this); addTest(new TestMVStoreTool());
new TestMVStoreTool().runTest(this); addTest(new TestMVTableEngine());
new TestMVTableEngine().runTest(this); addTest(new TestObjectDataType());
new TestObjectDataType().runTest(this); addTest(new TestRandomMapOps());
new TestRandomMapOps().runTest(this); addTest(new TestSpinLock());
new TestSpinLock().runTest(this); addTest(new TestStreamStore());
new TestStreamStore().runTest(this); addTest(new TestTransactionStore());
new TestTransactionStore().runTest(this);
// unit // unit
new TestAutoReconnect().runTest(this); addTest(new TestAutoReconnect());
new TestBnf().runTest(this); addTest(new TestBitField());
new TestCache().runTest(this); addTest(new TestBnf());
new TestClearReferences().runTest(this); addTest(new TestCache());
new TestCollation().runTest(this); addTest(new TestClearReferences());
new TestCompress().runTest(this); addTest(new TestCollation());
new TestConnectionInfo().runTest(this); addTest(new TestCompress());
new TestDataPage().runTest(this); addTest(new TestConnectionInfo());
new TestDate().runTest(this); addTest(new TestDataPage());
new TestDateIso8601().runTest(this); addTest(new TestDateIso8601());
new TestExit().runTest(this); addTest(new TestExit());
new TestFile().runTest(this); addTest(new TestFile());
new TestFileLock().runTest(this); addTest(new TestFileLock());
new TestFileLockProcess().runTest(this); addTest(new TestFtp());
new TestFileLockSerialized().runTest(this); addTest(new TestIntArray());
new TestFtp().runTest(this); addTest(new TestIntIntHashMap());
new TestFileSystem().runTest(this); addTest(new TestIntPerfectHash());
new TestIntArray().runTest(this); addTest(new TestJmx());
new TestIntIntHashMap().runTest(this); addTest(new TestMathUtils());
new TestIntPerfectHash().runTest(this); addTest(new TestModifyOnWrite());
new TestJmx().runTest(this); addTest(new TestOldVersion());
new TestMathUtils().runTest(this); addTest(new TestObjectDeserialization());
new TestModifyOnWrite().runTest(this); addTest(new TestMultiThreadedKernel());
new TestOldVersion().runTest(this); addTest(new TestOverflow());
new TestNetUtils().runTest(this); addTest(new TestPageStore());
new TestObjectDeserialization().runTest(this); addTest(new TestPageStoreCoverage());
new TestMultiThreadedKernel().runTest(this); addTest(new TestPerfectHash());
new TestOverflow().runTest(this); addTest(new TestPgServer());
new TestPageStore().runTest(this); addTest(new TestReader());
new TestPageStoreCoverage().runTest(this); addTest(new TestRecovery());
new TestPattern().runTest(this); addTest(new TestScriptReader());
new TestPerfectHash().runTest(this); addTest(createTest("org.h2.test.unit.TestServlet"));
new TestPgServer().runTest(this); addTest(new TestSecurity());
new TestReader().runTest(this); addTest(new TestShell());
new TestRecovery().runTest(this); addTest(new TestSort());
new TestSampleApps().runTest(this); addTest(new TestStreams());
new TestScriptReader().runTest(this); addTest(new TestStringUtils());
runTest("org.h2.test.unit.TestServlet"); addTest(new TestTraceSystem());
new TestSecurity().runTest(this); addTest(new TestUpgrade());
new TestShell().runTest(this); addTest(new TestUtils());
new TestSort().runTest(this); addTest(new TestValue());
new TestStreams().runTest(this); addTest(new TestValueHashMap());
new TestStringCache().runTest(this); addTest(new TestWeb());
new TestStringUtils().runTest(this);
new TestTools().runTest(this); runAddedTests();
new TestTraceSystem().runTest(this);
new TestUpgrade().runTest(this); // serial
new TestUtils().runTest(this); addTest(new TestDate());
new TestValue().runTest(this); addTest(new TestCluster());
new TestValueHashMap().runTest(this); addTest(new TestConcurrent());
new TestValueMemory().runTest(this); addTest(new TestFileLockSerialized());
new TestWeb().runTest(this); addTest(new TestFileLockProcess());
} addTest(new TestFileSystem());
addTest(new TestNetUtils());
private void runTest(String className) { addTest(new TestPattern());
addTest(new TestTools());
addTest(new TestSampleApps());
addTest(new TestStringCache());
addTest(new TestValueMemory());
runAddedTests(1);
}
private void addTest(TestBase test) {
tests.add(test);
}
private void runAddedTests() {
int threadCount = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors();
threadCount = 1;
runAddedTests(threadCount);
}
private void runAddedTests(int threadCount) {
Task[] tasks = new Task[threadCount];
for (int i=0; i<threadCount;i++) {
Task t = new Task() {
@Override
public void call() throws Exception {
while (true) {
TestBase test;
synchronized (tests) {
if (tests.isEmpty()) {
break;
}
test = tests.remove(0);
}
test.runTest(TestAll.this);
}
}
};
t.execute();
tasks[i] = t;
}
for(Task t : tasks) {
t.get();
}
}
private static TestBase createTest(String className) {
try { try {
Class<?> clazz = Class.forName(className); Class<?> clazz = Class.forName(className);
TestBase test = (TestBase) clazz.newInstance(); return (TestBase) clazz.newInstance();
test.runTest(this);
} catch (Exception e) { } catch (Exception e) {
// ignore // ignore
TestBase.printlnWithTime(0, className + " class not found"); TestBase.printlnWithTime(0, className + " class not found");
...@@ -839,6 +898,14 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -839,6 +898,14 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
// ignore // ignore
TestBase.printlnWithTime(0, className + " class not found"); TestBase.printlnWithTime(0, className + " class not found");
} }
return new TestBase() {
@Override
public void test() throws Exception {
// ignore
}
};
} }
/** /**
...@@ -868,10 +935,10 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -868,10 +935,10 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
* Stop the server if it was started. * Stop the server if it was started.
*/ */
public void afterTest() { public void afterTest() {
FileUtils.deleteRecursive("trace.db", true);
if (networked && server != null) { if (networked && server != null) {
server.stop(); server.stop();
} }
FileUtils.deleteRecursive("trace.db", true);
FileUtils.deleteRecursive(TestBase.BASE_TEST_DIR, true); FileUtils.deleteRecursive(TestBase.BASE_TEST_DIR, true);
} }
......
...@@ -18,6 +18,8 @@ import java.lang.reflect.InvocationTargetException; ...@@ -18,6 +18,8 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.ResultSet; import java.sql.ResultSet;
...@@ -32,8 +34,7 @@ import java.util.LinkedList; ...@@ -32,8 +34,7 @@ import java.util.LinkedList;
import java.util.SimpleTimeZone; import java.util.SimpleTimeZone;
import org.h2.jdbc.JdbcConnection; import org.h2.jdbc.JdbcConnection;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.message.TraceSystem; import org.h2.store.fs.FilePath;
import org.h2.store.FileLock;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.test.utils.ProxyCodeGenerator; import org.h2.test.utils.ProxyCodeGenerator;
import org.h2.test.utils.ResultVerifier; import org.h2.test.utils.ResultVerifier;
...@@ -52,7 +53,7 @@ public abstract class TestBase { ...@@ -52,7 +53,7 @@ public abstract class TestBase {
/** /**
* The temporary directory. * The temporary directory.
*/ */
protected static final String TEMP_DIR = "./data/temp"; private static final String TEMP_DIR = "./data/temp";
/** /**
* An id used to create unique file names. * An id used to create unique file names.
...@@ -115,6 +116,7 @@ public abstract class TestBase { ...@@ -115,6 +116,7 @@ public abstract class TestBase {
*/ */
public TestBase init(TestAll conf) throws Exception { public TestBase init(TestAll conf) throws Exception {
baseDir = getTestDir(""); baseDir = getTestDir("");
FileUtils.createDirectories(baseDir);
System.setProperty("java.io.tmpdir", TEMP_DIR); System.setProperty("java.io.tmpdir", TEMP_DIR);
this.config = conf; this.config = conf;
return this; return this;
...@@ -154,15 +156,6 @@ public abstract class TestBase { ...@@ -154,15 +156,6 @@ public abstract class TestBase {
if (e instanceof OutOfMemoryError) { if (e instanceof OutOfMemoryError) {
throw (OutOfMemoryError) e; throw (OutOfMemoryError) e;
} }
} finally {
try {
FileUtils.deleteRecursive("memFS:", false);
FileUtils.deleteRecursive("nioMemFS:", false);
FileUtils.deleteRecursive("memLZF:", false);
FileUtils.deleteRecursive("nioMemLZF:", false);
} catch (RuntimeException e) {
e.printStackTrace();
}
} }
} }
...@@ -473,19 +466,32 @@ public abstract class TestBase { ...@@ -473,19 +466,32 @@ public abstract class TestBase {
System.err.println("ERROR: " + s + " " + e.toString() System.err.println("ERROR: " + s + " " + e.toString()
+ " ------------------------------"); + " ------------------------------");
e.printStackTrace(); e.printStackTrace();
// synchronize on this class, because file locks are only visible to
// other JVMs
synchronized (TestBase.class) {
try { try {
TraceSystem ts = new TraceSystem(null); // lock
FileLock lock = new FileLock(ts, "error.lock", 1000); FileChannel fc = FilePath.get("error.lock").open("rw");
lock.lock(FileLock.LOCK_FILE); FileLock lock;
while (true) {
lock = fc.tryLock();
if (lock != null) {
break;
}
Thread.sleep(10);
}
// append
FileWriter fw = new FileWriter("error.txt", true); FileWriter fw = new FileWriter("error.txt", true);
PrintWriter pw = new PrintWriter(fw); PrintWriter pw = new PrintWriter(fw);
e.printStackTrace(pw); e.printStackTrace(pw);
pw.close(); pw.close();
fw.close(); fw.close();
lock.unlock(); // unlock
lock.release();
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
} }
}
System.err.flush(); System.err.flush();
} }
...@@ -509,7 +515,7 @@ public abstract class TestBase { ...@@ -509,7 +515,7 @@ public abstract class TestBase {
* @param millis the time in milliseconds * @param millis the time in milliseconds
* @param s the message * @param s the message
*/ */
static void printlnWithTime(long millis, String s) { static synchronized void printlnWithTime(long millis, String s) {
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
s = dateFormat.format(new java.util.Date()) + " " + s = dateFormat.format(new java.util.Date()) + " " +
formatTime(millis) + " " + s; formatTime(millis) + " " + s;
...@@ -1578,4 +1584,8 @@ public abstract class TestBase { ...@@ -1578,4 +1584,8 @@ public abstract class TestBase {
throw (E) e; throw (E) e;
} }
protected String getTestName() {
return getClass().getSimpleName();
}
} }
...@@ -33,8 +33,8 @@ public class TestAlter extends TestBase { ...@@ -33,8 +33,8 @@ public class TestAlter extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
deleteDb("alter"); deleteDb(getTestName());
conn = getConnection("alter"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
testAlterTableAlterColumnAsSelfColumn(); testAlterTableAlterColumnAsSelfColumn();
testAlterTableDropColumnWithReferences(); testAlterTableDropColumnWithReferences();
...@@ -49,7 +49,7 @@ public class TestAlter extends TestBase { ...@@ -49,7 +49,7 @@ public class TestAlter extends TestBase {
testAlterTableAddColumnAfter(); testAlterTableAddColumnAfter();
testAlterTableModifyColumn(); testAlterTableModifyColumn();
conn.close(); conn.close();
deleteDb("alter"); deleteDb(getTestName());
} }
private void testAlterTableAlterColumnAsSelfColumn() throws SQLException { private void testAlterTableAlterColumnAsSelfColumn() throws SQLException {
...@@ -121,7 +121,7 @@ public class TestAlter extends TestBase { ...@@ -121,7 +121,7 @@ public class TestAlter extends TestBase {
stat.execute("alter table test alter id rename to id2"); stat.execute("alter table test alter id rename to id2");
// disconnect and reconnect // disconnect and reconnect
conn.close(); conn.close();
conn = getConnection("alter"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("insert into test values(1)"); stat.execute("insert into test values(1)");
assertThrows(ErrorCode.CHECK_CONSTRAINT_VIOLATED_1, stat). assertThrows(ErrorCode.CHECK_CONSTRAINT_VIOLATED_1, stat).
......
...@@ -32,8 +32,8 @@ public class TestAlterSchemaRename extends TestBase { ...@@ -32,8 +32,8 @@ public class TestAlterSchemaRename extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
deleteDb("alter"); deleteDb(getTestName());
conn = getConnection("alter"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
testTryToRenameSystemSchemas(); testTryToRenameSystemSchemas();
testSimpleRename(); testSimpleRename();
...@@ -41,7 +41,7 @@ public class TestAlterSchemaRename extends TestBase { ...@@ -41,7 +41,7 @@ public class TestAlterSchemaRename extends TestBase {
testCrossSchemaViews(); testCrossSchemaViews();
testAlias(); testAlias();
conn.close(); conn.close();
deleteDb("alter"); deleteDb(getTestName());
} }
private void testTryToRenameSystemSchemas() throws SQLException { private void testTryToRenameSystemSchemas() throws SQLException {
...@@ -93,7 +93,7 @@ public class TestAlterSchemaRename extends TestBase { ...@@ -93,7 +93,7 @@ public class TestAlterSchemaRename extends TestBase {
assertEquals(6, rs.getInt(1)); assertEquals(6, rs.getInt(1));
if (!config.memory) { if (!config.memory) {
conn.close(); conn.close();
conn = getConnection("alter"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
stat.executeQuery("select * from s2_new.v1"); stat.executeQuery("select * from s2_new.v1");
} }
...@@ -116,7 +116,7 @@ public class TestAlterSchemaRename extends TestBase { ...@@ -116,7 +116,7 @@ public class TestAlterSchemaRename extends TestBase {
assertEquals("4321", rs.getString(1)); assertEquals("4321", rs.getString(1));
if (!config.memory) { if (!config.memory) {
conn.close(); conn.close();
conn = getConnection("alter"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
stat.executeQuery("CALL S2.REVERSE('1234')"); stat.executeQuery("CALL S2.REVERSE('1234')");
} }
......
...@@ -21,7 +21,7 @@ import org.h2.tools.Server; ...@@ -21,7 +21,7 @@ import org.h2.tools.Server;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
/** /**
* Test for the cluster feature. * Test the cluster feature.
*/ */
public class TestCluster extends TestBase { public class TestCluster extends TestBase {
......
...@@ -6,12 +6,17 @@ ...@@ -6,12 +6,17 @@
package org.h2.test.db; package org.h2.test.db;
import java.sql.Connection; import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.SimpleTimeZone;
import java.util.TimeZone; import java.util.TimeZone;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
...@@ -37,12 +42,116 @@ public class TestDateStorage extends TestBase { ...@@ -37,12 +42,116 @@ public class TestDateStorage extends TestBase {
@Override @Override
public void test() throws SQLException { public void test() throws SQLException {
deleteDb("date"); deleteDb(getTestName());
testDateTimeTimestampWithCalendar();
testMoveDatabaseToAnotherTimezone(); testMoveDatabaseToAnotherTimezone();
testAllTimeZones(); testAllTimeZones();
testCurrentTimeZone(); testCurrentTimeZone();
} }
private void testDateTimeTimestampWithCalendar() throws SQLException {
Connection conn = getConnection(getTestName());
Statement stat = conn.createStatement();
stat.execute("create table ts(x timestamp primary key)");
stat.execute("create table t(x time primary key)");
stat.execute("create table d(x date)");
Calendar utcCalendar = new GregorianCalendar(new SimpleTimeZone(0, "Z"));
TimeZone old = TimeZone.getDefault();
DateTimeUtils.resetCalendar();
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
try {
Timestamp ts1 = Timestamp.valueOf("2010-03-13 18:15:00");
Time t1 = new Time(ts1.getTime());
Date d1 = new Date(ts1.getTime());
// when converted to UTC, this is 03:15, which doesn't actually
// exist because of summer time change at that day
Timestamp ts2 = Timestamp.valueOf("2010-03-13 19:15:00");
Time t2 = new Time(ts2.getTime());
Date d2 = new Date(ts2.getTime());
PreparedStatement prep;
ResultSet rs;
prep = conn.prepareStatement("insert into ts values(?)");
prep.setTimestamp(1, ts1, utcCalendar);
prep.execute();
prep.setTimestamp(1, ts2, utcCalendar);
prep.execute();
prep = conn.prepareStatement("insert into t values(?)");
prep.setTime(1, t1, utcCalendar);
prep.execute();
prep.setTime(1, t2, utcCalendar);
prep.execute();
prep = conn.prepareStatement("insert into d values(?)");
prep.setDate(1, d1, utcCalendar);
prep.execute();
prep.setDate(1, d2, utcCalendar);
prep.execute();
rs = stat.executeQuery("select * from ts order by x");
rs.next();
assertEquals("2010-03-14 02:15:00.0",
rs.getString(1));
assertEquals("2010-03-13 18:15:00.0",
rs.getTimestamp(1, utcCalendar).toString());
assertEquals("2010-03-14 03:15:00.0",
rs.getTimestamp(1).toString());
assertEquals("2010-03-14 02:15:00.0",
rs.getString("x"));
assertEquals("2010-03-13 18:15:00.0",
rs.getTimestamp("x", utcCalendar).toString());
assertEquals("2010-03-14 03:15:00.0",
rs.getTimestamp("x").toString());
rs.next();
assertEquals("2010-03-14 03:15:00.0",
rs.getString(1));
assertEquals("2010-03-13 19:15:00.0",
rs.getTimestamp(1, utcCalendar).toString());
assertEquals("2010-03-14 03:15:00.0",
rs.getTimestamp(1).toString());
assertEquals("2010-03-14 03:15:00.0",
rs.getString("x"));
assertEquals("2010-03-13 19:15:00.0",
rs.getTimestamp("x", utcCalendar).toString());
assertEquals("2010-03-14 03:15:00.0",
rs.getTimestamp("x").toString());
rs = stat.executeQuery("select * from t order by x");
rs.next();
assertEquals("02:15:00", rs.getString(1));
assertEquals("18:15:00", rs.getTime(1, utcCalendar).toString());
assertEquals("02:15:00", rs.getTime(1).toString());
assertEquals("02:15:00", rs.getString("x"));
assertEquals("18:15:00", rs.getTime("x", utcCalendar).toString());
assertEquals("02:15:00", rs.getTime("x").toString());
rs.next();
assertEquals("03:15:00", rs.getString(1));
assertEquals("19:15:00", rs.getTime(1, utcCalendar).toString());
assertEquals("03:15:00", rs.getTime(1).toString());
assertEquals("03:15:00", rs.getString("x"));
assertEquals("19:15:00", rs.getTime("x", utcCalendar).toString());
assertEquals("03:15:00", rs.getTime("x").toString());
rs = stat.executeQuery("select * from d order by x");
rs.next();
assertEquals("2010-03-14", rs.getString(1));
assertEquals("2010-03-13", rs.getDate(1, utcCalendar).toString());
assertEquals("2010-03-14", rs.getDate(1).toString());
assertEquals("2010-03-14", rs.getString("x"));
assertEquals("2010-03-13", rs.getDate("x", utcCalendar).toString());
assertEquals("2010-03-14", rs.getDate("x").toString());
rs.next();
assertEquals("2010-03-14", rs.getString(1));
assertEquals("2010-03-13", rs.getDate(1, utcCalendar).toString());
assertEquals("2010-03-14", rs.getDate(1).toString());
assertEquals("2010-03-14", rs.getString("x"));
assertEquals("2010-03-13", rs.getDate("x", utcCalendar).toString());
assertEquals("2010-03-14", rs.getDate("x").toString());
} finally {
TimeZone.setDefault(old);
DateTimeUtils.resetCalendar();
}
stat.execute("drop table ts");
stat.execute("drop table t");
stat.execute("drop table d");
conn.close();
}
private void testMoveDatabaseToAnotherTimezone() throws SQLException { private void testMoveDatabaseToAnotherTimezone() throws SQLException {
if (config.memory) { if (config.memory) {
return; return;
...@@ -50,7 +159,7 @@ public class TestDateStorage extends TestBase { ...@@ -50,7 +159,7 @@ public class TestDateStorage extends TestBase {
if (!SysProperties.STORE_LOCAL_TIME) { if (!SysProperties.STORE_LOCAL_TIME) {
return; return;
} }
String db = "date;LOG=0;FILE_LOCK=NO"; String db = getTestName() + ";LOG=0;FILE_LOCK=NO";
Connection conn = getConnection(db); Connection conn = getConnection(db);
Statement stat; Statement stat;
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -128,7 +237,7 @@ public class TestDateStorage extends TestBase { ...@@ -128,7 +237,7 @@ public class TestDateStorage extends TestBase {
} }
private void testAllTimeZones() throws SQLException { private void testAllTimeZones() throws SQLException {
Connection conn = getConnection("date"); Connection conn = getConnection(getTestName());
TimeZone defaultTimeZone = TimeZone.getDefault(); TimeZone defaultTimeZone = TimeZone.getDefault();
PreparedStatement prep = conn.prepareStatement("CALL CAST(? AS DATE)"); PreparedStatement prep = conn.prepareStatement("CALL CAST(? AS DATE)");
try { try {
...@@ -146,7 +255,7 @@ public class TestDateStorage extends TestBase { ...@@ -146,7 +255,7 @@ public class TestDateStorage extends TestBase {
DateTimeUtils.resetCalendar(); DateTimeUtils.resetCalendar();
} }
conn.close(); conn.close();
deleteDb("date"); deleteDb(getTestName());
} }
private void test(PreparedStatement prep, int d) throws SQLException { private void test(PreparedStatement prep, int d) throws SQLException {
......
...@@ -94,11 +94,8 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -94,11 +94,8 @@ public class TestFunctions extends TestBase implements AggregateFunction {
testToCharFromText(); testToCharFromText();
testTranslate(); testTranslate();
testGenerateSeries(); testGenerateSeries();
// TODO
// testCachingOfDeterministicFunctionAlias();
deleteDb("functions"); deleteDb("functions");
FileUtils.deleteRecursive(TEMP_DIR, true);
} }
private void testDataType() throws SQLException { private void testDataType() throws SQLException {
......
...@@ -22,14 +22,12 @@ import java.sql.ResultSet; ...@@ -22,14 +22,12 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Savepoint; import java.sql.Savepoint;
import java.sql.Statement; import java.sql.Statement;
import java.util.List;
import java.util.Random; import java.util.Random;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
import org.h2.jdbc.JdbcConnection; import org.h2.jdbc.JdbcConnection;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
...@@ -81,8 +79,6 @@ public class TestLob extends TestBase { ...@@ -81,8 +79,6 @@ public class TestLob extends TestBase {
testConvert(); testConvert();
testCreateAsSelect(); testCreateAsSelect();
testDelete(); testDelete();
testTempFilesDeleted(true);
testTempFilesDeleted(false);
testLobServerMemory(); testLobServerMemory();
testUpdatingLobRow(); testUpdatingLobRow();
if (config.memory) { if (config.memory) {
...@@ -110,7 +106,6 @@ public class TestLob extends TestBase { ...@@ -110,7 +106,6 @@ public class TestLob extends TestBase {
testLob(true); testLob(true);
testJavaObject(); testJavaObject();
deleteDb("lob"); deleteDb("lob");
FileUtils.deleteRecursive(TEMP_DIR, true);
} }
private void testRemovedAfterTimeout() throws Exception { private void testRemovedAfterTimeout() throws Exception {
...@@ -669,41 +664,6 @@ public class TestLob extends TestBase { ...@@ -669,41 +664,6 @@ public class TestLob extends TestBase {
conn.close(); conn.close();
} }
private void testTempFilesDeleted(boolean stream) throws Exception {
FileUtils.deleteRecursive(TEMP_DIR, true);
FileUtils.createDirectories(TEMP_DIR);
List<String> list = FileUtils.newDirectoryStream(TEMP_DIR);
assertEquals("Unexpected temp file: " + list, 0, list.size());
deleteDb("lob");
Connection conn = getConnection("lob");
Statement stat;
stat = conn.createStatement();
stat.execute("create table test(id int primary key, name text)");
PreparedStatement prep = conn.prepareStatement(
"insert into test values(2, ?)");
if (stream) {
String large = new String(new char[1024 * 1024 * 2]).replace((char) 0, 'x');
prep.setCharacterStream(1, new StringReader(large), -1);
large = null;
prep.execute();
} else {
stat.execute("insert into test values(1, space(100000))");
}
/*
list = FileUtils.newDirectoryStream(TEMP_DIR);
assertEquals("Unexpected temp file: " + list, 0, list.size());
*/
ResultSet rs;
rs = stat.executeQuery("select * from test");
while (rs.next()) {
rs.getCharacterStream("name").close();
}
prep.close();
conn.close();
list = FileUtils.newDirectoryStream(TEMP_DIR);
assertEquals("Unexpected temp file: " + list, 0, list.size());
}
private void testLobUpdateMany() throws SQLException { private void testLobUpdateMany() throws SQLException {
deleteDb("lob"); deleteDb("lob");
Connection conn = getConnection("lob"); Connection conn = getConnection("lob");
......
...@@ -64,7 +64,7 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -64,7 +64,7 @@ public class TestMultiThread extends TestBase implements Runnable {
} }
private void testConcurrentSchemaChange() throws Exception { private void testConcurrentSchemaChange() throws Exception {
String db = "testConcurrentSchemaChange"; String db = getTestName();
deleteDb(db); deleteDb(db);
final String url = getURL(db + ";MULTI_THREADED=1", true); final String url = getURL(db + ";MULTI_THREADED=1", true);
Connection conn = getConnection(url); Connection conn = getConnection(url);
...@@ -98,7 +98,7 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -98,7 +98,7 @@ public class TestMultiThread extends TestBase implements Runnable {
} }
private void testConcurrentLobAdd() throws Exception { private void testConcurrentLobAdd() throws Exception {
String db = "concurrentLobAdd"; String db = getTestName();
deleteDb(db); deleteDb(db);
final String url = getURL(db + ";MULTI_THREADED=1", true); final String url = getURL(db + ";MULTI_THREADED=1", true);
Connection conn = getConnection(url); Connection conn = getConnection(url);
...@@ -137,7 +137,7 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -137,7 +137,7 @@ public class TestMultiThread extends TestBase implements Runnable {
if (config.mvcc) { if (config.mvcc) {
return; return;
} }
String db = "concurrentView"; String db = getTestName();
deleteDb(db); deleteDb(db);
final String url = getURL(db + ";MULTI_THREADED=1", true); final String url = getURL(db + ";MULTI_THREADED=1", true);
final Random r = new Random(); final Random r = new Random();
...@@ -176,8 +176,8 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -176,8 +176,8 @@ public class TestMultiThread extends TestBase implements Runnable {
} }
private void testConcurrentAlter() throws Exception { private void testConcurrentAlter() throws Exception {
deleteDb("concurrentAlter"); deleteDb(getTestName());
final Connection conn = getConnection("concurrentAlter"); final Connection conn = getConnection(getTestName());
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
Task t = new Task() { Task t = new Task() {
@Override @Override
...@@ -195,14 +195,13 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -195,14 +195,13 @@ public class TestMultiThread extends TestBase implements Runnable {
} }
t.get(); t.get();
conn.close(); conn.close();
deleteDb("concurrentAlter");
} }
private void testConcurrentAnalyze() throws Exception { private void testConcurrentAnalyze() throws Exception {
if (config.mvcc) { if (config.mvcc) {
return; return;
} }
deleteDb("concurrentAnalyze"); deleteDb(getTestName());
final String url = getURL("concurrentAnalyze;MULTI_THREADED=1", true); final String url = getURL("concurrentAnalyze;MULTI_THREADED=1", true);
Connection conn = getConnection(url); Connection conn = getConnection(url);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
...@@ -227,7 +226,6 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -227,7 +226,6 @@ public class TestMultiThread extends TestBase implements Runnable {
t.get(); t.get();
stat.execute("drop table test"); stat.execute("drop table test");
conn.close(); conn.close();
deleteDb("concurrentAnalyze");
} }
private void testConcurrentInsertUpdateSelect() throws Exception { private void testConcurrentInsertUpdateSelect() throws Exception {
...@@ -255,7 +253,7 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -255,7 +253,7 @@ public class TestMultiThread extends TestBase implements Runnable {
} }
private Connection getConnection() throws SQLException { private Connection getConnection() throws SQLException {
return getConnection("jdbc:h2:mem:multiThread"); return getConnection("jdbc:h2:mem:" + getTestName());
} }
@Override @Override
......
...@@ -31,8 +31,8 @@ public class TestViewAlterTable extends TestBase { ...@@ -31,8 +31,8 @@ public class TestViewAlterTable extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
deleteDb("alter"); deleteDb(getTestName());
conn = getConnection("alter"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
testDropColumnWithoutViews(); testDropColumnWithoutViews();
...@@ -47,7 +47,7 @@ public class TestViewAlterTable extends TestBase { ...@@ -47,7 +47,7 @@ public class TestViewAlterTable extends TestBase {
testForeignKey(); testForeignKey();
conn.close(); conn.close();
deleteDb("alter"); deleteDb(getTestName());
} }
private void testDropColumnWithoutViews() throws SQLException { private void testDropColumnWithoutViews() throws SQLException {
......
...@@ -32,8 +32,8 @@ public class TestViewDropView extends TestBase { ...@@ -32,8 +32,8 @@ public class TestViewDropView extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
deleteDb("alter"); deleteDb(getTestName());
conn = getConnection("alter"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
testDropViewDefaultBehaviour(); testDropViewDefaultBehaviour();
...@@ -45,7 +45,7 @@ public class TestViewDropView extends TestBase { ...@@ -45,7 +45,7 @@ public class TestViewDropView extends TestBase {
testCreateOrReplaceForceViewWithNowInvalidDependentViews(); testCreateOrReplaceForceViewWithNowInvalidDependentViews();
conn.close(); conn.close();
deleteDb("alter"); deleteDb(getTestName());
} }
private void testCreateForceView() throws SQLException { private void testCreateForceView() throws SQLException {
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
*/ */
package org.h2.test.jdbc; package org.h2.test.jdbc;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.sql.BatchUpdateException; import java.sql.BatchUpdateException;
import java.sql.CallableStatement; import java.sql.CallableStatement;
import java.sql.Connection; import java.sql.Connection;
...@@ -156,16 +154,9 @@ public class TestBatchUpdates extends TestBase { ...@@ -156,16 +154,9 @@ public class TestBatchUpdates extends TestBase {
} }
try { try {
prep.executeBatch(); prep.executeBatch();
fail();
} catch (BatchUpdateException e) { } catch (BatchUpdateException e) {
PrintStream temp = System.err; // expected
try {
ByteArrayOutputStream buff = new ByteArrayOutputStream();
PrintStream p = new PrintStream(buff);
System.setErr(p);
e.printStackTrace();
} finally {
System.setErr(temp);
}
} }
conn.close(); conn.close();
} }
......
...@@ -45,12 +45,12 @@ public class TestLobApi extends TestBase { ...@@ -45,12 +45,12 @@ public class TestLobApi extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
deleteDb("lob"); deleteDb(getTestName());
testUnsupportedOperations(); testUnsupportedOperations();
testLobStaysOpenUntilCommitted(); testLobStaysOpenUntilCommitted();
testInputStreamThrowsException(true); testInputStreamThrowsException(true);
testInputStreamThrowsException(false); testInputStreamThrowsException(false);
conn = (JdbcConnection) getConnection("lob"); conn = (JdbcConnection) getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id int, x blob)"); stat.execute("create table test(id int, x blob)");
testBlob(0); testBlob(0);
...@@ -68,7 +68,7 @@ public class TestLobApi extends TestBase { ...@@ -68,7 +68,7 @@ public class TestLobApi extends TestBase {
} }
private void testUnsupportedOperations() throws Exception { private void testUnsupportedOperations() throws Exception {
Connection conn = getConnection("lob"); Connection conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id int, c clob, b blob)"); stat.execute("create table test(id int, c clob, b blob)");
stat.execute("insert into test values(1, 'x', x'00')"); stat.execute("insert into test values(1, 'x', x'00')");
...@@ -118,7 +118,7 @@ public class TestLobApi extends TestBase { ...@@ -118,7 +118,7 @@ public class TestLobApi extends TestBase {
* the result set is closed (see ResultSet.close). * the result set is closed (see ResultSet.close).
*/ */
private void testLobStaysOpenUntilCommitted() throws Exception { private void testLobStaysOpenUntilCommitted() throws Exception {
Connection conn = getConnection("lob"); Connection conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id identity, c clob, b blob)"); stat.execute("create table test(id identity, c clob, b blob)");
PreparedStatement prep = conn.prepareStatement( PreparedStatement prep = conn.prepareStatement(
...@@ -163,7 +163,7 @@ public class TestLobApi extends TestBase { ...@@ -163,7 +163,7 @@ public class TestLobApi extends TestBase {
private void testInputStreamThrowsException(final boolean ioException) private void testInputStreamThrowsException(final boolean ioException)
throws Exception { throws Exception {
Connection conn = getConnection("lob"); Connection conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id identity, c clob, b blob)"); stat.execute("create table test(id identity, c clob, b blob)");
PreparedStatement prep = conn.prepareStatement( PreparedStatement prep = conn.prepareStatement(
......
...@@ -13,7 +13,6 @@ import java.math.BigDecimal; ...@@ -13,7 +13,6 @@ import java.math.BigDecimal;
import java.net.URL; import java.net.URL;
import java.sql.Array; import java.sql.Array;
import java.sql.Connection; import java.sql.Connection;
import java.sql.Date;
import java.sql.ParameterMetaData; import java.sql.ParameterMetaData;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
...@@ -21,19 +20,13 @@ import java.sql.ResultSetMetaData; ...@@ -21,19 +20,13 @@ import java.sql.ResultSetMetaData;
import java.sql.RowId; import java.sql.RowId;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.sql.Types; import java.sql.Types;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
import java.util.UUID; import java.util.UUID;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.api.Trigger; import org.h2.api.Trigger;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.DateTimeUtils;
import org.h2.util.Task; import org.h2.util.Task;
/** /**
...@@ -59,7 +52,6 @@ public class TestPreparedStatement extends TestBase { ...@@ -59,7 +52,6 @@ public class TestPreparedStatement extends TestBase {
testUnwrap(conn); testUnwrap(conn);
testUnsupportedOperations(conn); testUnsupportedOperations(conn);
testChangeType(conn); testChangeType(conn);
testDateTimeTimestampWithCalendar(conn);
testCallTablePrepared(conn); testCallTablePrepared(conn);
testValues(conn); testValues(conn);
testToString(conn); testToString(conn);
...@@ -169,108 +161,6 @@ public class TestPreparedStatement extends TestBase { ...@@ -169,108 +161,6 @@ public class TestPreparedStatement extends TestBase {
prep.executeQuery(); prep.executeQuery();
} }
private void testDateTimeTimestampWithCalendar(Connection conn)
throws SQLException {
Statement stat = conn.createStatement();
stat.execute("create table ts(x timestamp primary key)");
stat.execute("create table t(x time primary key)");
stat.execute("create table d(x date)");
Calendar utcCalendar = new GregorianCalendar(new SimpleTimeZone(0, "Z"));
TimeZone old = TimeZone.getDefault();
DateTimeUtils.resetCalendar();
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
try {
Timestamp ts1 = Timestamp.valueOf("2010-03-13 18:15:00");
Time t1 = new Time(ts1.getTime());
Date d1 = new Date(ts1.getTime());
// when converted to UTC, this is 03:15, which doesn't actually
// exist because of summer time change at that day
Timestamp ts2 = Timestamp.valueOf("2010-03-13 19:15:00");
Time t2 = new Time(ts2.getTime());
Date d2 = new Date(ts2.getTime());
PreparedStatement prep;
ResultSet rs;
prep = conn.prepareStatement("insert into ts values(?)");
prep.setTimestamp(1, ts1, utcCalendar);
prep.execute();
prep.setTimestamp(1, ts2, utcCalendar);
prep.execute();
prep = conn.prepareStatement("insert into t values(?)");
prep.setTime(1, t1, utcCalendar);
prep.execute();
prep.setTime(1, t2, utcCalendar);
prep.execute();
prep = conn.prepareStatement("insert into d values(?)");
prep.setDate(1, d1, utcCalendar);
prep.execute();
prep.setDate(1, d2, utcCalendar);
prep.execute();
rs = stat.executeQuery("select * from ts order by x");
rs.next();
assertEquals("2010-03-14 02:15:00.0",
rs.getString(1));
assertEquals("2010-03-13 18:15:00.0",
rs.getTimestamp(1, utcCalendar).toString());
assertEquals("2010-03-14 03:15:00.0",
rs.getTimestamp(1).toString());
assertEquals("2010-03-14 02:15:00.0",
rs.getString("x"));
assertEquals("2010-03-13 18:15:00.0",
rs.getTimestamp("x", utcCalendar).toString());
assertEquals("2010-03-14 03:15:00.0",
rs.getTimestamp("x").toString());
rs.next();
assertEquals("2010-03-14 03:15:00.0",
rs.getString(1));
assertEquals("2010-03-13 19:15:00.0",
rs.getTimestamp(1, utcCalendar).toString());
assertEquals("2010-03-14 03:15:00.0",
rs.getTimestamp(1).toString());
assertEquals("2010-03-14 03:15:00.0",
rs.getString("x"));
assertEquals("2010-03-13 19:15:00.0",
rs.getTimestamp("x", utcCalendar).toString());
assertEquals("2010-03-14 03:15:00.0",
rs.getTimestamp("x").toString());
rs = stat.executeQuery("select * from t order by x");
rs.next();
assertEquals("02:15:00", rs.getString(1));
assertEquals("18:15:00", rs.getTime(1, utcCalendar).toString());
assertEquals("02:15:00", rs.getTime(1).toString());
assertEquals("02:15:00", rs.getString("x"));
assertEquals("18:15:00", rs.getTime("x", utcCalendar).toString());
assertEquals("02:15:00", rs.getTime("x").toString());
rs.next();
assertEquals("03:15:00", rs.getString(1));
assertEquals("19:15:00", rs.getTime(1, utcCalendar).toString());
assertEquals("03:15:00", rs.getTime(1).toString());
assertEquals("03:15:00", rs.getString("x"));
assertEquals("19:15:00", rs.getTime("x", utcCalendar).toString());
assertEquals("03:15:00", rs.getTime("x").toString());
rs = stat.executeQuery("select * from d order by x");
rs.next();
assertEquals("2010-03-14", rs.getString(1));
assertEquals("2010-03-13", rs.getDate(1, utcCalendar).toString());
assertEquals("2010-03-14", rs.getDate(1).toString());
assertEquals("2010-03-14", rs.getString("x"));
assertEquals("2010-03-13", rs.getDate("x", utcCalendar).toString());
assertEquals("2010-03-14", rs.getDate("x").toString());
rs.next();
assertEquals("2010-03-14", rs.getString(1));
assertEquals("2010-03-13", rs.getDate(1, utcCalendar).toString());
assertEquals("2010-03-14", rs.getDate(1).toString());
assertEquals("2010-03-14", rs.getString("x"));
assertEquals("2010-03-13", rs.getDate("x", utcCalendar).toString());
assertEquals("2010-03-14", rs.getDate("x").toString());
} finally {
TimeZone.setDefault(old);
DateTimeUtils.resetCalendar();
}
stat.execute("drop table ts");
stat.execute("drop table t");
stat.execute("drop table d");
}
private static void testCallTablePrepared(Connection conn) throws SQLException { private static void testCallTablePrepared(Connection conn) throws SQLException {
PreparedStatement prep = conn.prepareStatement("call table(x int = (1))"); PreparedStatement prep = conn.prepareStatement("call table(x int = (1))");
prep.executeQuery(); prep.executeQuery();
......
...@@ -32,7 +32,6 @@ import java.sql.Timestamp; ...@@ -32,7 +32,6 @@ import java.sql.Timestamp;
import java.sql.Types; import java.sql.Types;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
...@@ -70,7 +69,6 @@ public class TestResultSet extends TestBase { ...@@ -70,7 +69,6 @@ public class TestResultSet extends TestBase {
testInsertRowWithUpdatableResultSetDefault(); testInsertRowWithUpdatableResultSetDefault();
testBeforeFirstAfterLast(); testBeforeFirstAfterLast();
testParseSpecialValues(); testParseSpecialValues();
testSpecialLocale();
testSubstringPrecision(); testSubstringPrecision();
testSubstringDataType(); testSubstringDataType();
testColumnLabelColumnName(); testColumnLabelColumnName();
...@@ -347,26 +345,6 @@ public class TestResultSet extends TestBase { ...@@ -347,26 +345,6 @@ public class TestResultSet extends TestBase {
assertTrue(expected.equals(o)); assertTrue(expected.equals(o));
} }
private void testSpecialLocale() throws SQLException {
Locale old = Locale.getDefault();
try {
// when using Turkish as the default locale, "i".toUpperCase() is
// not "I"
Locale.setDefault(new Locale("tr"));
stat.execute("create table test(I1 int, i2 int, b int, c int, d int) " +
"as select 1, 1, 1, 1, 1");
ResultSet rs = stat.executeQuery("select * from test");
rs.next();
rs.getString("I1");
rs.getString("i1");
rs.getString("I2");
rs.getString("i2");
stat.execute("drop table test");
} finally {
Locale.setDefault(old);
}
}
private void testSubstringDataType() throws SQLException { private void testSubstringDataType() throws SQLException {
ResultSet rs = stat.executeQuery("select substr(x, 1, 1) from dual"); ResultSet rs = stat.executeQuery("select substr(x, 1, 1) from dual");
rs.next(); rs.next();
......
...@@ -38,8 +38,8 @@ public class TestMvccMultiThreaded extends TestBase { ...@@ -38,8 +38,8 @@ public class TestMvccMultiThreaded extends TestBase {
} }
private void testMergeWithUniqueKeyViolation() throws Exception { private void testMergeWithUniqueKeyViolation() throws Exception {
deleteDb("mvccMultiThreaded"); deleteDb(getTestName());
Connection conn = getConnection("mvccMultiThreaded"); Connection conn = getConnection(getTestName());
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(x int primary key, y int unique)"); stat.execute("create table test(x int primary key, y int unique)");
stat.execute("insert into test values(1, 1)"); stat.execute("insert into test values(1, 1)");
...@@ -51,12 +51,12 @@ public class TestMvccMultiThreaded extends TestBase { ...@@ -51,12 +51,12 @@ public class TestMvccMultiThreaded extends TestBase {
} }
private void testConcurrentMerge() throws Exception { private void testConcurrentMerge() throws Exception {
deleteDb("mvccMultiThreaded"); deleteDb(getTestName());
int len = 3; int len = 3;
final Connection[] connList = new Connection[len]; final Connection[] connList = new Connection[len];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
Connection conn = getConnection( Connection conn = getConnection(
"mvccMultiThreaded;MVCC=TRUE;LOCK_TIMEOUT=500"); getTestName() + ";MVCC=TRUE;LOCK_TIMEOUT=500");
connList[i] = conn; connList[i] = conn;
} }
Connection conn = connList[0]; Connection conn = connList[0];
...@@ -88,16 +88,16 @@ public class TestMvccMultiThreaded extends TestBase { ...@@ -88,16 +88,16 @@ public class TestMvccMultiThreaded extends TestBase {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
connList[i].close(); connList[i].close();
} }
deleteDb("mvccMultiThreaded"); deleteDb(getTestName());
} }
private void testConcurrentUpdate(String suffix) throws Exception { private void testConcurrentUpdate(String suffix) throws Exception {
deleteDb("mvccMultiThreaded"); deleteDb(getTestName());
int len = 2; int len = 2;
final Connection[] connList = new Connection[len]; final Connection[] connList = new Connection[len];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
connList[i] = getConnection( connList[i] = getConnection(
"mvccMultiThreaded;MVCC=TRUE" + suffix); getTestName() + ";MVCC=TRUE" + suffix);
} }
Connection conn = connList[0]; Connection conn = connList[0];
conn.createStatement().execute( conn.createStatement().execute(
...@@ -133,7 +133,6 @@ public class TestMvccMultiThreaded extends TestBase { ...@@ -133,7 +133,6 @@ public class TestMvccMultiThreaded extends TestBase {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
connList[i].close(); connList[i].close();
} }
deleteDb("mvccMultiThreaded");
} }
} }
...@@ -39,12 +39,12 @@ public class TestRowLocks extends TestBase { ...@@ -39,12 +39,12 @@ public class TestRowLocks extends TestBase {
public void test() throws Exception { public void test() throws Exception {
testSetMode(); testSetMode();
testCases(); testCases();
deleteDb("rowLocks"); deleteDb(getTestName());
} }
private void testSetMode() throws SQLException { private void testSetMode() throws SQLException {
deleteDb("rowLocks"); deleteDb(getTestName());
c1 = getConnection("rowLocks"); c1 = getConnection(getTestName());
Statement stat = c1.createStatement(); Statement stat = c1.createStatement();
stat.execute("SET LOCK_MODE 2"); stat.execute("SET LOCK_MODE 2");
ResultSet rs = stat.executeQuery("call lock_mode()"); ResultSet rs = stat.executeQuery("call lock_mode()");
...@@ -54,8 +54,8 @@ public class TestRowLocks extends TestBase { ...@@ -54,8 +54,8 @@ public class TestRowLocks extends TestBase {
} }
private void testCases() throws Exception { private void testCases() throws Exception {
deleteDb("rowLocks"); deleteDb(getTestName());
c1 = getConnection("rowLocks;MVCC=TRUE"); c1 = getConnection(getTestName() + ";MVCC=TRUE");
s1 = c1.createStatement(); s1 = c1.createStatement();
s1.execute("SET LOCK_TIMEOUT 10000"); s1.execute("SET LOCK_TIMEOUT 10000");
s1.execute("CREATE TABLE TEST AS " + s1.execute("CREATE TABLE TEST AS " +
...@@ -64,7 +64,7 @@ public class TestRowLocks extends TestBase { ...@@ -64,7 +64,7 @@ public class TestRowLocks extends TestBase {
c1.setAutoCommit(false); c1.setAutoCommit(false);
s1.execute("UPDATE TEST SET NAME='Hallo' WHERE ID=1"); s1.execute("UPDATE TEST SET NAME='Hallo' WHERE ID=1");
c2 = getConnection("rowLocks"); c2 = getConnection(getTestName());
c2.setAutoCommit(false); c2.setAutoCommit(false);
s2 = c2.createStatement(); s2 = c2.createStatement();
......
...@@ -43,10 +43,10 @@ public class TestAutoServer extends TestBase { ...@@ -43,10 +43,10 @@ public class TestAutoServer extends TestBase {
private void testUnsupportedCombinations() throws SQLException { private void testUnsupportedCombinations() throws SQLException {
String[] urls = { String[] urls = {
"jdbc:h2:test;file_lock=no;auto_server=true", "jdbc:h2:" + getTestName() + ";file_lock=no;auto_server=true",
"jdbc:h2:test;file_lock=serialized;auto_server=true", "jdbc:h2:" + getTestName() + ";file_lock=serialized;auto_server=true",
"jdbc:h2:test;access_mode_data=r;auto_server=true", "jdbc:h2:" + getTestName() + ";access_mode_data=r;auto_server=true",
"jdbc:h2:mem:test;auto_server=true" "jdbc:h2:mem:" + getTestName() + ";auto_server=true"
}; };
for (String url : urls) { for (String url : urls) {
assertThrows(SQLException.class, this).getConnection(url); assertThrows(SQLException.class, this).getConnection(url);
...@@ -63,8 +63,8 @@ public class TestAutoServer extends TestBase { ...@@ -63,8 +63,8 @@ public class TestAutoServer extends TestBase {
if (config.memory || config.networked) { if (config.memory || config.networked) {
return; return;
} }
deleteDb("autoServer"); deleteDb(getTestName());
String url = getURL("autoServer;AUTO_SERVER=TRUE", true); String url = getURL(getTestName() + ";AUTO_SERVER=TRUE", true);
if (port) { if (port) {
url += ";AUTO_SERVER_PORT=11111"; url += ";AUTO_SERVER_PORT=11111";
} }
...@@ -76,7 +76,7 @@ public class TestAutoServer extends TestBase { ...@@ -76,7 +76,7 @@ public class TestAutoServer extends TestBase {
for (; i > 0; i--) { for (; i > 0; i--) {
Thread.sleep(100); Thread.sleep(100);
SortedProperties prop = SortedProperties.loadProperties( SortedProperties prop = SortedProperties.loadProperties(
getBaseDir() + "/autoServer.lock.db"); getBaseDir() + "/" + getTestName() + ".lock.db");
String key = prop.getProperty("id"); String key = prop.getProperty("id");
String server = prop.getProperty("server"); String server = prop.getProperty("server");
if (server != null) { if (server != null) {
...@@ -117,10 +117,10 @@ public class TestAutoServer extends TestBase { ...@@ -117,10 +117,10 @@ public class TestAutoServer extends TestBase {
if (config.memory || config.networked) { if (config.memory || config.networked) {
return; return;
} }
deleteDb("autoServerLinkedTable1"); deleteDb(getTestName() + "1");
deleteDb("autoServerLinkedTable2"); deleteDb(getTestName() + "2");
String url = getURL("autoServerLinkedTable1;AUTO_SERVER=TRUE", true); String url = getURL(getTestName() + "1;AUTO_SERVER=TRUE", true);
String urlLinked = getURL("autoServerLinkedTable2", true); String urlLinked = getURL(getTestName() + "2", true);
String user = getUser(), password = getPassword(); String user = getUser(), password = getPassword();
Connection connLinked = getConnection(urlLinked, user, password); Connection connLinked = getConnection(urlLinked, user, password);
...@@ -163,8 +163,8 @@ public class TestAutoServer extends TestBase { ...@@ -163,8 +163,8 @@ public class TestAutoServer extends TestBase {
// ignore // ignore
} }
deleteDb("autoServerLinkedTable1"); deleteDb(getTestName() + "1");
deleteDb("autoServerLinkedTable2"); deleteDb(getTestName() + "2");
} }
/** /**
......
...@@ -6,11 +6,7 @@ ...@@ -6,11 +6,7 @@
package org.h2.test.server; package org.h2.test.server;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.PrintWriter; import java.io.PrintWriter;
...@@ -47,7 +43,6 @@ import org.h2.store.fs.FileUtils; ...@@ -47,7 +43,6 @@ import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.test.utils.AssertThrows; import org.h2.test.utils.AssertThrows;
import org.h2.tools.Server; import org.h2.tools.Server;
import org.h2.util.IOUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Task; import org.h2.util.Task;
...@@ -72,7 +67,6 @@ public class TestWeb extends TestBase { ...@@ -72,7 +67,6 @@ public class TestWeb extends TestBase {
testServlet(); testServlet();
testWrongParameters(); testWrongParameters();
testTools(); testTools();
testTransfer();
testAlreadyRunning(); testAlreadyRunning();
testStartWebServerWithConnection(); testStartWebServerWithConnection();
testServer(); testServer();
...@@ -164,8 +158,8 @@ public class TestWeb extends TestBase { ...@@ -164,8 +158,8 @@ public class TestWeb extends TestBase {
if (config.memory || config.cipher != null) { if (config.memory || config.cipher != null) {
return; return;
} }
deleteDb("web"); deleteDb(getTestName());
Connection conn = getConnection("web"); Connection conn = getConnection(getTestName());
conn.createStatement().execute( conn.createStatement().execute(
"create table test(id int) as select 1"); "create table test(id int) as select 1");
conn.close(); conn.close();
...@@ -183,14 +177,14 @@ public class TestWeb extends TestBase { ...@@ -183,14 +177,14 @@ public class TestWeb extends TestBase {
result = client.get(url, "tools.jsp"); result = client.get(url, "tools.jsp");
FileUtils.delete(getBaseDir() + "/backup.zip"); FileUtils.delete(getBaseDir() + "/backup.zip");
result = client.get(url, "tools.do?tool=Backup&args=-dir," + result = client.get(url, "tools.do?tool=Backup&args=-dir," +
getBaseDir() + ",-db,web,-file," + getBaseDir() + ",-db," + getTestName() + ",-file," +
getBaseDir() + "/backup.zip"); getBaseDir() + "/backup.zip");
deleteDb("web"); deleteDb(getTestName());
assertTrue(FileUtils.exists(getBaseDir() + "/backup.zip")); assertTrue(FileUtils.exists(getBaseDir() + "/backup.zip"));
result = client.get(url, result = client.get(url,
"tools.do?tool=DeleteDbFiles&args=-dir," + "tools.do?tool=DeleteDbFiles&args=-dir," +
getBaseDir() + ",-db,web"); getBaseDir() + ",-db," + getTestName());
String fn = getBaseDir() + "/web"; String fn = getBaseDir() + "/" + getTestName();
if (config.mvStore) { if (config.mvStore) {
fn += Constants.SUFFIX_MV_FILE; fn += Constants.SUFFIX_MV_FILE;
} else { } else {
...@@ -198,53 +192,23 @@ public class TestWeb extends TestBase { ...@@ -198,53 +192,23 @@ public class TestWeb extends TestBase {
} }
assertFalse(FileUtils.exists(fn)); assertFalse(FileUtils.exists(fn));
result = client.get(url, "tools.do?tool=Restore&args=-dir," + result = client.get(url, "tools.do?tool=Restore&args=-dir," +
getBaseDir() + ",-db,web,-file," + getBaseDir() + getBaseDir() + ",-db," + getTestName() +",-file," + getBaseDir() +
"/backup.zip"); "/backup.zip");
assertTrue(FileUtils.exists(fn)); assertTrue(FileUtils.exists(fn));
FileUtils.delete(getBaseDir() + "/web.h2.sql"); FileUtils.delete(getBaseDir() + "/web.h2.sql");
FileUtils.delete(getBaseDir() + "/backup.zip"); FileUtils.delete(getBaseDir() + "/backup.zip");
result = client.get(url, "tools.do?tool=Recover&args=-dir," + result = client.get(url, "tools.do?tool=Recover&args=-dir," +
getBaseDir() + ",-db,web"); getBaseDir() + ",-db," + getTestName());
assertTrue(FileUtils.exists(getBaseDir() + "/web.h2.sql")); assertTrue(FileUtils.exists(getBaseDir() + "/" + getTestName() + ".h2.sql"));
FileUtils.delete(getBaseDir() + "/web.h2.sql"); FileUtils.delete(getBaseDir() + "/web.h2.sql");
result = client.get(url, "tools.do?tool=RunScript&args=-script," + result = client.get(url, "tools.do?tool=RunScript&args=-script," +
getBaseDir() + "/web.h2.sql,-url," + getURL("web", true) + getBaseDir() + "/" + getTestName() + ".h2.sql,-url," + getURL(getTestName(), true) +
",-user," + getUser() + ",-password," + getPassword()); ",-user," + getUser() + ",-password," + getPassword());
FileUtils.delete(getBaseDir() + "/web.h2.sql"); FileUtils.delete(getBaseDir() + "/" + getTestName() + ".h2.sql");
assertTrue(FileUtils.exists(fn)); assertTrue(FileUtils.exists(fn));
deleteDb("web"); deleteDb(getTestName());
} finally {
server.shutdown();
}
}
private void testTransfer() throws Exception {
Server server = new Server();
server.setOut(new PrintStream(new ByteArrayOutputStream()));
server.runTool("-web", "-webPort", "8182", "-properties", "null");
File transfer = new File("transfer");
transfer.mkdirs();
try {
FileOutputStream f = new FileOutputStream("transfer/test.txt");
f.write("Hello World".getBytes());
f.close();
WebClient client = new WebClient();
String url = "http://localhost:8182";
String result = client.get(url);
client.readSessionId(result);
String test = client.get(url, "transfer/test.txt");
assertEquals("Hello World", test);
new File("transfer/testUpload.txt").delete();
client.upload(url + "/transfer/testUpload.txt",
"testUpload.txt", new ByteArrayInputStream(
"Hallo Welt".getBytes()));
byte[] d = IOUtils.readBytesAndClose(
new FileInputStream("transfer/testUpload.txt"), -1);
assertEquals("Hallo Welt", new String(d));
new File("transfer/testUpload.txt").delete();
} finally { } finally {
server.shutdown(); server.shutdown();
FileUtils.deleteRecursive("transfer", true);
} }
} }
...@@ -289,7 +253,7 @@ public class TestWeb extends TestBase { ...@@ -289,7 +253,7 @@ public class TestWeb extends TestBase {
} }
private void testIfExists() throws Exception { private void testIfExists() throws Exception {
Connection conn = getConnection("jdbc:h2:mem:webExists", Connection conn = getConnection("jdbc:h2:mem:" + getTestName(),
getUser(), getPassword()); getUser(), getPassword());
Server server = new Server(); Server server = new Server();
server.setOut(new PrintStream(new ByteArrayOutputStream())); server.setOut(new PrintStream(new ByteArrayOutputStream()));
...@@ -304,12 +268,12 @@ public class TestWeb extends TestBase { ...@@ -304,12 +268,12 @@ public class TestWeb extends TestBase {
client.readSessionId(result); client.readSessionId(result);
result = client.get(url, "login.jsp"); result = client.get(url, "login.jsp");
result = client.get(url, "test.do?driver=org.h2.Driver" + result = client.get(url, "test.do?driver=org.h2.Driver" +
"&url=jdbc:h2:mem:webExists" + "&url=jdbc:h2:mem:" + getTestName() +
"&user=" + getUser() + "&password=" + "&user=" + getUser() + "&password=" +
getPassword() + "&name=_test_"); getPassword() + "&name=_test_");
assertTrue(result.indexOf("Exception") < 0); assertTrue(result.indexOf("Exception") < 0);
result = client.get(url, "test.do?driver=org.h2.Driver" + result = client.get(url, "test.do?driver=org.h2.Driver" +
"&url=jdbc:h2:mem:web" + "&url=jdbc:h2:mem:" + getTestName() + "Wrong" +
"&user=" + getUser() + "&password=" + "&user=" + getUser() + "&password=" +
getPassword() + "&name=_test_"); getPassword() + "&name=_test_");
assertContains(result, "Exception"); assertContains(result, "Exception");
...@@ -340,13 +304,16 @@ public class TestWeb extends TestBase { ...@@ -340,13 +304,16 @@ public class TestWeb extends TestBase {
result = client.get(url, "login.jsp"); result = client.get(url, "login.jsp");
assertTrue(result.indexOf("Einstellung") < 0); assertTrue(result.indexOf("Einstellung") < 0);
result = client.get(url, "test.do?driver=abc" + result = client.get(url, "test.do?driver=abc" +
"&url=jdbc:abc:mem:web&user=sa&password=sa&name=_test_"); "&url=jdbc:abc:mem: " + getTestName() +
"&user=sa&password=sa&name=_test_");
assertContains(result, "Exception"); assertContains(result, "Exception");
result = client.get(url, "test.do?driver=org.h2.Driver" + result = client.get(url, "test.do?driver=org.h2.Driver" +
"&url=jdbc:h2:mem:web&user=sa&password=sa&name=_test_"); "&url=jdbc:h2:mem:" + getTestName() +
"&user=sa&password=sa&name=_test_");
assertTrue(result.indexOf("Exception") < 0); assertTrue(result.indexOf("Exception") < 0);
result = client.get(url, "login.do?driver=org.h2.Driver" + result = client.get(url, "login.do?driver=org.h2.Driver" +
"&url=jdbc:h2:mem:web&user=sa&password=sa&name=_test_"); "&url=jdbc:h2:mem:" + getTestName() +
"&user=sa&password=sa&name=_test_");
result = client.get(url, "header.jsp"); result = client.get(url, "header.jsp");
result = client.get(url, "query.do?sql=" + result = client.get(url, "query.do?sql=" +
"create table test(id int primary key, name varchar);" + "create table test(id int primary key, name varchar);" +
...@@ -561,7 +528,8 @@ public class TestWeb extends TestBase { ...@@ -561,7 +528,8 @@ public class TestWeb extends TestBase {
result = client.get(url, "logout.do"); result = client.get(url, "logout.do");
result = client.get(url, "login.do?driver=org.h2.Driver&" + result = client.get(url, "login.do?driver=org.h2.Driver&" +
"url=jdbc:h2:mem:web&user=sa&password=sa&name=_test_"); "url=jdbc:h2:mem:" + getTestName() +
"&user=sa&password=sa&name=_test_");
result = client.get(url, "logout.do"); result = client.get(url, "logout.do");
result = client.get(url, "settingRemove.do?name=_test_"); result = client.get(url, "settingRemove.do?name=_test_");
...@@ -580,7 +548,7 @@ public class TestWeb extends TestBase { ...@@ -580,7 +548,7 @@ public class TestWeb extends TestBase {
Server.openBrowser("testUrl"); Server.openBrowser("testUrl");
assertEquals("testUrl", lastUrl); assertEquals("testUrl", lastUrl);
String oldUrl = lastUrl; String oldUrl = lastUrl;
final Connection conn = getConnection("testWeb"); final Connection conn = getConnection(getTestName());
Task t = new Task() { Task t = new Task() {
@Override @Override
public void call() throws Exception { public void call() throws Exception {
...@@ -611,7 +579,6 @@ public class TestWeb extends TestBase { ...@@ -611,7 +579,6 @@ public class TestWeb extends TestBase {
} else { } else {
System.clearProperty(SysProperties.H2_BROWSER); System.clearProperty(SysProperties.H2_BROWSER);
} }
deleteDb("testWeb");
} }
} }
......
...@@ -46,10 +46,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -46,10 +46,7 @@ public class TestConcurrent extends TestMVStore {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
FileUtils.createDirectories(getBaseDir()); FileUtils.createDirectories(getBaseDir());
FileUtils.deleteRecursive("memFS:", false);
testInterruptReopen(); testInterruptReopen();
testConcurrentSaveCompact(); testConcurrentSaveCompact();
testConcurrentDataType(); testConcurrentDataType();
...@@ -68,7 +65,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -68,7 +65,7 @@ public class TestConcurrent extends TestMVStore {
} }
private void testInterruptReopen() throws Exception { private void testInterruptReopen() throws Exception {
String fileName = "retry:nio:" + getBaseDir() + "/testInterruptReopen.h3"; String fileName = "retry:nio:" + getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
final MVStore s = new MVStore.Builder(). final MVStore s = new MVStore.Builder().
fileName(fileName). fileName(fileName).
...@@ -99,7 +96,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -99,7 +96,7 @@ public class TestConcurrent extends TestMVStore {
} }
private void testConcurrentSaveCompact() throws Exception { private void testConcurrentSaveCompact() throws Exception {
String fileName = "memFS:testConcurrentSaveCompact"; String fileName = "memFS:" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
final MVStore s = new MVStore.Builder(). final MVStore s = new MVStore.Builder().
fileName(fileName). fileName(fileName).
...@@ -188,7 +185,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -188,7 +185,7 @@ public class TestConcurrent extends TestMVStore {
} }
private void testConcurrentAutoCommitAndChange() throws InterruptedException { private void testConcurrentAutoCommitAndChange() throws InterruptedException {
String fileName = "memFS:testConcurrentChangeAndBackgroundCompact"; String fileName = "memFS:" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
final MVStore s = new MVStore.Builder(). final MVStore s = new MVStore.Builder().
fileName(fileName).pageSplitSize(1000). fileName(fileName).pageSplitSize(1000).
...@@ -268,7 +265,7 @@ public class TestConcurrent extends TestMVStore { ...@@ -268,7 +265,7 @@ public class TestConcurrent extends TestMVStore {
} }
private void testConcurrentChangeAndCompact() throws InterruptedException { private void testConcurrentChangeAndCompact() throws InterruptedException {
String fileName = "memFS:testConcurrentChangeAndBackgroundCompact"; String fileName = "memFS:" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
final MVStore s = new MVStore.Builder().fileName( final MVStore s = new MVStore.Builder().fileName(
fileName). fileName).
...@@ -346,11 +343,10 @@ public class TestConcurrent extends TestMVStore { ...@@ -346,11 +343,10 @@ public class TestConcurrent extends TestMVStore {
s.commit(); s.commit();
s.close(); s.close();
} }
FileUtils.deleteRecursive("memFS:", false);
} }
private void testConcurrentFree() throws InterruptedException { private void testConcurrentFree() throws InterruptedException {
String fileName = "memFS:testConcurrentFree.h3"; String fileName = "memFS:" + getTestName();
for (int test = 0; test < 10; test++) { for (int test = 0; test < 10; test++) {
FileUtils.delete(fileName); FileUtils.delete(fileName);
final MVStore s1 = new MVStore.Builder(). final MVStore s1 = new MVStore.Builder().
...@@ -425,11 +421,11 @@ public class TestConcurrent extends TestMVStore { ...@@ -425,11 +421,11 @@ public class TestConcurrent extends TestMVStore {
assertTrue("" + chunkCount, chunkCount < 3); assertTrue("" + chunkCount, chunkCount < 3);
s.close(); s.close();
} }
FileUtils.deleteRecursive("memFS:", false);
} }
private void testConcurrentStoreAndRemoveMap() throws InterruptedException { private void testConcurrentStoreAndRemoveMap() throws InterruptedException {
String fileName = "memFS:testConcurrentStoreAndRemoveMap.h3"; String fileName = "memFS:" + getTestName();
FileUtils.delete(fileName);
final MVStore s = openStore(fileName); final MVStore s = openStore(fileName);
int count = 200; int count = 200;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
...@@ -458,11 +454,10 @@ public class TestConcurrent extends TestMVStore { ...@@ -458,11 +454,10 @@ public class TestConcurrent extends TestMVStore {
} }
task.get(); task.get();
s.close(); s.close();
FileUtils.deleteRecursive("memFS:", false);
} }
private void testConcurrentStoreAndClose() throws InterruptedException { private void testConcurrentStoreAndClose() throws InterruptedException {
String fileName = "memFS:testConcurrentStoreAndClose"; String fileName = "memFS:" + getTestName();
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
FileUtils.delete(fileName); FileUtils.delete(fileName);
final MVStore s = openStore(fileName); final MVStore s = openStore(fileName);
...@@ -500,7 +495,6 @@ public class TestConcurrent extends TestMVStore { ...@@ -500,7 +495,6 @@ public class TestConcurrent extends TestMVStore {
} }
s.close(); s.close();
} }
FileUtils.deleteRecursive("memFS:", false);
} }
/** /**
...@@ -557,8 +551,8 @@ public class TestConcurrent extends TestMVStore { ...@@ -557,8 +551,8 @@ public class TestConcurrent extends TestMVStore {
} }
private void testConcurrentOnlineBackup() throws Exception { private void testConcurrentOnlineBackup() throws Exception {
String fileName = getBaseDir() + "/onlineBackup.h3"; String fileName = getBaseDir() + "/" + getTestName();
String fileNameRestore = getBaseDir() + "/onlineRestore.h3"; String fileNameRestore = getBaseDir() + "/" + getTestName() + "2";
final MVStore s = openStore(fileName); final MVStore s = openStore(fileName);
final MVMap<Integer, byte[]> map = s.openMap("test"); final MVMap<Integer, byte[]> map = s.openMap("test");
final Random r = new Random(); final Random r = new Random();
......
...@@ -44,9 +44,6 @@ public class TestMVRTree extends TestMVStore { ...@@ -44,9 +44,6 @@ public class TestMVRTree extends TestMVStore {
@Override @Override
public void test() { public void test() {
FileUtils.deleteRecursive(getBaseDir(), true);
FileUtils.createDirectories(getBaseDir());
testRemoveAll(); testRemoveAll();
testRandomInsert(); testRandomInsert();
testSpatialKey(); testSpatialKey();
...@@ -58,7 +55,7 @@ public class TestMVRTree extends TestMVStore { ...@@ -58,7 +55,7 @@ public class TestMVRTree extends TestMVStore {
} }
private void testRemoveAll() { private void testRemoveAll() {
String fileName = getBaseDir() + "/testRemoveAll.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
s = new MVStore.Builder().fileName(fileName). s = new MVStore.Builder().fileName(fileName).
...@@ -77,7 +74,7 @@ public class TestMVRTree extends TestMVStore { ...@@ -77,7 +74,7 @@ public class TestMVRTree extends TestMVStore {
} }
private void testRandomInsert() { private void testRandomInsert() {
String fileName = getBaseDir() + "/testMany.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
s = new MVStore.Builder().fileName(fileName). s = new MVStore.Builder().fileName(fileName).
...@@ -143,7 +140,7 @@ public class TestMVRTree extends TestMVStore { ...@@ -143,7 +140,7 @@ public class TestMVRTree extends TestMVStore {
} }
private void testMany() { private void testMany() {
String fileName = getBaseDir() + "/testMany.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
s = openStore(fileName); s = openStore(fileName);
...@@ -209,7 +206,7 @@ public class TestMVRTree extends TestMVStore { ...@@ -209,7 +206,7 @@ public class TestMVRTree extends TestMVStore {
} }
private void testSimple() { private void testSimple() {
String fileName = getBaseDir() + "/testTree.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
s = openStore(fileName); s = openStore(fileName);
...@@ -387,7 +384,7 @@ public class TestMVRTree extends TestMVStore { ...@@ -387,7 +384,7 @@ public class TestMVRTree extends TestMVStore {
} }
private void testRandom(boolean quadraticSplit) { private void testRandom(boolean quadraticSplit) {
String fileName = getBaseDir() + "/testRandom.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
......
...@@ -50,8 +50,6 @@ public class TestMVStore extends TestBase { ...@@ -50,8 +50,6 @@ public class TestMVStore extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
FileUtils.createDirectories(getBaseDir());
testRemoveMapRollback(); testRemoveMapRollback();
testProvidedFileStoreNotOpenedAndClosed(); testProvidedFileStoreNotOpenedAndClosed();
testVolatileMap(); testVolatileMap();
...@@ -127,7 +125,8 @@ public class TestMVStore extends TestBase { ...@@ -127,7 +125,8 @@ public class TestMVStore extends TestBase {
assertNull(map.get("1")); assertNull(map.get("1"));
store.close(); store.close();
String fileName = getBaseDir() + "/testRemoveMapRollback.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
store = new MVStore.Builder(). store = new MVStore.Builder().
autoCommitDisabled(). autoCommitDisabled().
fileName(fileName). fileName(fileName).
...@@ -168,7 +167,8 @@ public class TestMVStore extends TestBase { ...@@ -168,7 +167,8 @@ public class TestMVStore extends TestBase {
} }
private void testVolatileMap() { private void testVolatileMap() {
String fileName = getBaseDir() + "/testVolatile.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore store = new MVStore.Builder(). MVStore store = new MVStore.Builder().
fileName(fileName). fileName(fileName).
open(); open();
...@@ -205,7 +205,8 @@ public class TestMVStore extends TestBase { ...@@ -205,7 +205,8 @@ public class TestMVStore extends TestBase {
} }
private void testCompressEmptyPage() { private void testCompressEmptyPage() {
String fileName = getBaseDir() + "/testDeletedMap.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore store = new MVStore.Builder(). MVStore store = new MVStore.Builder().
cacheSize(100).fileName(fileName). cacheSize(100).fileName(fileName).
compress(). compress().
...@@ -222,7 +223,8 @@ public class TestMVStore extends TestBase { ...@@ -222,7 +223,8 @@ public class TestMVStore extends TestBase {
} }
private void testCompressed() { private void testCompressed() {
String fileName = getBaseDir() + "/testCompressed.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
long lastSize = 0; long lastSize = 0;
for (int level = 0; level <= 2; level++) { for (int level = 0; level <= 2; level++) {
FileUtils.delete(fileName); FileUtils.delete(fileName);
...@@ -254,7 +256,8 @@ public class TestMVStore extends TestBase { ...@@ -254,7 +256,8 @@ public class TestMVStore extends TestBase {
} }
private void testFileFormatExample() { private void testFileFormatExample() {
String fileName = getBaseDir() + "/testFileFormatExample.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore s = MVStore.open(fileName); MVStore s = MVStore.open(fileName);
MVMap<Integer, String> map = s.openMap("data"); MVMap<Integer, String> map = s.openMap("data");
for (int i = 0; i < 400; i++) { for (int i = 0; i < 400; i++) {
...@@ -270,7 +273,8 @@ public class TestMVStore extends TestBase { ...@@ -270,7 +273,8 @@ public class TestMVStore extends TestBase {
} }
private void testMaxChunkLength() { private void testMaxChunkLength() {
String fileName = getBaseDir() + "/testMaxChunkLength.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore s = new MVStore.Builder().fileName(fileName).open(); MVStore s = new MVStore.Builder().fileName(fileName).open();
MVMap<Integer, byte[]> map = s.openMap("data"); MVMap<Integer, byte[]> map = s.openMap("data");
map.put(0, new byte[2 * 1024 * 1024]); map.put(0, new byte[2 * 1024 * 1024]);
...@@ -285,7 +289,8 @@ public class TestMVStore extends TestBase { ...@@ -285,7 +289,8 @@ public class TestMVStore extends TestBase {
} }
private void testCacheInfo() { private void testCacheInfo() {
String fileName = getBaseDir() + "/testCloseMap.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore s = new MVStore.Builder().fileName(fileName).cacheSize(2).open(); MVStore s = new MVStore.Builder().fileName(fileName).cacheSize(2).open();
assertEquals(2, s.getCacheSize()); assertEquals(2, s.getCacheSize());
MVMap<Integer, byte[]> map; MVMap<Integer, byte[]> map;
...@@ -355,7 +360,7 @@ public class TestMVStore extends TestBase { ...@@ -355,7 +360,7 @@ public class TestMVStore extends TestBase {
} }
private void testRemoveMap() throws Exception { private void testRemoveMap() throws Exception {
String fileName = getBaseDir() + "/testCloseMap.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = new MVStore.Builder(). MVStore s = new MVStore.Builder().
fileName(fileName). fileName(fileName).
...@@ -418,7 +423,7 @@ public class TestMVStore extends TestBase { ...@@ -418,7 +423,7 @@ public class TestMVStore extends TestBase {
} }
private void testNewerWriteVersion() throws Exception { private void testNewerWriteVersion() throws Exception {
String fileName = getBaseDir() + "/testNewerWriteVersion.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = new MVStore.Builder(). MVStore s = new MVStore.Builder().
encryptionKey("007".toCharArray()). encryptionKey("007".toCharArray()).
...@@ -475,7 +480,7 @@ public class TestMVStore extends TestBase { ...@@ -475,7 +480,7 @@ public class TestMVStore extends TestBase {
} }
private void testCompactFully() throws Exception { private void testCompactFully() throws Exception {
String fileName = getBaseDir() + "/testCompactFully.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = new MVStore.Builder(). MVStore s = new MVStore.Builder().
fileName(fileName). fileName(fileName).
...@@ -500,7 +505,7 @@ public class TestMVStore extends TestBase { ...@@ -500,7 +505,7 @@ public class TestMVStore extends TestBase {
} }
private void testBackgroundExceptionListener() throws Exception { private void testBackgroundExceptionListener() throws Exception {
String fileName = getBaseDir() + "/testBackgroundExceptionListener.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
final AtomicReference<Throwable> exRef = final AtomicReference<Throwable> exRef =
...@@ -516,28 +521,34 @@ public class TestMVStore extends TestBase { ...@@ -516,28 +521,34 @@ public class TestMVStore extends TestBase {
}). }).
open(); open();
s.setAutoCommitDelay(50); s.setAutoCommitDelay(10);
MVMap<Integer, String> m; MVMap<Integer, String> m;
m = s.openMap("data"); m = s.openMap("data");
s.getFileStore().getFile().close(); s.getFileStore().getFile().close();
try {
m.put(1, "Hello"); m.put(1, "Hello");
for (int i = 0; i < 200; i++) { for (int i = 0; i < 200; i++) {
if (exRef.get() != null) { if (exRef.get() != null) {
break; break;
} }
Thread.sleep(1); Thread.sleep(10);
} }
Throwable e = exRef.get(); Throwable e = exRef.get();
assertTrue(e != null); assertTrue(e != null);
assertEquals(DataUtils.ERROR_WRITING_FAILED, assertEquals(DataUtils.ERROR_WRITING_FAILED,
DataUtils.getErrorCode(e.getMessage())); DataUtils.getErrorCode(e.getMessage()));
} catch (IllegalStateException e) {
// sometimes it is detected right away
assertEquals(DataUtils.ERROR_CLOSED,
DataUtils.getErrorCode(e.getMessage()));
}
s.closeImmediately(); s.closeImmediately();
FileUtils.delete(fileName); FileUtils.delete(fileName);
} }
private void testAtomicOperations() { private void testAtomicOperations() {
String fileName = getBaseDir() + "/testAtomicOperations.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
MVMap<Integer, byte[]> m; MVMap<Integer, byte[]> m;
...@@ -572,7 +583,7 @@ public class TestMVStore extends TestBase { ...@@ -572,7 +583,7 @@ public class TestMVStore extends TestBase {
} }
private void testWriteBuffer() { private void testWriteBuffer() {
String fileName = getBaseDir() + "/testWriteBuffer.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
MVMap<Integer, byte[]> m; MVMap<Integer, byte[]> m;
...@@ -617,7 +628,8 @@ public class TestMVStore extends TestBase { ...@@ -617,7 +628,8 @@ public class TestMVStore extends TestBase {
} }
private void testWriteDelay() throws InterruptedException { private void testWriteDelay() throws InterruptedException {
String fileName = getBaseDir() + "/testWriteDelay.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore s; MVStore s;
MVMap<Integer, String> m; MVMap<Integer, String> m;
...@@ -640,34 +652,33 @@ public class TestMVStore extends TestBase { ...@@ -640,34 +652,33 @@ public class TestMVStore extends TestBase {
s = new MVStore.Builder(). s = new MVStore.Builder().
fileName(fileName). fileName(fileName).
open(); open();
s.setAutoCommitDelay(1);
m = s.openMap("data"); m = s.openMap("data");
m.put(1, "Hello"); m.put(1, "Hello");
s.commit();
long v = s.getCurrentVersion();
m.put(2, "World."); m.put(2, "World.");
Thread.sleep(5); s.commit();
// must not store, as nothing has been committed yet s.close();
s.closeImmediately();
s = new MVStore.Builder(). s = new MVStore.Builder().
fileName(fileName). fileName(fileName).
open(); open();
s.setAutoCommitDelay(1); s.setAutoCommitDelay(2);
m = s.openMap("data"); m = s.openMap("data");
assertEquals("World.", m.get(2)); assertEquals("World.", m.get(2));
m.put(2, "World"); m.put(2, "World");
s.commit(); s.commit();
v = s.getCurrentVersion(); long v = s.getCurrentVersion();
long time = System.currentTimeMillis();
m.put(3, "!"); m.put(3, "!");
for (int i = 100; i > 0; i--) { for (int i = 200; i > 0; i--) {
if (s.getCurrentVersion() > v) { if (s.getCurrentVersion() > v) {
break; break;
} }
if (i < 10) { long diff = System.currentTimeMillis() - time;
if (diff > 1000) {
fail(); fail();
} }
Thread.sleep(1); Thread.sleep(10);
} }
s.closeImmediately(); s.closeImmediately();
...@@ -684,7 +695,7 @@ public class TestMVStore extends TestBase { ...@@ -684,7 +695,7 @@ public class TestMVStore extends TestBase {
} }
private void testEncryptedFile() { private void testEncryptedFile() {
String fileName = getBaseDir() + "/testEncryptedFile.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
MVMap<Integer, String> m; MVMap<Integer, String> m;
...@@ -741,7 +752,7 @@ public class TestMVStore extends TestBase { ...@@ -741,7 +752,7 @@ public class TestMVStore extends TestBase {
} }
private void testFileFormatChange() { private void testFileFormatChange() {
String fileName = getBaseDir() + "/testFileFormatChange.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
MVMap<Integer, Integer> m; MVMap<Integer, Integer> m;
...@@ -774,7 +785,7 @@ public class TestMVStore extends TestBase { ...@@ -774,7 +785,7 @@ public class TestMVStore extends TestBase {
} }
private void testRecreateMap() { private void testRecreateMap() {
String fileName = getBaseDir() + "/testRecreateMap.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
MVMap<Integer, Integer> m = s.openMap("test"); MVMap<Integer, Integer> m = s.openMap("test");
...@@ -805,7 +816,7 @@ public class TestMVStore extends TestBase { ...@@ -805,7 +816,7 @@ public class TestMVStore extends TestBase {
} }
private void testCustomMapType() { private void testCustomMapType() {
String fileName = getBaseDir() + "/testMapType.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
SequenceMap seq = s.openMap("data", new SequenceMap.Builder()); SequenceMap seq = s.openMap("data", new SequenceMap.Builder());
...@@ -818,7 +829,8 @@ public class TestMVStore extends TestBase { ...@@ -818,7 +829,8 @@ public class TestMVStore extends TestBase {
} }
private void testCacheSize() { private void testCacheSize() {
String fileName = getBaseDir() + "/testCacheSize.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore s; MVStore s;
MVMap<Integer, String> map; MVMap<Integer, String> map;
s = new MVStore.Builder(). s = new MVStore.Builder().
...@@ -857,7 +869,8 @@ public class TestMVStore extends TestBase { ...@@ -857,7 +869,8 @@ public class TestMVStore extends TestBase {
} }
private void testConcurrentOpen() { private void testConcurrentOpen() {
String fileName = getBaseDir() + "/testConcurrentOpen.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore s = new MVStore.Builder().fileName(fileName).open(); MVStore s = new MVStore.Builder().fileName(fileName).open();
try { try {
MVStore s1 = new MVStore.Builder().fileName(fileName).open(); MVStore s1 = new MVStore.Builder().fileName(fileName).open();
...@@ -881,7 +894,8 @@ public class TestMVStore extends TestBase { ...@@ -881,7 +894,8 @@ public class TestMVStore extends TestBase {
} }
private void testFileHeader() { private void testFileHeader() {
String fileName = getBaseDir() + "/testFileHeader.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
s.setRetentionTime(Integer.MAX_VALUE); s.setRetentionTime(Integer.MAX_VALUE);
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
...@@ -910,7 +924,8 @@ public class TestMVStore extends TestBase { ...@@ -910,7 +924,8 @@ public class TestMVStore extends TestBase {
} }
private void testFileHeaderCorruption() throws Exception { private void testFileHeaderCorruption() throws Exception {
String fileName = getBaseDir() + "/testFileHeader.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore s = new MVStore.Builder(). MVStore s = new MVStore.Builder().
fileName(fileName).pageSplitSize(1000).autoCommitDisabled().open(); fileName(fileName).pageSplitSize(1000).autoCommitDisabled().open();
s.setRetentionTime(0); s.setRetentionTime(0);
...@@ -1100,7 +1115,7 @@ public class TestMVStore extends TestBase { ...@@ -1100,7 +1115,7 @@ public class TestMVStore extends TestBase {
} }
private void testStoreVersion() { private void testStoreVersion() {
String fileName = getBaseDir() + "/testStoreVersion.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = MVStore.open(fileName); MVStore s = MVStore.open(fileName);
assertEquals(0, s.getCurrentVersion()); assertEquals(0, s.getCurrentVersion());
...@@ -1144,7 +1159,7 @@ public class TestMVStore extends TestBase { ...@@ -1144,7 +1159,7 @@ public class TestMVStore extends TestBase {
} }
private void testObjects() { private void testObjects() {
String fileName = getBaseDir() + "/testObjects.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
Map<Object, Object> map; Map<Object, Object> map;
...@@ -1167,7 +1182,7 @@ public class TestMVStore extends TestBase { ...@@ -1167,7 +1182,7 @@ public class TestMVStore extends TestBase {
} }
private void testExample() { private void testExample() {
String fileName = getBaseDir() + "/testExample.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
// open the store (in-memory if fileName is null) // open the store (in-memory if fileName is null)
...@@ -1190,7 +1205,7 @@ public class TestMVStore extends TestBase { ...@@ -1190,7 +1205,7 @@ public class TestMVStore extends TestBase {
} }
private void testExampleMvcc() { private void testExampleMvcc() {
String fileName = getBaseDir() + "/testExampleMvcc.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
// open the store (in-memory if fileName is null) // open the store (in-memory if fileName is null)
...@@ -1236,7 +1251,7 @@ public class TestMVStore extends TestBase { ...@@ -1236,7 +1251,7 @@ public class TestMVStore extends TestBase {
} }
private void testOpenStoreCloseLoop() { private void testOpenStoreCloseLoop() {
String fileName = getBaseDir() + "/testOpenClose.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
for (int k = 0; k < 1; k++) { for (int k = 0; k < 1; k++) {
// long t = System.currentTimeMillis(); // long t = System.currentTimeMillis();
...@@ -1282,7 +1297,7 @@ public class TestMVStore extends TestBase { ...@@ -1282,7 +1297,7 @@ public class TestMVStore extends TestBase {
} }
private void testVersion() { private void testVersion() {
String fileName = getBaseDir() + "/testVersion.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
s = openStore(fileName); s = openStore(fileName);
...@@ -1347,7 +1362,7 @@ public class TestMVStore extends TestBase { ...@@ -1347,7 +1362,7 @@ public class TestMVStore extends TestBase {
} }
private void testTruncateFile() { private void testTruncateFile() {
String fileName = getBaseDir() + "/testTruncate.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
MVMap<Integer, String> m; MVMap<Integer, String> m;
...@@ -1377,7 +1392,7 @@ public class TestMVStore extends TestBase { ...@@ -1377,7 +1392,7 @@ public class TestMVStore extends TestBase {
} }
private void testFastDelete() { private void testFastDelete() {
String fileName = getBaseDir() + "/testFastDelete.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s; MVStore s;
MVMap<Integer, String> m; MVMap<Integer, String> m;
...@@ -1419,7 +1434,7 @@ public class TestMVStore extends TestBase { ...@@ -1419,7 +1434,7 @@ public class TestMVStore extends TestBase {
} }
private void testRollbackStored() { private void testRollbackStored() {
String fileName = getBaseDir() + "/testRollback.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVMap<String, String> meta; MVMap<String, String> meta;
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
...@@ -1512,7 +1527,7 @@ public class TestMVStore extends TestBase { ...@@ -1512,7 +1527,7 @@ public class TestMVStore extends TestBase {
} }
private void testRollbackInMemory() { private void testRollbackInMemory() {
String fileName = getBaseDir() + "/testRollback.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName, 5); MVStore s = openStore(fileName, 5);
s.setAutoCommitDelay(0); s.setAutoCommitDelay(0);
...@@ -1553,7 +1568,7 @@ public class TestMVStore extends TestBase { ...@@ -1553,7 +1568,7 @@ public class TestMVStore extends TestBase {
} }
private void testMeta() { private void testMeta() {
String fileName = getBaseDir() + "/testMeta.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
s.setRetentionTime(Integer.MAX_VALUE); s.setRetentionTime(Integer.MAX_VALUE);
...@@ -1623,7 +1638,8 @@ public class TestMVStore extends TestBase { ...@@ -1623,7 +1638,8 @@ public class TestMVStore extends TestBase {
} }
private void testLargeImport() { private void testLargeImport() {
String fileName = getBaseDir() + "/testImport.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
int len = 1000; int len = 1000;
for (int j = 0; j < 5; j++) { for (int j = 0; j < 5; j++) {
FileUtils.delete(fileName); FileUtils.delete(fileName);
...@@ -1659,7 +1675,7 @@ public class TestMVStore extends TestBase { ...@@ -1659,7 +1675,7 @@ public class TestMVStore extends TestBase {
} }
private void testBtreeStore() { private void testBtreeStore() {
String fileName = getBaseDir() + "/testBtreeStore.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
s.close(); s.close();
...@@ -1707,7 +1723,7 @@ public class TestMVStore extends TestBase { ...@@ -1707,7 +1723,7 @@ public class TestMVStore extends TestBase {
} }
private void testCompactMapNotOpen() { private void testCompactMapNotOpen() {
String fileName = getBaseDir() + "/testCompactNotOpen.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName, 1000); MVStore s = openStore(fileName, 1000);
MVMap<Integer, String> m = s.openMap("data"); MVMap<Integer, String> m = s.openMap("data");
...@@ -1767,7 +1783,7 @@ public class TestMVStore extends TestBase { ...@@ -1767,7 +1783,7 @@ public class TestMVStore extends TestBase {
} }
private void testCompact() { private void testCompact() {
String fileName = getBaseDir() + "/testCompact.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
long initialLength = 0; long initialLength = 0;
for (int j = 0; j < 20; j++) { for (int j = 0; j < 20; j++) {
...@@ -1808,7 +1824,7 @@ public class TestMVStore extends TestBase { ...@@ -1808,7 +1824,7 @@ public class TestMVStore extends TestBase {
} }
private void testReuseSpace() { private void testReuseSpace() {
String fileName = getBaseDir() + "/testReuseSpace.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
long initialLength = 0; long initialLength = 0;
for (int j = 0; j < 20; j++) { for (int j = 0; j < 20; j++) {
...@@ -1835,7 +1851,7 @@ public class TestMVStore extends TestBase { ...@@ -1835,7 +1851,7 @@ public class TestMVStore extends TestBase {
} }
private void testRandom() { private void testRandom() {
String fileName = getBaseDir() + "/testRandom.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
MVMap<Integer, Integer> m = s.openMap("data"); MVMap<Integer, Integer> m = s.openMap("data");
...@@ -1898,7 +1914,7 @@ public class TestMVStore extends TestBase { ...@@ -1898,7 +1914,7 @@ public class TestMVStore extends TestBase {
} }
private void testKeyValueClasses() { private void testKeyValueClasses() {
String fileName = getBaseDir() + "/testKeyValueClasses.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
MVMap<Integer, String> is = s.openMap("intString"); MVMap<Integer, String> is = s.openMap("intString");
...@@ -1923,7 +1939,7 @@ public class TestMVStore extends TestBase { ...@@ -1923,7 +1939,7 @@ public class TestMVStore extends TestBase {
} }
private void testIterate() { private void testIterate() {
String fileName = getBaseDir() + "/testIterate.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
MVMap<Integer, String> m = s.openMap("data"); MVMap<Integer, String> m = s.openMap("data");
...@@ -1956,7 +1972,7 @@ public class TestMVStore extends TestBase { ...@@ -1956,7 +1972,7 @@ public class TestMVStore extends TestBase {
} }
private void testCloseTwice() { private void testCloseTwice() {
String fileName = getBaseDir() + "/testCloseTwice.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
MVMap<Integer, String> m = s.openMap("data"); MVMap<Integer, String> m = s.openMap("data");
...@@ -1969,7 +1985,7 @@ public class TestMVStore extends TestBase { ...@@ -1969,7 +1985,7 @@ public class TestMVStore extends TestBase {
} }
private void testSimple() { private void testSimple() {
String fileName = getBaseDir() + "/testSimple.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore s = openStore(fileName); MVStore s = openStore(fileName);
MVMap<Integer, String> m = s.openMap("data"); MVMap<Integer, String> m = s.openMap("data");
...@@ -1998,7 +2014,7 @@ public class TestMVStore extends TestBase { ...@@ -1998,7 +2014,7 @@ public class TestMVStore extends TestBase {
if (!config.big) { if (!config.big) {
return; return;
} }
String fileName = getBaseDir() + "/testLargerThan2G.h3"; String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName); FileUtils.delete(fileName);
MVStore store = new MVStore.Builder().cacheSize(16). MVStore store = new MVStore.Builder().cacheSize(16).
fileName(fileName).open(); fileName(fileName).open();
......
...@@ -29,7 +29,6 @@ import org.h2.mvstore.MVStore; ...@@ -29,7 +29,6 @@ import org.h2.mvstore.MVStore;
import org.h2.mvstore.db.TransactionStore; import org.h2.mvstore.db.TransactionStore;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.tools.DeleteDbFiles;
import org.h2.tools.Recover; import org.h2.tools.Recover;
import org.h2.tools.Restore; import org.h2.tools.Restore;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
...@@ -89,14 +88,14 @@ public class TestMVTableEngine extends TestBase { ...@@ -89,14 +88,14 @@ public class TestMVTableEngine extends TestBase {
} }
private void testLobReuse() throws Exception { private void testLobReuse() throws Exception {
deleteDb("testLobReuse"); deleteDb(getTestName());
Connection conn = getConnection("testLobReuse"); Connection conn = getConnection(getTestName());
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(id identity primary key, lob clob)"); stat.execute("create table test(id identity primary key, lob clob)");
conn.close(); conn.close();
byte[] buffer = new byte[8192]; byte[] buffer = new byte[8192];
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
conn = getConnection("testLobReuse"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("insert into test(lob) select space(1025) from system_range(1, 10)"); stat.execute("insert into test(lob) select space(1025) from system_range(1, 10)");
stat.execute("delete from test where random() > 0.5"); stat.execute("delete from test where random() > 0.5");
...@@ -113,8 +112,8 @@ public class TestMVTableEngine extends TestBase { ...@@ -113,8 +112,8 @@ public class TestMVTableEngine extends TestBase {
} }
private void testShutdownDuringLobCreation() throws Exception { private void testShutdownDuringLobCreation() throws Exception {
deleteDb("testShutdownDuringLobCreation"); deleteDb(getTestName());
Connection conn = getConnection("testShutdownDuringLobCreation"); Connection conn = getConnection(getTestName());
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(data clob) as select space(10000)"); stat.execute("create table test(data clob) as select space(10000)");
final PreparedStatement prep = conn final PreparedStatement prep = conn
...@@ -159,7 +158,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -159,7 +158,7 @@ public class TestMVTableEngine extends TestBase {
} catch (Exception e) { } catch (Exception e) {
// ignore // ignore
} }
conn = getConnection("testShutdownDuringLobCreation"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("shutdown defrag"); stat.execute("shutdown defrag");
try { try {
...@@ -167,7 +166,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -167,7 +166,7 @@ public class TestMVTableEngine extends TestBase {
} catch (Exception e) { } catch (Exception e) {
// ignore // ignore
} }
conn = getConnection("testShutdownDuringLobCreation"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select * " + ResultSet rs = stat.executeQuery("select * " +
"from information_schema.settings " + "from information_schema.settings " +
...@@ -180,8 +179,8 @@ public class TestMVTableEngine extends TestBase { ...@@ -180,8 +179,8 @@ public class TestMVTableEngine extends TestBase {
} }
private void testLobCreationThenShutdown() throws Exception { private void testLobCreationThenShutdown() throws Exception {
deleteDb("testLobCreationThenShutdown"); deleteDb(getTestName());
Connection conn = getConnection("testLobCreationThenShutdown"); Connection conn = getConnection(getTestName());
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(id identity, data clob)"); stat.execute("create table test(id identity, data clob)");
PreparedStatement prep = conn PreparedStatement prep = conn
...@@ -199,7 +198,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -199,7 +198,7 @@ public class TestMVTableEngine extends TestBase {
} catch (Exception e) { } catch (Exception e) {
// ignore // ignore
} }
conn = getConnection("testLobCreationThenShutdown"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("drop all objects"); stat.execute("drop all objects");
stat.execute("shutdown defrag"); stat.execute("shutdown defrag");
...@@ -208,7 +207,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -208,7 +207,7 @@ public class TestMVTableEngine extends TestBase {
} catch (Exception e) { } catch (Exception e) {
// ignore // ignore
} }
conn = getConnection("testLobCreationThenShutdown"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select * " + ResultSet rs = stat.executeQuery("select * " +
"from information_schema.settings " + "from information_schema.settings " +
...@@ -221,14 +220,14 @@ public class TestMVTableEngine extends TestBase { ...@@ -221,14 +220,14 @@ public class TestMVTableEngine extends TestBase {
} }
private void testManyTransactions() throws Exception { private void testManyTransactions() throws Exception {
deleteDb("testManyTransactions"); deleteDb(getTestName());
Connection conn = getConnection("testManyTransactions"); Connection conn = getConnection(getTestName());
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test()"); stat.execute("create table test()");
conn.setAutoCommit(false); conn.setAutoCommit(false);
stat.execute("insert into test values()"); stat.execute("insert into test values()");
Connection conn2 = getConnection("testManyTransactions"); Connection conn2 = getConnection(getTestName());
Statement stat2 = conn2.createStatement(); Statement stat2 = conn2.createStatement();
for (long i = 0; i < 100000; i++) { for (long i = 0; i < 100000; i++) {
stat2.execute("insert into test values()"); stat2.execute("insert into test values()");
...@@ -238,9 +237,8 @@ public class TestMVTableEngine extends TestBase { ...@@ -238,9 +237,8 @@ public class TestMVTableEngine extends TestBase {
} }
private void testAppendOnly() throws Exception { private void testAppendOnly() throws Exception {
deleteDb("testAppendOnly"); deleteDb(getTestName());
Connection conn = getConnection( Connection conn = getConnection(getTestName());
"testAppendOnly");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("set retention_time 0"); stat.execute("set retention_time 0");
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
...@@ -250,11 +248,11 @@ public class TestMVTableEngine extends TestBase { ...@@ -250,11 +248,11 @@ public class TestMVTableEngine extends TestBase {
} }
stat.execute("create table test as select x from system_range(1, 1000)"); stat.execute("create table test as select x from system_range(1, 1000)");
conn.close(); conn.close();
String fileName = getBaseDir() + "/testAppendOnly" + Constants.SUFFIX_MV_FILE; String fileName = getBaseDir() + "/" + getTestName() + Constants.SUFFIX_MV_FILE;
long fileSize = FileUtils.size(fileName); long fileSize = FileUtils.size(fileName);
conn = getConnection( conn = getConnection(
"testAppendOnly;reuse_space=false"); getTestName() + ";reuse_space=false");
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("set retention_time 0"); stat.execute("set retention_time 0");
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
...@@ -270,8 +268,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -270,8 +268,7 @@ public class TestMVTableEngine extends TestBase {
// undo all changes // undo all changes
fc.truncate(fileSize); fc.truncate(fileSize);
conn = getConnection( conn = getConnection(getTestName());
"testAppendOnly");
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("select * from dummy0 where 1 = 0"); stat.execute("select * from dummy0 where 1 = 0");
stat.execute("select * from dummy9 where 1 = 0"); stat.execute("select * from dummy9 where 1 = 0");
...@@ -280,11 +277,11 @@ public class TestMVTableEngine extends TestBase { ...@@ -280,11 +277,11 @@ public class TestMVTableEngine extends TestBase {
} }
private void testLowRetentionTime() throws SQLException { private void testLowRetentionTime() throws SQLException {
deleteDb("testLowRetentionTime"); deleteDb(getTestName());
Connection conn = getConnection( Connection conn = getConnection(
"testLowRetentionTime;RETENTION_TIME=10;WRITE_DELAY=10"); getTestName() + ";RETENTION_TIME=10;WRITE_DELAY=10");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
Connection conn2 = getConnection("testLowRetentionTime"); Connection conn2 = getConnection(getTestName());
Statement stat2 = conn2.createStatement(); Statement stat2 = conn2.createStatement();
stat.execute("create alias sleep as " + stat.execute("create alias sleep as " +
"$$void sleep(int ms) throws Exception { Thread.sleep(ms); }$$"); "$$void sleep(int ms) throws Exception { Thread.sleep(ms); }$$");
...@@ -309,12 +306,11 @@ public class TestMVTableEngine extends TestBase { ...@@ -309,12 +306,11 @@ public class TestMVTableEngine extends TestBase {
} }
private void testOldAndNew() throws SQLException { private void testOldAndNew() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
deleteDb(getTestName());
String urlOld = getURL("mvstore;MV_STORE=FALSE", true); String urlOld = getURL(getTestName() + ";MV_STORE=FALSE", true);
String urlNew = getURL("mvstore;MV_STORE=TRUE", true); String urlNew = getURL(getTestName() + ";MV_STORE=TRUE", true);
String url = getURL("mvstore", true); String url = getURL(getTestName(), true);
conn = getConnection(urlOld); conn = getConnection(urlOld);
conn.createStatement().execute("create table test_old(id int)"); conn.createStatement().execute("create table test_old(id int)");
...@@ -337,10 +333,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -337,10 +333,10 @@ public class TestMVTableEngine extends TestBase {
} }
private void testTemporaryTables() throws SQLException { private void testTemporaryTables() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
String url = "mvstore;MV_STORE=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -365,10 +361,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -365,10 +361,10 @@ public class TestMVTableEngine extends TestBase {
} }
private void testUniqueIndex() throws SQLException { private void testUniqueIndex() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
String url = "mvstore;MV_STORE=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -381,10 +377,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -381,10 +377,10 @@ public class TestMVTableEngine extends TestBase {
} }
private void testSecondaryIndex() throws SQLException { private void testSecondaryIndex() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
String url = "mvstore;MV_STORE=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -403,10 +399,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -403,10 +399,10 @@ public class TestMVTableEngine extends TestBase {
} }
private void testGarbageCollectionForLOB() throws SQLException { private void testGarbageCollectionForLOB() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
String url = "mvstore;MV_STORE=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -425,7 +421,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -425,7 +421,7 @@ public class TestMVTableEngine extends TestBase {
assertThrows(ErrorCode.IO_EXCEPTION_1, prep). assertThrows(ErrorCode.IO_EXCEPTION_1, prep).
setBinaryStream(1, createFailingStream(new IllegalStateException())); setBinaryStream(1, createFailingStream(new IllegalStateException()));
conn.close(); conn.close();
MVStore s = MVStore.open(getBaseDir()+ "/mvstore.mv.db"); MVStore s = MVStore.open(getBaseDir()+ "/" + getTestName() + ".mv.db");
assertTrue(s.hasMap("lobData")); assertTrue(s.hasMap("lobData"));
MVMap<Long, byte[]> lobData = s.openMap("lobData"); MVMap<Long, byte[]> lobData = s.openMap("lobData");
assertEquals(0, lobData.sizeAsLong()); assertEquals(0, lobData.sizeAsLong());
...@@ -439,10 +435,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -439,10 +435,10 @@ public class TestMVTableEngine extends TestBase {
} }
private void testSpatial() throws SQLException { private void testSpatial() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
String url = "mvstore;MV_STORE=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -462,12 +458,12 @@ public class TestMVTableEngine extends TestBase { ...@@ -462,12 +458,12 @@ public class TestMVTableEngine extends TestBase {
return; return;
} }
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Connection conn2; Connection conn2;
Statement stat; Statement stat;
Statement stat2; Statement stat2;
String url = "mvstore;MV_STORE=TRUE;MVCC=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE;MVCC=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -519,12 +515,12 @@ public class TestMVTableEngine extends TestBase { ...@@ -519,12 +515,12 @@ public class TestMVTableEngine extends TestBase {
} }
private void testMinMaxWithNull() throws Exception { private void testMinMaxWithNull() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Connection conn2; Connection conn2;
Statement stat; Statement stat;
Statement stat2; Statement stat2;
String url = "mvstore;MV_STORE=TRUE;MVCC=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE;MVCC=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -549,12 +545,12 @@ public class TestMVTableEngine extends TestBase { ...@@ -549,12 +545,12 @@ public class TestMVTableEngine extends TestBase {
} }
private void testTimeout() throws Exception { private void testTimeout() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Connection conn2; Connection conn2;
Statement stat; Statement stat;
Statement stat2; Statement stat2;
String url = "mvstore;MV_STORE=TRUE;MVCC=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE;MVCC=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -574,10 +570,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -574,10 +570,10 @@ public class TestMVTableEngine extends TestBase {
if (config.memory) { if (config.memory) {
return; return;
} }
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
String url = "mvstore;MV_STORE=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -599,10 +595,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -599,10 +595,10 @@ public class TestMVTableEngine extends TestBase {
} }
private void testTransactionLogUsuallyNotStored() throws Exception { private void testTransactionLogUsuallyNotStored() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
String url = "mvstore;MV_STORE=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -619,7 +615,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -619,7 +615,7 @@ public class TestMVTableEngine extends TestBase {
stat.execute("shutdown immediately"); stat.execute("shutdown immediately");
JdbcUtils.closeSilently(conn); JdbcUtils.closeSilently(conn);
String file = getBaseDir() + "/mvstore" + Constants.SUFFIX_MV_FILE; String file = getBaseDir() + "/" + getTestName() + Constants.SUFFIX_MV_FILE;
MVStore store = MVStore.open(file); MVStore store = MVStore.open(file);
TransactionStore t = new TransactionStore(store); TransactionStore t = new TransactionStore(store);
...@@ -629,9 +625,8 @@ public class TestMVTableEngine extends TestBase { ...@@ -629,9 +625,8 @@ public class TestMVTableEngine extends TestBase {
} }
private void testShrinkDatabaseFile() throws Exception { private void testShrinkDatabaseFile() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); deleteDb(getTestName());
String dbName = "mvstore" + String dbName = getTestName() + ";MV_STORE=TRUE";
";MV_STORE=TRUE";
Connection conn; Connection conn;
Statement stat; Statement stat;
long maxSize = 0; long maxSize = 0;
...@@ -672,7 +667,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -672,7 +667,7 @@ public class TestMVTableEngine extends TestBase {
} catch (Exception e) { } catch (Exception e) {
// ignore // ignore
} }
String fileName = getBaseDir() + "/mvstore" String fileName = getBaseDir() + "/" + getTestName()
+ Constants.SUFFIX_MV_FILE; + Constants.SUFFIX_MV_FILE;
long size = FileUtils.size(fileName); long size = FileUtils.size(fileName);
if (i < 10) { if (i < 10) {
...@@ -681,22 +676,22 @@ public class TestMVTableEngine extends TestBase { ...@@ -681,22 +676,22 @@ public class TestMVTableEngine extends TestBase {
fail(i + " size: " + size + " max: " + maxSize); fail(i + " size: " + size + " max: " + maxSize);
} }
} }
long sizeOld = FileUtils.size(getBaseDir() + "/mvstore" long sizeOld = FileUtils.size(getBaseDir() + "/" + getTestName()
+ Constants.SUFFIX_MV_FILE); + Constants.SUFFIX_MV_FILE);
conn = getConnection(dbName); conn = getConnection(dbName);
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("shutdown compact"); stat.execute("shutdown compact");
conn.close(); conn.close();
long sizeNew = FileUtils.size(getBaseDir() + "/mvstore" long sizeNew = FileUtils.size(getBaseDir() + "/" + getTestName()
+ Constants.SUFFIX_MV_FILE); + Constants.SUFFIX_MV_FILE);
assertTrue("new: " + sizeNew + " old: " + sizeOld, sizeNew < sizeOld); assertTrue("new: " + sizeNew + " old: " + sizeOld, sizeNew < sizeOld);
} }
private void testTwoPhaseCommit() throws Exception { private void testTwoPhaseCommit() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
String url = "mvstore;MV_STORE=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -720,10 +715,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -720,10 +715,10 @@ public class TestMVTableEngine extends TestBase {
} }
private void testRecover() throws Exception { private void testRecover() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
String url = "mvstore;MV_STORE=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE";
url = getURL(url, true); url = getURL(url, true);
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -733,11 +728,11 @@ public class TestMVTableEngine extends TestBase { ...@@ -733,11 +728,11 @@ public class TestMVTableEngine extends TestBase {
stat.execute("insert into test2 values('Hello World')"); stat.execute("insert into test2 values('Hello World')");
conn.close(); conn.close();
Recover.execute(getBaseDir(), "mvstore"); Recover.execute(getBaseDir(), getTestName());
DeleteDbFiles.execute(getBaseDir(), "mvstore", true); deleteDb(getTestName());
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("runscript from '" + getBaseDir() + "/mvstore.h2.sql'"); stat.execute("runscript from '" + getBaseDir() + "/" + getTestName()+ ".h2.sql'");
ResultSet rs; ResultSet rs;
rs = stat.executeQuery("select * from test"); rs = stat.executeQuery("select * from test");
assertTrue(rs.next()); assertTrue(rs.next());
...@@ -750,10 +745,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -750,10 +745,10 @@ public class TestMVTableEngine extends TestBase {
} }
private void testRollback() throws Exception { private void testRollback() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
String url = "mvstore;MV_STORE=TRUE"; deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE";
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id identity)"); stat.execute("create table test(id identity)");
...@@ -765,11 +760,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -765,11 +760,10 @@ public class TestMVTableEngine extends TestBase {
} }
private void testSeparateKey() throws Exception { private void testSeparateKey() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
deleteDb(getTestName());
String url = "mvstore;MV_STORE=TRUE"; String url = getTestName() + ";MV_STORE=TRUE";
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -791,12 +785,11 @@ public class TestMVTableEngine extends TestBase { ...@@ -791,12 +785,11 @@ public class TestMVTableEngine extends TestBase {
} }
private void testRollbackAfterCrash() throws Exception { private void testRollbackAfterCrash() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
deleteDb(getTestName());
String url = "mvstore;MV_STORE=TRUE"; String url = getTestName() + ";MV_STORE=TRUE";
String url2 = "mvstore2;MV_STORE=TRUE"; String url2 = getTestName() + "2;MV_STORE=TRUE";
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -839,9 +832,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -839,9 +832,10 @@ public class TestMVTableEngine extends TestBase {
"from system_range(1, 10)"); "from system_range(1, 10)");
conn.setAutoCommit(false); conn.setAutoCommit(false);
stat.execute("delete from test where id > 5"); stat.execute("delete from test where id > 5");
stat.execute("backup to '" + getBaseDir() + "/backup.zip'"); stat.execute("backup to '" + getBaseDir() + "/" + getTestName() + ".zip'");
conn.rollback(); conn.rollback();
Restore.execute(getBaseDir() + "/backup.zip", getBaseDir(), "mvstore2"); Restore.execute(getBaseDir() + "/" +getTestName() + ".zip",
getBaseDir(), getTestName() + "2");
Connection conn2; Connection conn2;
conn2 = getConnection(url2); conn2 = getConnection(url2);
conn.close(); conn.close();
...@@ -850,11 +844,10 @@ public class TestMVTableEngine extends TestBase { ...@@ -850,11 +844,10 @@ public class TestMVTableEngine extends TestBase {
} }
private void testReferentialIntegrity() throws Exception { private void testReferentialIntegrity() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
deleteDb(getTestName());
conn = getConnection("mvstore;MV_STORE=TRUE"); conn = getConnection(getTestName() + ";MV_STORE=TRUE");
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id int, parent int " + stat.execute("create table test(id int, parent int " +
...@@ -923,11 +916,11 @@ public class TestMVTableEngine extends TestBase { ...@@ -923,11 +916,11 @@ public class TestMVTableEngine extends TestBase {
} }
private void testWriteDelay() throws Exception { private void testWriteDelay() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
ResultSet rs; ResultSet rs;
conn = getConnection("mvstore;MV_STORE=TRUE"); deleteDb(getTestName());
conn = getConnection(getTestName() + ";MV_STORE=TRUE");
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id int)"); stat.execute("create table test(id int)");
stat.execute("set write_delay 0"); stat.execute("set write_delay 0");
...@@ -938,7 +931,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -938,7 +931,7 @@ public class TestMVTableEngine extends TestBase {
} catch (Exception e) { } catch (Exception e) {
// ignore // ignore
} }
conn = getConnection("mvstore;MV_STORE=TRUE"); conn = getConnection(getTestName() + ";MV_STORE=TRUE");
stat = conn.createStatement(); stat = conn.createStatement();
rs = stat.executeQuery("select * from test"); rs = stat.executeQuery("select * from test");
assertTrue(rs.next()); assertTrue(rs.next());
...@@ -946,11 +939,11 @@ public class TestMVTableEngine extends TestBase { ...@@ -946,11 +939,11 @@ public class TestMVTableEngine extends TestBase {
} }
private void testAutoCommit() throws SQLException { private void testAutoCommit() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
ResultSet rs; ResultSet rs;
conn = getConnection("mvstore;MV_STORE=TRUE"); deleteDb(getTestName());
conn = getConnection(getTestName() + ";MV_STORE=TRUE");
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar)"); stat.execute("create table test(id int primary key, name varchar)");
...@@ -980,22 +973,22 @@ public class TestMVTableEngine extends TestBase { ...@@ -980,22 +973,22 @@ public class TestMVTableEngine extends TestBase {
} }
private void testReopen() throws SQLException { private void testReopen() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn; Connection conn;
Statement stat; Statement stat;
conn = getConnection("mvstore;MV_STORE=TRUE"); deleteDb(getTestName());
conn = getConnection(getTestName() + ";MV_STORE=TRUE");
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id int, name varchar)"); stat.execute("create table test(id int, name varchar)");
conn.close(); conn.close();
conn = getConnection("mvstore;MV_STORE=TRUE"); conn = getConnection(getTestName() + ";MV_STORE=TRUE");
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("drop table test"); stat.execute("drop table test");
conn.close(); conn.close();
} }
private void testBlob() throws SQLException, IOException { private void testBlob() throws SQLException, IOException {
FileUtils.deleteRecursive(getBaseDir(), true); deleteDb(getTestName());
String dbName = "mvstore;MV_STORE=TRUE"; String dbName = getTestName() + ";MV_STORE=TRUE";
Connection conn; Connection conn;
Statement stat; Statement stat;
conn = getConnection(dbName); conn = getConnection(dbName);
...@@ -1018,12 +1011,11 @@ public class TestMVTableEngine extends TestBase { ...@@ -1018,12 +1011,11 @@ public class TestMVTableEngine extends TestBase {
assertEquals(129, len); assertEquals(129, len);
} }
conn.close(); conn.close();
FileUtils.deleteRecursive(getBaseDir(), true);
} }
private void testEncryption() throws Exception { private void testEncryption() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); deleteDb(getTestName());
String dbName = "mvstore;MV_STORE=TRUE"; String dbName = getTestName() + ";MV_STORE=TRUE";
Connection conn; Connection conn;
Statement stat; Statement stat;
String url = getURL(dbName + ";CIPHER=AES", true); String url = getURL(dbName + ";CIPHER=AES", true);
...@@ -1038,12 +1030,11 @@ public class TestMVTableEngine extends TestBase { ...@@ -1038,12 +1030,11 @@ public class TestMVTableEngine extends TestBase {
stat.execute("select * from test"); stat.execute("select * from test");
stat.execute("drop table test"); stat.execute("drop table test");
conn.close(); conn.close();
FileUtils.deleteRecursive(getBaseDir(), true);
} }
private void testExclusiveLock() throws Exception { private void testExclusiveLock() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); deleteDb(getTestName());
String dbName = "mvstore;MV_STORE=TRUE;MVCC=FALSE"; String dbName = getTestName() + ";MV_STORE=TRUE;MVCC=FALSE";
Connection conn, conn2; Connection conn, conn2;
Statement stat, stat2; Statement stat, stat2;
conn = getConnection(dbName); conn = getConnection(dbName);
...@@ -1062,31 +1053,29 @@ public class TestMVTableEngine extends TestBase { ...@@ -1062,31 +1053,29 @@ public class TestMVTableEngine extends TestBase {
assertEquals("WRITE", rs2.getString("lock_type")); assertEquals("WRITE", rs2.getString("lock_type"));
conn2.close(); conn2.close();
conn.close(); conn.close();
FileUtils.deleteRecursive(getBaseDir(), true);
} }
private void testReadOnly() throws Exception { private void testReadOnly() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); deleteDb(getTestName());
String dbName = "mvstore;MV_STORE=TRUE"; String dbName = getTestName() + ";MV_STORE=TRUE";
Connection conn; Connection conn;
Statement stat; Statement stat;
conn = getConnection(dbName); conn = getConnection(dbName);
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("create table test(id int)"); stat.execute("create table test(id int)");
conn.close(); conn.close();
FileUtils.setReadOnly(getBaseDir() + "/mvstore" + FileUtils.setReadOnly(getBaseDir() + "/" + getTestName() +
Constants.SUFFIX_MV_FILE); Constants.SUFFIX_MV_FILE);
conn = getConnection(dbName); conn = getConnection(dbName);
Database db = (Database) ((JdbcConnection) conn).getSession() Database db = (Database) ((JdbcConnection) conn).getSession()
.getDataHandler(); .getDataHandler();
assertTrue(db.getMvStore().getStore().getFileStore().isReadOnly()); assertTrue(db.getMvStore().getStore().getFileStore().isReadOnly());
conn.close(); conn.close();
FileUtils.deleteRecursive(getBaseDir(), true);
} }
private void testReuseDiskSpace() throws Exception { private void testReuseDiskSpace() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); deleteDb(getTestName());
String dbName = "mvstore;MV_STORE=TRUE"; String dbName = getTestName() + ";MV_STORE=TRUE";
Connection conn; Connection conn;
Statement stat; Statement stat;
long maxSize = 0; long maxSize = 0;
...@@ -1101,7 +1090,7 @@ public class TestMVTableEngine extends TestBase { ...@@ -1101,7 +1090,7 @@ public class TestMVTableEngine extends TestBase {
"from system_range(1, 1000)"); "from system_range(1, 1000)");
stat.execute("drop table test"); stat.execute("drop table test");
conn.close(); conn.close();
long size = FileUtils.size(getBaseDir() + "/mvstore" long size = FileUtils.size(getBaseDir() + "/" + getTestName()
+ Constants.SUFFIX_MV_FILE); + Constants.SUFFIX_MV_FILE);
if (i < 10) { if (i < 10) {
maxSize = (int) (Math.max(size, maxSize) * 1.1); maxSize = (int) (Math.max(size, maxSize) * 1.1);
...@@ -1112,8 +1101,8 @@ public class TestMVTableEngine extends TestBase { ...@@ -1112,8 +1101,8 @@ public class TestMVTableEngine extends TestBase {
} }
private void testDataTypes() throws Exception { private void testDataTypes() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); deleteDb(getTestName());
String dbName = "mvstore;MV_STORE=TRUE"; String dbName = getTestName() + ";MV_STORE=TRUE";
Connection conn = getConnection(dbName); Connection conn = getConnection(dbName);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
...@@ -1272,8 +1261,8 @@ public class TestMVTableEngine extends TestBase { ...@@ -1272,8 +1261,8 @@ public class TestMVTableEngine extends TestBase {
} }
private void testLocking() throws Exception { private void testLocking() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); deleteDb(getTestName());
String dbName = "mvstore;MV_STORE=TRUE;MVCC=FALSE"; String dbName = getTestName() + ";MV_STORE=TRUE;MVCC=FALSE";
Connection conn = getConnection(dbName); Connection conn = getConnection(dbName);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("set lock_timeout 1000"); stat.execute("set lock_timeout 1000");
...@@ -1308,8 +1297,8 @@ public class TestMVTableEngine extends TestBase { ...@@ -1308,8 +1297,8 @@ public class TestMVTableEngine extends TestBase {
} }
private void testSimple() throws Exception { private void testSimple() throws Exception {
FileUtils.deleteRecursive(getBaseDir(), true); deleteDb(getTestName());
String dbName = "mvstore;MV_STORE=TRUE"; String dbName = getTestName() + ";MV_STORE=TRUE";
Connection conn = getConnection(dbName); Connection conn = getConnection(dbName);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar)"); stat.execute("create table test(id int primary key, name varchar)");
......
...@@ -41,8 +41,6 @@ public class TestStreamStore extends TestBase { ...@@ -41,8 +41,6 @@ public class TestStreamStore extends TestBase {
@Override @Override
public void test() throws IOException { public void test() throws IOException {
FileUtils.deleteRecursive(getBaseDir(), true);
FileUtils.createDirectories(getBaseDir());
testIOException(); testIOException();
testSaveCount(); testSaveCount();
testExceptionDuringStore(); testExceptionDuringStore();
......
...@@ -27,7 +27,7 @@ public class BnfRandom implements BnfVisitor { ...@@ -27,7 +27,7 @@ public class BnfRandom implements BnfVisitor {
private int level; private int level;
private String sql; private String sql;
BnfRandom() throws Exception { public BnfRandom() throws Exception {
Bnf config = Bnf.getInstance(null); Bnf config = Bnf.getInstance(null);
config.linkStatements(); config.linkStatements();
......
...@@ -43,8 +43,8 @@ public class TestBtreeIndex extends TestBase { ...@@ -43,8 +43,8 @@ public class TestBtreeIndex extends TestBase {
} }
private void testAddDelete() throws SQLException { private void testAddDelete() throws SQLException {
deleteDb("index"); deleteDb(getTestName());
Connection conn = getConnection("index"); Connection conn = getConnection(getTestName());
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID bigint primary key)"); stat.execute("CREATE TABLE TEST(ID bigint primary key)");
...@@ -54,7 +54,7 @@ public class TestBtreeIndex extends TestBase { ...@@ -54,7 +54,7 @@ public class TestBtreeIndex extends TestBase {
count + ")"); count + ")");
if (!config.memory) { if (!config.memory) {
conn.close(); conn.close();
conn = getConnection("index"); conn = getConnection(getTestName());
stat = conn.createStatement(); stat = conn.createStatement();
} }
for (int i = 1; i < count; i++) { for (int i = 1; i < count; i++) {
...@@ -68,7 +68,7 @@ public class TestBtreeIndex extends TestBase { ...@@ -68,7 +68,7 @@ public class TestBtreeIndex extends TestBase {
} finally { } finally {
conn.close(); conn.close();
} }
deleteDb("index"); deleteDb(getTestName());
} }
@Override @Override
...@@ -78,7 +78,7 @@ public class TestBtreeIndex extends TestBase { ...@@ -78,7 +78,7 @@ public class TestBtreeIndex extends TestBase {
private void testOne(int seed) throws SQLException { private void testOne(int seed) throws SQLException {
org.h2.Driver.load(); org.h2.Driver.load();
deleteDb("index"); deleteDb(getTestName());
printTime("testIndex " + seed); printTime("testIndex " + seed);
Random random = new Random(seed); Random random = new Random(seed);
int distinct, prefixLength; int distinct, prefixLength;
...@@ -101,8 +101,8 @@ public class TestBtreeIndex extends TestBase { ...@@ -101,8 +101,8 @@ public class TestBtreeIndex extends TestBase {
} }
} }
String prefix = buff.toString().substring(0, prefixLength); String prefix = buff.toString().substring(0, prefixLength);
DeleteDbFiles.execute(getBaseDir() + "/index", null, true); DeleteDbFiles.execute(getBaseDir() + "/" + getTestName(), null, true);
Connection conn = getConnection("index"); Connection conn = getConnection(getTestName());
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE a(text VARCHAR PRIMARY KEY)"); stat.execute("CREATE TABLE a(text VARCHAR PRIMARY KEY)");
...@@ -192,7 +192,7 @@ public class TestBtreeIndex extends TestBase { ...@@ -192,7 +192,7 @@ public class TestBtreeIndex extends TestBase {
} finally { } finally {
conn.close(); conn.close();
} }
deleteDb("index"); deleteDb(getTestName());
} }
private void printError(int seed, String message) { private void printError(int seed, String message) {
......
...@@ -38,15 +38,15 @@ public class TestFuzzOptimizations extends TestBase { ...@@ -38,15 +38,15 @@ public class TestFuzzOptimizations extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
deleteDb("optimizations"); deleteDb(getTestName());
conn = getConnection("optimizations"); conn = getConnection(getTestName());
if (!config.diskResult) { if (!config.diskResult) {
testIn(); testIn();
} }
testGroupSorted(); testGroupSorted();
testInSelect(); testInSelect();
conn.close(); conn.close();
deleteDb("optimizations"); deleteDb(getTestName());
} }
/* /*
......
...@@ -13,7 +13,6 @@ import org.h2.engine.SysProperties; ...@@ -13,7 +13,6 @@ import org.h2.engine.SysProperties;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.test.TestAll; import org.h2.test.TestAll;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.tools.DeleteDbFiles;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
/** /**
...@@ -44,8 +43,8 @@ public class TestRandomSQL extends TestBase { ...@@ -44,8 +43,8 @@ public class TestRandomSQL extends TestBase {
} }
} }
private String getDatabaseName() { protected String getDatabaseName() {
return "dataRandomSQL/randomSql" + seed; return getTestName() + "/db" + seed;
} }
private Connection connect() throws SQLException { private Connection connect() throws SQLException {
...@@ -53,13 +52,7 @@ public class TestRandomSQL extends TestBase { ...@@ -53,13 +52,7 @@ public class TestRandomSQL extends TestBase {
} }
private void deleteDb() { private void deleteDb() {
String name = getDatabaseName(); FileUtils.delete(getDatabaseName());
if (name.startsWith("memFS:")) {
DeleteDbFiles.execute("memFS:/", name, true);
} else {
DeleteDbFiles.execute(getBaseDir() + "/dataRandomSQL", null, true);
FileUtils.delete(getBaseDir() + "/dataRandomSQL");
}
} }
@Override @Override
...@@ -111,7 +104,8 @@ public class TestRandomSQL extends TestBase { ...@@ -111,7 +104,8 @@ public class TestRandomSQL extends TestBase {
public void testCase(int i) throws Exception { public void testCase(int i) throws Exception {
String old = SysProperties.getScriptDirectory(); String old = SysProperties.getScriptDirectory();
try { try {
System.setProperty(SysProperties.H2_SCRIPT_DIRECTORY, "dataScript/"); System.setProperty(SysProperties.H2_SCRIPT_DIRECTORY,
getBaseDir() + "/" + getTestName());
seed = i; seed = i;
printTime("seed: " + seed); printTime("seed: " + seed);
deleteDb(); deleteDb();
......
...@@ -56,28 +56,28 @@ public class TestAutoReconnect extends TestBase { ...@@ -56,28 +56,28 @@ public class TestAutoReconnect extends TestBase {
testReconnect(); testReconnect();
autoServer = false; autoServer = false;
testReconnect(); testReconnect();
deleteDb("autoReconnect"); deleteDb(getTestName());
} }
private void testWrongUrl() throws Exception { private void testWrongUrl() throws Exception {
deleteDb("autoReconnect"); deleteDb(getTestName());
Server tcp = Server.createTcpServer().start(); Server tcp = Server.createTcpServer().start();
try { try {
conn = getConnection("jdbc:h2:" + getBaseDir() + conn = getConnection("jdbc:h2:" + getBaseDir() +
"/autoReconnect;AUTO_SERVER=TRUE"); "/" + getTestName() + ";AUTO_SERVER=TRUE");
assertThrows(ErrorCode.DATABASE_ALREADY_OPEN_1, this). assertThrows(ErrorCode.DATABASE_ALREADY_OPEN_1, this).
getConnection("jdbc:h2:" + getBaseDir() + getConnection("jdbc:h2:" + getBaseDir() +
"/autoReconnect;OPEN_NEW=TRUE"); "/" + getTestName() + ";OPEN_NEW=TRUE");
assertThrows(ErrorCode.DATABASE_ALREADY_OPEN_1, this). assertThrows(ErrorCode.DATABASE_ALREADY_OPEN_1, this).
getConnection("jdbc:h2:" + getBaseDir() + getConnection("jdbc:h2:" + getBaseDir() +
"/autoReconnect;OPEN_NEW=TRUE"); "/" + getTestName() + ";OPEN_NEW=TRUE");
conn.close(); conn.close();
conn = getConnection("jdbc:h2:tcp://localhost/" + getBaseDir() + conn = getConnection("jdbc:h2:tcp://localhost/" + getBaseDir() +
"/autoReconnect"); "/" + getTestName());
assertThrows(ErrorCode.DATABASE_ALREADY_OPEN_1, this). assertThrows(ErrorCode.DATABASE_ALREADY_OPEN_1, this).
getConnection("jdbc:h2:" + getBaseDir() + getConnection("jdbc:h2:" + getBaseDir() +
"/autoReconnect;AUTO_SERVER=TRUE;OPEN_NEW=TRUE"); "/" + getTestName() + ";AUTO_SERVER=TRUE;OPEN_NEW=TRUE");
conn.close(); conn.close();
} finally { } finally {
tcp.stop(); tcp.stop();
...@@ -85,15 +85,15 @@ public class TestAutoReconnect extends TestBase { ...@@ -85,15 +85,15 @@ public class TestAutoReconnect extends TestBase {
} }
private void testReconnect() throws Exception { private void testReconnect() throws Exception {
deleteDb("autoReconnect"); deleteDb(getTestName());
if (autoServer) { if (autoServer) {
url = "jdbc:h2:" + getBaseDir() + "/autoReconnect;" + url = "jdbc:h2:" + getBaseDir() + "/" + getTestName() + ";" +
"FILE_LOCK=SOCKET;" + "FILE_LOCK=SOCKET;" +
"AUTO_SERVER=TRUE;OPEN_NEW=TRUE"; "AUTO_SERVER=TRUE;OPEN_NEW=TRUE";
restart(); restart();
} else { } else {
server = Server.createTcpServer("-tcpPort", "8181").start(); server = Server.createTcpServer("-tcpPort", "8181").start();
url = "jdbc:h2:tcp://localhost:8181/" + getBaseDir() + "/autoReconnect;" + url = "jdbc:h2:tcp://localhost:8181/" + getBaseDir() + "/" + getTestName() + ";" +
"FILE_LOCK=SOCKET;AUTO_RECONNECT=TRUE"; "FILE_LOCK=SOCKET;AUTO_RECONNECT=TRUE";
} }
......
...@@ -44,12 +44,12 @@ public class TestConnectionInfo extends TestBase { ...@@ -44,12 +44,12 @@ public class TestConnectionInfo extends TestBase {
return; return;
} }
assertThrows(ErrorCode.URL_RELATIVE_TO_CWD, this). assertThrows(ErrorCode.URL_RELATIVE_TO_CWD, this).
getConnection("jdbc:h2:test"); getConnection("jdbc:h2:" + getTestName());
assertThrows(ErrorCode.URL_RELATIVE_TO_CWD, this). assertThrows(ErrorCode.URL_RELATIVE_TO_CWD, this).
getConnection("jdbc:h2:data/test"); getConnection("jdbc:h2:data/" + getTestName());
getConnection("jdbc:h2:./testDatabase").close(); getConnection("jdbc:h2:./data/" + getTestName()).close();
DeleteDbFiles.execute(".", "testDatabase", true); DeleteDbFiles.execute("data", getTestName(), true);
} }
private void testConnectInitError() throws Exception { private void testConnectInitError() throws Exception {
...@@ -62,14 +62,14 @@ public class TestConnectionInfo extends TestBase { ...@@ -62,14 +62,14 @@ public class TestConnectionInfo extends TestBase {
private void testConnectionInfo() { private void testConnectionInfo() {
Properties info = new Properties(); Properties info = new Properties();
ConnectionInfo connectionInfo = new ConnectionInfo( ConnectionInfo connectionInfo = new ConnectionInfo(
"jdbc:h2:mem:test" + "jdbc:h2:mem:" + getTestName() +
";LOG=2" + ";LOG=2" +
";ACCESS_MODE_DATA=rws" + ";ACCESS_MODE_DATA=rws" +
";INIT=CREATE this...\\;INSERT that..." + ";INIT=CREATE this...\\;INSERT that..." +
";IFEXISTS=TRUE", ";IFEXISTS=TRUE",
info); info);
assertEquals("jdbc:h2:mem:test", assertEquals("jdbc:h2:mem:" + getTestName(),
connectionInfo.getURL()); connectionInfo.getURL());
assertEquals("2", assertEquals("2",
......
...@@ -17,7 +17,7 @@ import org.h2.util.SmallLRUCache; ...@@ -17,7 +17,7 @@ import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter; import org.h2.util.TempFileDeleter;
/** /**
* Tests the in-memory file system. * Tests the in-memory file store.
*/ */
public class TestFile extends TestBase implements DataHandler { public class TestFile extends TestBase implements DataHandler {
......
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.unit;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Locale;
import org.h2.test.TestBase;
public class TestLocale extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String... a) throws Exception {
// System.setProperty("h2.storeLocalTime", "true");
TestBase.createCaller().init().test();
}
@Override
public void test() throws SQLException {
testSpecialLocale();
}
private void testSpecialLocale() throws SQLException {
deleteDb(getTestName());
Connection conn = getConnection(getTestName());
Statement stat = conn.createStatement();
Locale old = Locale.getDefault();
try {
// when using Turkish as the default locale, "i".toUpperCase() is
// not "I"
Locale.setDefault(new Locale("tr"));
stat.execute("create table test(I1 int, i2 int, b int, c int, d int) " +
"as select 1, 1, 1, 1, 1");
ResultSet rs = stat.executeQuery("select * from test");
rs.next();
rs.getString("I1");
rs.getString("i1");
rs.getString("I2");
rs.getString("i2");
stat.execute("drop table test");
} finally {
Locale.setDefault(old);
}
conn.close();
}
}
...@@ -38,18 +38,18 @@ public class TestSampleApps extends TestBase { ...@@ -38,18 +38,18 @@ public class TestSampleApps extends TestBase {
if (!getBaseDir().startsWith(TestBase.BASE_TEST_DIR)) { if (!getBaseDir().startsWith(TestBase.BASE_TEST_DIR)) {
return; return;
} }
deleteDb("optimizations"); deleteDb(getTestName());
InputStream in = getClass().getClassLoader().getResourceAsStream( InputStream in = getClass().getClassLoader().getResourceAsStream(
"org/h2/samples/optimizations.sql"); "org/h2/samples/optimizations.sql");
new File(getBaseDir()).mkdirs(); new File(getBaseDir()).mkdirs();
FileOutputStream out = new FileOutputStream(getBaseDir() + FileOutputStream out = new FileOutputStream(getBaseDir() +
"/optimizations.sql"); "/optimizations.sql");
IOUtils.copyAndClose(in, out); IOUtils.copyAndClose(in, out);
String url = "jdbc:h2:" + getBaseDir() + "/optimizations"; String url = "jdbc:h2:" + getBaseDir() + "/" + getTestName();
testApp("", org.h2.tools.RunScript.class, "-url", url, "-user", "sa", testApp("", org.h2.tools.RunScript.class, "-url", url, "-user", "sa",
"-password", "sa", "-script", getBaseDir() + "-password", "sa", "-script", getBaseDir() +
"/optimizations.sql", "-checkResults"); "/optimizations.sql", "-checkResults");
deleteDb("optimizations"); deleteDb(getTestName());
testApp("Compacting...\nDone.", org.h2.samples.Compact.class); testApp("Compacting...\nDone.", org.h2.samples.Compact.class);
testApp("NAME: Bob Meier\n" + testApp("NAME: Bob Meier\n" +
"EMAIL: bob.meier@abcde.abc\n" + "EMAIL: bob.meier@abcde.abc\n" +
......
...@@ -517,6 +517,13 @@ public class TestTools extends TestBase { ...@@ -517,6 +517,13 @@ public class TestTools extends TestBase {
} }
private void testServerMain() throws SQLException { private void testServerMain() throws SQLException {
testNonSSL();
if (!config.fast) {
testSSL();
}
}
private void testNonSSL() throws SQLException {
String result; String result;
Connection conn; Connection conn;
...@@ -538,6 +545,11 @@ public class TestTools extends TestBase { ...@@ -538,6 +545,11 @@ public class TestTools extends TestBase {
result = runServer(0, new String[]{"-tcpShutdown", result = runServer(0, new String[]{"-tcpShutdown",
"tcp://localhost:9001", "-tcpPassword", "abc", "-tcpShutdownForce"}); "tcp://localhost:9001", "-tcpPassword", "abc", "-tcpShutdownForce"});
assertTrue(result.contains("Shutting down")); assertTrue(result.contains("Shutting down"));
}
private void testSSL() throws SQLException {
String result;
Connection conn;
result = runServer(0, new String[]{"-tcp", result = runServer(0, new String[]{"-tcp",
"-tcpAllowOthers", "-tcpPort", "9001", "-tcpPassword", "abcdef", "-tcpSSL"}); "-tcpAllowOthers", "-tcpPort", "9001", "-tcpPassword", "abcdef", "-tcpSSL"});
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论