提交 37a2bbe5 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 c6207251
...@@ -65,6 +65,7 @@ import org.h2.constant.SysProperties; ...@@ -65,6 +65,7 @@ import org.h2.constant.SysProperties;
* - Newsletter: prepare, send (always send to BCC!!) * - Newsletter: prepare, send (always send to BCC!!)
* - Add to freshmeat * - Add to freshmeat
* - Upload to http://code.google.com/p/h2database/downloads/list * - Upload to http://code.google.com/p/h2database/downloads/list
* - svn copy: .../svn/trunk .../svn/tags/version-1.0.x; Version 1.0.x (yyyy-mm-dd)
* *
* @author Thomas * @author Thomas
*/ */
......
...@@ -514,30 +514,30 @@ Features of H2 ...@@ -514,30 +514,30 @@ Features of H2
} }
void testUnit() { void testUnit() {
new TestBitField().runTest(this); // new TestBitField().runTest(this);
new TestCompress().runTest(this); // new TestCompress().runTest(this);
new TestDataPage().runTest(this); // new TestDataPage().runTest(this);
new TestDate().runTest(this); // new TestDate().runTest(this);
new TestExit().runTest(this); // new TestExit().runTest(this);
new TestFile().runTest(this); // new TestFile().runTest(this);
new TestFileLock().runTest(this); // new TestFileLock().runTest(this);
new TestFtp().runTest(this); // new TestFtp().runTest(this);
new TestFileSystem().runTest(this); // new TestFileSystem().runTest(this);
new TestIntArray().runTest(this); // new TestIntArray().runTest(this);
new TestIntIntHashMap().runTest(this); // new TestIntIntHashMap().runTest(this);
new TestMultiThreadedKernel().runTest(this); // new TestMultiThreadedKernel().runTest(this);
new TestOverflow().runTest(this); // new TestOverflow().runTest(this);
new TestPattern().runTest(this); // new TestPattern().runTest(this);
new TestReader().runTest(this); // new TestReader().runTest(this);
new TestSampleApps().runTest(this); // new TestSampleApps().runTest(this);
new TestScriptReader().runTest(this); // new TestScriptReader().runTest(this);
new TestSecurity().runTest(this); // new TestSecurity().runTest(this);
new TestStreams().runTest(this); // new TestStreams().runTest(this);
new TestStringCache().runTest(this); // new TestStringCache().runTest(this);
new TestStringUtils().runTest(this); // new TestStringUtils().runTest(this);
new TestTools().runTest(this); new TestTools().runTest(this);
new TestValue().runTest(this); // new TestValue().runTest(this);
new TestValueHashMap().runTest(this); // new TestValueHashMap().runTest(this);
} }
void testDatabase() throws Exception { void testDatabase() throws Exception {
...@@ -548,73 +548,73 @@ Features of H2 ...@@ -548,73 +548,73 @@ Features of H2
// mvcc = true; // mvcc = true;
// db // db
new TestScriptSimple().runTest(this); // new TestScriptSimple().runTest(this);
new TestScript().runTest(this); // new TestScript().runTest(this);
new TestAutoRecompile().runTest(this); // new TestAutoRecompile().runTest(this);
new TestBackup().runTest(this); // new TestBackup().runTest(this);
new TestBatchUpdates().runTest(this); // new TestBatchUpdates().runTest(this);
new TestBigDb().runTest(this); // new TestBigDb().runTest(this);
new TestBigResult().runTest(this); // new TestBigResult().runTest(this);
new TestCache().runTest(this); // new TestCache().runTest(this);
new TestCases().runTest(this); // new TestCases().runTest(this);
new TestCheckpoint().runTest(this); // new TestCheckpoint().runTest(this);
new TestCluster().runTest(this); // new TestCluster().runTest(this);
new TestCompatibility().runTest(this); // new TestCompatibility().runTest(this);
new TestCsv().runTest(this); // new TestCsv().runTest(this);
new TestFullText().runTest(this); // new TestFullText().runTest(this);
new TestFunctions().runTest(this); // new TestFunctions().runTest(this);
new TestIndex().runTest(this); // new TestIndex().runTest(this);
new TestLinkedTable().runTest(this); // new TestLinkedTable().runTest(this);
new TestListener().runTest(this); // new TestListener().runTest(this);
new TestLob().runTest(this); // new TestLob().runTest(this);
new TestLogFile().runTest(this); // new TestLogFile().runTest(this);
new TestMemoryUsage().runTest(this); // new TestMemoryUsage().runTest(this);
new TestMultiConn().runTest(this); // new TestMultiConn().runTest(this);
new TestMultiDimension().runTest(this); // new TestMultiDimension().runTest(this);
new TestMultiThread().runTest(this); // new TestMultiThread().runTest(this);
new TestOpenClose().runTest(this); // new TestOpenClose().runTest(this);
new TestOptimizations().runTest(this); // new TestOptimizations().runTest(this);
new TestPowerOff().runTest(this); // new TestPowerOff().runTest(this);
new TestReadOnly().runTest(this); // new TestReadOnly().runTest(this);
new TestRights().runTest(this); // new TestRights().runTest(this);
new TestRunscript().runTest(this); // new TestRunscript().runTest(this);
new TestSQLInjection().runTest(this); // new TestSQLInjection().runTest(this);
new TestSequence().runTest(this); // new TestSequence().runTest(this);
new TestSpaceReuse().runTest(this); // new TestSpaceReuse().runTest(this);
new TestSpeed().runTest(this); // new TestSpeed().runTest(this);
new TestTempTables().runTest(this); // new TestTempTables().runTest(this);
new TestTransaction().runTest(this); // new TestTransaction().runTest(this);
new TestTriggersConstraints().runTest(this); // new TestTriggersConstraints().runTest(this);
new TestTwoPhaseCommit().runTest(this); // new TestTwoPhaseCommit().runTest(this);
new TestView().runTest(this); // new TestView().runTest(this);
//
// server // // server
new TestNestedLoop().runTest(this); // new TestNestedLoop().runTest(this);
new TestWeb().runTest(this); // new TestWeb().runTest(this);
new TestPgServer().runTest(this); // new TestPgServer().runTest(this);
//
// jdbc // // jdbc
new TestCallableStatement().runTest(this); // new TestCallableStatement().runTest(this);
new TestCancel().runTest(this); // new TestCancel().runTest(this);
new TestDatabaseEventListener().runTest(this); // new TestDatabaseEventListener().runTest(this);
new TestDataSource().runTest(this); // new TestDataSource().runTest(this);
new TestManyJdbcObjects().runTest(this); // new TestManyJdbcObjects().runTest(this);
new TestMetaData().runTest(this); // new TestMetaData().runTest(this);
new TestNativeSQL().runTest(this); // new TestNativeSQL().runTest(this);
new TestPreparedStatement().runTest(this); // new TestPreparedStatement().runTest(this);
new TestResultSet().runTest(this); // new TestResultSet().runTest(this);
new TestStatement().runTest(this); // new TestStatement().runTest(this);
new TestTransactionIsolation().runTest(this); // new TestTransactionIsolation().runTest(this);
new TestUpdatableResultSet().runTest(this); // new TestUpdatableResultSet().runTest(this);
new TestXA().runTest(this); // new TestXA().runTest(this);
new TestZloty().runTest(this); // new TestZloty().runTest(this);
//
// mvcc // // mvcc
new TestMVCC().runTest(this); // new TestMVCC().runTest(this);
//
// synthetic // // synthetic
new TestRandomSQL().runTest(this); // new TestRandomSQL().runTest(this);
new TestKillRestart().runTest(this); // new TestKillRestart().runTest(this);
afterTest(); afterTest();
} }
......
...@@ -21,9 +21,6 @@ package org.h2.test.trace; ...@@ -21,9 +21,6 @@ package org.h2.test.trace;
/** /**
* A function call argument used by the statement. * A function call argument used by the statement.
*
* @author Thomas Mueller
*
*/ */
class Arg { class Arg {
private Class clazz; private Class clazz;
......
...@@ -19,13 +19,11 @@ ...@@ -19,13 +19,11 @@
*/ */
package org.h2.test.trace; package org.h2.test.trace;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* The parser to parse a statement (a single line in the log file). * The parser to parse a statement (a single line in the log file).
*
* @author Thomas Mueller
*
*/ */
class Parser { class Parser {
private static final int STRING = 0, NAME = 1, NUMBER = 2, SPECIAL = 3; private static final int STRING = 0, NAME = 1, NUMBER = 2, SPECIAL = 3;
...@@ -181,17 +179,7 @@ class Parser { ...@@ -181,17 +179,7 @@ class Parser {
return new Arg(player, String.class, s); return new Arg(player, String.class, s);
} else if (tokenType == NUMBER) { } else if (tokenType == NUMBER) {
String number = readToken().toLowerCase(); String number = readToken().toLowerCase();
if (number.startsWith("0x")) { if (number.indexOf("e") >= 0 || number.indexOf(".") >= 0) {
if (number.endsWith("l")) {
Long v = new Long(Long.parseLong(number.substring(2, number
.length() - 1), 16));
return new Arg(player, long.class, v);
} else {
Integer v = new Integer(Integer.parseInt(number.substring(
2, number.length() - 1), 16));
return new Arg(player, int.class, v);
}
} else if (number.indexOf("e") >= 0 || number.indexOf(".") >= 0) {
Double v = new Double(Double.parseDouble(number)); Double v = new Double(Double.parseDouble(number));
return new Arg(player, double.class, v); return new Arg(player, double.class, v);
} else if (number.endsWith("l")) { } else if (number.endsWith("l")) {
...@@ -223,6 +211,12 @@ class Parser { ...@@ -223,6 +211,12 @@ class Parser {
String[] list = new String[values.size()]; String[] list = new String[values.size()];
values.toArray(list); values.toArray(list);
return new Arg(player, String[].class, list); return new Arg(player, String[].class, list);
} else if (readIf("BigDecimal")) {
read("(");
ArrayList values = new ArrayList();
values.add(parseValue().getValue());
read(")");
return new Arg(player, BigDecimal.class, values);
} else { } else {
throw new Error("Unsupported constructor: " + readToken()); throw new Error("Unsupported constructor: " + readToken());
} }
......
...@@ -27,26 +27,33 @@ import java.util.HashMap; ...@@ -27,26 +27,33 @@ import java.util.HashMap;
/** /**
* The command line tool to re-run the log file. This is done using reflection. * The command line tool to re-run the log file. This is done using reflection.
*
* @author Thomas Mueller
*
*/ */
public class Player { public class Player {
// TODO support Calendar
// TODO support Object[]
// TODO support Object
// TODO support URL
// TODO support Array
// TODO support Ref
// TODO support SQLInput, SQLOutput
// TODO support Properties
// TODO support Map
// TODO support SQLXML
private boolean log; private boolean log;
private static final String[] IMPORTED_PACKAGES = { "", "java.lang.", "java.sql.", "javax.sql." }; private static final String[] IMPORTED_PACKAGES = { "", "java.lang.", "java.sql.", "javax.sql." };
private HashMap objects = new HashMap(); private HashMap objects = new HashMap();
private String lastReturn; private String lastReturn;
private boolean checkResults;
/** /**
* Execute a trace file using the command line. The log file name to execute (replayed) must be specified * Execute a trace file using the command line. The log file name to execute (replayed) must be specified
* as the last parameter. The following optional command line parameters are supported: * as the last parameter. The following optional command line parameters are supported:
* <ul> * <ul>
* <li><code>-log</code> to enable logging the executed statement to System.out * <li><code>-log</code> to enable logging the executed statement to System.out
* <li><code>-checkResults</code> if this is set, the values returned at runtime are compared with the values in the log file
* </ul> * </ul>
* *
* @param args the arguments of the application * @param args the arguments of the application
...@@ -73,8 +80,6 @@ public class Player { ...@@ -73,8 +80,6 @@ public class Player {
for (int i = 0; i < args.length - 1; i++) { for (int i = 0; i < args.length - 1; i++) {
if ("-log".equals(args[i])) { if ("-log".equals(args[i])) {
log = true; log = true;
} else if ("-checkResults".equals(args[i])) {
checkResults = true;
} else { } else {
throw new Error("Unknown setting: " + args[i]); throw new Error("Unknown setting: " + args[i]);
} }
...@@ -82,7 +87,7 @@ public class Player { ...@@ -82,7 +87,7 @@ public class Player {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.out.println("Usage: java " + getClass().getName() System.out.println("Usage: java " + getClass().getName()
+ " [-log] [-checkResult] <fileName>"); + " [-log] <fileName>");
return; return;
} }
runFile(fileName, log); runFile(fileName, log);
...@@ -112,18 +117,6 @@ public class Player { ...@@ -112,18 +117,6 @@ public class Player {
} }
private void runLine(String line) { private void runLine(String line) {
if (line.startsWith("//return")) {
if (checkResults && lastReturn != null) {
int start = line.indexOf(' ');
int end = line.lastIndexOf(';');
if (start >= 0 && end > start) {
String expected = line.substring(start, end).trim();
if (lastReturn.equals(expected)) {
logError("expected: " + expected + " got: " + lastReturn);
}
}
}
}
if (!line.startsWith("/**/")) { if (!line.startsWith("/**/")) {
return; return;
} }
......
...@@ -21,14 +21,10 @@ package org.h2.test.trace; ...@@ -21,14 +21,10 @@ package org.h2.test.trace;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* Represents a statement (a single line in the log file). * Represents a statement (a single line in the log file).
*
* @author Thomas Mueller
*
*/ */
class Statement { class Statement {
private Player player; private Player player;
...@@ -66,21 +62,6 @@ class Statement { ...@@ -66,21 +62,6 @@ class Statement {
} }
private Method findMethod(Class clazz) throws Exception { private Method findMethod(Class clazz) throws Exception {
if ((clazz.getModifiers() & Modifier.PUBLIC) == 0) {
// http://forum.java.sun.com/thread.jspa?threadID=704100&messageID=4084720
// bug 4071957
Class[] interfaces = clazz.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
Class c = interfaces[i];
if (c.getName().startsWith("javax.")) {
try {
return c.getMethod(methodName, parameterTypes);
} catch (Exception e) {
// TODO this is slow, but a workaround for a JVM bug
}
}
}
}
try { try {
return clazz.getMethod(methodName, parameterTypes); return clazz.getMethod(methodName, parameterTypes);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
......
...@@ -22,21 +22,16 @@ package org.h2.test.trace; ...@@ -22,21 +22,16 @@ package org.h2.test.trace;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/** /**
* Some String manipulations / formatting functions used by this tool. * Some String manipulations / formatting functions used by this tool.
*
* @author Thomas Mueller
*
*/ */
public class StringTools { public class StringTools {
// private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
// "yyyy-MM-dd HH:mm:ss.SSS Z");
static String[] arraySplit(String s, char separatorChar) { static String[] arraySplit(String s, char separatorChar) {
if (s == null) { if (s == null) {
return null; return null;
...@@ -193,6 +188,8 @@ public class StringTools { ...@@ -193,6 +188,8 @@ public class StringTools {
return null; return null;
} else if (clazz == String.class) { } else if (clazz == String.class) {
return StringUtils.quoteJavaString(value.toString()); return StringUtils.quoteJavaString(value.toString());
} else if (clazz == BigDecimal.class) {
return "new BigDecimal(\"" + value.toString() + "\")";
} else if (clazz.isArray()) { } else if (clazz.isArray()) {
if (clazz == String[].class) { if (clazz == String[].class) {
return StringUtils.quoteJavaStringArray((String[]) value); return StringUtils.quoteJavaStringArray((String[]) value);
......
...@@ -7,8 +7,10 @@ package org.h2.test.unit; ...@@ -7,8 +7,10 @@ package org.h2.test.unit;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.PrintStream; import java.io.PrintStream;
import java.math.BigDecimal;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
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;
...@@ -32,16 +34,16 @@ public class TestTools extends TestBase { ...@@ -32,16 +34,16 @@ public class TestTools extends TestBase {
public void test() throws Exception { public void test() throws Exception {
deleteDb("utils"); deleteDb("utils");
testServerMain(); // testServerMain();
testRemove(); // testRemove();
testConvertTraceFile(); testConvertTraceFile();
testManagementDb(); // testManagementDb();
testResourceGenerator(); // testResourceGenerator();
testChangePassword(); // testChangePassword();
testServer(); // testServer();
testScriptRunscript(); // testScriptRunscript();
testBackupRestore(); // testBackupRestore();
testRecover(); // testRecover();
} }
private void testServerMain() throws Exception { private void testServerMain() throws Exception {
...@@ -116,8 +118,21 @@ public class TestTools extends TestBase { ...@@ -116,8 +118,21 @@ public class TestTools extends TestBase {
String url = "jdbc:h2:" + baseDir + "/toolsConvertTraceFile"; String url = "jdbc:h2:" + baseDir + "/toolsConvertTraceFile";
Connection conn = DriverManager.getConnection(url + ";TRACE_LEVEL_FILE=3", "sa", "sa"); Connection conn = DriverManager.getConnection(url + ";TRACE_LEVEL_FILE=3", "sa", "sa");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar)");
stat.execute("insert into test values(1, 'Hello')"); int todoFloatDoubleLongShortByteBoolean;
int todoByteArray;
int todoInputStream;
int todoReader;
int todoDateTimeTimestamp;
int todoIntArray;
int todoBlobClob;
stat.execute("create table test(id int primary key, name varchar, amount decimal)");
PreparedStatement prep = conn.prepareStatement("insert into test values(?, ?, ?)");
prep.setInt(1, 1);
prep.setString(2, "Hello");
prep.setBigDecimal(3, new BigDecimal("10.20"));
prep.executeUpdate();
conn.close(); conn.close();
ConvertTraceFile.main(new String[]{"-traceFile", baseDir + "/toolsConvertTraceFile.trace.db", "-javaClass", baseDir + "/Test", "-script", baseDir + "/test.sql"}); ConvertTraceFile.main(new String[]{"-traceFile", baseDir + "/toolsConvertTraceFile.trace.db", "-javaClass", baseDir + "/Test", "-script", baseDir + "/test.sql"});
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论