提交 ad1a436f authored 作者: Thomas Mueller's avatar Thomas Mueller

junit compatibility

上级 f2c6461d
...@@ -24,12 +24,12 @@ public class TestAutoRecompile extends TestBase { ...@@ -24,12 +24,12 @@ public class TestAutoRecompile extends TestBase {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY)");
PreparedStatement prep = conn.prepareStatement("SELECT * FROM TEST"); PreparedStatement prep = conn.prepareStatement("SELECT * FROM TEST");
check(prep.executeQuery().getMetaData().getColumnCount(), 1); assertEquals(prep.executeQuery().getMetaData().getColumnCount(), 1);
stat.execute("ALTER TABLE TEST ADD COLUMN NAME VARCHAR(255)"); stat.execute("ALTER TABLE TEST ADD COLUMN NAME VARCHAR(255)");
check(prep.executeQuery().getMetaData().getColumnCount(), 2); assertEquals(prep.executeQuery().getMetaData().getColumnCount(), 2);
stat.execute("DROP TABLE TEST"); stat.execute("DROP TABLE TEST");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, X INT, Y INT)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, X INT, Y INT)");
check(prep.executeQuery().getMetaData().getColumnCount(), 3); assertEquals(prep.executeQuery().getMetaData().getColumnCount(), 3);
// TODO test auto-recompile with insert..select, views and so on // TODO test auto-recompile with insert..select, views and so on
prep = conn.prepareStatement("INSERT INTO TEST VALUES(1, 2, 3)"); prep = conn.prepareStatement("INSERT INTO TEST VALUES(1, 2, 3)");
...@@ -38,13 +38,13 @@ public class TestAutoRecompile extends TestBase { ...@@ -38,13 +38,13 @@ public class TestAutoRecompile extends TestBase {
prep.execute(); prep.execute();
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
try { try {
prep.execute(); prep.execute();
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
conn.close(); conn.close();
} }
......
...@@ -45,11 +45,11 @@ public class TestBigResult extends TestBase { ...@@ -45,11 +45,11 @@ public class TestBigResult extends TestBase {
"WHERE SQL_STMT='commit' OR SQL_STMT='rollback')"); "WHERE SQL_STMT='commit' OR SQL_STMT='rollback')");
int count = 0, last = 1; int count = 0, last = 1;
while (rs.next()) { while (rs.next()) {
check(last, rs.getInt(1)); assertEquals(last, rs.getInt(1));
last += 2; last += 2;
count++; count++;
} }
check(len / 2, count); assertEquals(len / 2, count);
conn.close(); conn.close();
} }
...@@ -96,15 +96,15 @@ public class TestBigResult extends TestBase { ...@@ -96,15 +96,15 @@ public class TestBigResult extends TestBase {
ResultSet rs; ResultSet rs;
rs = stat.executeQuery("select id from test order by id limit 10 offset 85"); rs = stat.executeQuery("select id from test order by id limit 10 offset 85");
for (int i = 85; rs.next(); i++) { for (int i = 85; rs.next(); i++) {
check(i, rs.getInt(1)); assertEquals(i, rs.getInt(1));
} }
rs = stat.executeQuery("select id from test order by id limit 10 offset 95"); rs = stat.executeQuery("select id from test order by id limit 10 offset 95");
for (int i = 95; rs.next(); i++) { for (int i = 95; rs.next(); i++) {
check(i, rs.getInt(1)); assertEquals(i, rs.getInt(1));
} }
rs = stat.executeQuery("select id from test order by id limit 10 offset 105"); rs = stat.executeQuery("select id from test order by id limit 10 offset 105");
for (int i = 105; rs.next(); i++) { for (int i = 105; rs.next(); i++) {
check(i, rs.getInt(1)); assertEquals(i, rs.getInt(1));
} }
conn.close(); conn.close();
} }
...@@ -133,22 +133,22 @@ public class TestBigResult extends TestBase { ...@@ -133,22 +133,22 @@ public class TestBigResult extends TestBase {
ResultSet rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID"); ResultSet rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID");
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
rs.next(); rs.next();
check(i, rs.getInt(1)); assertEquals(i, rs.getInt(1));
check("Name " + i, rs.getString(2)); assertEquals("Name " + i, rs.getString(2));
check("First Name " + i, rs.getString(3)); assertEquals("First Name " + i, rs.getString(3));
check(i * 10, rs.getInt(4)); assertEquals(i * 10, rs.getInt(4));
check(i * i, rs.getInt(5)); assertEquals(i * i, rs.getInt(5));
} }
stat.setMaxRows(len + 1); stat.setMaxRows(len + 1);
rs = stat.executeQuery("SELECT * FROM TEST WHERE ID >= 1000 ORDER BY ID"); rs = stat.executeQuery("SELECT * FROM TEST WHERE ID >= 1000 ORDER BY ID");
for (int i = 1000; i < len; i++) { for (int i = 1000; i < len; i++) {
rs.next(); rs.next();
check(i, rs.getInt(1)); assertEquals(i, rs.getInt(1));
check("Name " + i, rs.getString(2)); assertEquals("Name " + i, rs.getString(2));
check("First Name " + i, rs.getString(3)); assertEquals("First Name " + i, rs.getString(3));
check(i * 10, rs.getInt(4)); assertEquals(i * 10, rs.getInt(4));
check(i * i, rs.getInt(5)); assertEquals(i * i, rs.getInt(5));
} }
stat.execute("SET MAX_MEMORY_ROWS 2"); stat.execute("SET MAX_MEMORY_ROWS 2");
......
...@@ -61,14 +61,14 @@ public class TestCluster extends TestBase { ...@@ -61,14 +61,14 @@ public class TestCluster extends TestBase {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test", "sa", "");
error("should not be able to connect in standalone mode"); error("should not be able to connect in standalone mode");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
try { try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", "");
error("should not be able to connect in standalone mode"); error("should not be able to connect in standalone mode");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
// test regular cluster connection // test regular cluster connection
...@@ -130,8 +130,8 @@ public class TestCluster extends TestBase { ...@@ -130,8 +130,8 @@ public class TestCluster extends TestBase {
prep.setInt(1, i); prep.setInt(1, i);
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
rs.next(); rs.next();
check(rs.getString(2), "Data" + i); assertEquals(rs.getString(2), "Data" + i);
checkFalse(rs.next()); assertFalse(rs.next());
} }
} }
......
...@@ -33,22 +33,22 @@ public class TestEncryptedDb extends TestBase { ...@@ -33,22 +33,22 @@ public class TestEncryptedDb extends TestBase {
try { try {
conn.close(); conn.close();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
try { try {
conn = getConnection("exclusive;CIPHER=AES", "sa", "1234 1234"); conn = getConnection("exclusive;CIPHER=AES", "sa", "1234 1234");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
conn = getConnection("exclusive;CIPHER=AES", "sa", "123 123"); conn = getConnection("exclusive;CIPHER=AES", "sa", "123 123");
stat = conn.createStatement(); stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT * FROM TEST"); ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
check(rs.next()); assertTrue(rs.next());
check(1, rs.getInt(1)); assertEquals(1, rs.getInt(1));
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
} }
......
...@@ -27,7 +27,7 @@ public class TestExclusive extends TestBase { ...@@ -27,7 +27,7 @@ public class TestExclusive extends TestBase {
conn2.close(); conn2.close();
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
stat.execute("set exclusive false"); stat.execute("set exclusive false");
...@@ -57,7 +57,7 @@ public class TestExclusive extends TestBase { ...@@ -57,7 +57,7 @@ public class TestExclusive extends TestBase {
break; break;
} }
} }
check(state[0], 2); assertEquals(state[0], 2);
stat.execute("set exclusive true"); stat.execute("set exclusive true");
conn.close(); conn.close();
......
...@@ -97,29 +97,29 @@ public class TestFullText extends TestBase { ...@@ -97,29 +97,29 @@ public class TestFullText extends TestBase {
ResultSet rs; ResultSet rs;
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hello', 0, 0)"); rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hello', 0, 0)");
rs.next(); rs.next();
check(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"); assertEquals(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=1");
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hallo', 0, 0)"); rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hallo', 0, 0)");
checkFalse(rs.next()); assertFalse(rs.next());
stat.execute("INSERT INTO TEST VALUES(2, 'Hallo Welt')"); stat.execute("INSERT INTO TEST VALUES(2, 'Hallo Welt')");
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hello', 0, 0)"); rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hello', 0, 0)");
rs.next(); rs.next();
check(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"); assertEquals(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=1");
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hallo', 0, 0)"); rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hallo', 0, 0)");
rs.next(); rs.next();
check(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=2"); assertEquals(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=2");
checkFalse(rs.next()); assertFalse(rs.next());
stat.execute("CALL " + prefix + "REINDEX()"); stat.execute("CALL " + prefix + "REINDEX()");
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hello', 0, 0)"); rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hello', 0, 0)");
rs.next(); rs.next();
check(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"); assertEquals(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=1");
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hallo', 0, 0)"); rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('Hallo', 0, 0)");
rs.next(); rs.next();
check(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=2"); assertEquals(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=2");
checkFalse(rs.next()); assertFalse(rs.next());
stat.execute("INSERT INTO TEST VALUES(3, 'Hello World')"); stat.execute("INSERT INTO TEST VALUES(3, 'Hello World')");
stat.execute("INSERT INTO TEST VALUES(4, 'Hello World')"); stat.execute("INSERT INTO TEST VALUES(4, 'Hello World')");
...@@ -127,38 +127,38 @@ public class TestFullText extends TestBase { ...@@ -127,38 +127,38 @@ public class TestFullText extends TestBase {
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 0, 0) ORDER BY QUERY"); rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 0, 0) ORDER BY QUERY");
rs.next(); rs.next();
check(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"); assertEquals(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=1");
rs.next(); rs.next();
check(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=3"); assertEquals(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=3");
rs.next(); rs.next();
check(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=4"); assertEquals(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=4");
rs.next(); rs.next();
check(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=5"); assertEquals(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=5");
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 1, 0)"); rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 1, 0)");
rs.next(); rs.next();
check(rs.getString(1).startsWith("\"PUBLIC\".\"TEST\" WHERE \"ID\"=")); assertTrue(rs.getString(1).startsWith("\"PUBLIC\".\"TEST\" WHERE \"ID\"="));
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 0, 2) ORDER BY QUERY"); rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 0, 2) ORDER BY QUERY");
rs.next(); rs.next();
check(rs.getString(1).startsWith("\"PUBLIC\".\"TEST\" WHERE \"ID\"=")); assertTrue(rs.getString(1).startsWith("\"PUBLIC\".\"TEST\" WHERE \"ID\"="));
rs.next(); rs.next();
check(rs.getString(1).startsWith("\"PUBLIC\".\"TEST\" WHERE \"ID\"=")); assertTrue(rs.getString(1).startsWith("\"PUBLIC\".\"TEST\" WHERE \"ID\"="));
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 2, 1) ORDER BY QUERY"); rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 2, 1) ORDER BY QUERY");
rs.next(); rs.next();
check(rs.getString(1).startsWith("\"PUBLIC\".\"TEST\" WHERE \"ID\"=")); assertTrue(rs.getString(1).startsWith("\"PUBLIC\".\"TEST\" WHERE \"ID\"="));
rs.next(); rs.next();
check(rs.getString(1).startsWith("\"PUBLIC\".\"TEST\" WHERE \"ID\"=")); assertTrue(rs.getString(1).startsWith("\"PUBLIC\".\"TEST\" WHERE \"ID\"="));
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('1', 0, 0)"); rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('1', 0, 0)");
rs.next(); rs.next();
check(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=1"); assertEquals(rs.getString(1), "\"PUBLIC\".\"TEST\" WHERE \"ID\"=1");
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
conn = getConnection("fullText"); conn = getConnection("fullText");
......
...@@ -50,18 +50,18 @@ public class TestFunctions extends TestBase { ...@@ -50,18 +50,18 @@ public class TestFunctions extends TestBase {
out.close(); out.close();
ResultSet rs = stat.executeQuery("SELECT LENGTH(FILE_READ('" + baseDir + "/test.txt')) LEN"); ResultSet rs = stat.executeQuery("SELECT LENGTH(FILE_READ('" + baseDir + "/test.txt')) LEN");
rs.next(); rs.next();
check(f.length(), rs.getInt(1)); assertEquals(f.length(), rs.getInt(1));
rs = stat.executeQuery("SELECT FILE_READ('" + baseDir + "/test.txt') PROP"); rs = stat.executeQuery("SELECT FILE_READ('" + baseDir + "/test.txt') PROP");
rs.next(); rs.next();
Properties p2 = new Properties(); Properties p2 = new Properties();
p2.load(rs.getBinaryStream(1)); p2.load(rs.getBinaryStream(1));
check(prop.size(), p2.size()); assertEquals(prop.size(), p2.size());
rs = stat.executeQuery("SELECT FILE_READ('" + baseDir + "/test.txt', NULL) PROP"); rs = stat.executeQuery("SELECT FILE_READ('" + baseDir + "/test.txt', NULL) PROP");
rs.next(); rs.next();
String ps = rs.getString(1); String ps = rs.getString(1);
FileReader r = new FileReader(f); FileReader r = new FileReader(f);
String ps2 = IOUtils.readStringAndClose(r, -1); String ps2 = IOUtils.readStringAndClose(r, -1);
check(ps, ps2); assertEquals(ps, ps2);
f.delete(); f.delete();
conn.close(); conn.close();
} }
...@@ -99,7 +99,7 @@ public class TestFunctions extends TestBase { ...@@ -99,7 +99,7 @@ public class TestFunctions extends TestBase {
stat.execute("CREATE AGGREGATE IF NOT EXISTS MEDIAN FOR \"" + MedianString.class.getName() + "\""); stat.execute("CREATE AGGREGATE IF NOT EXISTS MEDIAN FOR \"" + MedianString.class.getName() + "\"");
ResultSet rs = stat.executeQuery("SELECT MEDIAN(X) FROM SYSTEM_RANGE(1, 9)"); ResultSet rs = stat.executeQuery("SELECT MEDIAN(X) FROM SYSTEM_RANGE(1, 9)");
rs.next(); rs.next();
check("5", rs.getString(1)); assertEquals("5", rs.getString(1));
conn.close(); conn.close();
if (config.memory) { if (config.memory) {
...@@ -111,8 +111,8 @@ public class TestFunctions extends TestBase { ...@@ -111,8 +111,8 @@ public class TestFunctions extends TestBase {
rs = stat.executeQuery("SELECT MEDIAN(X) FROM SYSTEM_RANGE(1, 9)"); rs = stat.executeQuery("SELECT MEDIAN(X) FROM SYSTEM_RANGE(1, 9)");
DatabaseMetaData meta = conn.getMetaData(); DatabaseMetaData meta = conn.getMetaData();
rs = meta.getProcedures(null, null, "MEDIAN"); rs = meta.getProcedures(null, null, "MEDIAN");
check(rs.next()); assertTrue(rs.next());
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SCRIPT"); rs = stat.executeQuery("SCRIPT");
boolean found = false; boolean found = false;
while (rs.next()) { while (rs.next()) {
...@@ -121,7 +121,7 @@ public class TestFunctions extends TestBase { ...@@ -121,7 +121,7 @@ public class TestFunctions extends TestBase {
found = true; found = true;
} }
} }
check(found); assertTrue(found);
stat.execute("DROP AGGREGATE MEDIAN"); stat.execute("DROP AGGREGATE MEDIAN");
stat.execute("DROP AGGREGATE IF EXISTS MEDIAN"); stat.execute("DROP AGGREGATE IF EXISTS MEDIAN");
conn.close(); conn.close();
...@@ -140,102 +140,102 @@ public class TestFunctions extends TestBase { ...@@ -140,102 +140,102 @@ public class TestFunctions extends TestBase {
ResultSet rs; ResultSet rs;
rs = stat.executeQuery("CALL ADD_ROW(1, 'Hello')"); rs = stat.executeQuery("CALL ADD_ROW(1, 'Hello')");
rs.next(); rs.next();
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
rs = stat.executeQuery("SELECT * FROM TEST"); rs = stat.executeQuery("SELECT * FROM TEST");
rs.next(); rs.next();
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
check(rs.getString(2), "Hello"); assertEquals(rs.getString(2), "Hello");
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("CALL ADD_ROW(2, 'World')"); rs = stat.executeQuery("CALL ADD_ROW(2, 'World')");
stat.execute("CREATE ALIAS SELECT_F FOR \"" + getClass().getName() + ".select\""); stat.execute("CREATE ALIAS SELECT_F FOR \"" + getClass().getName() + ".select\"");
rs = stat.executeQuery("CALL SELECT_F('SELECT * FROM TEST ORDER BY ID')"); rs = stat.executeQuery("CALL SELECT_F('SELECT * FROM TEST ORDER BY ID')");
check(rs.getMetaData().getColumnCount(), 2); assertEquals(rs.getMetaData().getColumnCount(), 2);
rs.next(); rs.next();
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
check(rs.getString(2), "Hello"); assertEquals(rs.getString(2), "Hello");
rs.next(); rs.next();
check(rs.getInt(1), 2); assertEquals(rs.getInt(1), 2);
check(rs.getString(2), "World"); assertEquals(rs.getString(2), "World");
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT NAME FROM SELECT_F('SELECT * FROM TEST ORDER BY NAME') ORDER BY NAME DESC"); rs = stat.executeQuery("SELECT NAME FROM SELECT_F('SELECT * FROM TEST ORDER BY NAME') ORDER BY NAME DESC");
check(rs.getMetaData().getColumnCount(), 1); assertEquals(rs.getMetaData().getColumnCount(), 1);
rs.next(); rs.next();
check(rs.getString(1), "World"); assertEquals(rs.getString(1), "World");
rs.next(); rs.next();
check(rs.getString(1), "Hello"); assertEquals(rs.getString(1), "Hello");
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT SELECT_F('SELECT * FROM TEST WHERE ID=' || ID) FROM TEST ORDER BY ID"); rs = stat.executeQuery("SELECT SELECT_F('SELECT * FROM TEST WHERE ID=' || ID) FROM TEST ORDER BY ID");
check(rs.getMetaData().getColumnCount(), 1); assertEquals(rs.getMetaData().getColumnCount(), 1);
rs.next(); rs.next();
check("((1, Hello))", rs.getString(1)); assertEquals("((1, Hello))", rs.getString(1));
rs.next(); rs.next();
check("((2, World))", rs.getString(1)); assertEquals("((2, World))", rs.getString(1));
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT SELECT_F('SELECT * FROM TEST ORDER BY ID') FROM DUAL"); rs = stat.executeQuery("SELECT SELECT_F('SELECT * FROM TEST ORDER BY ID') FROM DUAL");
check(rs.getMetaData().getColumnCount(), 1); assertEquals(rs.getMetaData().getColumnCount(), 1);
rs.next(); rs.next();
check("((1, Hello), (2, World))", rs.getString(1)); assertEquals("((1, Hello), (2, World))", rs.getString(1));
checkFalse(rs.next()); assertFalse(rs.next());
try { try {
rs = stat.executeQuery("CALL SELECT_F('ERROR')"); rs = stat.executeQuery("CALL SELECT_F('ERROR')");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
check("42001", e.getSQLState()); assertEquals("42001", e.getSQLState());
} }
stat.execute("CREATE ALIAS SIMPLE FOR \"" + getClass().getName() + ".simpleResultSet\""); stat.execute("CREATE ALIAS SIMPLE FOR \"" + getClass().getName() + ".simpleResultSet\"");
rs = stat.executeQuery("CALL SIMPLE(2, 1,1,1,1,1,1,1)"); rs = stat.executeQuery("CALL SIMPLE(2, 1,1,1,1,1,1,1)");
check(rs.getMetaData().getColumnCount(), 2); assertEquals(rs.getMetaData().getColumnCount(), 2);
rs.next(); rs.next();
check(rs.getInt(1), 0); assertEquals(rs.getInt(1), 0);
check(rs.getString(2), "Hello"); assertEquals(rs.getString(2), "Hello");
rs.next(); rs.next();
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
check(rs.getString(2), "World"); assertEquals(rs.getString(2), "World");
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM SIMPLE(1, 1,1,1,1,1,1,1)"); rs = stat.executeQuery("SELECT * FROM SIMPLE(1, 1,1,1,1,1,1,1)");
check(rs.getMetaData().getColumnCount(), 2); assertEquals(rs.getMetaData().getColumnCount(), 2);
rs.next(); rs.next();
check(rs.getInt(1), 0); assertEquals(rs.getInt(1), 0);
check(rs.getString(2), "Hello"); assertEquals(rs.getString(2), "Hello");
checkFalse(rs.next()); assertFalse(rs.next());
stat.execute("CREATE ALIAS ARRAY FOR \"" + getClass().getName() + ".getArray\""); stat.execute("CREATE ALIAS ARRAY FOR \"" + getClass().getName() + ".getArray\"");
rs = stat.executeQuery("CALL ARRAY()"); rs = stat.executeQuery("CALL ARRAY()");
check(rs.getMetaData().getColumnCount(), 2); assertEquals(rs.getMetaData().getColumnCount(), 2);
rs.next(); rs.next();
check(rs.getInt(1), 0); assertEquals(rs.getInt(1), 0);
check(rs.getString(2), "Hello"); assertEquals(rs.getString(2), "Hello");
checkFalse(rs.next()); assertFalse(rs.next());
stat.execute("CREATE ALIAS ROOT FOR \"" + getClass().getName() + ".root\""); stat.execute("CREATE ALIAS ROOT FOR \"" + getClass().getName() + ".root\"");
rs = stat.executeQuery("CALL ROOT(9)"); rs = stat.executeQuery("CALL ROOT(9)");
rs.next(); rs.next();
check(rs.getInt(1), 3); assertEquals(rs.getInt(1), 3);
checkFalse(rs.next()); assertFalse(rs.next());
stat.execute("CREATE ALIAS MAX_ID FOR \"" + getClass().getName() + ".selectMaxId\""); stat.execute("CREATE ALIAS MAX_ID FOR \"" + getClass().getName() + ".selectMaxId\"");
rs = stat.executeQuery("CALL MAX_ID()"); rs = stat.executeQuery("CALL MAX_ID()");
rs.next(); rs.next();
check(rs.getInt(1), 2); assertEquals(rs.getInt(1), 2);
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM MAX_ID()"); rs = stat.executeQuery("SELECT * FROM MAX_ID()");
rs.next(); rs.next();
check(rs.getInt(1), 2); assertEquals(rs.getInt(1), 2);
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("CALL CASE WHEN -9 < 0 THEN 0 ELSE ROOT(-9) END"); rs = stat.executeQuery("CALL CASE WHEN -9 < 0 THEN 0 ELSE ROOT(-9) END");
rs.next(); rs.next();
check(rs.getInt(1), 0); assertEquals(rs.getInt(1), 0);
checkFalse(rs.next()); assertFalse(rs.next());
stat.execute("CREATE ALIAS blob2stream FOR \"" + getClass().getName() + ".blob2stream\""); stat.execute("CREATE ALIAS blob2stream FOR \"" + getClass().getName() + ".blob2stream\"");
stat.execute("CREATE ALIAS stream2stream FOR \"" + getClass().getName() + ".stream2stream\""); stat.execute("CREATE ALIAS stream2stream FOR \"" + getClass().getName() + ".stream2stream\"");
...@@ -254,10 +254,10 @@ public class TestFunctions extends TestBase { ...@@ -254,10 +254,10 @@ public class TestFunctions extends TestBase {
stat.execute("CREATE ALIAS NULL_RESULT FOR \"" + getClass().getName() + ".nullResultSet\""); stat.execute("CREATE ALIAS NULL_RESULT FOR \"" + getClass().getName() + ".nullResultSet\"");
rs = stat.executeQuery("CALL NULL_RESULT()"); rs = stat.executeQuery("CALL NULL_RESULT()");
check(rs.getMetaData().getColumnCount(), 1); assertEquals(rs.getMetaData().getColumnCount(), 1);
rs.next(); rs.next();
check(rs.getString(1), null); assertEquals(rs.getString(1), null);
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
} }
...@@ -266,7 +266,7 @@ public class TestFunctions extends TestBase { ...@@ -266,7 +266,7 @@ public class TestFunctions extends TestBase {
ResultSet rs = stat.executeQuery("CALL " + sql); ResultSet rs = stat.executeQuery("CALL " + sql);
rs.next(); rs.next();
String s = rs.getString(1); String s = rs.getString(1);
check(value, s); assertEquals(value, s);
} }
public static BufferedInputStream blob2stream(Blob value) throws SQLException { public static BufferedInputStream blob2stream(Blob value) throws SQLException {
......
...@@ -99,11 +99,11 @@ public class TestIndex extends TestBase { ...@@ -99,11 +99,11 @@ public class TestIndex extends TestBase {
String s1 = rs.next() ? rs.getString(1) : null; String s1 = rs.next() ? rs.getString(1) : null;
rs = stat.executeQuery(sql.replace('A', 'B')); rs = stat.executeQuery(sql.replace('A', 'B'));
String s2 = rs.next() ? rs.getString(1) : null; String s2 = rs.next() ? rs.getString(1) : null;
check(s1, s2); assertEquals(s1, s2);
} else { } else {
int count1 = stat.getUpdateCount(); int count1 = stat.getUpdateCount();
int count2 = stat.executeUpdate(sql.replace('A', 'B')); int count2 = stat.executeUpdate(sql.replace('A', 'B'));
check(count1, count2); assertEquals(count1, count2);
} }
} }
stat.execute("drop table testA, testB"); stat.execute("drop table testA, testB");
...@@ -129,20 +129,20 @@ public class TestIndex extends TestBase { ...@@ -129,20 +129,20 @@ public class TestIndex extends TestBase {
stat.execute("CREATE INDEX IDX_ND ON TEST(ID DESC)"); stat.execute("CREATE INDEX IDX_ND ON TEST(ID DESC)");
rs = conn.getMetaData().getIndexInfo(null, null, "TEST", false, false); rs = conn.getMetaData().getIndexInfo(null, null, "TEST", false, false);
rs.next(); rs.next();
check(rs.getString("ASC_OR_DESC"), "D"); assertEquals(rs.getString("ASC_OR_DESC"), "D");
check(rs.getInt("SORT_TYPE"), SortOrder.DESCENDING); assertEquals(rs.getInt("SORT_TYPE"), SortOrder.DESCENDING);
stat.execute("INSERT INTO TEST SELECT X FROM SYSTEM_RANGE(1, 30)"); stat.execute("INSERT INTO TEST SELECT X FROM SYSTEM_RANGE(1, 30)");
rs = stat.executeQuery("SELECT COUNT(*) FROM TEST WHERE ID BETWEEN 10 AND 20"); rs = stat.executeQuery("SELECT COUNT(*) FROM TEST WHERE ID BETWEEN 10 AND 20");
rs.next(); rs.next();
check(rs.getInt(1), 11); assertEquals(rs.getInt(1), 11);
reconnect(); reconnect();
rs = conn.getMetaData().getIndexInfo(null, null, "TEST", false, false); rs = conn.getMetaData().getIndexInfo(null, null, "TEST", false, false);
rs.next(); rs.next();
check(rs.getString("ASC_OR_DESC"), "D"); assertEquals(rs.getString("ASC_OR_DESC"), "D");
check(rs.getInt("SORT_TYPE"), SortOrder.DESCENDING); assertEquals(rs.getInt("SORT_TYPE"), SortOrder.DESCENDING);
rs = stat.executeQuery("SELECT COUNT(*) FROM TEST WHERE ID BETWEEN 10 AND 20"); rs = stat.executeQuery("SELECT COUNT(*) FROM TEST WHERE ID BETWEEN 10 AND 20");
rs.next(); rs.next();
check(rs.getInt(1), 11); assertEquals(rs.getInt(1), 11);
stat.execute("DROP TABLE TEST"); stat.execute("DROP TABLE TEST");
conn.close(); conn.close();
} }
...@@ -166,7 +166,7 @@ public class TestIndex extends TestBase { ...@@ -166,7 +166,7 @@ public class TestIndex extends TestBase {
while (rs.next()) { while (rs.next()) {
int id = rs.getInt("ID"); int id = rs.getInt("ID");
String name = rs.getString("NAME"); String name = rs.getString("NAME");
check("" + id, name.trim()); assertEquals("" + id, name.trim());
} }
if (!config.memory) { if (!config.memory) {
reconnect(); reconnect();
...@@ -174,7 +174,7 @@ public class TestIndex extends TestBase { ...@@ -174,7 +174,7 @@ public class TestIndex extends TestBase {
while (rs.next()) { while (rs.next()) {
int id = rs.getInt("ID"); int id = rs.getInt("ID");
String name = rs.getString("NAME"); String name = rs.getString("NAME");
check("" + id, name.trim()); assertEquals("" + id, name.trim());
} }
} }
stat.execute("DROP TABLE TEST"); stat.execute("DROP TABLE TEST");
...@@ -247,8 +247,8 @@ public class TestIndex extends TestBase { ...@@ -247,8 +247,8 @@ public class TestIndex extends TestBase {
prep.setInt(1, a); prep.setInt(1, a);
prep.setInt(2, a); prep.setInt(2, a);
prep.execute(); prep.execute();
check(1, getValue(stat, "SELECT COUNT(*) FROM TEST WHERE A=" + a)); assertEquals(1, getValue(stat, "SELECT COUNT(*) FROM TEST WHERE A=" + a));
check(0, getValue(stat, "SELECT COUNT(*) FROM TEST WHERE A=-1-" + a)); assertEquals(0, getValue(stat, "SELECT COUNT(*) FROM TEST WHERE A=-1-" + a));
} }
reconnect(); reconnect();
...@@ -256,12 +256,12 @@ public class TestIndex extends TestBase { ...@@ -256,12 +256,12 @@ public class TestIndex extends TestBase {
prep = conn.prepareStatement("DELETE FROM TEST WHERE A=?"); prep = conn.prepareStatement("DELETE FROM TEST WHERE A=?");
for (int a = 0; a < len; a++) { for (int a = 0; a < len; a++) {
if (getValue(stat, "SELECT COUNT(*) FROM TEST WHERE A=" + a) != 1) { if (getValue(stat, "SELECT COUNT(*) FROM TEST WHERE A=" + a) != 1) {
check(1, getValue(stat, "SELECT COUNT(*) FROM TEST WHERE A=" + a)); assertEquals(1, getValue(stat, "SELECT COUNT(*) FROM TEST WHERE A=" + a));
} }
prep.setInt(1, a); prep.setInt(1, a);
check(1, prep.executeUpdate()); assertEquals(1, prep.executeUpdate());
} }
check(0, getValue(stat, "SELECT COUNT(*) FROM TEST")); assertEquals(0, getValue(stat, "SELECT COUNT(*) FROM TEST"));
} }
void testMultiColumnIndex() throws Exception { void testMultiColumnIndex() throws Exception {
...@@ -280,12 +280,12 @@ public class TestIndex extends TestBase { ...@@ -280,12 +280,12 @@ public class TestIndex extends TestBase {
prep = conn.prepareStatement("DELETE FROM TEST WHERE A=?"); prep = conn.prepareStatement("DELETE FROM TEST WHERE A=?");
for (int a = 0; a < len; a++) { for (int a = 0; a < len; a++) {
log(stat, "SELECT * FROM TEST"); log(stat, "SELECT * FROM TEST");
check(2, getValue(stat, "SELECT COUNT(*) FROM TEST WHERE A=" + (len - a - 1))); assertEquals(2, getValue(stat, "SELECT COUNT(*) FROM TEST WHERE A=" + (len - a - 1)));
check((len - a) * 2, getValue(stat, "SELECT COUNT(*) FROM TEST")); assertEquals((len - a) * 2, getValue(stat, "SELECT COUNT(*) FROM TEST"));
prep.setInt(1, len - a - 1); prep.setInt(1, len - a - 1);
prep.execute(); prep.execute();
} }
check(0, getValue(stat, "SELECT COUNT(*) FROM TEST")); assertEquals(0, getValue(stat, "SELECT COUNT(*) FROM TEST"));
} }
void testMultiColumnHashIndex() throws Exception { void testMultiColumnHashIndex() throws Exception {
...@@ -324,8 +324,8 @@ public class TestIndex extends TestBase { ...@@ -324,8 +324,8 @@ public class TestIndex extends TestBase {
reconnect(); reconnect();
ResultSet rs = stat.executeQuery("SELECT * FROM TEST WHERE DATA <> 'i('||a||','||b||')u('||a||','||b||')'"); ResultSet rs = stat.executeQuery("SELECT * FROM TEST WHERE DATA <> 'i('||a||','||b||')u('||a||','||b||')'");
checkFalse(rs.next()); assertFalse(rs.next());
check(len * (len / 2), getValue(stat, "SELECT COUNT(*) FROM TEST")); assertEquals(len * (len / 2), getValue(stat, "SELECT COUNT(*) FROM TEST"));
stat.execute("DROP TABLE TEST"); stat.execute("DROP TABLE TEST");
} }
......
...@@ -86,10 +86,10 @@ public class TestLinkedTable extends TestBase { ...@@ -86,10 +86,10 @@ public class TestLinkedTable extends TestBase {
stat2.execute("CREATE LINKED TABLE two('org.h2.Driver', 'jdbc:h2:mem:one', 'sa', 'sa', 'A');"); stat2.execute("CREATE LINKED TABLE two('org.h2.Driver', 'jdbc:h2:mem:one', 'sa', 'sa', 'A');");
ResultSet rs = stat2.executeQuery("SELECT * FROM one"); ResultSet rs = stat2.executeQuery("SELECT * FROM one");
rs.next(); rs.next();
check(rs.getInt(1), 2); assertEquals(rs.getInt(1), 2);
rs = stat2.executeQuery("SELECT * FROM two"); rs = stat2.executeQuery("SELECT * FROM two");
rs.next(); rs.next();
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
conn.close(); conn.close();
conn2.close(); conn2.close();
} }
...@@ -137,7 +137,7 @@ public class TestLinkedTable extends TestBase { ...@@ -137,7 +137,7 @@ public class TestLinkedTable extends TestBase {
stat2.executeUpdate("UPDATE TEST_LINK_U SET ID=ID+1"); stat2.executeUpdate("UPDATE TEST_LINK_U SET ID=ID+1");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
stat2.executeUpdate("UPDATE TEST_LINK_DI SET ID=ID+1"); stat2.executeUpdate("UPDATE TEST_LINK_DI SET ID=ID+1");
stat2.executeUpdate("UPDATE TEST_LINK_U SET NAME=NAME || ID"); stat2.executeUpdate("UPDATE TEST_LINK_U SET NAME=NAME || ID");
...@@ -145,30 +145,30 @@ public class TestLinkedTable extends TestBase { ...@@ -145,30 +145,30 @@ public class TestLinkedTable extends TestBase {
rs = stat2.executeQuery("SELECT * FROM TEST_LINK_DI ORDER BY ID"); rs = stat2.executeQuery("SELECT * FROM TEST_LINK_DI ORDER BY ID");
rs.next(); rs.next();
check(rs.getInt(1), 2); assertEquals(rs.getInt(1), 2);
check(rs.getString(2), "Hello2"); assertEquals(rs.getString(2), "Hello2");
rs.next(); rs.next();
check(rs.getInt(1), 3); assertEquals(rs.getInt(1), 3);
check(rs.getString(2), "World3"); assertEquals(rs.getString(2), "World3");
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat2.executeQuery("SELECT * FROM TEST_LINK_U ORDER BY ID"); rs = stat2.executeQuery("SELECT * FROM TEST_LINK_U ORDER BY ID");
rs.next(); rs.next();
check(rs.getInt(1), 2); assertEquals(rs.getInt(1), 2);
check(rs.getString(2), "Hello2"); assertEquals(rs.getString(2), "Hello2");
rs.next(); rs.next();
check(rs.getInt(1), 3); assertEquals(rs.getInt(1), 3);
check(rs.getString(2), "World3"); assertEquals(rs.getString(2), "World3");
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID"); rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID");
rs.next(); rs.next();
check(rs.getInt(1), 2); assertEquals(rs.getInt(1), 2);
check(rs.getString(2), "Hello2"); assertEquals(rs.getString(2), "Hello2");
rs.next(); rs.next();
check(rs.getInt(1), 3); assertEquals(rs.getInt(1), 3);
check(rs.getString(2), "World3"); assertEquals(rs.getString(2), "World3");
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
conn2.close(); conn2.close();
...@@ -227,7 +227,7 @@ public class TestLinkedTable extends TestBase { ...@@ -227,7 +227,7 @@ public class TestLinkedTable extends TestBase {
stat.execute("SELECT * FROM TEST_TEMP"); stat.execute("SELECT * FROM TEST_TEMP");
error("temp table must not be persistent"); error("temp table must not be persistent");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
conn.close(); conn.close();
...@@ -240,8 +240,8 @@ public class TestLinkedTable extends TestBase { ...@@ -240,8 +240,8 @@ public class TestLinkedTable extends TestBase {
testRow(stat, "LINK_TEST"); testRow(stat, "LINK_TEST");
ResultSet rs = stat.executeQuery("SELECT * FROM LINK_TEST"); ResultSet rs = stat.executeQuery("SELECT * FROM LINK_TEST");
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
check(10, meta.getPrecision(1)); assertEquals(10, meta.getPrecision(1));
check(200, meta.getPrecision(2)); assertEquals(200, meta.getPrecision(2));
conn.close(); conn.close();
conn = DriverManager.getConnection("jdbc:h2:" + baseDir + "/linked2", "sa2", "def"); conn = DriverManager.getConnection("jdbc:h2:" + baseDir + "/linked2", "sa2", "def");
...@@ -252,41 +252,41 @@ public class TestLinkedTable extends TestBase { ...@@ -252,41 +252,41 @@ public class TestLinkedTable extends TestBase {
rs = stat.executeQuery("SELECT COUNT(*) FROM LINK_TEST"); rs = stat.executeQuery("SELECT COUNT(*) FROM LINK_TEST");
rs.next(); rs.next();
check(rs.getInt(1), 4); assertEquals(rs.getInt(1), 4);
rs = stat.executeQuery("SELECT COUNT(*) FROM LINK_TEST WHERE NAME='Link Test'"); rs = stat.executeQuery("SELECT COUNT(*) FROM LINK_TEST WHERE NAME='Link Test'");
rs.next(); rs.next();
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
int uc = stat.executeUpdate("DELETE FROM LINK_TEST WHERE ID=3"); int uc = stat.executeUpdate("DELETE FROM LINK_TEST WHERE ID=3");
check(uc, 1); assertEquals(uc, 1);
rs = stat.executeQuery("SELECT COUNT(*) FROM LINK_TEST"); rs = stat.executeQuery("SELECT COUNT(*) FROM LINK_TEST");
rs.next(); rs.next();
check(rs.getInt(1), 3); assertEquals(rs.getInt(1), 3);
rs = stat.executeQuery("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='LINK_TEST'"); rs = stat.executeQuery("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='LINK_TEST'");
rs.next(); rs.next();
check(rs.getString("TABLE_TYPE"), "TABLE LINK"); assertEquals(rs.getString("TABLE_TYPE"), "TABLE LINK");
rs.next(); rs.next();
rs = stat.executeQuery("SELECT * FROM LINK_TEST WHERE ID=0"); rs = stat.executeQuery("SELECT * FROM LINK_TEST WHERE ID=0");
rs.next(); rs.next();
check(rs.getString("NAME") == null && rs.wasNull()); assertTrue(rs.getString("NAME") == null && rs.wasNull());
check(rs.getString("XT") == null && rs.wasNull()); assertTrue(rs.getString("XT") == null && rs.wasNull());
check(rs.getInt("ID") == 0 && !rs.wasNull()); assertTrue(rs.getInt("ID") == 0 && !rs.wasNull());
check(rs.getBigDecimal("XD") == null && rs.wasNull()); assertTrue(rs.getBigDecimal("XD") == null && rs.wasNull());
check(rs.getTimestamp("XTS") == null && rs.wasNull()); assertTrue(rs.getTimestamp("XTS") == null && rs.wasNull());
check(rs.getBytes("XBY") == null && rs.wasNull()); assertTrue(rs.getBytes("XBY") == null && rs.wasNull());
check(!rs.getBoolean("XBO") && rs.wasNull()); assertTrue(!rs.getBoolean("XBO") && rs.wasNull());
check(rs.getShort("XSM") == 0 && rs.wasNull()); assertTrue(rs.getShort("XSM") == 0 && rs.wasNull());
check(rs.getLong("XBI") == 0 && rs.wasNull()); assertTrue(rs.getLong("XBI") == 0 && rs.wasNull());
check(rs.getString("XBL") == null && rs.wasNull()); assertTrue(rs.getString("XBL") == null && rs.wasNull());
check(rs.getString("XDA") == null && rs.wasNull()); assertTrue(rs.getString("XDA") == null && rs.wasNull());
check(rs.getString("XTI") == null && rs.wasNull()); assertTrue(rs.getString("XTI") == null && rs.wasNull());
check(rs.getString("XCL") == null && rs.wasNull()); assertTrue(rs.getString("XCL") == null && rs.wasNull());
check(rs.getString("XDO") == null && rs.wasNull()); assertTrue(rs.getString("XDO") == null && rs.wasNull());
checkFalse(rs.next()); assertFalse(rs.next());
stat.execute("DROP TABLE LINK_TEST"); stat.execute("DROP TABLE LINK_TEST");
...@@ -294,8 +294,8 @@ public class TestLinkedTable extends TestBase { ...@@ -294,8 +294,8 @@ public class TestLinkedTable extends TestBase {
+ "/linked1', 'sa1', 'abc', '(SELECT COUNT(*) FROM TEST)')"); + "/linked1', 'sa1', 'abc', '(SELECT COUNT(*) FROM TEST)')");
rs = stat.executeQuery("SELECT * FROM LINK_TEST"); rs = stat.executeQuery("SELECT * FROM LINK_TEST");
rs.next(); rs.next();
check(rs.getInt(1), 3); assertEquals(rs.getInt(1), 3);
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
...@@ -306,23 +306,23 @@ public class TestLinkedTable extends TestBase { ...@@ -306,23 +306,23 @@ public class TestLinkedTable extends TestBase {
void testRow(Statement stat, String name) throws Exception { void testRow(Statement stat, String name) throws Exception {
ResultSet rs = stat.executeQuery("SELECT * FROM " + name + " WHERE ID=1"); ResultSet rs = stat.executeQuery("SELECT * FROM " + name + " WHERE ID=1");
rs.next(); rs.next();
check(rs.getString("NAME"), "Hello"); assertEquals(rs.getString("NAME"), "Hello");
check(rs.getByte("XT"), -1); assertEquals(rs.getByte("XT"), -1);
BigDecimal bd = rs.getBigDecimal("XD"); BigDecimal bd = rs.getBigDecimal("XD");
check(bd.equals(new BigDecimal("10.30"))); assertTrue(bd.equals(new BigDecimal("10.30")));
Timestamp ts = rs.getTimestamp("XTS"); Timestamp ts = rs.getTimestamp("XTS");
String s = ts.toString(); String s = ts.toString();
check(s, "2001-02-03 11:22:33.4455"); assertEquals(s, "2001-02-03 11:22:33.4455");
check(ts.equals(Timestamp.valueOf("2001-02-03 11:22:33.4455"))); assertTrue(ts.equals(Timestamp.valueOf("2001-02-03 11:22:33.4455")));
check(rs.getBytes("XBY"), new byte[] { (byte) 255, (byte) 1, (byte) 2 }); assertEquals(rs.getBytes("XBY"), new byte[] { (byte) 255, (byte) 1, (byte) 2 });
check(rs.getBoolean("XBO")); assertTrue(rs.getBoolean("XBO"));
check(rs.getShort("XSM"), 3000); assertEquals(rs.getShort("XSM"), 3000);
check(rs.getLong("XBI"), 1234567890123456789L); assertEquals(rs.getLong("XBI"), 1234567890123456789L);
check(rs.getString("XBL"), "1122aa"); assertEquals(rs.getString("XBL"), "1122aa");
check(rs.getString("XDA"), "0002-01-01"); assertEquals(rs.getString("XDA"), "0002-01-01");
check(rs.getString("XTI"), "00:00:00"); assertEquals(rs.getString("XTI"), "00:00:00");
check(rs.getString("XCL"), "J\u00fcrg"); assertEquals(rs.getString("XCL"), "J\u00fcrg");
check(rs.getString("XDO"), "2.25"); assertEquals(rs.getString("XDO"), "2.25");
} }
......
...@@ -174,7 +174,7 @@ public class TestLob extends TestBase { ...@@ -174,7 +174,7 @@ public class TestLob extends TestBase {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
conn.rollback(); conn.rollback();
conn.close(); conn.close();
...@@ -257,7 +257,7 @@ public class TestLob extends TestBase { ...@@ -257,7 +257,7 @@ public class TestLob extends TestBase {
while (rs.next()) { while (rs.next()) {
String d1 = rs.getString("DATA").trim(); String d1 = rs.getString("DATA").trim();
String d2 = rs.getString("DATA2").trim(); String d2 = rs.getString("DATA2").trim();
check(d1, d2); assertEquals(d1, d2);
} }
} }
...@@ -278,9 +278,9 @@ public class TestLob extends TestBase { ...@@ -278,9 +278,9 @@ public class TestLob extends TestBase {
conn.createStatement().execute("SHUTDOWN IMMEDIATELY"); conn.createStatement().execute("SHUTDOWN IMMEDIATELY");
conn = reconnect(null); conn = reconnect(null);
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST"); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST");
check(rs.next()); assertTrue(rs.next());
rs.getInt(1); rs.getInt(1);
check(rs.getString(2).length(), 10000); assertEquals(rs.getString(2).length(), 10000);
conn.close(); conn.close();
} }
...@@ -405,8 +405,8 @@ public class TestLob extends TestBase { ...@@ -405,8 +405,8 @@ public class TestLob extends TestBase {
ResultSet rs; ResultSet rs;
rs = stat.executeQuery("select value from information_schema.settings where NAME='COMPRESS_LOB'"); rs = stat.executeQuery("select value from information_schema.settings where NAME='COMPRESS_LOB'");
rs.next(); rs.next();
check(rs.getString(1), compress ? "LZF" : "NO"); assertEquals(rs.getString(1), compress ? "LZF" : "NO");
checkFalse(rs.next()); assertFalse(rs.next());
stat.execute("create table test(text clob)"); stat.execute("create table test(text clob)");
stat.execute("create table test2(text clob)"); stat.execute("create table test2(text clob)");
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
...@@ -418,15 +418,15 @@ public class TestLob extends TestBase { ...@@ -418,15 +418,15 @@ public class TestLob extends TestBase {
stat.execute("insert into test2 select * from test"); stat.execute("insert into test2 select * from test");
rs = stat.executeQuery("select * from test2"); rs = stat.executeQuery("select * from test2");
rs.next(); rs.next();
check(rs.getString(1), spaces); assertEquals(rs.getString(1), spaces);
stat.execute("drop table test"); stat.execute("drop table test");
rs = stat.executeQuery("select * from test2"); rs = stat.executeQuery("select * from test2");
rs.next(); rs.next();
check(rs.getString(1), spaces); assertEquals(rs.getString(1), spaces);
stat.execute("alter table test2 add column id int before text"); stat.execute("alter table test2 add column id int before text");
rs = stat.executeQuery("select * from test2"); rs = stat.executeQuery("select * from test2");
rs.next(); rs.next();
check(rs.getString("text"), spaces); assertEquals(rs.getString("text"), spaces);
conn.close(); conn.close();
} }
...@@ -460,11 +460,11 @@ public class TestLob extends TestBase { ...@@ -460,11 +460,11 @@ public class TestLob extends TestBase {
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST"); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST");
while (rs.next()) { while (rs.next()) {
if (i == 0) { if (i == 0) {
check(xml + rs.getInt(1), rs.getString(2)); assertEquals(xml + rs.getInt(1), rs.getString(2));
} else { } else {
Reader r = rs.getCharacterStream(2); Reader r = rs.getCharacterStream(2);
String result = IOUtils.readStringAndClose(r, -1); String result = IOUtils.readStringAndClose(r, -1);
check(xml + rs.getInt(1), result); assertEquals(xml + rs.getInt(1), result);
} }
} }
} }
...@@ -501,8 +501,8 @@ public class TestLob extends TestBase { ...@@ -501,8 +501,8 @@ public class TestLob extends TestBase {
Blob b = rs.getBlob("B"); Blob b = rs.getBlob("B");
Clob c = rs.getClob("C"); Clob c = rs.getClob("C");
int l = i; int l = i;
check(b.length(), l); assertEquals(b.length(), l);
check(c.length(), l); assertEquals(c.length(), l);
checkStream(b.getBinaryStream(), getRandomStream(l, i), -1); checkStream(b.getBinaryStream(), getRandomStream(l, i), -1);
checkReader(c.getCharacterStream(), getRandomReader(l, i), -1); checkReader(c.getCharacterStream(), getRandomReader(l, i), -1);
} }
...@@ -523,8 +523,8 @@ public class TestLob extends TestBase { ...@@ -523,8 +523,8 @@ public class TestLob extends TestBase {
Blob b = rs.getBlob("B"); Blob b = rs.getBlob("B");
Clob c = rs.getClob("C"); Clob c = rs.getClob("C");
int l = i; int l = i;
check(b.length(), l); assertEquals(b.length(), l);
check(c.length(), l); assertEquals(c.length(), l);
checkStream(b.getBinaryStream(), getRandomStream(l, -i), -1); checkStream(b.getBinaryStream(), getRandomStream(l, -i), -1);
checkReader(c.getCharacterStream(), getRandomReader(l, -i), -1); checkReader(c.getCharacterStream(), getRandomReader(l, -i), -1);
} }
...@@ -549,7 +549,7 @@ public class TestLob extends TestBase { ...@@ -549,7 +549,7 @@ public class TestLob extends TestBase {
conn = reconnect(conn); conn = reconnect(conn);
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST ORDER BY ID"); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST ORDER BY ID");
rs.next(); rs.next();
check("Bohlen", rs.getString("C")); assertEquals("Bohlen", rs.getString("C"));
checkReader(new CharArrayReader("Bohlen".toCharArray()), rs.getCharacterStream("C"), -1); checkReader(new CharArrayReader("Bohlen".toCharArray()), rs.getCharacterStream("C"), -1);
rs.next(); rs.next();
checkReader(new CharArrayReader("B\u00f6hlen".toCharArray()), rs.getCharacterStream("C"), -1); checkReader(new CharArrayReader("B\u00f6hlen".toCharArray()), rs.getCharacterStream("C"), -1);
...@@ -557,15 +557,15 @@ public class TestLob extends TestBase { ...@@ -557,15 +557,15 @@ public class TestLob extends TestBase {
checkReader(getRandomReader(501, 1), rs.getCharacterStream("C"), -1); checkReader(getRandomReader(501, 1), rs.getCharacterStream("C"), -1);
Clob clob = rs.getClob("C"); Clob clob = rs.getClob("C");
checkReader(getRandomReader(501, 1), clob.getCharacterStream(), -1); checkReader(getRandomReader(501, 1), clob.getCharacterStream(), -1);
check(clob.length(), 501); assertEquals(clob.length(), 501);
rs.next(); rs.next();
checkReader(getRandomReader(401, 2), rs.getCharacterStream("C"), -1); checkReader(getRandomReader(401, 2), rs.getCharacterStream("C"), -1);
checkReader(getRandomReader(1500, 2), rs.getCharacterStream("C"), 401); checkReader(getRandomReader(1500, 2), rs.getCharacterStream("C"), 401);
clob = rs.getClob("C"); clob = rs.getClob("C");
checkReader(getRandomReader(1501, 2), clob.getCharacterStream(), 401); checkReader(getRandomReader(1501, 2), clob.getCharacterStream(), 401);
checkReader(getRandomReader(401, 2), clob.getCharacterStream(), 401); checkReader(getRandomReader(401, 2), clob.getCharacterStream(), 401);
check(clob.length(), 401); assertEquals(clob.length(), 401);
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
} }
...@@ -757,9 +757,9 @@ public class TestLob extends TestBase { ...@@ -757,9 +757,9 @@ public class TestLob extends TestBase {
TestLobObject a = (TestLobObject) oa; TestLobObject a = (TestLobObject) oa;
Object ob = rs.getObject("DATA"); Object ob = rs.getObject("DATA");
TestLobObject b = (TestLobObject) ob; TestLobObject b = (TestLobObject) ob;
check(a.data, "abc"); assertEquals(a.data, "abc");
check(b.data, "abc"); assertEquals(b.data, "abc");
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
} }
...@@ -774,7 +774,7 @@ public class TestLob extends TestBase { ...@@ -774,7 +774,7 @@ public class TestLob extends TestBase {
int ca = a.read(); int ca = a.read();
a.read(new byte[0]); a.read(new byte[0]);
int cb = b.read(); int cb = b.read();
check(ca, cb); assertEquals(ca, cb);
if (ca == -1) { if (ca == -1) {
break; break;
} }
...@@ -791,7 +791,7 @@ public class TestLob extends TestBase { ...@@ -791,7 +791,7 @@ public class TestLob extends TestBase {
for (int i = 0; len < 0 || i < len; i++) { for (int i = 0; len < 0 || i < len; i++) {
int ca = a.read(); int ca = a.read();
int cb = b.read(); int cb = b.read();
check(ca, cb); assertEquals(ca, cb);
if (ca == -1) { if (ca == -1) {
break; break;
} }
......
...@@ -30,7 +30,7 @@ public class TestLogFile extends TestBase { ...@@ -30,7 +30,7 @@ public class TestLogFile extends TestBase {
} }
long length = 0; long length = 0;
ArrayList files = FileLister.getDatabaseFiles(baseDir, "logfile", false); ArrayList files = FileLister.getDatabaseFiles(baseDir, "logfile", false);
checkSmaller(files.size(), maxFiles + 2); assertSmaller(files.size(), maxFiles + 2);
for (int i = 0; i < files.size(); i++) { for (int i = 0; i < files.size(); i++) {
String fileName = (String) files.get(i); String fileName = (String) files.get(i);
long len = new File(fileName).length(); long len = new File(fileName).length();
...@@ -57,7 +57,7 @@ public class TestLogFile extends TestBase { ...@@ -57,7 +57,7 @@ public class TestLogFile extends TestBase {
insert(); insert();
long l2 = reconnect(maxFiles); long l2 = reconnect(maxFiles);
trace("length:" + length + " l2:" + l2); trace("length:" + length + " l2:" + l2);
check(l2 <= length * 2); assertTrue(l2 <= length * 2);
} }
conn.close(); conn.close();
} finally { } finally {
...@@ -71,7 +71,7 @@ public class TestLogFile extends TestBase { ...@@ -71,7 +71,7 @@ public class TestLogFile extends TestBase {
String name = files[j]; String name = files[j];
if (name.startsWith("logfile") && name.endsWith(".log.db")) { if (name.startsWith("logfile") && name.endsWith(".log.db")) {
long length = new File(name).length(); long length = new File(name).length();
checkSmaller(length, MAX_LOG_SIZE * 1024 * 1024 * 2); assertSmaller(length, MAX_LOG_SIZE * 1024 * 1024 * 2);
} }
} }
} }
......
...@@ -104,10 +104,10 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener { ...@@ -104,10 +104,10 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
t1.join(1000); t1.join(1000);
ResultSet rs = s1.executeQuery("SELECT * FROM TEST1 ORDER BY ID"); ResultSet rs = s1.executeQuery("SELECT * FROM TEST1 ORDER BY ID");
rs.next(); rs.next();
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
rs.next(); rs.next();
check(rs.getInt(1), 5); assertEquals(rs.getInt(1), 5);
checkFalse(rs.next()); assertFalse(rs.next());
conn1.close(); conn1.close();
conn2.close(); conn2.close();
conn3.close(); conn3.close();
...@@ -194,12 +194,12 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener { ...@@ -194,12 +194,12 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
ResultSet rs; ResultSet rs;
rs = conn.createStatement().executeQuery("SELECT * FROM MULTI_A ORDER BY ID"); rs = conn.createStatement().executeQuery("SELECT * FROM MULTI_A ORDER BY ID");
rs.next(); rs.next();
check(rs.getString("NAME"), "0-insert-A"); assertEquals(rs.getString("NAME"), "0-insert-A");
checkFalse(rs.next()); assertFalse(rs.next());
rs = conn.createStatement().executeQuery("SELECT * FROM MULTI_B ORDER BY ID"); rs = conn.createStatement().executeQuery("SELECT * FROM MULTI_B ORDER BY ID");
rs.next(); rs.next();
check(rs.getString("NAME"), "1-insert-D"); assertEquals(rs.getString("NAME"), "1-insert-D");
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
} }
......
...@@ -26,9 +26,9 @@ public class TestMultiDimension extends TestBase { ...@@ -26,9 +26,9 @@ public class TestMultiDimension extends TestBase {
int x = rand.nextInt(1000), y = rand.nextInt(1000), z = rand.nextInt(1000); int x = rand.nextInt(1000), y = rand.nextInt(1000), z = rand.nextInt(1000);
MultiDimension tool = MultiDimension.getInstance(); MultiDimension tool = MultiDimension.getInstance();
long xyz = tool.interleave(new int[] { x, y, z }); long xyz = tool.interleave(new int[] { x, y, z });
check(x, tool.deinterleave(xyz, 3, 0)); assertEquals(x, tool.deinterleave(xyz, 3, 0));
check(y, tool.deinterleave(xyz, 3, 1)); assertEquals(y, tool.deinterleave(xyz, 3, 1));
check(z, tool.deinterleave(xyz, 3, 2)); assertEquals(z, tool.deinterleave(xyz, 3, 2));
} }
deleteDb("multiDimension"); deleteDb("multiDimension");
...@@ -95,11 +95,11 @@ public class TestMultiDimension extends TestBase { ...@@ -95,11 +95,11 @@ public class TestMultiDimension extends TestBase {
ResultSet rs2 = prepRegular.executeQuery(); ResultSet rs2 = prepRegular.executeQuery();
timeRegular += System.currentTimeMillis() - time; timeRegular += System.currentTimeMillis() - time;
while (rs1.next()) { while (rs1.next()) {
check(rs2.next()); assertTrue(rs2.next());
check(rs1.getInt(1), rs2.getInt(1)); assertEquals(rs1.getInt(1), rs2.getInt(1));
check(rs1.getInt(2), rs2.getInt(2)); assertEquals(rs1.getInt(2), rs2.getInt(2));
} }
checkFalse(rs2.next()); assertFalse(rs2.next());
} }
trace("multi: " + timeMulti + " regular: " + timeRegular); trace("multi: " + timeMulti + " regular: " + timeRegular);
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
...@@ -120,11 +120,11 @@ public class TestMultiDimension extends TestBase { ...@@ -120,11 +120,11 @@ public class TestMultiDimension extends TestBase {
ResultSet rs2 = prep2.executeQuery(); ResultSet rs2 = prep2.executeQuery();
time2 = System.currentTimeMillis() - time2; time2 = System.currentTimeMillis() - time2;
while (rs1.next()) { while (rs1.next()) {
check(rs2.next()); assertTrue(rs2.next());
check(rs1.getInt(1), rs2.getInt(1)); assertEquals(rs1.getInt(1), rs2.getInt(1));
check(rs1.getInt(2), rs2.getInt(2)); assertEquals(rs1.getInt(2), rs2.getInt(2));
} }
checkFalse(rs2.next()); assertFalse(rs2.next());
// it just has to work, no need to compare the performance // it just has to work, no need to compare the performance
// trace("t1="+time1+" t2="+time2+" size="+size); // trace("t1="+time1+" t2="+time2+" size="+size);
} }
......
...@@ -56,8 +56,8 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -56,8 +56,8 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
stat = conn.createStatement(); stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT * FROM TEST"); ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
rs.next(); rs.next();
check(rs.getString(1).length(), 10000); assertEquals(rs.getString(1).length(), 10000);
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
} }
...@@ -131,7 +131,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -131,7 +131,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
conn = DriverManager.getConnection(url, "sa", ""); conn = DriverManager.getConnection(url, "sa", "");
ResultSet rs = conn.createStatement().executeQuery("select count(*) from employee"); ResultSet rs = conn.createStatement().executeQuery("select count(*) from employee");
rs.next(); rs.next();
check(rs.getInt(1), len); assertEquals(rs.getInt(1), len);
conn.close(); conn.close();
} }
......
...@@ -78,7 +78,7 @@ public class TestOptimizations extends TestBase { ...@@ -78,7 +78,7 @@ public class TestOptimizations extends TestBase {
rs.next(); rs.next();
if (!config.mvcc) { if (!config.mvcc) {
String plan = rs.getString(1); String plan = rs.getString(1);
check(plan.indexOf("direct") > 0); assertTrue(plan.indexOf("direct") > 0);
} }
rs = stat.executeQuery("select min(x), max(x) from test"); rs = stat.executeQuery("select min(x), max(x) from test");
rs.next(); rs.next();
...@@ -90,8 +90,8 @@ public class TestOptimizations extends TestBase { ...@@ -90,8 +90,8 @@ public class TestOptimizations extends TestBase {
if (rs.wasNull()) { if (rs.wasNull()) {
max = -1; max = -1;
} }
check(minExpected, min); assertEquals(minExpected, min);
check(maxExpected, max); assertEquals(maxExpected, max);
} }
conn.close(); conn.close();
} }
...@@ -108,7 +108,7 @@ public class TestOptimizations extends TestBase { ...@@ -108,7 +108,7 @@ public class TestOptimizations extends TestBase {
rs = stat.executeQuery("EXPLAIN SELECT id FROM Logs WHERE id < 100 and type=2 AND id<100"); rs = stat.executeQuery("EXPLAIN SELECT id FROM Logs WHERE id < 100 and type=2 AND id<100");
rs.next(); rs.next();
String plan = rs.getString(1); String plan = rs.getString(1);
check(plan.indexOf("TYPE_INDEX") > 0); assertTrue(plan.indexOf("TYPE_INDEX") > 0);
conn.close(); conn.close();
} }
...@@ -133,38 +133,38 @@ public class TestOptimizations extends TestBase { ...@@ -133,38 +133,38 @@ public class TestOptimizations extends TestBase {
ResultSet rs; ResultSet rs;
rs = stat.executeQuery("SELECT TYPE, COUNT(*) FROM TEST GROUP BY TYPE ORDER BY TYPE"); rs = stat.executeQuery("SELECT TYPE, COUNT(*) FROM TEST GROUP BY TYPE ORDER BY TYPE");
for (int i = 0; rs.next(); i++) { for (int i = 0; rs.next(); i++) {
check(i, rs.getInt(1)); assertEquals(i, rs.getInt(1));
check(groupCount[i], rs.getInt(2)); assertEquals(groupCount[i], rs.getInt(2));
} }
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE"); rs = stat.executeQuery("SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE");
for (int i = 0; rs.next(); i++) { for (int i = 0; rs.next(); i++) {
check(i, rs.getInt(1)); assertEquals(i, rs.getInt(1));
} }
checkFalse(rs.next()); assertFalse(rs.next());
stat.execute("ANALYZE"); stat.execute("ANALYZE");
rs = stat.executeQuery("SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE"); rs = stat.executeQuery("SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE");
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
check(rs.next()); assertTrue(rs.next());
check(i, rs.getInt(1)); assertEquals(i, rs.getInt(1));
} }
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE LIMIT 5 OFFSET 2"); rs = stat.executeQuery("SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE LIMIT 5 OFFSET 2");
for (int i = 2; i < 7; i++) { for (int i = 2; i < 7; i++) {
check(rs.next()); assertTrue(rs.next());
check(i, rs.getInt(1)); assertEquals(i, rs.getInt(1));
} }
checkFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE LIMIT 0 OFFSET 0 SAMPLE_SIZE 3"); rs = stat.executeQuery("SELECT DISTINCT TYPE FROM TEST ORDER BY TYPE LIMIT 0 OFFSET 0 SAMPLE_SIZE 3");
// must have at least one row // must have at least one row
check(rs.next()); assertTrue(rs.next());
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
rs.getInt(1); rs.getInt(1);
if (i > 0 && !rs.next()) { if (i > 0 && !rs.next()) {
break; break;
} }
} }
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
} }
...@@ -179,7 +179,7 @@ public class TestOptimizations extends TestBase { ...@@ -179,7 +179,7 @@ public class TestOptimizations extends TestBase {
rs = prep.executeQuery(); rs = prep.executeQuery();
rs.next(); rs.next();
String b = rs.getString(1); String b = rs.getString(1);
checkFalse(a.equals(b)); assertFalse(a.equals(b));
conn.close(); conn.close();
} }
...@@ -226,15 +226,15 @@ public class TestOptimizations extends TestBase { ...@@ -226,15 +226,15 @@ public class TestOptimizations extends TestBase {
PreparedStatement prep = conn.prepareStatement("select * from test where id = (select id from test2)"); PreparedStatement prep = conn.prepareStatement("select * from test where id = (select id from test2)");
ResultSet rs1 = prep.executeQuery(); ResultSet rs1 = prep.executeQuery();
rs1.next(); rs1.next();
check(rs1.getInt(1), 1); assertEquals(rs1.getInt(1), 1);
rs1.next(); rs1.next();
check(rs1.getInt(1), 1); assertEquals(rs1.getInt(1), 1);
checkFalse(rs1.next()); assertFalse(rs1.next());
stat.execute("update test2 set id = 2"); stat.execute("update test2 set id = 2");
ResultSet rs2 = prep.executeQuery(); ResultSet rs2 = prep.executeQuery();
rs2.next(); rs2.next();
check(rs2.getInt(1), 2); assertEquals(rs2.getInt(1), 2);
conn.close(); conn.close();
} }
...@@ -303,9 +303,9 @@ public class TestOptimizations extends TestBase { ...@@ -303,9 +303,9 @@ public class TestOptimizations extends TestBase {
Integer minDb = (Integer) rs.getObject(1); Integer minDb = (Integer) rs.getObject(1);
Integer maxDb = (Integer) rs.getObject(2); Integer maxDb = (Integer) rs.getObject(2);
int countDb = rs.getInt(3); int countDb = rs.getInt(3);
check(minDb, min); assertEquals(minDb, min);
check(maxDb, max); assertEquals(maxDb, max);
check(countDb, count); assertEquals(countDb, count);
break; break;
} }
default: default:
...@@ -328,41 +328,41 @@ public class TestOptimizations extends TestBase { ...@@ -328,41 +328,41 @@ public class TestOptimizations extends TestBase {
prep.setInt(1, 1); prep.setInt(1, 1);
rs = prep.executeQuery(); rs = prep.executeQuery();
rs.next(); rs.next();
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
check(rs.getString(2), "Hello"); assertEquals(rs.getString(2), "Hello");
checkFalse(rs.next()); assertFalse(rs.next());
prep = conn.prepareStatement("select * from test t1 where t1.id in(?, ?) order by id"); prep = conn.prepareStatement("select * from test t1 where t1.id in(?, ?) order by id");
prep.setInt(1, 1); prep.setInt(1, 1);
prep.setInt(2, 2); prep.setInt(2, 2);
rs = prep.executeQuery(); rs = prep.executeQuery();
rs.next(); rs.next();
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
check(rs.getString(2), "Hello"); assertEquals(rs.getString(2), "Hello");
rs.next(); rs.next();
check(rs.getInt(1), 2); assertEquals(rs.getInt(1), 2);
check(rs.getString(2), "World"); assertEquals(rs.getString(2), "World");
checkFalse(rs.next()); assertFalse(rs.next());
prep = conn.prepareStatement("select * from test t1 where t1.id in(select t2.id from test t2 where t2.id=?)"); prep = conn.prepareStatement("select * from test t1 where t1.id in(select t2.id from test t2 where t2.id=?)");
prep.setInt(1, 2); prep.setInt(1, 2);
rs = prep.executeQuery(); rs = prep.executeQuery();
rs.next(); rs.next();
check(rs.getInt(1), 2); assertEquals(rs.getInt(1), 2);
check(rs.getString(2), "World"); assertEquals(rs.getString(2), "World");
checkFalse(rs.next()); assertFalse(rs.next());
prep = conn prep = conn
.prepareStatement("select * from test t1 where t1.id in(select t2.id from test t2 where t2.id=? and t1.id<>t2.id)"); .prepareStatement("select * from test t1 where t1.id in(select t2.id from test t2 where t2.id=? and t1.id<>t2.id)");
prep.setInt(1, 2); prep.setInt(1, 2);
rs = prep.executeQuery(); rs = prep.executeQuery();
checkFalse(rs.next()); assertFalse(rs.next());
prep = conn prep = conn
.prepareStatement("select * from test t1 where t1.id in(select t2.id from test t2 where t2.id in(cast(?+10 as varchar)))"); .prepareStatement("select * from test t1 where t1.id in(select t2.id from test t2 where t2.id in(cast(?+10 as varchar)))");
prep.setInt(1, 2); prep.setInt(1, 2);
rs = prep.executeQuery(); rs = prep.executeQuery();
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
} }
......
...@@ -80,17 +80,17 @@ public class TestPowerOff extends TestBase { ...@@ -80,17 +80,17 @@ public class TestPowerOff extends TestBase {
ResultSet rs = stat.executeQuery("SELECT * FROM TEST" + i + " ORDER BY ID"); ResultSet rs = stat.executeQuery("SELECT * FROM TEST" + i + " ORDER BY ID");
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
rs.next(); rs.next();
check(rs.getInt(1), j); assertEquals(rs.getInt(1), j);
check(rs.getString(2), "Hello"); assertEquals(rs.getString(2), "Hello");
} }
if (i == 1) { if (i == 1) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
rs.next(); rs.next();
check(rs.getInt(1), j + 10); assertEquals(rs.getInt(1), j + 10);
check(rs.getString(2), "World"); assertEquals(rs.getString(2), "World");
} }
} }
checkFalse(rs.next()); assertFalse(rs.next());
} }
conn.close(); conn.close();
} }
...@@ -147,8 +147,8 @@ public class TestPowerOff extends TestBase { ...@@ -147,8 +147,8 @@ public class TestPowerOff extends TestBase {
conn = getConnection(url); conn = getConnection(url);
stat = conn.createStatement(); stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT * FROM TEST"); ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
check(rs.next()); assertTrue(rs.next());
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
} }
...@@ -167,7 +167,7 @@ public class TestPowerOff extends TestBase { ...@@ -167,7 +167,7 @@ public class TestPowerOff extends TestBase {
stat.execute("CHECKPOINT"); stat.execute("CHECKPOINT");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
boolean deleted = false; boolean deleted = false;
ArrayList files = FileLister.getDatabaseFiles(dir, dbName, false); ArrayList files = FileLister.getDatabaseFiles(dir, dbName, false);
...@@ -178,7 +178,7 @@ public class TestPowerOff extends TestBase { ...@@ -178,7 +178,7 @@ public class TestPowerOff extends TestBase {
deleted = true; deleted = true;
} }
} }
check(deleted); assertTrue(deleted);
conn = getConnection(url); conn = getConnection(url);
conn.close(); conn.close();
} }
...@@ -201,7 +201,7 @@ public class TestPowerOff extends TestBase { ...@@ -201,7 +201,7 @@ public class TestPowerOff extends TestBase {
stat.execute("CHECKPOINT"); stat.execute("CHECKPOINT");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
((JdbcConnection) conn).setPowerOffCount(0); ((JdbcConnection) conn).setPowerOffCount(0);
...@@ -209,7 +209,7 @@ public class TestPowerOff extends TestBase { ...@@ -209,7 +209,7 @@ public class TestPowerOff extends TestBase {
stat = conn.createStatement(); stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT COUNT(*) FROM TEST"); ResultSet rs = stat.executeQuery("SELECT COUNT(*) FROM TEST");
rs.next(); rs.next();
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
conn.close(); conn.close();
} }
...@@ -307,18 +307,18 @@ public class TestPowerOff extends TestBase { ...@@ -307,18 +307,18 @@ public class TestPowerOff extends TestBase {
if (!rs.next()) { if (!rs.next()) {
state = 1; state = 1;
} else { } else {
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
String name1 = rs.getString(2); String name1 = rs.getString(2);
check(rs.next()); assertTrue(rs.next());
check(rs.getInt(1), 2); assertEquals(rs.getInt(1), 2);
String name2 = rs.getString(2); String name2 = rs.getString(2);
checkFalse(rs.next()); assertFalse(rs.next());
if ("Hello".equals(name1)) { if ("Hello".equals(name1)) {
check(name2, "World"); assertEquals(name2, "World");
state = 2; state = 2;
} else { } else {
check(name1, "Hallo"); assertEquals(name1, "Hallo");
check(name2, "Welt"); assertEquals(name2, "Welt");
state = 3; state = 3;
} }
} }
......
...@@ -35,9 +35,9 @@ public class TestReadOnly extends TestBase { ...@@ -35,9 +35,9 @@ public class TestReadOnly extends TestBase {
private void testReadOnlyFiles(boolean setReadOnly) throws Exception { private void testReadOnlyFiles(boolean setReadOnly) throws Exception {
File f = File.createTempFile("test", "temp"); File f = File.createTempFile("test", "temp");
check(f.canWrite()); assertTrue(f.canWrite());
f.setReadOnly(); f.setReadOnly();
check(!f.canWrite()); assertTrue(!f.canWrite());
f.delete(); f.delete();
f = File.createTempFile("test", "temp"); f = File.createTempFile("test", "temp");
...@@ -45,7 +45,7 @@ public class TestReadOnly extends TestBase { ...@@ -45,7 +45,7 @@ public class TestReadOnly extends TestBase {
r.write(1); r.write(1);
f.setReadOnly(); f.setReadOnly();
r.close(); r.close();
check(!f.canWrite()); assertTrue(!f.canWrite());
f.delete(); f.delete();
deleteDb("readonly"); deleteDb("readonly");
...@@ -54,7 +54,7 @@ public class TestReadOnly extends TestBase { ...@@ -54,7 +54,7 @@ public class TestReadOnly extends TestBase {
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
stat.execute("INSERT INTO TEST VALUES(1, 'Hello')"); stat.execute("INSERT INTO TEST VALUES(1, 'Hello')");
stat.execute("INSERT INTO TEST VALUES(2, 'World')"); stat.execute("INSERT INTO TEST VALUES(2, 'World')");
check(!conn.isReadOnly()); assertTrue(!conn.isReadOnly());
conn.close(); conn.close();
if (setReadOnly) { if (setReadOnly) {
...@@ -63,14 +63,14 @@ public class TestReadOnly extends TestBase { ...@@ -63,14 +63,14 @@ public class TestReadOnly extends TestBase {
} else { } else {
conn = getConnection("readonly;ACCESS_MODE_DATA=r"); conn = getConnection("readonly;ACCESS_MODE_DATA=r");
} }
check(conn.isReadOnly()); assertTrue(conn.isReadOnly());
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("SELECT * FROM TEST"); stat.execute("SELECT * FROM TEST");
try { try {
stat.execute("DELETE FROM TEST"); stat.execute("DELETE FROM TEST");
error("read only delete"); error("read only delete");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
conn.close(); conn.close();
...@@ -85,7 +85,7 @@ public class TestReadOnly extends TestBase { ...@@ -85,7 +85,7 @@ public class TestReadOnly extends TestBase {
stat.execute("DELETE FROM TEST"); stat.execute("DELETE FROM TEST");
error("read only delete"); error("read only delete");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
stat.execute("SET DB_CLOSE_DELAY=0"); stat.execute("SET DB_CLOSE_DELAY=0");
conn.close(); conn.close();
......
...@@ -55,7 +55,7 @@ public class TestRights extends TestBase { ...@@ -55,7 +55,7 @@ public class TestRights extends TestBase {
stat2.execute("SELECT * FROM TEST"); stat2.execute("SELECT * FROM TEST");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
stat2.execute("CREATE LOCAL TEMPORARY TABLE IF NOT EXISTS MY_TEST(ID INT)"); stat2.execute("CREATE LOCAL TEMPORARY TABLE IF NOT EXISTS MY_TEST(ID INT)");
stat2.execute("INSERT INTO MY_TEST VALUES(1)"); stat2.execute("INSERT INTO MY_TEST VALUES(1)");
...@@ -84,13 +84,13 @@ public class TestRights extends TestBase { ...@@ -84,13 +84,13 @@ public class TestRights extends TestBase {
stat.execute("alter user test1 admin false"); stat.execute("alter user test1 admin false");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
try { try {
stat.execute("drop user test1"); stat.execute("drop user test1");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
stat.execute("drop schema b"); stat.execute("drop schema b");
stat.execute("alter user test1 admin false"); stat.execute("alter user test1 admin false");
...@@ -173,19 +173,19 @@ public class TestRights extends TestBase { ...@@ -173,19 +173,19 @@ public class TestRights extends TestBase {
conn = getConnection("rights", "Test", "abc"); conn = getConnection("rights", "Test", "abc");
error("mixed case user name"); error("mixed case user name");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
try { try {
conn = getConnection("rights", "TEST", "abc"); conn = getConnection("rights", "TEST", "abc");
error("wrong password"); error("wrong password");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
try { try {
conn = getConnection("rights", "TEST", null); conn = getConnection("rights", "TEST", null);
error("wrong password"); error("wrong password");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
conn = getConnection("rights", "TEST", "def"); conn = getConnection("rights", "TEST", "def");
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -242,7 +242,7 @@ public class TestRights extends TestBase { ...@@ -242,7 +242,7 @@ public class TestRights extends TestBase {
ResultSet rs = conn.createStatement().executeQuery( ResultSet rs = conn.createStatement().executeQuery(
"SELECT STORAGE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='TEST'"); "SELECT STORAGE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='TEST'");
rs.next(); rs.next();
check(rs.getString(1), type); assertEquals(rs.getString(1), type);
executeSuccess("DROP TABLE TEST"); executeSuccess("DROP TABLE TEST");
} }
...@@ -251,7 +251,7 @@ public class TestRights extends TestBase { ...@@ -251,7 +251,7 @@ public class TestRights extends TestBase {
stat.execute(sql); stat.execute(sql);
error("not admin"); error("not admin");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
} }
......
...@@ -69,7 +69,7 @@ public class TestRunscript extends TestBase implements Trigger { ...@@ -69,7 +69,7 @@ public class TestRunscript extends TestBase implements Trigger {
stat2.execute(sql); stat2.execute(sql);
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
} }
sql = "runscript from '" + baseDir + "/backup.2.sql'"; sql = "runscript from '" + baseDir + "/backup.2.sql'";
......
...@@ -30,12 +30,12 @@ public class TestSQLInjection extends TestBase { ...@@ -30,12 +30,12 @@ public class TestSQLInjection extends TestBase {
stat.execute("CREATE SCHEMA CONST"); stat.execute("CREATE SCHEMA CONST");
stat.execute("CREATE CONSTANT CONST.ACTIVE VALUE 'Active'"); stat.execute("CREATE CONSTANT CONST.ACTIVE VALUE 'Active'");
stat.execute("INSERT INTO USERS VALUES('James', '123456', CONST.ACTIVE)"); stat.execute("INSERT INTO USERS VALUES('James', '123456', CONST.ACTIVE)");
check(checkPasswordInsecure("123456")); assertTrue(checkPasswordInsecure("123456"));
checkFalse(checkPasswordInsecure("abcdef")); assertFalse(checkPasswordInsecure("abcdef"));
check(checkPasswordInsecure("' OR ''='")); assertTrue(checkPasswordInsecure("' OR ''='"));
check(checkPasswordSecure("123456")); assertTrue(checkPasswordSecure("123456"));
checkFalse(checkPasswordSecure("abcdef")); assertFalse(checkPasswordSecure("abcdef"));
checkFalse(checkPasswordSecure("' OR ''='")); assertFalse(checkPasswordSecure("' OR ''='"));
stat.execute("CALL 123"); stat.execute("CALL 123");
stat.execute("CALL 'Hello'"); stat.execute("CALL 'Hello'");
stat.execute("CALL $$Hello World$$"); stat.execute("CALL $$Hello World$$");
...@@ -45,25 +45,25 @@ public class TestSQLInjection extends TestBase { ...@@ -45,25 +45,25 @@ public class TestSQLInjection extends TestBase {
stat.execute("CALL 'Hello'"); stat.execute("CALL 'Hello'");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
try { try {
stat.execute("CALL $$Hello World$$"); stat.execute("CALL $$Hello World$$");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
stat.execute("SET ALLOW_LITERALS NONE"); stat.execute("SET ALLOW_LITERALS NONE");
try { try {
check(checkPasswordInsecure("123456")); assertTrue(checkPasswordInsecure("123456"));
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
check(checkPasswordSecure("123456")); assertTrue(checkPasswordSecure("123456"));
checkFalse(checkPasswordSecure("' OR ''='")); assertFalse(checkPasswordSecure("' OR ''='"));
conn.close(); conn.close();
if (config.memory) { if (config.memory) {
...@@ -73,13 +73,13 @@ public class TestSQLInjection extends TestBase { ...@@ -73,13 +73,13 @@ public class TestSQLInjection extends TestBase {
reconnect("sqlInjection"); reconnect("sqlInjection");
try { try {
check(checkPasswordInsecure("123456")); assertTrue(checkPasswordInsecure("123456"));
error("Should fail now"); error("Should fail now");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
check(checkPasswordSecure("123456")); assertTrue(checkPasswordSecure("123456"));
checkFalse(checkPasswordSecure("' OR ''='")); assertFalse(checkPasswordSecure("' OR ''='"));
conn.close(); conn.close();
} }
......
...@@ -316,7 +316,7 @@ public class TestScript extends TestBase { ...@@ -316,7 +316,7 @@ public class TestScript extends TestBase {
} }
private void writeResult(String s, SQLException e) throws Exception { private void writeResult(String s, SQLException e) throws Exception {
checkNotGeneralException(e); assertKnownException(e);
s = ("> " + s).trim(); s = ("> " + s).trim();
String compare = readLine(); String compare = readLine();
if (compare != null && compare.startsWith(">")) { if (compare != null && compare.startsWith(">")) {
......
...@@ -50,7 +50,7 @@ public class TestScriptSimple extends TestBase { ...@@ -50,7 +50,7 @@ public class TestScriptSimple extends TestBase {
while (rs.next()) { while (rs.next()) {
String expected = reader.readStatement().trim(); String expected = reader.readStatement().trim();
String got = "> " + rs.getString(1); String got = "> " + rs.getString(1);
check(expected, got); assertEquals(expected, got);
} }
} else { } else {
conn.createStatement().execute(sql); conn.createStatement().execute(sql);
......
...@@ -65,12 +65,12 @@ public class TestSequence extends TestBase { ...@@ -65,12 +65,12 @@ public class TestSequence extends TestBase {
stat.execute("call next value for test_Sequence3"); stat.execute("call next value for test_Sequence3");
ResultSet rs = stat.executeQuery("select * from information_schema.sequences order by sequence_name"); ResultSet rs = stat.executeQuery("select * from information_schema.sequences order by sequence_name");
rs.next(); rs.next();
check(rs.getString("SEQUENCE_NAME"), "TEST_SEQUENCE"); assertEquals(rs.getString("SEQUENCE_NAME"), "TEST_SEQUENCE");
check(rs.getString("CACHE"), "32"); assertEquals(rs.getString("CACHE"), "32");
rs.next(); rs.next();
check(rs.getString("SEQUENCE_NAME"), "TEST_SEQUENCE3"); assertEquals(rs.getString("SEQUENCE_NAME"), "TEST_SEQUENCE3");
check(rs.getString("CACHE"), "3"); assertEquals(rs.getString("CACHE"), "3");
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
} }
...@@ -88,11 +88,11 @@ public class TestSequence extends TestBase { ...@@ -88,11 +88,11 @@ public class TestSequence extends TestBase {
long last = 0; long last = 0;
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
long v1 = getNext(stat); long v1 = getNext(stat);
check(v1 > last); assertTrue(v1 > last);
last = v1; last = v1;
for (int j = 0; j < 100; j++) { for (int j = 0; j < 100; j++) {
long v2 = getNext(stat2); long v2 = getNext(stat2);
check(v2 > last); assertTrue(v2 > last);
last = v2; last = v2;
} }
} }
......
...@@ -29,7 +29,7 @@ public class TestSessionsLocks extends TestBase { ...@@ -29,7 +29,7 @@ public class TestSessionsLocks extends TestBase {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
ResultSet rs; ResultSet rs;
rs = stat.executeQuery("select * from information_schema.locks order by session_id"); rs = stat.executeQuery("select * from information_schema.locks order by session_id");
checkFalse(rs.next()); assertFalse(rs.next());
Connection conn2 = getConnection("sessionsLocks"); Connection conn2 = getConnection("sessionsLocks");
Statement stat2 = conn2.createStatement(); Statement stat2 = conn2.createStatement();
stat2.execute("create table test(id int primary key, name varchar)"); stat2.execute("create table test(id int primary key, name varchar)");
...@@ -37,30 +37,30 @@ public class TestSessionsLocks extends TestBase { ...@@ -37,30 +37,30 @@ public class TestSessionsLocks extends TestBase {
stat2.execute("insert into test values(1, 'Hello')"); stat2.execute("insert into test values(1, 'Hello')");
rs = stat.executeQuery("select * from information_schema.locks order by session_id"); rs = stat.executeQuery("select * from information_schema.locks order by session_id");
rs.next(); rs.next();
check("PUBLIC", rs.getString("TABLE_SCHEMA")); assertEquals("PUBLIC", rs.getString("TABLE_SCHEMA"));
check("TEST", rs.getString("TABLE_NAME")); assertEquals("TEST", rs.getString("TABLE_NAME"));
rs.getString("SESSION_ID"); rs.getString("SESSION_ID");
if (config.mvcc) { if (config.mvcc) {
check("READ", rs.getString("LOCK_TYPE")); assertEquals("READ", rs.getString("LOCK_TYPE"));
} else { } else {
check("WRITE", rs.getString("LOCK_TYPE")); assertEquals("WRITE", rs.getString("LOCK_TYPE"));
} }
checkFalse(rs.next()); assertFalse(rs.next());
conn2.commit(); conn2.commit();
conn2.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); conn2.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
stat2.execute("SELECT * FROM TEST"); stat2.execute("SELECT * FROM TEST");
rs = stat.executeQuery("select * from information_schema.locks order by session_id"); rs = stat.executeQuery("select * from information_schema.locks order by session_id");
if (!config.mvcc) { if (!config.mvcc) {
rs.next(); rs.next();
check("PUBLIC", rs.getString("TABLE_SCHEMA")); assertEquals("PUBLIC", rs.getString("TABLE_SCHEMA"));
check("TEST", rs.getString("TABLE_NAME")); assertEquals("TEST", rs.getString("TABLE_NAME"));
rs.getString("SESSION_ID"); rs.getString("SESSION_ID");
check("READ", rs.getString("LOCK_TYPE")); assertEquals("READ", rs.getString("LOCK_TYPE"));
} }
checkFalse(rs.next()); assertFalse(rs.next());
conn2.commit(); conn2.commit();
rs = stat.executeQuery("select * from information_schema.locks order by session_id"); rs = stat.executeQuery("select * from information_schema.locks order by session_id");
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
conn2.close(); conn2.close();
} }
...@@ -77,16 +77,16 @@ public class TestSessionsLocks extends TestBase { ...@@ -77,16 +77,16 @@ public class TestSessionsLocks extends TestBase {
rs.getTimestamp("SESSION_START"); rs.getTimestamp("SESSION_START");
rs.getString("STATEMENT"); rs.getString("STATEMENT");
rs.getTimestamp("STATEMENT_START"); rs.getTimestamp("STATEMENT_START");
checkFalse(rs.next()); assertFalse(rs.next());
Connection conn2 = getConnection("sessionsLocks"); Connection conn2 = getConnection("sessionsLocks");
final Statement stat2 = conn2.createStatement(); final Statement stat2 = conn2.createStatement();
rs = stat.executeQuery("select * from information_schema.sessions order by SESSION_START, ID"); rs = stat.executeQuery("select * from information_schema.sessions order by SESSION_START, ID");
check(rs.next()); assertTrue(rs.next());
check(sessionId, rs.getInt("ID")); assertEquals(sessionId, rs.getInt("ID"));
check(rs.next()); assertTrue(rs.next());
int otherId = rs.getInt("ID"); int otherId = rs.getInt("ID");
check(otherId != sessionId); assertTrue(otherId != sessionId);
checkFalse(rs.next()); assertFalse(rs.next());
stat2.execute("set throttle 1"); stat2.execute("set throttle 1");
final boolean[] done = new boolean[1]; final boolean[] done = new boolean[1];
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
...@@ -111,7 +111,7 @@ public class TestSessionsLocks extends TestBase { ...@@ -111,7 +111,7 @@ public class TestSessionsLocks extends TestBase {
break; break;
} }
} }
check(done[0]); assertTrue(done[0]);
break; break;
} }
} }
......
...@@ -48,22 +48,22 @@ public class TestTempTables extends TestBase { ...@@ -48,22 +48,22 @@ public class TestTempTables extends TestBase {
s1.execute("create local temporary table test_temp(id int) on commit delete rows"); s1.execute("create local temporary table test_temp(id int) on commit delete rows");
s1.execute("insert into test_temp values(1)"); s1.execute("insert into test_temp values(1)");
rs = s1.executeQuery("select * from test_temp"); rs = s1.executeQuery("select * from test_temp");
checkResultRowCount(rs, 1); assertResultRowCount(rs, 1);
c1.commit(); c1.commit();
rs = s1.executeQuery("select * from test_temp"); rs = s1.executeQuery("select * from test_temp");
checkResultRowCount(rs, 0); assertResultRowCount(rs, 0);
s1.execute("drop table test_temp"); s1.execute("drop table test_temp");
s1.execute("create local temporary table test_temp(id int) on commit drop"); s1.execute("create local temporary table test_temp(id int) on commit drop");
s1.execute("insert into test_temp values(1)"); s1.execute("insert into test_temp values(1)");
rs = s1.executeQuery("select * from test_temp"); rs = s1.executeQuery("select * from test_temp");
checkResultRowCount(rs, 1); assertResultRowCount(rs, 1);
c1.commit(); c1.commit();
try { try {
rs = s1.executeQuery("select * from test_temp"); rs = s1.executeQuery("select * from test_temp");
error("test_temp should have been dropped automatically"); error("test_temp should have been dropped automatically");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
c1.close(); c1.close();
......
...@@ -39,14 +39,14 @@ public class TestTransaction extends TestBase { ...@@ -39,14 +39,14 @@ public class TestTransaction extends TestBase {
stat.execute("insert into test values(1)"); stat.execute("insert into test values(1)");
stat.execute("set @x = 1"); stat.execute("set @x = 1");
conn.commit(); conn.commit();
checkSingleValue(stat, "select id from test", 1); assertSingleValue(stat, "select id from test", 1);
checkSingleValue(stat, "call @x", 1); assertSingleValue(stat, "call @x", 1);
stat.execute("update test set id=2"); stat.execute("update test set id=2");
stat.execute("set @x = 2"); stat.execute("set @x = 2");
conn.rollback(); conn.rollback();
checkSingleValue(stat, "select id from test", 1); assertSingleValue(stat, "select id from test", 1);
checkSingleValue(stat, "call @x", 2); assertSingleValue(stat, "call @x", 2);
conn.close(); conn.close();
} }
...@@ -68,7 +68,7 @@ public class TestTransaction extends TestBase { ...@@ -68,7 +68,7 @@ public class TestTransaction extends TestBase {
s2.executeUpdate("insert into B values('two', 1)"); s2.executeUpdate("insert into B values('two', 1)");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
c2.commit(); c2.commit();
c1.rollback(); c1.rollback();
...@@ -140,22 +140,22 @@ public class TestTransaction extends TestBase { ...@@ -140,22 +140,22 @@ public class TestTransaction extends TestBase {
ResultSet rs; ResultSet rs;
rs = stat.executeQuery("SELECT COUNT(*) FROM " + tableName); rs = stat.executeQuery("SELECT COUNT(*) FROM " + tableName);
rs.next(); rs.next();
check(count, rs.getInt(1)); assertEquals(count, rs.getInt(1));
} }
public void testIsolation() throws Exception { public void testIsolation() throws Exception {
Connection conn = getConnection("transaction"); Connection conn = getConnection("transaction");
trace("default TransactionIsolation=" + conn.getTransactionIsolation()); trace("default TransactionIsolation=" + conn.getTransactionIsolation());
conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
check(conn.getTransactionIsolation() == Connection.TRANSACTION_READ_COMMITTED); assertTrue(conn.getTransactionIsolation() == Connection.TRANSACTION_READ_COMMITTED);
conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
check(conn.getTransactionIsolation() == Connection.TRANSACTION_SERIALIZABLE); assertTrue(conn.getTransactionIsolation() == Connection.TRANSACTION_SERIALIZABLE);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
check(conn.getAutoCommit()); assertTrue(conn.getAutoCommit());
conn.setAutoCommit(false); conn.setAutoCommit(false);
checkFalse(conn.getAutoCommit()); assertFalse(conn.getAutoCommit());
conn.setAutoCommit(true); conn.setAutoCommit(true);
check(conn.getAutoCommit()); assertTrue(conn.getAutoCommit());
test(stat, "CREATE TABLE TEST(ID INT PRIMARY KEY)"); test(stat, "CREATE TABLE TEST(ID INT PRIMARY KEY)");
conn.commit(); conn.commit();
test(stat, "INSERT INTO TEST VALUES(0)"); test(stat, "INSERT INTO TEST VALUES(0)");
...@@ -221,7 +221,7 @@ public class TestTransaction extends TestBase { ...@@ -221,7 +221,7 @@ public class TestTransaction extends TestBase {
rs1.next(); rs1.next();
error("next worked on a closed result set"); error("next worked on a closed result set");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
// this is already closed, so but closing again should no do any harm // this is already closed, so but closing again should no do any harm
rs1.close(); rs1.close();
......
...@@ -53,13 +53,13 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -53,13 +53,13 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat.execute("DROP TABLE IF EXISTS TEST"); stat.execute("DROP TABLE IF EXISTS TEST");
stat.execute("create sequence seq"); stat.execute("create sequence seq");
stat.execute("create table test(id int primary key)"); stat.execute("create table test(id int primary key)");
checkSingleValue(stat, "call seq.nextval", 1); assertSingleValue(stat, "call seq.nextval", 1);
conn.setAutoCommit(false); conn.setAutoCommit(false);
stat.execute("create trigger test_upd before insert on test call \"" + Test.class.getName() + "\""); stat.execute("create trigger test_upd before insert on test call \"" + Test.class.getName() + "\"");
stat.execute("insert into test values(1)"); stat.execute("insert into test values(1)");
checkSingleValue(stat, "call seq.nextval", 3); assertSingleValue(stat, "call seq.nextval", 3);
stat.execute("alter table test add column name varchar"); stat.execute("alter table test add column name varchar");
checkSingleValue(stat, "call seq.nextval", 4); assertSingleValue(stat, "call seq.nextval", 4);
stat.execute("drop sequence seq"); stat.execute("drop sequence seq");
stat.execute("drop table test"); stat.execute("drop table test");
conn.close(); conn.close();
...@@ -73,7 +73,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -73,7 +73,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat.execute("alter table test add constraint test_parent_id foreign key(parent) references test (id) on delete cascade"); stat.execute("alter table test add constraint test_parent_id foreign key(parent) references test (id) on delete cascade");
stat.execute("insert into test select x, x/2 from system_range(0, 100)"); stat.execute("insert into test select x, x/2 from system_range(0, 100)");
stat.execute("delete from test"); stat.execute("delete from test");
checkSingleValue(stat, "select count(*) from test", 0); assertSingleValue(stat, "select count(*) from test", 0);
stat.execute("drop table test"); stat.execute("drop table test");
conn.close(); conn.close();
} }
...@@ -113,13 +113,13 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -113,13 +113,13 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
rs = stat.executeQuery("SELECT * FROM TEST"); rs = stat.executeQuery("SELECT * FROM TEST");
rs.next(); rs.next();
check(rs.getString(2), "Hello-updated"); assertEquals(rs.getString(2), "Hello-updated");
checkFalse(rs.next()); assertFalse(rs.next());
stat.execute("UPDATE TEST SET NAME=NAME||'-upd'"); stat.execute("UPDATE TEST SET NAME=NAME||'-upd'");
rs = stat.executeQuery("SELECT * FROM TEST"); rs = stat.executeQuery("SELECT * FROM TEST");
rs.next(); rs.next();
check(rs.getString(2), "Hello-updated-upd-updated2"); assertEquals(rs.getString(2), "Hello-updated-upd-updated2");
checkFalse(rs.next()); assertFalse(rs.next());
mustNotCallTrigger = true; mustNotCallTrigger = true;
stat.execute("DROP TRIGGER IF EXISTS INS_BEFORE"); stat.execute("DROP TRIGGER IF EXISTS INS_BEFORE");
...@@ -128,7 +128,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -128,7 +128,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat.execute("DROP TRIGGER INS_BEFORE"); stat.execute("DROP TRIGGER INS_BEFORE");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
stat.execute("DROP TRIGGER INS_AFTER"); stat.execute("DROP TRIGGER INS_AFTER");
stat.execute("DROP TRIGGER UPD_BEFORE"); stat.execute("DROP TRIGGER UPD_BEFORE");
...@@ -182,7 +182,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -182,7 +182,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
throw new Error("Commit must not work here"); throw new Error("Commit must not work here");
} catch (SQLException e) { } catch (SQLException e) {
try { try {
checkNotGeneralException(e); assertKnownException(e);
} catch (Exception e2) { } catch (Exception e2) {
throw new Error("Unexpected: " + e.toString()); throw new Error("Unexpected: " + e.toString());
} }
...@@ -192,7 +192,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -192,7 +192,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
throw new Error("CREATE TABLE WORKED, but implicitly commits"); throw new Error("CREATE TABLE WORKED, but implicitly commits");
} catch (SQLException e) { } catch (SQLException e) {
try { try {
checkNotGeneralException(e); assertKnownException(e);
} catch (Exception e2) { } catch (Exception e2) {
throw new Error("Unexpected: " + e.toString()); throw new Error("Unexpected: " + e.toString());
} }
......
...@@ -39,14 +39,14 @@ public class TestTwoPhaseCommit extends TestBase { ...@@ -39,14 +39,14 @@ public class TestTwoPhaseCommit extends TestBase {
stat.execute("SET WRITE_DELAY 0"); stat.execute("SET WRITE_DELAY 0");
ResultSet rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID"); ResultSet rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID");
rs.next(); rs.next();
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
check(rs.getString(2), "Hello"); assertEquals(rs.getString(2), "Hello");
if (!rolledBack) { if (!rolledBack) {
rs.next(); rs.next();
check(rs.getInt(1), 2); assertEquals(rs.getInt(1), 2);
check(rs.getString(2), "World"); assertEquals(rs.getString(2), "World");
} }
checkFalse(rs.next()); assertFalse(rs.next());
conn.close(); conn.close();
} }
......
...@@ -27,8 +27,8 @@ public class TestView extends TestBase { ...@@ -27,8 +27,8 @@ public class TestView extends TestBase {
s.execute("create view t" + (i + 1) + " as select * from t" + i); s.execute("create view t" + (i + 1) + " as select * from t" + i);
s.execute("select * from t" + (i + 1)); s.execute("select * from t" + (i + 1));
ResultSet rs = s.executeQuery("select count(*) from t" + (i + 1) + " where id=2"); ResultSet rs = s.executeQuery("select count(*) from t" + (i + 1) + " where id=2");
check(rs.next()); assertTrue(rs.next());
check(rs.getInt(1), 1); assertEquals(rs.getInt(1), 1);
} }
conn.close(); conn.close();
conn = getConnection("view"); conn = getConnection("view");
......
...@@ -63,7 +63,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -63,7 +63,7 @@ public class TestBatchUpdates extends TestBase {
for (int i = 0; i < updateCounts.length; i++) { for (int i = 0; i < updateCounts.length; i++) {
total += updateCounts[i]; total += updateCounts[i];
} }
check(4, total); assertEquals(4, total);
conn.close(); conn.close();
} }
...@@ -194,7 +194,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -194,7 +194,7 @@ public class TestBatchUpdates extends TestBase {
retValue[i++] = rs.getInt(1); retValue[i++] = rs.getInt(1);
for (int j = 0; j < updateCount.length; j++) { for (int j = 0; j < updateCount.length; j++) {
trace("UpdateCount:" + updateCount[j]); trace("UpdateCount:" + updateCount[j]);
check(updateCount[j], retValue[j]); assertEquals(updateCount[j], retValue[j]);
} }
} }
......
...@@ -37,15 +37,15 @@ public class TestCallableStatement extends TestBase { ...@@ -37,15 +37,15 @@ public class TestCallableStatement extends TestBase {
call = conn.prepareCall("SELECT * FROM TEST", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); call = conn.prepareCall("SELECT * FROM TEST", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
rs = call.executeQuery(); rs = call.executeQuery();
rs.next(); rs.next();
check(1, rs.getInt(1)); assertEquals(1, rs.getInt(1));
check("Hello", rs.getString(2)); assertEquals("Hello", rs.getString(2));
checkFalse(rs.next()); assertFalse(rs.next());
call = conn.prepareCall("SELECT * FROM TEST", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); call = conn.prepareCall("SELECT * FROM TEST", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
rs = call.executeQuery(); rs = call.executeQuery();
rs.next(); rs.next();
check(1, rs.getInt(1)); assertEquals(1, rs.getInt(1));
check("Hello", rs.getString(2)); assertEquals("Hello", rs.getString(2));
checkFalse(rs.next()); assertFalse(rs.next());
} }
} }
...@@ -74,7 +74,7 @@ public class TestCancel extends TestBase { ...@@ -74,7 +74,7 @@ public class TestCancel extends TestBase {
stat.execute("select count(*) from system_range(1, 1000000), system_range(1, 1000000)"); stat.execute("select count(*) from system_range(1, 1000000), system_range(1, 1000000)");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
stat.execute("set query_timeout 0"); stat.execute("set query_timeout 0");
stat.execute("select count(*) from system_range(1, 1000), system_range(1, 1000)"); stat.execute("select count(*) from system_range(1, 1000), system_range(1, 1000)");
...@@ -100,23 +100,23 @@ public class TestCancel extends TestBase { ...@@ -100,23 +100,23 @@ public class TestCancel extends TestBase {
deleteDb("cancel"); deleteDb("cancel");
Connection conn = getConnection("cancel"); Connection conn = getConnection("cancel");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
check(0, stat.getQueryTimeout()); assertEquals(0, stat.getQueryTimeout());
stat.setQueryTimeout(1); stat.setQueryTimeout(1);
check(1, stat.getQueryTimeout()); assertEquals(1, stat.getQueryTimeout());
Statement s2 = conn.createStatement(); Statement s2 = conn.createStatement();
check(1, s2.getQueryTimeout()); assertEquals(1, s2.getQueryTimeout());
ResultSet rs = s2.executeQuery("SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME = 'QUERY_TIMEOUT'"); ResultSet rs = s2.executeQuery("SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME = 'QUERY_TIMEOUT'");
rs.next(); rs.next();
check(1000, rs.getInt(1)); assertEquals(1000, rs.getInt(1));
try { try {
stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"); stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
check(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode()); assertEquals(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode());
} }
stat.setQueryTimeout(0); stat.setQueryTimeout(0);
stat.execute("SET QUERY_TIMEOUT 1100"); stat.execute("SET QUERY_TIMEOUT 1100");
check(2, stat.getQueryTimeout()); assertEquals(2, stat.getQueryTimeout());
conn.close(); conn.close();
} }
...@@ -129,7 +129,7 @@ public class TestCancel extends TestBase { ...@@ -129,7 +129,7 @@ public class TestCancel extends TestBase {
stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"); stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
check(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode()); assertEquals(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode());
} }
conn.close(); conn.close();
} }
...@@ -145,7 +145,7 @@ public class TestCancel extends TestBase { ...@@ -145,7 +145,7 @@ public class TestCancel extends TestBase {
stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"); stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)");
error(); error();
} catch (SQLException e) { } catch (SQLException e) {
check(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode()); assertEquals(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode());
} }
conn.close(); conn.close();
} finally { } finally {
...@@ -186,7 +186,7 @@ public class TestCancel extends TestBase { ...@@ -186,7 +186,7 @@ public class TestCancel extends TestBase {
query.executeQuery( query.executeQuery(
"SELECT VISIT(ID), (SELECT SUM(X) FROM SYSTEM_RANGE(1, 10000) WHERE X<>ID) FROM TEST ORDER BY ID"); "SELECT VISIT(ID), (SELECT SUM(X) FROM SYSTEM_RANGE(1, 10000) WHERE X<>ID) FROM TEST ORDER BY ID");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
// ignore cancelled statements // ignore cancelled statements
} }
cancel.stopNow(); cancel.stopNow();
......
...@@ -54,7 +54,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent ...@@ -54,7 +54,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
conn = DriverManager.getConnection(url, p); conn = DriverManager.getConnection(url, p);
conn.close(); conn.close();
if (l.calledOpened) { if (l.calledOpened) {
check(!l.calledScan); assertTrue(!l.calledScan);
} }
} }
...@@ -67,8 +67,8 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent ...@@ -67,8 +67,8 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
org.h2.Driver.load(); org.h2.Driver.load();
Connection conn = DriverManager.getConnection("jdbc:h2:mem:databaseEventListener", p); Connection conn = DriverManager.getConnection("jdbc:h2:mem:databaseEventListener", p);
conn.close(); conn.close();
check(l.calledOpened); assertTrue(l.calledOpened);
check(l.calledClosingDatabase); assertTrue(l.calledClosingDatabase);
} }
public void closingDatabase() { public void closingDatabase() {
......
...@@ -63,7 +63,7 @@ public class TestNativeSQL extends TestBase { ...@@ -63,7 +63,7 @@ public class TestNativeSQL extends TestBase {
testRandom(); testRandom();
testQuotes(); testQuotes();
conn.close(); conn.close();
check(conn.isClosed()); assertTrue(conn.isClosed());
} }
private void testQuotes() throws Exception { private void testQuotes() throws Exception {
...@@ -101,7 +101,7 @@ public class TestNativeSQL extends TestBase { ...@@ -101,7 +101,7 @@ public class TestNativeSQL extends TestBase {
ResultSet rs = stat.executeQuery(sql); ResultSet rs = stat.executeQuery(sql);
rs.next(); rs.next();
String raw = buffRaw.toString(); String raw = buffRaw.toString();
check(raw, rs.getString(1)); assertEquals(raw, rs.getString(1));
} }
} }
...@@ -117,7 +117,7 @@ public class TestNativeSQL extends TestBase { ...@@ -117,7 +117,7 @@ public class TestNativeSQL extends TestBase {
try { try {
conn.nativeSQL(sql); conn.nativeSQL(sql);
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(sql, e); assertKnownException(sql, e);
} }
} }
String smallest = null; String smallest = null;
...@@ -226,9 +226,9 @@ public class TestNativeSQL extends TestBase { ...@@ -226,9 +226,9 @@ public class TestNativeSQL extends TestBase {
stat.execute("CALL {d '2001-01-01'} // this is a test"); stat.execute("CALL {d '2001-01-01'} // this is a test");
error("expected error if setEscapeProcessing=false"); error("expected error if setEscapeProcessing=false");
} catch (SQLException e) { } catch (SQLException e) {
checkNotGeneralException(e); assertKnownException(e);
} }
checkFalse(conn.isClosed()); assertFalse(conn.isClosed());
} }
void test(Connection conn, String original, String expected) throws Exception { void test(Connection conn, String original, String expected) throws Exception {
...@@ -237,10 +237,10 @@ public class TestNativeSQL extends TestBase { ...@@ -237,10 +237,10 @@ public class TestNativeSQL extends TestBase {
try { try {
String result = conn.nativeSQL(original); String result = conn.nativeSQL(original);
trace("result: <" + result + ">"); trace("result: <" + result + ">");
check(expected, result); assertEquals(expected, result);
} catch (SQLException e) { } catch (SQLException e) {
check(expected, null); assertEquals(expected, null);
checkNotGeneralException(e); assertKnownException(e);
trace("got exception, good"); trace("got exception, good");
} }
} }
......
...@@ -60,7 +60,7 @@ public class TestConnectionPool extends TestBase { ...@@ -60,7 +60,7 @@ public class TestConnectionPool extends TestBase {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
threads[i].join(); threads[i].join();
} }
check(0, man.getActiveConnections()); assertEquals(0, man.getActiveConnections());
man.dispose(); man.dispose();
} }
......
...@@ -69,7 +69,7 @@ public class TestDataSource extends TestBase { ...@@ -69,7 +69,7 @@ public class TestDataSource extends TestBase {
XAResource res = xaConn.getXAResource(); XAResource res = xaConn.getXAResource();
Connection conn = xaConn.getConnection(); Connection conn = xaConn.getConnection();
Xid[] list = res.recover(XAResource.TMSTARTRSCAN); Xid[] list = res.recover(XAResource.TMSTARTRSCAN);
check(list.length, 0); assertEquals(list.length, 0);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("SELECT * FROM DUAL"); stat.execute("SELECT * FROM DUAL");
conn.close(); conn.close();
......
...@@ -63,7 +63,7 @@ public class TestXA extends TestBase { ...@@ -63,7 +63,7 @@ public class TestXA extends TestBase {
xa.getXAResource().start(xid, xa.getXAResource().start(xid,
XAResource.TMNOFLAGS); XAResource.TMNOFLAGS);
Connection c = xa.getConnection(); Connection c = xa.getConnection();
check(!c.getAutoCommit()); assertTrue(!c.getAutoCommit());
c.close(); c.close();
} }
......
...@@ -71,7 +71,7 @@ public class TestTimer extends TestBase { ...@@ -71,7 +71,7 @@ public class TestTimer extends TestBase {
rs = stat.executeQuery("SELECT COUNT(*) FROM TEST"); rs = stat.executeQuery("SELECT COUNT(*) FROM TEST");
rs.next(); rs.next();
int c = rs.getInt(1); int c = rs.getInt(1);
check(c, count); assertEquals(c, count);
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
if (time > start + 5000) { if (time > start + 5000) {
println("rows: " + count); println("rows: " + count);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论