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

--no commit message

--no commit message
上级 c6207251
......@@ -65,6 +65,7 @@ import org.h2.constant.SysProperties;
* - Newsletter: prepare, send (always send to BCC!!)
* - Add to freshmeat
* - 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
*/
......
......@@ -514,30 +514,30 @@ Features of H2
}
void testUnit() {
new TestBitField().runTest(this);
new TestCompress().runTest(this);
new TestDataPage().runTest(this);
new TestDate().runTest(this);
new TestExit().runTest(this);
new TestFile().runTest(this);
new TestFileLock().runTest(this);
new TestFtp().runTest(this);
new TestFileSystem().runTest(this);
new TestIntArray().runTest(this);
new TestIntIntHashMap().runTest(this);
new TestMultiThreadedKernel().runTest(this);
new TestOverflow().runTest(this);
new TestPattern().runTest(this);
new TestReader().runTest(this);
new TestSampleApps().runTest(this);
new TestScriptReader().runTest(this);
new TestSecurity().runTest(this);
new TestStreams().runTest(this);
new TestStringCache().runTest(this);
new TestStringUtils().runTest(this);
// new TestBitField().runTest(this);
// new TestCompress().runTest(this);
// new TestDataPage().runTest(this);
// new TestDate().runTest(this);
// new TestExit().runTest(this);
// new TestFile().runTest(this);
// new TestFileLock().runTest(this);
// new TestFtp().runTest(this);
// new TestFileSystem().runTest(this);
// new TestIntArray().runTest(this);
// new TestIntIntHashMap().runTest(this);
// new TestMultiThreadedKernel().runTest(this);
// new TestOverflow().runTest(this);
// new TestPattern().runTest(this);
// new TestReader().runTest(this);
// new TestSampleApps().runTest(this);
// new TestScriptReader().runTest(this);
// new TestSecurity().runTest(this);
// new TestStreams().runTest(this);
// new TestStringCache().runTest(this);
// new TestStringUtils().runTest(this);
new TestTools().runTest(this);
new TestValue().runTest(this);
new TestValueHashMap().runTest(this);
// new TestValue().runTest(this);
// new TestValueHashMap().runTest(this);
}
void testDatabase() throws Exception {
......@@ -548,73 +548,73 @@ Features of H2
// mvcc = true;
// db
new TestScriptSimple().runTest(this);
new TestScript().runTest(this);
new TestAutoRecompile().runTest(this);
new TestBackup().runTest(this);
new TestBatchUpdates().runTest(this);
new TestBigDb().runTest(this);
new TestBigResult().runTest(this);
new TestCache().runTest(this);
new TestCases().runTest(this);
new TestCheckpoint().runTest(this);
new TestCluster().runTest(this);
new TestCompatibility().runTest(this);
new TestCsv().runTest(this);
new TestFullText().runTest(this);
new TestFunctions().runTest(this);
new TestIndex().runTest(this);
new TestLinkedTable().runTest(this);
new TestListener().runTest(this);
new TestLob().runTest(this);
new TestLogFile().runTest(this);
new TestMemoryUsage().runTest(this);
new TestMultiConn().runTest(this);
new TestMultiDimension().runTest(this);
new TestMultiThread().runTest(this);
new TestOpenClose().runTest(this);
new TestOptimizations().runTest(this);
new TestPowerOff().runTest(this);
new TestReadOnly().runTest(this);
new TestRights().runTest(this);
new TestRunscript().runTest(this);
new TestSQLInjection().runTest(this);
new TestSequence().runTest(this);
new TestSpaceReuse().runTest(this);
new TestSpeed().runTest(this);
new TestTempTables().runTest(this);
new TestTransaction().runTest(this);
new TestTriggersConstraints().runTest(this);
new TestTwoPhaseCommit().runTest(this);
new TestView().runTest(this);
// server
new TestNestedLoop().runTest(this);
new TestWeb().runTest(this);
new TestPgServer().runTest(this);
// jdbc
new TestCallableStatement().runTest(this);
new TestCancel().runTest(this);
new TestDatabaseEventListener().runTest(this);
new TestDataSource().runTest(this);
new TestManyJdbcObjects().runTest(this);
new TestMetaData().runTest(this);
new TestNativeSQL().runTest(this);
new TestPreparedStatement().runTest(this);
new TestResultSet().runTest(this);
new TestStatement().runTest(this);
new TestTransactionIsolation().runTest(this);
new TestUpdatableResultSet().runTest(this);
new TestXA().runTest(this);
new TestZloty().runTest(this);
// mvcc
new TestMVCC().runTest(this);
// synthetic
new TestRandomSQL().runTest(this);
new TestKillRestart().runTest(this);
// new TestScriptSimple().runTest(this);
// new TestScript().runTest(this);
// new TestAutoRecompile().runTest(this);
// new TestBackup().runTest(this);
// new TestBatchUpdates().runTest(this);
// new TestBigDb().runTest(this);
// new TestBigResult().runTest(this);
// new TestCache().runTest(this);
// new TestCases().runTest(this);
// new TestCheckpoint().runTest(this);
// new TestCluster().runTest(this);
// new TestCompatibility().runTest(this);
// new TestCsv().runTest(this);
// new TestFullText().runTest(this);
// new TestFunctions().runTest(this);
// new TestIndex().runTest(this);
// new TestLinkedTable().runTest(this);
// new TestListener().runTest(this);
// new TestLob().runTest(this);
// new TestLogFile().runTest(this);
// new TestMemoryUsage().runTest(this);
// new TestMultiConn().runTest(this);
// new TestMultiDimension().runTest(this);
// new TestMultiThread().runTest(this);
// new TestOpenClose().runTest(this);
// new TestOptimizations().runTest(this);
// new TestPowerOff().runTest(this);
// new TestReadOnly().runTest(this);
// new TestRights().runTest(this);
// new TestRunscript().runTest(this);
// new TestSQLInjection().runTest(this);
// new TestSequence().runTest(this);
// new TestSpaceReuse().runTest(this);
// new TestSpeed().runTest(this);
// new TestTempTables().runTest(this);
// new TestTransaction().runTest(this);
// new TestTriggersConstraints().runTest(this);
// new TestTwoPhaseCommit().runTest(this);
// new TestView().runTest(this);
//
// // server
// new TestNestedLoop().runTest(this);
// new TestWeb().runTest(this);
// new TestPgServer().runTest(this);
//
// // jdbc
// new TestCallableStatement().runTest(this);
// new TestCancel().runTest(this);
// new TestDatabaseEventListener().runTest(this);
// new TestDataSource().runTest(this);
// new TestManyJdbcObjects().runTest(this);
// new TestMetaData().runTest(this);
// new TestNativeSQL().runTest(this);
// new TestPreparedStatement().runTest(this);
// new TestResultSet().runTest(this);
// new TestStatement().runTest(this);
// new TestTransactionIsolation().runTest(this);
// new TestUpdatableResultSet().runTest(this);
// new TestXA().runTest(this);
// new TestZloty().runTest(this);
//
// // mvcc
// new TestMVCC().runTest(this);
//
// // synthetic
// new TestRandomSQL().runTest(this);
// new TestKillRestart().runTest(this);
afterTest();
}
......
......@@ -21,9 +21,6 @@ package org.h2.test.trace;
/**
* A function call argument used by the statement.
*
* @author Thomas Mueller
*
*/
class Arg {
private Class clazz;
......
......@@ -19,13 +19,11 @@
*/
package org.h2.test.trace;
import java.math.BigDecimal;
import java.util.ArrayList;
/**
* The parser to parse a statement (a single line in the log file).
*
* @author Thomas Mueller
*
*/
class Parser {
private static final int STRING = 0, NAME = 1, NUMBER = 2, SPECIAL = 3;
......@@ -181,17 +179,7 @@ class Parser {
return new Arg(player, String.class, s);
} else if (tokenType == NUMBER) {
String number = readToken().toLowerCase();
if (number.startsWith("0x")) {
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) {
if (number.indexOf("e") >= 0 || number.indexOf(".") >= 0) {
Double v = new Double(Double.parseDouble(number));
return new Arg(player, double.class, v);
} else if (number.endsWith("l")) {
......@@ -223,6 +211,12 @@ class Parser {
String[] list = new String[values.size()];
values.toArray(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 {
throw new Error("Unsupported constructor: " + readToken());
}
......
......@@ -27,11 +27,20 @@ import java.util.HashMap;
/**
* The command line tool to re-run the log file. This is done using reflection.
*
* @author Thomas Mueller
*
*/
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;
......@@ -39,14 +48,12 @@ public class Player {
private HashMap objects = new HashMap();
private String lastReturn;
private boolean checkResults;
/**
* 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:
* <ul>
* <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>
*
* @param args the arguments of the application
......@@ -73,8 +80,6 @@ public class Player {
for (int i = 0; i < args.length - 1; i++) {
if ("-log".equals(args[i])) {
log = true;
} else if ("-checkResults".equals(args[i])) {
checkResults = true;
} else {
throw new Error("Unknown setting: " + args[i]);
}
......@@ -82,7 +87,7 @@ public class Player {
} catch (Exception e) {
e.printStackTrace();
System.out.println("Usage: java " + getClass().getName()
+ " [-log] [-checkResult] <fileName>");
+ " [-log] <fileName>");
return;
}
runFile(fileName, log);
......@@ -112,18 +117,6 @@ public class Player {
}
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("/**/")) {
return;
}
......
......@@ -21,14 +21,10 @@ package org.h2.test.trace;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
/**
* Represents a statement (a single line in the log file).
*
* @author Thomas Mueller
*
*/
class Statement {
private Player player;
......@@ -66,21 +62,6 @@ class Statement {
}
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 {
return clazz.getMethod(methodName, parameterTypes);
} catch (NoSuchMethodException e) {
......
......@@ -22,21 +22,16 @@ package org.h2.test.trace;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import org.h2.util.StringUtils;
/**
* Some String manipulations / formatting functions used by this tool.
*
* @author Thomas Mueller
*
*/
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) {
if (s == null) {
return null;
......@@ -193,6 +188,8 @@ public class StringTools {
return null;
} else if (clazz == String.class) {
return StringUtils.quoteJavaString(value.toString());
} else if (clazz == BigDecimal.class) {
return "new BigDecimal(\"" + value.toString() + "\")";
} else if (clazz.isArray()) {
if (clazz == String[].class) {
return StringUtils.quoteJavaStringArray((String[]) value);
......
......@@ -7,8 +7,10 @@ package org.h2.test.unit;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
......@@ -32,16 +34,16 @@ public class TestTools extends TestBase {
public void test() throws Exception {
deleteDb("utils");
testServerMain();
testRemove();
// testServerMain();
// testRemove();
testConvertTraceFile();
testManagementDb();
testResourceGenerator();
testChangePassword();
testServer();
testScriptRunscript();
testBackupRestore();
testRecover();
// testManagementDb();
// testResourceGenerator();
// testChangePassword();
// testServer();
// testScriptRunscript();
// testBackupRestore();
// testRecover();
}
private void testServerMain() throws Exception {
......@@ -116,8 +118,21 @@ public class TestTools extends TestBase {
String url = "jdbc:h2:" + baseDir + "/toolsConvertTraceFile";
Connection conn = DriverManager.getConnection(url + ";TRACE_LEVEL_FILE=3", "sa", "sa");
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();
ConvertTraceFile.main(new String[]{"-traceFile", baseDir + "/toolsConvertTraceFile.trace.db", "-javaClass", baseDir + "/Test", "-script", baseDir + "/test.sql"});
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论