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

junit compatibility

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