提交 433bf879 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 0ea30d28
...@@ -14,10 +14,10 @@ import org.h2.test.TestBase; ...@@ -14,10 +14,10 @@ import org.h2.test.TestBase;
public class TestCancel extends TestBase { public class TestCancel extends TestBase {
class Canceller extends Thread { class CancelThread extends Thread {
private Statement cancel; private Statement cancel;
private int wait; private int wait;
Canceller(Statement cancel, int wait) { CancelThread(Statement cancel, int wait) {
this.cancel = cancel; this.cancel = cancel;
this.wait = wait; this.wait = wait;
} }
...@@ -53,8 +53,8 @@ public class TestCancel extends TestBase { ...@@ -53,8 +53,8 @@ public class TestCancel extends TestBase {
// TODO test insert.. select // TODO test insert.. select
for (int i = 1;;) { for (int i = 1;;) {
Statement query = conn.createStatement(); Statement query = conn.createStatement();
Canceller canceller = new Canceller(query, i); CancelThread cancel = new CancelThread(query, i);
canceller.start(); cancel.start();
Thread.yield(); Thread.yield();
int j=0; int j=0;
try { try {
......
...@@ -7,6 +7,10 @@ package org.h2.test.jdbc; ...@@ -7,6 +7,10 @@ package org.h2.test.jdbc;
import java.sql.Connection; import java.sql.Connection;
import java.sql.Statement; import java.sql.Statement;
import javax.sql.ConnectionEvent;
import javax.sql.ConnectionEventListener;
import javax.sql.XAConnection;
import org.h2.jdbcx.JdbcDataSource; import org.h2.jdbcx.JdbcDataSource;
import org.h2.test.TestBase; import org.h2.test.TestBase;
...@@ -36,12 +40,33 @@ public class TestDataSource extends TestBase { ...@@ -36,12 +40,33 @@ public class TestDataSource extends TestBase {
// } // }
public void test() throws Exception { public void test() throws Exception {
deleteDb("datasource"); testDataSource();
testXAConnection();
}
private void testXAConnection() throws Exception {
deleteDb(BASE_DIR, "dataSource");
JdbcDataSource ds = new JdbcDataSource();
ds.setURL("jdbc:h2:"+BASE_DIR+"/dataSource");
XAConnection xaConn = ds.getXAConnection();
xaConn.addConnectionEventListener(new ConnectionEventListener() {
public void connectionClosed(ConnectionEvent event) {
}
public void connectionErrorOccurred(ConnectionEvent event) {
}
});
Connection conn = xaConn.getConnection();
Statement stat = conn.createStatement();
stat.execute("SELECT * FROM DUAL");
conn.close();
xaConn.close();
}
private void testDataSource() throws Exception {
deleteDb(BASE_DIR, "dataSource");
JdbcDataSource ds = new JdbcDataSource(); JdbcDataSource ds = new JdbcDataSource();
ds.setURL("jdbc:h2:"+BASE_DIR+"/datasource"); ds.setURL("jdbc:h2:"+BASE_DIR+"/dataSource");
ds.setUser("sa"); ds.setUser("sa");
ds.setPassword("");
Connection conn = ds.getConnection(); Connection conn = ds.getConnection();
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("SELECT * FROM DUAL"); stat.execute("SELECT * FROM DUAL");
......
...@@ -499,11 +499,11 @@ public class TestMetaData extends TestBase { ...@@ -499,11 +499,11 @@ public class TestMetaData extends TestBase {
int minor = meta.getDriverMinorVersion(); int minor = meta.getDriverMinorVersion();
trace("meta.getDriverMinorVersion:" + minor); trace("meta.getDriverMinorVersion:" + minor);
String drivername = meta.getDriverName(); String driverName = meta.getDriverName();
trace("meta.getDriverName:" + drivername); trace("meta.getDriverName:" + driverName);
String driverversion = meta.getDriverVersion(); String driverVersion = meta.getDriverVersion();
trace("meta.getDriverVersion:" + driverversion); trace("meta.getDriverVersion:" + driverVersion);
meta.getSearchStringEscape(); meta.getSearchStringEscape();
......
...@@ -29,7 +29,7 @@ public class TestNativeSQL extends TestBase { ...@@ -29,7 +29,7 @@ public class TestNativeSQL extends TestBase {
conn.nativeSQL("TEST-TEST/TEST/*TEST*/TEST--\rTEST--{fn }"); conn.nativeSQL("TEST-TEST/TEST/*TEST*/TEST--\rTEST--{fn }");
conn.nativeSQL("TEST-TEST//TEST"); conn.nativeSQL("TEST-TEST//TEST");
conn.nativeSQL("'{}' '' \"1\" \"\"\"\""); conn.nativeSQL("'{}' '' \"1\" \"\"\"\"");
conn.nativeSQL("{?= call HEELO{t '10'}}"); conn.nativeSQL("{?= call HELLO{t '10'}}");
conn.nativeSQL("TEST 'test'{OJ OUTER JOIN}'test'{oj OUTER JOIN}"); conn.nativeSQL("TEST 'test'{OJ OUTER JOIN}'test'{oj OUTER JOIN}");
conn.nativeSQL("{call {ts '2001-01-10'}}"); conn.nativeSQL("{call {ts '2001-01-10'}}");
conn.nativeSQL("call ? { 1: '}' };"); conn.nativeSQL("call ? { 1: '}' };");
......
...@@ -46,13 +46,13 @@ public class TestPreparedStatement extends TestBase { ...@@ -46,13 +46,13 @@ public class TestPreparedStatement extends TestBase {
private void testUUIDGeneratedKeys(Connection conn) throws Exception { private void testUUIDGeneratedKeys(Connection conn) throws Exception {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TESTUUID(id UUID DEFAULT random_UUID() PRIMARY KEY)"); stat.execute("CREATE TABLE TEST_UUID(id UUID DEFAULT random_UUID() PRIMARY KEY)");
stat.execute("INSERT INTO TESTUUID() VALUES()"); stat.execute("INSERT INTO TEST_UUID() VALUES()");
ResultSet rs = stat.getGeneratedKeys(); ResultSet rs = stat.getGeneratedKeys();
rs.next(); rs.next();
byte[] data = rs.getBytes(1); byte[] data = rs.getBytes(1);
check(data.length, 16); check(data.length, 16);
stat.execute("DROP TABLE TESTUUID"); stat.execute("DROP TABLE TEST_UUID");
} }
private void testSetObject(Connection conn) throws Exception { private void testSetObject(Connection conn) throws Exception {
...@@ -592,12 +592,12 @@ public class TestPreparedStatement extends TestBase { ...@@ -592,12 +592,12 @@ public class TestPreparedStatement extends TestBase {
PreparedStatement prep; PreparedStatement prep;
ResultSet rs; ResultSet rs;
stat.execute("CREATE TABLE T_CLOB(ID INT PRIMARY KEY,V1 CLOB,V2 CLOB)"); stat.execute("CREATE TABLE T_CLOB(ID INT PRIMARY KEY,V1 CLOB,V2 CLOB)");
StringBuffer asciibuffer=new StringBuffer(); StringBuffer asciiBuffer=new StringBuffer();
int len = getLength(); int len = getLength();
for(int i=0;i<len;i++) { for(int i=0;i<len;i++) {
asciibuffer.append((char)('a'+(i%20))); asciiBuffer.append((char)('a'+(i%20)));
} }
String ascii1=asciibuffer.toString(); String ascii1=asciiBuffer.toString();
String ascii2="Number2 "+ascii1; String ascii2="Number2 "+ascii1;
prep=conn.prepareStatement("INSERT INTO T_CLOB VALUES(?,?,?)"); prep=conn.prepareStatement("INSERT INTO T_CLOB VALUES(?,?,?)");
......
...@@ -29,8 +29,8 @@ public class TestResultSet extends TestBase { ...@@ -29,8 +29,8 @@ public class TestResultSet extends TestBase {
Statement stat; Statement stat;
public void test() throws Exception { public void test() throws Exception {
deleteDb("resultset"); deleteDb("resultSet");
conn = getConnection("resultset"); conn = getConnection("resultSet");
stat=conn.createStatement(); stat=conn.createStatement();
...@@ -134,7 +134,7 @@ public class TestResultSet extends TestBase { ...@@ -134,7 +134,7 @@ public class TestResultSet extends TestBase {
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
check(meta.getColumnCount(), 3); check(meta.getColumnCount(), 3);
check(meta.getCatalogName(1), "RESULTSET"); check(meta.getCatalogName(1), "resultSet".toUpperCase());
check("PUBLIC".equals(meta.getSchemaName(2))); check("PUBLIC".equals(meta.getSchemaName(2)));
check("TEST".equals(meta.getTableName(1))); check("TEST".equals(meta.getTableName(1)));
check("ID".equals(meta.getColumnName(1))); check("ID".equals(meta.getColumnName(1)));
...@@ -670,7 +670,7 @@ public class TestResultSet extends TestBase { ...@@ -670,7 +670,7 @@ public class TestResultSet extends TestBase {
stat.execute("INSERT INTO TEST VALUES(1,X'01010101')"); stat.execute("INSERT INTO TEST VALUES(1,X'01010101')");
stat.execute("INSERT INTO TEST VALUES(2,X'02020202')"); stat.execute("INSERT INTO TEST VALUES(2,X'02020202')");
stat.execute("INSERT INTO TEST VALUES(3,X'00')"); stat.execute("INSERT INTO TEST VALUES(3,X'00')");
stat.execute("INSERT INTO TEST VALUES(4,X'ffFFff')"); stat.execute("INSERT INTO TEST VALUES(4,X'ffffff')");
stat.execute("INSERT INTO TEST VALUES(5,X'0bcec1')"); stat.execute("INSERT INTO TEST VALUES(5,X'0bcec1')");
stat.execute("INSERT INTO TEST VALUES(6,NULL)"); stat.execute("INSERT INTO TEST VALUES(6,NULL)");
rs=stat.executeQuery("SELECT * FROM TEST ORDER BY ID"); rs=stat.executeQuery("SELECT * FROM TEST ORDER BY ID");
......
...@@ -15,8 +15,8 @@ public class TestXA { ...@@ -15,8 +15,8 @@ public class TestXA {
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
// InitialContext ictx = new InitialContext(); // InitialContext context = new InitialContext();
// ictx.rebind(USER_TRANSACTION_JNDI_NAME, jotm.getUserTransaction()); // context.rebind(USER_TRANSACTION_JNDI_NAME, j.getUserTransaction());
JdbcDataSource ds1 = new JdbcDataSource(); JdbcDataSource ds1 = new JdbcDataSource();
ds1.setPassword(""); ds1.setPassword("");
...@@ -28,7 +28,7 @@ public class TestXA { ...@@ -28,7 +28,7 @@ public class TestXA {
ds2.setUser("sa"); ds2.setUser("sa");
ds2.setURL("jdbc:h2:db2H2"); ds2.setURL("jdbc:h2:db2H2");
// UserTransaction ut = (UserTransaction) ictx.lookup("UserTransaction"); // UserTransaction ut = (UserTransaction) context.lookup("UserTransaction");
// ut.begin(); // ut.begin();
Connection c1 = ds1.getXAConnection().getConnection(); Connection c1 = ds1.getXAConnection().getConnection();
...@@ -36,15 +36,15 @@ public class TestXA { ...@@ -36,15 +36,15 @@ public class TestXA {
Connection c2 = ds2.getXAConnection().getConnection(); Connection c2 = ds2.getXAConnection().getConnection();
c2.setAutoCommit(false); c2.setAutoCommit(false);
c1.createStatement().executeUpdate("create table test(id int, teste varchar(255))"); c1.createStatement().executeUpdate("create table test(id int, test varchar(255))");
c2.createStatement().executeUpdate("create table test(id int, teste varchar(255))"); c2.createStatement().executeUpdate("create table test(id int, test varchar(255))");
// ut.rollback(); // ut.rollback();
c1.close(); c1.close();
c2.close(); c2.close();
// jotm.stop(); // j.stop();
// System.exit(0); // System.exit(0);
} }
......
...@@ -82,11 +82,11 @@ public class TestZloty extends TestBase { ...@@ -82,11 +82,11 @@ public class TestZloty extends TestBase {
prep.setInt(1, 3); prep.setInt(1, 3);
try { try {
BigDecimal crappyVal=new BigDecimal("12.100000") { BigDecimal value=new BigDecimal("12.100000") {
private static final long serialVersionUID = -7909023971521750844L; private static final long serialVersionUID = -7909023971521750844L;
public String toString() { return "12,100000 EURO"; } public String toString() { return "12,100000 EURO"; }
}; };
prep.setBigDecimal(2, crappyVal); prep.setBigDecimal(2, value);
prep.execute(); prep.execute();
error("unexpected success"); error("unexpected success");
} catch(SQLException e) { } catch(SQLException e) {
......
...@@ -61,8 +61,8 @@ public class Listener implements Runnable { ...@@ -61,8 +61,8 @@ public class Listener implements Runnable {
System.out.println("Closed with Exception: " + e); System.out.println("Closed with Exception: " + e);
} }
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
int ops = (int) (1000 * maxValue / time); int operationsPerSecond = (int) (1000 * maxValue / time);
System.out.println("Max=" + maxValue + " operations/sec=" + ops); System.out.println("Max=" + maxValue + " operations/sec=" + operationsPerSecond);
} }
} }
......
...@@ -56,7 +56,7 @@ class DbConnection implements DbInterface { ...@@ -56,7 +56,7 @@ class DbConnection implements DbInterface {
tables.remove(i); tables.remove(i);
i--; i--;
} catch (SQLException e) { } catch (SQLException e) {
// maybe a referencial integrity // maybe a referential integrity
} }
} }
// could not drop any table and still tables to drop // could not drop any table and still tables to drop
......
...@@ -12,7 +12,7 @@ import java.util.*; ...@@ -12,7 +12,7 @@ import java.util.*;
import org.h2.test.TestBase; import org.h2.test.TestBase;
class Result implements Comparable { class Result implements Comparable {
static final int SUCCESS=0, BOOLEAN=1, INT=2, EXCEPTION=3, RESULTSET=4; static final int SUCCESS=0, BOOLEAN=1, INT=2, EXCEPTION=3, RESULT_SET=4;
private int type; private int type;
private boolean bool; private boolean bool;
private int intValue; private int intValue;
...@@ -46,7 +46,7 @@ class Result implements Comparable { ...@@ -46,7 +46,7 @@ class Result implements Comparable {
Result(TestSynth config, String sql, ResultSet rs) { Result(TestSynth config, String sql, ResultSet rs) {
this.sql = sql; this.sql = sql;
type = RESULTSET; type = RESULT_SET;
try { try {
rows = new ArrayList(); rows = new ArrayList();
header = new ArrayList(); header = new ArrayList();
...@@ -81,7 +81,7 @@ class Result implements Comparable { ...@@ -81,7 +81,7 @@ class Result implements Comparable {
exception.printStackTrace(new PrintWriter(w)); exception.printStackTrace(new PrintWriter(w));
return "exception: "+exception.getSQLState()+": "+exception.getMessage() + "\r\n"+w.toString(); return "exception: "+exception.getSQLState()+": "+exception.getMessage() + "\r\n"+w.toString();
} }
case RESULTSET: case RESULT_SET:
String result = "ResultSet { // size=" + rows.size() + "\r\n "; String result = "ResultSet { // size=" + rows.size() + "\r\n ";
for(int i=0; i<header.size(); i++) { for(int i=0; i<header.size(); i++) {
Column column = (Column)header.get(i); Column column = (Column)header.get(i);
...@@ -110,7 +110,7 @@ class Result implements Comparable { ...@@ -110,7 +110,7 @@ class Result implements Comparable {
case BOOLEAN: case BOOLEAN:
case INT: case INT:
case SUCCESS: case SUCCESS:
case RESULTSET: case RESULT_SET:
return toString().compareTo(r.toString()); return toString().compareTo(r.toString());
default: default:
throw new Error("internal"); throw new Error("internal");
...@@ -132,7 +132,7 @@ class Result implements Comparable { ...@@ -132,7 +132,7 @@ class Result implements Comparable {
System.out.println("> update count: "+intValue); System.out.println("> update count: "+intValue);
} }
break; break;
case RESULTSET: case RESULT_SET:
System.out.println("> rs "+rows.size()); System.out.println("> rs "+rows.size());
break; break;
} }
......
...@@ -61,7 +61,7 @@ public class TestCrashAPI extends TestBase { ...@@ -61,7 +61,7 @@ public class TestCrashAPI extends TestBase {
if(delete) { if(delete) {
deleteDb(); deleteDb();
} }
// can not use FILE_LOCK=NO, otherwise something could be written into the database in the finalizer // can not use FILE_LOCK=NO, otherwise something could be written into the database in the finalize method
String add = ""; // ";STORAGE=TEXT"; String add = ""; // ";STORAGE=TEXT";
// int testing; // int testing;
...@@ -75,7 +75,7 @@ public class TestCrashAPI extends TestBase { ...@@ -75,7 +75,7 @@ public class TestCrashAPI extends TestBase {
// config.logMode = 2; // config.logMode = 2;
// } // }
String url = getURL(DIR + "/crashapi" + seed, true) + add; String url = getURL(DIR + "/crashApi" + seed, true) + add;
Connection conn = null; Connection conn = null;
// System.gc(); // System.gc();
......
...@@ -25,7 +25,7 @@ public abstract class TestHalt extends TestBase { ...@@ -25,7 +25,7 @@ public abstract class TestHalt extends TestBase {
private SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm:ss "); private SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm:ss ");
protected static final int OP_INSERT = 1, OP_DELETE = 2, OP_UPDATE = 4, OP_SELECT = 8; protected static final int OP_INSERT = 1, OP_DELETE = 2, OP_UPDATE = 4, OP_SELECT = 8;
protected static final int FLAG_NODELAY = 1, FLAG_LOBS = 2; protected static final int FLAG_NO_DELAY = 1, FLAG_LOBS = 2;
protected int operations, flags, value; protected int operations, flags, value;
protected Connection conn; protected Connection conn;
protected Random random = new Random(); protected Random random = new Random();
...@@ -120,7 +120,7 @@ public abstract class TestHalt extends TestBase { ...@@ -120,7 +120,7 @@ public abstract class TestHalt extends TestBase {
// int operations = OP_INSERT; // int operations = OP_INSERT;
// OP_DELETE = 1, OP_UPDATE = 2, OP_SELECT = 4; // OP_DELETE = 1, OP_UPDATE = 2, OP_SELECT = 4;
// int flags = FLAG_NODELAY; // int flags = FLAG_NODELAY;
// FLAG_NODELAY = 1, FLAG_AUTOCOMMIT = 2, FLAG_SMALLCACHE = 4; // FLAG_NO_DELAY = 1, FLAG_AUTO_COMMIT = 2, FLAG_SMALL_CACHE = 4;
int value = random.nextInt(1000); int value = random.nextInt(1000);
// for Derby and HSQLDB // for Derby and HSQLDB
// String classPath = "-cp .;D:/data/java/hsqldb.jar;D:/data/java/derby.jar"; // String classPath = "-cp .;D:/data/java/hsqldb.jar;D:/data/java/derby.jar";
......
...@@ -53,7 +53,7 @@ public class TestHaltApp extends TestHalt { ...@@ -53,7 +53,7 @@ public class TestHaltApp extends TestHalt {
protected void appStart() throws SQLException { protected void appStart() throws SQLException {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
if((flags & FLAG_NODELAY) != 0) { if((flags & FLAG_NO_DELAY) != 0) {
stat.execute("SET WRITE_DELAY 0"); stat.execute("SET WRITE_DELAY 0");
stat.execute("SET MAX_LOG_SIZE 1"); stat.execute("SET MAX_LOG_SIZE 1");
} }
...@@ -97,7 +97,7 @@ public class TestHaltApp extends TestHalt { ...@@ -97,7 +97,7 @@ public class TestHaltApp extends TestHalt {
conn.commit(); conn.commit();
log("committed: " + rowCount, null); log("committed: " + rowCount, null);
} }
if((flags & FLAG_NODELAY) != 0) { if((flags & FLAG_NO_DELAY) != 0) {
if(random.nextInt(100) == 0) { if(random.nextInt(100) == 0) {
stat.execute("CHECKPOINT"); stat.execute("CHECKPOINT");
} }
......
...@@ -35,10 +35,10 @@ public class TestMultiNews extends TestMultiThread { ...@@ -35,10 +35,10 @@ public class TestMultiNews extends TestMultiThread {
PreparedStatement prep; PreparedStatement prep;
if(random.nextBoolean()) { if(random.nextBoolean()) {
prep = conn.prepareStatement( prep = conn.prepareStatement(
"SELECT * FROM NEWS WHERE FLINK = ?"); "SELECT * FROM NEWS WHERE LINK = ?");
} else { } else {
prep = conn.prepareStatement( prep = conn.prepareStatement(
"SELECT * FROM NEWS WHERE FVALUE = ?"); "SELECT * FROM NEWS WHERE VALUE = ?");
} }
prep.setString(1, PREFIX_URL + random.nextInt(len)); prep.setString(1, PREFIX_URL + random.nextInt(len));
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
...@@ -50,7 +50,7 @@ public class TestMultiNews extends TestMultiThread { ...@@ -50,7 +50,7 @@ public class TestMultiNews extends TestMultiThread {
} }
} else { } else {
PreparedStatement prep = conn.prepareStatement( PreparedStatement prep = conn.prepareStatement(
"UPDATE NEWS SET FSTATE = ? WHERE FID = ?"); "UPDATE NEWS SET STATE = ? WHERE FID = ?");
prep.setInt(1, random.nextInt(100)); prep.setInt(1, random.nextInt(100));
prep.setInt(2, random.nextInt(len)); prep.setInt(2, random.nextInt(len));
int count = prep.executeUpdate(); int count = prep.executeUpdate();
...@@ -77,16 +77,16 @@ public class TestMultiNews extends TestMultiThread { ...@@ -77,16 +77,16 @@ public class TestMultiNews extends TestMultiThread {
stat.execute( stat.execute(
"CREATE TABLE TEST (ID IDENTITY, NAME VARCHAR)"); "CREATE TABLE TEST (ID IDENTITY, NAME VARCHAR)");
stat.execute( stat.execute(
"CREATE TABLE NEWS (FID NUMERIC(19) PRIMARY KEY, FCOMMENTS LONGVARCHAR, " + "CREATE TABLE NEWS (FID NUMERIC(19) PRIMARY KEY, COMMENTS LONGVARCHAR, " +
"FLINK VARCHAR(255), FSTATE INTEGER, FVALUE VARCHAR(255))"); "LINK VARCHAR(255), STATE INTEGER, VALUE VARCHAR(255))");
stat.execute( stat.execute(
"CREATE INDEX IF NOT EXISTS NEWS_GUID_VALUE_INDEX ON NEWS(FVALUE)"); "CREATE INDEX IF NOT EXISTS NEWS_GUID_VALUE_INDEX ON NEWS(VALUE)");
stat.execute( stat.execute(
"CREATE INDEX IF NOT EXISTS NEWS_LINK_INDEX ON NEWS(FLINK)"); "CREATE INDEX IF NOT EXISTS NEWS_LINK_INDEX ON NEWS(LINK)");
stat.execute( stat.execute(
"CREATE INDEX IF NOT EXISTS NEWS_STATE_INDEX ON NEWS(FSTATE)"); "CREATE INDEX IF NOT EXISTS NEWS_STATE_INDEX ON NEWS(STATE)");
PreparedStatement prep = conn.prepareStatement( PreparedStatement prep = conn.prepareStatement(
"INSERT INTO NEWS (FID, FCOMMENTS, FLINK, FSTATE, FVALUE) VALUES " + "INSERT INTO NEWS (FID, COMMENTS, LINK, STATE, VALUE) VALUES " +
"(?, ?, ?, ?, ?) "); "(?, ?, ?, ?, ?) ");
PreparedStatement prep2 = conn.prepareStatement( PreparedStatement prep2 = conn.prepareStatement(
"INSERT INTO TEST (NAME) VALUES (?)"); "INSERT INTO TEST (NAME) VALUES (?)");
...@@ -100,10 +100,10 @@ public class TestMultiNews extends TestMultiThread { ...@@ -100,10 +100,10 @@ public class TestMultiNews extends TestMultiThread {
} }
String comment = buff.toString(); String comment = buff.toString();
prep.setInt(1, i); // FID prep.setInt(1, i); // FID
prep.setString(2, comment); // FCOMMENTS prep.setString(2, comment); // COMMENTS
prep.setString(3, PREFIX_URL + i); // FLINK prep.setString(3, PREFIX_URL + i); // LINK
prep.setInt(4, 0); // FSTATE prep.setInt(4, 0); // STATE
prep.setString(5, PREFIX_URL + i); // FVALUE prep.setString(5, PREFIX_URL + i); // VALUE
prep.execute(); prep.execute();
prep2.setString(1, comment); prep2.setString(1, comment);
prep2.execute(); prep2.execute();
......
...@@ -25,12 +25,12 @@ public class TestMultiNewsSimple extends TestMultiThread { ...@@ -25,12 +25,12 @@ public class TestMultiNewsSimple extends TestMultiThread {
void first() throws SQLException { void first() throws SQLException {
Connection conn = base.getConnection(); Connection conn = base.getConnection();
conn.createStatement().execute("create table news(fid identity, fstate int default 0, text varchar default '')"); conn.createStatement().execute("create table news(id identity, state int default 0, text varchar default '')");
PreparedStatement prep = conn.prepareStatement("insert into news() values()"); PreparedStatement prep = conn.prepareStatement("insert into news() values()");
for(int i=0; i<newsCount; i++) { for(int i=0; i<newsCount; i++) {
prep.executeUpdate(); prep.executeUpdate();
} }
conn.createStatement().execute("update news set text = 'Text' || fid"); conn.createStatement().execute("update news set text = 'Text' || id");
conn.close(); conn.close();
} }
...@@ -52,12 +52,12 @@ public class TestMultiNewsSimple extends TestMultiThread { ...@@ -52,12 +52,12 @@ public class TestMultiNewsSimple extends TestMultiThread {
} }
} else { } else {
if(random.nextBoolean()) { if(random.nextBoolean()) {
PreparedStatement prep = conn.prepareStatement("update news set fstate = ? where fid = ?"); PreparedStatement prep = conn.prepareStatement("update news set state = ? where id = ?");
prep.setInt(1, random.nextInt(getNewsCount())); prep.setInt(1, random.nextInt(getNewsCount()));
prep.setInt(2, random.nextInt(10)); prep.setInt(2, random.nextInt(10));
prep.execute(); prep.execute();
} else { } else {
PreparedStatement prep = conn.prepareStatement("select * from news where fid = ?"); PreparedStatement prep = conn.prepareStatement("select * from news where id = ?");
prep.setInt(1, random.nextInt(getNewsCount())); prep.setInt(1, random.nextInt(getNewsCount()));
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
if(!rs.next()) { if(!rs.next()) {
......
...@@ -27,7 +27,7 @@ public class TestMultiOrder extends TestMultiThread { ...@@ -27,7 +27,7 @@ public class TestMultiOrder extends TestMultiThread {
} }
void begin() throws SQLException { void begin() throws SQLException {
insertLine = conn.prepareStatement("insert into orderline(orderid, lineid, text, amount) values(?, ?, ?, ?)"); insertLine = conn.prepareStatement("insert into orderLine(orderid, lineid, text, amount) values(?, ?, ?, ?)");
insertCustomer(); insertCustomer();
} }
...@@ -114,10 +114,10 @@ public class TestMultiOrder extends TestMultiThread { ...@@ -114,10 +114,10 @@ public class TestMultiOrder extends TestMultiThread {
Connection conn = base.getConnection(); Connection conn = base.getConnection();
conn.createStatement().execute("drop table customer if exists"); conn.createStatement().execute("drop table customer if exists");
conn.createStatement().execute("drop table orders if exists"); conn.createStatement().execute("drop table orders if exists");
conn.createStatement().execute("drop table orderline if exists"); conn.createStatement().execute("drop table orderLine if exists");
conn.createStatement().execute("create table customer(id int primary key, name varchar, account decimal)"); conn.createStatement().execute("create table customer(id int primary key, name varchar, account decimal)");
conn.createStatement().execute("create table orders(id int identity primary key, customer_id int, total decimal)"); conn.createStatement().execute("create table orders(id int identity primary key, customer_id int, total decimal)");
conn.createStatement().execute("create table orderline(orderid int, lineid int, text varchar, amount decimal, primary key(orderid, lineid))"); conn.createStatement().execute("create table orderLine(orderid int, lineid int, text varchar, amount decimal, primary key(orderid, lineid))");
conn.close(); conn.close();
} }
...@@ -133,10 +133,10 @@ public class TestMultiOrder extends TestMultiThread { ...@@ -133,10 +133,10 @@ public class TestMultiOrder extends TestMultiThread {
base.check(rs.getInt(1), orderCount); base.check(rs.getInt(1), orderCount);
// System.out.println("orders: " + rs.getInt(1)); // System.out.println("orders: " + rs.getInt(1));
rs = conn.createStatement().executeQuery("select count(*) from orderline"); rs = conn.createStatement().executeQuery("select count(*) from orderLine");
rs.next(); rs.next();
base.check(rs.getInt(1), orderLineCount); base.check(rs.getInt(1), orderLineCount);
// System.out.println("orderlines: " + rs.getInt(1)); // System.out.println("orderLines: " + rs.getInt(1));
conn.close(); conn.close();
} }
......
...@@ -35,8 +35,8 @@ public class TestRandomSQL extends TestBase { ...@@ -35,8 +35,8 @@ public class TestRandomSQL extends TestBase {
} }
private String getDatabaseName() { private String getDatabaseName() {
// return "dataSynth/randomsql" + dbId+";TRACE_LEVEL_FILE=3"; // return "dataSynth/randomSql" + dbId+";TRACE_LEVEL_FILE=3";
return "dataSynth/randomsql" + dbId; return "dataSynth/randomSql" + dbId;
} }
private Connection connect() throws Exception { private Connection connect() throws Exception {
......
...@@ -182,7 +182,8 @@ public class TestSynth extends TestBase { ...@@ -182,7 +182,8 @@ public class TestSynth extends TestBase {
Result copy = (Result) results.get(i); Result copy = (Result) results.get(i);
if (original.compareTo(copy) != 0) { if (original.compareTo(copy) != 0) {
if (showError) { if (showError) {
throw new Error("Results don't match: original (0): \r\n" + original + "\r\nother:\r\n" + copy); throw new Error("Results don't match: original (0): \r\n" + original + "\r\n" +
"other:\r\n" + copy);
} else { } else {
throw new Error("Results don't match"); throw new Error("Results don't match");
} }
......
...@@ -45,7 +45,7 @@ public class TestExit extends TestBase implements DatabaseEventListener { ...@@ -45,7 +45,7 @@ public class TestExit extends TestBase implements DatabaseEventListener {
} }
proc.waitFor(); proc.waitFor();
if(!getClosedFile().exists()) { if(!getClosedFile().exists()) {
error("didnt close database"); error("did not close database");
} }
procDef = new String[]{ procDef = new String[]{
"java", "-cp", classPath, "java", "-cp", classPath,
......
...@@ -18,16 +18,16 @@ public class TestSampleApps extends TestBase { ...@@ -18,16 +18,16 @@ public class TestSampleApps extends TestBase {
testApp(org.h2.samples.Compact.class, null, "Compacting...\nDone."); testApp(org.h2.samples.Compact.class, null, "Compacting...\nDone.");
testApp(org.h2.samples.CsvSample.class, null, testApp(org.h2.samples.CsvSample.class, null,
"NAME: Bob Meier\n" "NAME: Bob Meier\n"
+ "EMAIL: bob.meier@abcde.fgh\n" + "EMAIL: bob.meier@abcde.abc\n"
+"PHONE: +41123456789\n\n" +"PHONE: +41123456789\n\n"
+"NAME: John Jones\n" +"NAME: John Jones\n"
+"EMAIL: johnjones@abcde.fgh\n" +"EMAIL: john.jones@abcde.abc\n"
+"PHONE: +41976543210\n"); +"PHONE: +41976543210\n");
testApp(org.h2.samples.Function.class, null, testApp(org.h2.samples.Function.class, null,
"2 is prime\n3 is prime\n5 is prime\n7 is prime\n11 is prime\n13 is prime\n17 is prime\n19 is prime"); "2 is prime\n3 is prime\n5 is prime\n7 is prime\n11 is prime\n13 is prime\n17 is prime\n19 is prime");
testApp(org.h2.samples.SecurePassword.class, null, "Hello"); testApp(org.h2.samples.SecurePassword.class, null, "Hello");
// TODO test ShowProgress (percent numbers are hardware specific) // TODO test ShowProgress (percent numbers are hardware specific)
// TODO test ShutdownServer (server needs to be started in a separater process) // TODO test ShutdownServer (server needs to be started in a separate process)
testApp(org.h2.samples.TriggerSample.class, null, "The sum is 20.00"); testApp(org.h2.samples.TriggerSample.class, null, "The sum is 20.00");
// tools // tools
......
...@@ -56,10 +56,10 @@ public class TestSecurity extends TestBase { ...@@ -56,10 +56,10 @@ public class TestSecurity extends TestBase {
public void testXTEA() throws Exception { public void testXTEA() throws Exception {
byte[] test = new byte[4096]; byte[] test = new byte[4096];
XTEA tea = new XTEA(); XTEA xtea = new XTEA();
tea.setKey("abcdefghijklmnop".getBytes()); xtea.setKey("abcdefghijklmnop".getBytes());
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
tea.decryptBlock(test, test, 0); xtea.decryptBlock(test, test, 0);
} }
} }
......
...@@ -58,20 +58,20 @@ public class TestStreams extends TestBase { ...@@ -58,20 +58,20 @@ public class TestStreams extends TestBase {
comp.close(); comp.close();
byte[] compressed = out.toByteArray(); byte[] compressed = out.toByteArray();
ByteArrayInputStream in = new ByteArrayInputStream(compressed); ByteArrayInputStream in = new ByteArrayInputStream(compressed);
LZFInputStream decomp = new LZFInputStream(in); LZFInputStream decompress = new LZFInputStream(in);
byte[] test = new byte[buffer.length]; byte[] test = new byte[buffer.length];
for(int j=0; j<buffer.length;) { for(int j=0; j<buffer.length;) {
int[] sizes = new int[]{0, 1, random.nextInt(100), random.nextInt(100000)}; int[] sizes = new int[]{0, 1, random.nextInt(100), random.nextInt(100000)};
int size = sizes[random.nextInt(sizes.length)]; int size = sizes[random.nextInt(sizes.length)];
if(size == 1) { if(size == 1) {
int x = decomp.read(); int x = decompress.read();
if(x < 0) { if(x < 0) {
break; break;
} }
test[j++] = (byte)x; test[j++] = (byte)x;
} else { } else {
size = Math.min(size, test.length-j); size = Math.min(size, test.length-j);
int l = decomp.read(test, j, size); int l = decompress.read(test, j, size);
if(l < 0) { if(l < 0) {
break; break;
} else { } else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论