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

--no commit message

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