提交 6ae22bc7 authored 作者: Thomas Mueller's avatar Thomas Mueller

junit compatibility

上级 67a43816
...@@ -22,6 +22,7 @@ import org.h2.test.db.TestCsv; ...@@ -22,6 +22,7 @@ import org.h2.test.db.TestCsv;
import org.h2.test.db.TestEncryptedDb; import org.h2.test.db.TestEncryptedDb;
import org.h2.test.db.TestExclusive; import org.h2.test.db.TestExclusive;
import org.h2.test.db.TestFullText; import org.h2.test.db.TestFullText;
import org.h2.test.db.TestFunctionOverload;
import org.h2.test.db.TestFunctions; import org.h2.test.db.TestFunctions;
import org.h2.test.db.TestIndex; import org.h2.test.db.TestIndex;
import org.h2.test.db.TestLinkedTable; import org.h2.test.db.TestLinkedTable;
...@@ -167,11 +168,25 @@ java org.h2.test.TestAll timer ...@@ -167,11 +168,25 @@ java org.h2.test.TestAll timer
/* /*
feature to clear the screen for the command CREATE ALIAS IF NOT EXISTS FTL_INIT FOR "org.h2.fulltext.FullTextLucene.init";
line console (not the web console but the Shell) ? Whenever my Shell CALL FTL_INIT();
gets too over populated with data, I have to close it and open it DROP TABLE IF EXISTS TEST;
again to clear the screen since there's no way I can clear the screen CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR);
for the current versions. INSERT INTO TEST VALUES(1, 'Hello World');
CALL FTL_CREATE_INDEX('PUBLIC', 'TEST', NULL);
SELECT * FROM FTL_SEARCH('Hello', 0, 0);
SELECT * FROM FTL_SEARCH('Hallo', 0, 0);
INSERT INTO TEST VALUES(2, 'Hallo Welt');
SELECT * FROM FTL_SEARCH('Hello', 0, 0);
SELECT * FROM FTL_SEARCH('Hallo', 0, 0);
CALL FTL_REINDEX();
SELECT * FROM FTL_SEARCH('Hello', 0, 0);
SELECT * FROM FTL_SEARCH('Hallo', 0, 0);
INSERT INTO TEST VALUES(3, 'Hello World');
INSERT INTO TEST VALUES(4, 'Hello World');
INSERT INTO TEST VALUES(5, 'Hello World');
SELECT * FROM FTL_SEARCH('World', 0, 0);
SELECT * FROM FTL_SEARCH('World', 1, 0);
C:\download\Data Concurrency and Consistency.pdf C:\download\Data Concurrency and Consistency.pdf
Console says English but is German Console says English but is German
...@@ -461,6 +476,7 @@ Roadmap: ...@@ -461,6 +476,7 @@ Roadmap:
new TestExclusive().runTest(this); new TestExclusive().runTest(this);
new TestFullText().runTest(this); new TestFullText().runTest(this);
new TestFunctions().runTest(this); new TestFunctions().runTest(this);
new TestFunctionOverload().runTest(this);
new TestIndex().runTest(this); new TestIndex().runTest(this);
new TestLinkedTable().runTest(this); new TestLinkedTable().runTest(this);
new TestListener().runTest(this); new TestListener().runTest(this);
......
...@@ -69,7 +69,8 @@ public abstract class TestBase { ...@@ -69,7 +69,8 @@ public abstract class TestBase {
test(); test();
println(""); println("");
} catch (Exception e) { } catch (Exception e) {
fail("FAIL " + e.toString(), e); println("FAIL " + e.toString());
logError("FAIL " + e.toString(), e);
if (config.stopOnError) { if (config.stopOnError) {
throw new Error("ERROR"); throw new Error("ERROR");
} }
...@@ -226,20 +227,15 @@ public abstract class TestBase { ...@@ -226,20 +227,15 @@ public abstract class TestBase {
return mb; return mb;
} }
protected void error() throws Exception { protected void fail() throws Exception {
error("Unexpected success"); fail("Unexpected success");
} }
protected void error(String string) throws Exception { protected void fail(String string) throws Exception {
println(string); println(string);
throw new Exception(string); throw new Exception(string);
} }
protected void fail(String s, Throwable e) {
println(s);
logError(s, e);
}
public static void logError(String s, Throwable e) { public static void logError(String s, Throwable e) {
if (e == null) { if (e == null) {
e = new Exception(s); e = new Exception(s);
...@@ -287,9 +283,15 @@ public abstract class TestBase { ...@@ -287,9 +283,15 @@ public abstract class TestBase {
public abstract void test() throws Exception; public abstract void test() throws Exception;
public void assertEquals(String message, int expected, int actual) throws Exception {
if (expected != actual) {
fail("Expected: " + expected + " actual: " + actual + " message: " + message);
}
}
public void assertEquals(int expected, int actual) throws Exception { public void assertEquals(int expected, int actual) throws Exception {
if (expected != actual) { if (expected != actual) {
error("Expected: " + expected + " actual: " + actual); fail("Expected: " + expected + " actual: " + actual);
} }
} }
...@@ -297,7 +299,7 @@ public abstract class TestBase { ...@@ -297,7 +299,7 @@ public abstract class TestBase {
assertTrue(expected.length == actual.length); assertTrue(expected.length == actual.length);
for (int i = 0; i < expected.length; i++) { for (int i = 0; i < expected.length; i++) {
if (expected[i] != actual[i]) { if (expected[i] != actual[i]) {
error("expected[" + i + "]: a=" + (int) expected[i] + " actual=" + (int) actual[i]); fail("Expected[" + i + "]: a=" + (int) expected[i] + " actual=" + (int) actual[i]);
} }
} }
} }
...@@ -306,7 +308,7 @@ public abstract class TestBase { ...@@ -306,7 +308,7 @@ public abstract class TestBase {
if (expected == null && actual == null) { if (expected == null && actual == null) {
return; return;
} else if (expected == null || actual == null) { } else if (expected == null || actual == null) {
error("Expected: " + expected + " Actual: " + actual); fail("Expected: " + expected + " Actual: " + actual);
} }
if (!expected.equals(actual)) { if (!expected.equals(actual)) {
for (int i = 0; i < expected.length(); i++) { for (int i = 0; i < expected.length(); i++) {
...@@ -324,49 +326,49 @@ public abstract class TestBase { ...@@ -324,49 +326,49 @@ public abstract class TestBase {
if (bl > 100) { if (bl > 100) {
actual = actual.substring(0, 100); actual = actual.substring(0, 100);
} }
error("Expected: " + expected + " (" + al + ") actual: " + actual + " (" + bl + ")"); fail("Expected: " + expected + " (" + al + ") actual: " + actual + " (" + bl + ")");
} }
} }
protected void assertSmaller(long a, long b) throws Exception { protected void assertSmaller(long a, long b) throws Exception {
if (a >= b) { if (a >= b) {
error("a: " + a + " is not smaller than b: " + b); fail("a: " + a + " is not smaller than b: " + b);
} }
} }
protected void assertContains(String result, String contains) throws Exception { protected void assertContains(String result, String contains) throws Exception {
if (result.indexOf(contains) < 0) { if (result.indexOf(contains) < 0) {
error(result + " does not contain: " + contains); fail(result + " does not contain: " + contains);
} }
} }
protected void assertStartsWith(String text, String expectedStart) throws Exception { protected void assertStartsWith(String text, String expectedStart) throws Exception {
if (!text.startsWith(expectedStart)) { if (!text.startsWith(expectedStart)) {
error(text + " does not start with: " + expectedStart); fail(text + " does not start with: " + expectedStart);
} }
} }
protected void assertEquals(long expected, long actual) throws Exception { protected void assertEquals(long expected, long actual) throws Exception {
if (expected != actual) { if (expected != actual) {
error("Expected: " + expected + " actual: " + actual); fail("Expected: " + expected + " actual: " + actual);
} }
} }
protected void assertEquals(double expected, double actual) throws Exception { protected void assertEquals(double expected, double actual) throws Exception {
if (expected != actual) { if (expected != actual) {
error("Expected: " + expected + " actual: " + actual); fail("Expected: " + expected + " actual: " + actual);
} }
} }
protected void assertEquals(float expected, float actual) throws Exception { protected void assertEquals(float expected, float actual) throws Exception {
if (expected != actual) { if (expected != actual) {
error("Expected: " + expected + " actual: " + actual); fail("Expected: " + expected + " actual: " + actual);
} }
} }
protected void assertEquals(boolean expected, boolean actual) throws Exception { protected void assertEquals(boolean expected, boolean actual) throws Exception {
if (expected != actual) { if (expected != actual) {
error("Boolean expected: " + expected + " actual: " + actual); fail("Boolean expected: " + expected + " actual: " + actual);
} }
} }
...@@ -376,7 +378,7 @@ public abstract class TestBase { ...@@ -376,7 +378,7 @@ public abstract class TestBase {
protected void assertTrue(String message, boolean condition) throws Exception { protected void assertTrue(String message, boolean condition) throws Exception {
if (!condition) { if (!condition) {
error(message); fail(message);
} }
} }
...@@ -386,7 +388,7 @@ public abstract class TestBase { ...@@ -386,7 +388,7 @@ public abstract class TestBase {
protected void assertFalse(String message, boolean value) throws Exception { protected void assertFalse(String message, boolean value) throws Exception {
if (value) { if (value) {
error(message); fail(message);
} }
} }
...@@ -410,19 +412,19 @@ public abstract class TestBase { ...@@ -410,19 +412,19 @@ public abstract class TestBase {
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
int cc = meta.getColumnCount(); int cc = meta.getColumnCount();
if (cc != columnCount) { if (cc != columnCount) {
error("result set contains " + cc + " columns not " + columnCount); fail("result set contains " + cc + " columns not " + columnCount);
} }
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
if (labels != null) { if (labels != null) {
String l = meta.getColumnLabel(i + 1); String l = meta.getColumnLabel(i + 1);
if (!labels[i].equals(l)) { if (!labels[i].equals(l)) {
error("column label " + i + " is " + l + " not " + labels[i]); fail("column label " + i + " is " + l + " not " + labels[i]);
} }
} }
if (datatypes != null) { if (datatypes != null) {
int t = meta.getColumnType(i + 1); int t = meta.getColumnType(i + 1);
if (datatypes[i] != t) { if (datatypes[i] != t) {
error("column datatype " + i + " is " + t + " not " + datatypes[i] + " (prec=" fail("column datatype " + i + " is " + t + " not " + datatypes[i] + " (prec="
+ meta.getPrecision(i + 1) + " scale=" + meta.getScale(i + 1) + ")"); + meta.getPrecision(i + 1) + " scale=" + meta.getScale(i + 1) + ")");
} }
String typeName = meta.getColumnTypeName(i + 1); String typeName = meta.getColumnTypeName(i + 1);
...@@ -454,13 +456,13 @@ public abstract class TestBase { ...@@ -454,13 +456,13 @@ public abstract class TestBase {
if (precision != null) { if (precision != null) {
int p = meta.getPrecision(i + 1); int p = meta.getPrecision(i + 1);
if (precision[i] != p) { if (precision[i] != p) {
error("column precision " + i + " is " + p + " not " + precision[i]); fail("column precision " + i + " is " + p + " not " + precision[i]);
} }
} }
if (scale != null) { if (scale != null) {
int s = meta.getScale(i + 1); int s = meta.getScale(i + 1);
if (scale[i] != s) { if (scale[i] != s) {
error("column scale " + i + " is " + s + " not " + scale[i]); fail("column scale " + i + " is " + s + " not " + scale[i]);
} }
} }
...@@ -481,22 +483,22 @@ public abstract class TestBase { ...@@ -481,22 +483,22 @@ public abstract class TestBase {
if (rows == 0) { if (rows == 0) {
// special case: no rows // special case: no rows
if (rs.next()) { if (rs.next()) {
error("testResultSet expected rowCount:" + rows + " got:0"); fail("testResultSet expected rowCount:" + rows + " got:0");
} }
} }
int len2 = data[0].length; int len2 = data[0].length;
if (len < len2) { if (len < len2) {
error("testResultSet expected columnCount:" + len2 + " got:" + len); fail("testResultSet expected columnCount:" + len2 + " got:" + len);
} }
for (int i = 0; i < rows; i++) { for (int i = 0; i < rows; i++) {
if (!rs.next()) { if (!rs.next()) {
error("testResultSet expected rowCount:" + rows + " got:" + i); fail("testResultSet expected rowCount:" + rows + " got:" + i);
} }
String[] row = getData(rs, len); String[] row = getData(rs, len);
if (ordered) { if (ordered) {
String[] good = data[i]; String[] good = data[i];
if (!testRow(good, row, good.length)) { if (!testRow(good, row, good.length)) {
error("testResultSet row not equal, got:\n" + formatRow(row) + "\n" + formatRow(good)); fail("testResultSet row not equal, got:\n" + formatRow(row) + "\n" + formatRow(good));
} }
} else { } else {
boolean found = false; boolean found = false;
...@@ -508,13 +510,13 @@ public abstract class TestBase { ...@@ -508,13 +510,13 @@ public abstract class TestBase {
} }
} }
if (!found) { if (!found) {
error("testResultSet no match for row:" + formatRow(row)); fail("testResultSet no match for row:" + formatRow(row));
} }
} }
} }
if (rs.next()) { if (rs.next()) {
String[] row = getData(rs, len); String[] row = getData(rs, len);
error("testResultSet expected rowcount:" + rows + " got:>=" + (rows + 1) + " data:" + formatRow(row)); fail("testResultSet expected rowcount:" + rows + " got:>=" + (rows + 1) + " data:" + formatRow(row));
} }
} }
...@@ -558,7 +560,7 @@ public abstract class TestBase { ...@@ -558,7 +560,7 @@ public abstract class TestBase {
try { try {
conn.createStatement().execute("SET WRITE_DELAY 0"); conn.createStatement().execute("SET WRITE_DELAY 0");
conn.createStatement().execute("CREATE TABLE TEST_A(ID INT)"); conn.createStatement().execute("CREATE TABLE TEST_A(ID INT)");
error("should be crashed already"); fail("should be crashed already");
} catch (SQLException e) { } catch (SQLException e) {
// expected // expected
} }
...@@ -622,7 +624,7 @@ public abstract class TestBase { ...@@ -622,7 +624,7 @@ public abstract class TestBase {
for (int i = 0; i < list1.size(); i++) { for (int i = 0; i < list1.size(); i++) {
String s = (String) list1.get(i); String s = (String) list1.get(i);
if (!list2.remove(s)) { if (!list2.remove(s)) {
error("not found: " + s); fail("not found: " + s);
} }
} }
assertEquals(list2.size(), 0); assertEquals(list2.size(), 0);
......
...@@ -36,13 +36,13 @@ public class TestAutoRecompile extends TestBase { ...@@ -36,13 +36,13 @@ public class TestAutoRecompile extends TestBase {
stat.execute("ALTER TABLE TEST ADD COLUMN Z INT"); stat.execute("ALTER TABLE TEST ADD COLUMN Z INT");
try { try {
prep.execute(); prep.execute();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
try { try {
prep.execute(); prep.execute();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -79,7 +79,7 @@ public class TestBigResult extends TestBase { ...@@ -79,7 +79,7 @@ public class TestBigResult extends TestBase {
deleteDb("bigResult"); deleteDb("bigResult");
ArrayList files = FileLister.getDatabaseFiles(baseDir, "bigResult", true); ArrayList files = FileLister.getDatabaseFiles(baseDir, "bigResult", true);
if (files.size() > 0) { if (files.size() > 0) {
error("file not deleted: " + files.get(0)); fail("file not deleted: " + files.get(0));
} }
} }
......
...@@ -215,13 +215,13 @@ public class TestCases extends TestBase { ...@@ -215,13 +215,13 @@ public class TestCases extends TestBase {
conn.close(); conn.close();
t.join(5000); t.join(5000);
if (stopped[0] == null) { if (stopped[0] == null) {
error("query still running"); fail("query still running");
} else { } else {
assertKnownException(stopped[0]); assertKnownException(stopped[0]);
} }
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
if (time > 5000) { if (time > 5000) {
error("closing took " + time); fail("closing took " + time);
} }
deleteDb("cases"); deleteDb("cases");
} }
...@@ -253,7 +253,7 @@ public class TestCases extends TestBase { ...@@ -253,7 +253,7 @@ public class TestCases extends TestBase {
stat.execute("insert into test values(1);"); stat.execute("insert into test values(1);");
try { try {
stat.execute("alter table test add column name varchar not null;"); stat.execute("alter table test add column name varchar not null;");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -280,7 +280,7 @@ public class TestCases extends TestBase { ...@@ -280,7 +280,7 @@ public class TestCases extends TestBase {
stat.execute("insert into test values(1)"); stat.execute("insert into test values(1)");
try { try {
stat.execute("alter table test alter column id date"); stat.execute("alter table test alter column id date");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -380,7 +380,7 @@ public class TestCases extends TestBase { ...@@ -380,7 +380,7 @@ public class TestCases extends TestBase {
stat = conn.createStatement(); stat = conn.createStatement();
try { try {
stat.execute("select * from abc"); stat.execute("select * from abc");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -568,7 +568,7 @@ public class TestCases extends TestBase { ...@@ -568,7 +568,7 @@ public class TestCases extends TestBase {
int id = rs.getInt(1); int id = rs.getInt(1);
String s = rs.getString("DATA"); String s = rs.getString("DATA");
if (!s.endsWith(")")) { if (!s.endsWith(")")) {
error("id=" + id); fail("id=" + id);
} }
} }
conn.close(); conn.close();
...@@ -587,7 +587,7 @@ public class TestCases extends TestBase { ...@@ -587,7 +587,7 @@ public class TestCases extends TestBase {
Statement stat2 = conn2.createStatement(); Statement stat2 = conn2.createStatement();
try { try {
stat2.execute("UPDATE TEST SET ID=2"); stat2.execute("UPDATE TEST SET ID=2");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -59,14 +59,14 @@ public class TestCluster extends TestBase { ...@@ -59,14 +59,14 @@ public class TestCluster extends TestBase {
try { try {
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"); fail("should not be able to connect in standalone mode");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(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"); fail("should not be able to connect in standalone mode");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -38,7 +38,7 @@ public class TestEncryptedDb extends TestBase { ...@@ -38,7 +38,7 @@ public class TestEncryptedDb extends TestBase {
try { try {
conn = getConnection("exclusive;CIPHER=AES", "sa", "1234 1234"); conn = getConnection("exclusive;CIPHER=AES", "sa", "1234 1234");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -25,7 +25,7 @@ public class TestExclusive extends TestBase { ...@@ -25,7 +25,7 @@ public class TestExclusive extends TestBase {
try { try {
Connection conn2 = getConnection("exclusive"); Connection conn2 = getConnection("exclusive");
conn2.close(); conn2.close();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
/*
* Copyright 2004-2008 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.db;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
/**
* Tests for overloaded user defined functions.
*
* @author Gary Tong
*/
public class TestFunctionOverload extends TestBase {
private static final String ME = TestFunctionOverload.class.getName();
private Connection conn;
private DatabaseMetaData meta;
public void test() throws Exception {
this.deleteDb("functionOverload");
conn = getConnection("functionOverload");
meta = conn.getMetaData();
testControl();
testOverload();
testOverloadNamedArgs();
testOverloadWithConnection();
testOverloadError();
conn.close();
}
private void testOverloadError() throws Exception {
Statement stat = conn.createStatement();
try {
stat.execute("create alias overloadError for \"" + ME + ".overloadError\"");
fail();
} catch (SQLException e) {
assertKnownException(e);
}
}
private void testControl() throws Exception {
Statement stat = conn.createStatement();
stat.execute("create alias overload0 for \"" + ME + ".overload0\"");
ResultSet rs = stat.executeQuery("select overload0() from dual");
assertTrue(rs.next());
assertEquals("0 args", 0, rs.getInt(1));
assertFalse(rs.next());
rs = meta.getProcedures(null, null, "OVERLOAD0");
rs.next();
assertFalse(rs.next());
}
private void testOverload() throws Exception {
Statement stat = conn.createStatement();
stat.execute("create alias overload1or2 for \"" + ME + ".overload1or2\"");
ResultSet rs = stat.executeQuery("select overload1or2(1) from dual");
rs.next();
assertEquals("1 arg", 1, rs.getInt(1));
assertFalse(rs.next());
rs = stat.executeQuery("select overload1or2(1, 2) from dual");
rs.next();
assertEquals("2 args", 3, rs.getInt(1));
assertFalse(rs.next());
rs = meta.getProcedures(null, null, "OVERLOAD1OR2");
rs.next();
assertEquals(1, rs.getInt("NUM_INPUT_PARAMS"));
rs.next();
assertEquals(2, rs.getInt("NUM_INPUT_PARAMS"));
assertFalse(rs.next());
}
private void testOverloadNamedArgs() throws Exception {
Statement stat = conn.createStatement();
stat.execute("create alias overload1or2Named for \"" + ME + ".overload1or2(int)\"");
ResultSet rs = stat.executeQuery("select overload1or2Named(1) from dual");
assertTrue("First Row", rs.next());
assertEquals("1 arg", 1, rs.getInt(1));
assertFalse("Second Row", rs.next());
rs.close();
try {
rs = stat.executeQuery("select overload1or2Named(1, 2) from dual");
rs.close();
fail();
} catch (SQLException e) {
assertKnownException(e);
}
stat.close();
}
private void testOverloadWithConnection() throws Exception {
Statement stat = conn.createStatement();
stat.execute("create alias overload1or2WithConn for \"" + ME + ".overload1or2WithConn\"");
ResultSet rs = stat.executeQuery("select overload1or2WithConn(1) from dual");
rs.next();
assertEquals("1 arg", 1, rs.getInt(1));
assertFalse(rs.next());
rs.close();
rs = stat.executeQuery("select overload1or2WithConn(1, 2) from dual");
rs.next();
assertEquals("2 args", 3, rs.getInt(1));
assertFalse(rs.next());
rs.close();
stat.close();
}
public static int overload0() {
return 0;
}
public static int overload1or2(int one) {
return one;
}
public static int overload1or2(int one, int two) {
return one + two;
}
public static int overload1or2WithConn(Connection conn, int one) throws SQLException {
conn.createStatement().executeQuery("select 1 from dual");
return one;
}
public static int overload1or2WithConn(int one, int two) {
return one + two;
}
public static int overloadError(int one, int two) {
return one + two;
}
public static int overloadError(double one, double two) {
return (int) (one + two);
}
}
...@@ -184,7 +184,7 @@ public class TestFunctions extends TestBase { ...@@ -184,7 +184,7 @@ public class TestFunctions extends TestBase {
try { try {
rs = stat.executeQuery("CALL SELECT_F('ERROR')"); rs = stat.executeQuery("CALL SELECT_F('ERROR')");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertEquals("42001", e.getSQLState()); assertEquals("42001", e.getSQLState());
} }
......
...@@ -135,7 +135,7 @@ public class TestLinkedTable extends TestBase { ...@@ -135,7 +135,7 @@ public class TestLinkedTable extends TestBase {
stat2.executeUpdate("INSERT INTO TEST_LINK_DI VALUES(2, 'World')"); stat2.executeUpdate("INSERT INTO TEST_LINK_DI VALUES(2, 'World')");
try { try {
stat2.executeUpdate("UPDATE TEST_LINK_U SET ID=ID+1"); stat2.executeUpdate("UPDATE TEST_LINK_U SET ID=ID+1");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -225,7 +225,7 @@ public class TestLinkedTable extends TestBase { ...@@ -225,7 +225,7 @@ public class TestLinkedTable extends TestBase {
testRow(stat, "TEST"); testRow(stat, "TEST");
try { try {
stat.execute("SELECT * FROM TEST_TEMP"); stat.execute("SELECT * FROM TEST_TEMP");
error("temp table must not be persistent"); fail("temp table must not be persistent");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -77,7 +77,7 @@ public class TestLob extends TestBase { ...@@ -77,7 +77,7 @@ public class TestLob extends TestBase {
stat.execute("CHECKPOINT"); stat.execute("CHECKPOINT");
ArrayList list2 = FileLister.getDatabaseFiles(baseDir, "lob", true); ArrayList list2 = FileLister.getDatabaseFiles(baseDir, "lob", true);
if (list2.size() >= list.size() + 5) { if (list2.size() >= list.size() + 5) {
error("Expected not many more files, got " + list2.size() + " was " + list.size()); fail("Expected not many more files, got " + list2.size() + " was " + list.size());
} }
stat.execute("DELETE FROM TEST"); stat.execute("DELETE FROM TEST");
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
...@@ -86,7 +86,7 @@ public class TestLob extends TestBase { ...@@ -86,7 +86,7 @@ public class TestLob extends TestBase {
stat.execute("CHECKPOINT"); stat.execute("CHECKPOINT");
ArrayList list3 = FileLister.getDatabaseFiles(baseDir, "lob", true); ArrayList list3 = FileLister.getDatabaseFiles(baseDir, "lob", true);
if (list3.size() >= list.size()) { if (list3.size() >= list.size()) {
error("Expected less files, got " + list2.size() + " was " + list.size()); fail("Expected less files, got " + list2.size() + " was " + list.size());
} }
conn.close(); conn.close();
} }
...@@ -170,7 +170,7 @@ public class TestLob extends TestBase { ...@@ -170,7 +170,7 @@ public class TestLob extends TestBase {
// in Linux, it seems it is still possible to read in files // in Linux, it seems it is still possible to read in files
// even if they are deleted // even if they are deleted
if (System.getProperty("os.name").indexOf("Windows") > 0) { if (System.getProperty("os.name").indexOf("Windows") > 0) {
error("Error expected; len=" + len); fail("Error expected; len=" + len);
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
...@@ -380,12 +380,12 @@ public class TestLob extends TestBase { ...@@ -380,12 +380,12 @@ public class TestLob extends TestBase {
for (int i = 0; i < 10000; i++) { for (int i = 0; i < 10000; i++) {
int ch = r.read(); int ch = r.read();
if (ch != ('0' + (i % 10))) { if (ch != ('0' + (i % 10))) {
error("expected " + (char) ('0' + (i % 10)) + " got: " + ch + " (" + (char) ch + ")"); fail("expected " + (char) ('0' + (i % 10)) + " got: " + ch + " (" + (char) ch + ")");
} }
} }
int ch = r.read(); int ch = r.read();
if (ch != -1) { if (ch != -1) {
error("expected -1 got: " + ch); fail("expected -1 got: " + ch);
} }
conn0.close(); conn0.close();
} }
......
...@@ -63,7 +63,7 @@ public class TestMemoryUsage extends TestBase { ...@@ -63,7 +63,7 @@ public class TestMemoryUsage extends TestBase {
System.gc(); System.gc();
int used = MemoryUtils.getMemoryUsed(); int used = MemoryUtils.getMemoryUsed();
if ((used - start) > 16000) { if ((used - start) > 16000) {
error("Used: " + (used - start)); fail("Used: " + (used - start));
} }
} }
conn.close(); conn.close();
...@@ -89,7 +89,7 @@ public class TestMemoryUsage extends TestBase { ...@@ -89,7 +89,7 @@ public class TestMemoryUsage extends TestBase {
System.gc(); System.gc();
int used = MemoryUtils.getMemoryUsed(); int used = MemoryUtils.getMemoryUsed();
if ((used - start) > 4000) { if ((used - start) > 4000) {
error("Used: " + (used - start)); fail("Used: " + (used - start));
} }
stat.execute("drop table test"); stat.execute("drop table test");
conn.close(); conn.close();
...@@ -153,7 +153,7 @@ public class TestMemoryUsage extends TestBase { ...@@ -153,7 +153,7 @@ public class TestMemoryUsage extends TestBase {
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
rs.next(); rs.next();
if (rs.next()) { if (rs.next()) {
error("one row expected, got more"); fail("one row expected, got more");
} }
if (i % 50000 == 0) { if (i % 50000 == 0) {
trace(" " + (100 * i / len) + "%"); trace(" " + (100 * i / len) + "%");
...@@ -170,7 +170,7 @@ public class TestMemoryUsage extends TestBase { ...@@ -170,7 +170,7 @@ public class TestMemoryUsage extends TestBase {
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
rs.next(); rs.next();
if (rs.next()) { if (rs.next()) {
error("one row expected, got more"); fail("one row expected, got more");
} }
if (i % 50000 == 0) { if (i % 50000 == 0) {
trace(" " + (100 * i / len) + "%"); trace(" " + (100 * i / len) + "%");
......
...@@ -206,7 +206,7 @@ public class TestOptimizations extends TestBase { ...@@ -206,7 +206,7 @@ public class TestOptimizations extends TestBase {
stat.execute(sql); stat.execute(sql);
time2 = System.currentTimeMillis() - time2; time2 = System.currentTimeMillis() - time2;
if (time2 > time * 2) { if (time2 > time * 2) {
error("not optimized: " + time + " optimized: " + time2 + " sql:" + sql); fail("not optimized: " + time + " optimized: " + time2 + " sql:" + sql);
} }
} }
......
...@@ -165,7 +165,7 @@ public class TestPowerOff extends TestBase { ...@@ -165,7 +165,7 @@ public class TestPowerOff extends TestBase {
try { try {
stat.execute("INSERT INTO TEST VALUES(2, 'Hello')"); stat.execute("INSERT INTO TEST VALUES(2, 'Hello')");
stat.execute("CHECKPOINT"); stat.execute("CHECKPOINT");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -199,7 +199,7 @@ public class TestPowerOff extends TestBase { ...@@ -199,7 +199,7 @@ public class TestPowerOff extends TestBase {
stat.execute("INSERT INTO TEST VALUES(2, 'Hello')"); stat.execute("INSERT INTO TEST VALUES(2, 'Hello')");
stat.execute("INSERT INTO TEST VALUES(3, 'Hello')"); stat.execute("INSERT INTO TEST VALUES(3, 'Hello')");
stat.execute("CHECKPOINT"); stat.execute("CHECKPOINT");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -294,7 +294,7 @@ public class TestPowerOff extends TestBase { ...@@ -294,7 +294,7 @@ public class TestPowerOff extends TestBase {
Database.setInitialPowerOffCount(0); Database.setInitialPowerOffCount(0);
Connection conn = getConnection(url); Connection conn = getConnection(url);
if (((JdbcConnection) conn).getPowerOffCount() != 0) { if (((JdbcConnection) conn).getPowerOffCount() != 0) {
error("power off count is not 0"); fail("power off count is not 0");
} }
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
DatabaseMetaData meta = conn.getMetaData(); DatabaseMetaData meta = conn.getMetaData();
......
...@@ -68,7 +68,7 @@ public class TestReadOnly extends TestBase { ...@@ -68,7 +68,7 @@ public class TestReadOnly extends TestBase {
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"); fail("read only delete");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -83,7 +83,7 @@ public class TestReadOnly extends TestBase { ...@@ -83,7 +83,7 @@ public class TestReadOnly extends TestBase {
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"); fail("read only delete");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -53,7 +53,7 @@ public class TestRights extends TestBase { ...@@ -53,7 +53,7 @@ public class TestRights extends TestBase {
Statement stat2 = conn2.createStatement(); Statement stat2 = conn2.createStatement();
try { try {
stat2.execute("SELECT * FROM TEST"); stat2.execute("SELECT * FROM TEST");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -82,13 +82,13 @@ public class TestRights extends TestBase { ...@@ -82,13 +82,13 @@ public class TestRights extends TestBase {
stat.execute("select * from b.test"); stat.execute("select * from b.test");
try { try {
stat.execute("alter user test1 admin false"); stat.execute("alter user test1 admin false");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
try { try {
stat.execute("drop user test1"); stat.execute("drop user test1");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -171,19 +171,19 @@ public class TestRights extends TestBase { ...@@ -171,19 +171,19 @@ public class TestRights extends TestBase {
try { try {
conn = getConnection("rights", "Test", "abc"); conn = getConnection("rights", "Test", "abc");
error("mixed case user name"); fail("mixed case user name");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
try { try {
conn = getConnection("rights", "TEST", "abc"); conn = getConnection("rights", "TEST", "abc");
error("wrong password"); fail("wrong password");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
try { try {
conn = getConnection("rights", "TEST", null); conn = getConnection("rights", "TEST", null);
error("wrong password"); fail("wrong password");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -249,7 +249,7 @@ public class TestRights extends TestBase { ...@@ -249,7 +249,7 @@ public class TestRights extends TestBase {
public void executeError(String sql) throws Exception { public void executeError(String sql) throws Exception {
try { try {
stat.execute(sql); stat.execute(sql);
error("not admin"); fail("not admin");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -67,7 +67,7 @@ public class TestRunscript extends TestBase implements Trigger { ...@@ -67,7 +67,7 @@ public class TestRunscript extends TestBase implements Trigger {
if (password) { if (password) {
try { try {
stat2.execute(sql); stat2.execute(sql);
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -43,13 +43,13 @@ public class TestSQLInjection extends TestBase { ...@@ -43,13 +43,13 @@ public class TestSQLInjection extends TestBase {
stat.execute("CALL 123"); stat.execute("CALL 123");
try { try {
stat.execute("CALL 'Hello'"); stat.execute("CALL 'Hello'");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
try { try {
stat.execute("CALL $$Hello World$$"); stat.execute("CALL $$Hello World$$");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -58,7 +58,7 @@ public class TestSQLInjection extends TestBase { ...@@ -58,7 +58,7 @@ public class TestSQLInjection extends TestBase {
try { try {
assertTrue(checkPasswordInsecure("123456")); assertTrue(checkPasswordInsecure("123456"));
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -74,7 +74,7 @@ public class TestSQLInjection extends TestBase { ...@@ -74,7 +74,7 @@ public class TestSQLInjection extends TestBase {
try { try {
assertTrue(checkPasswordInsecure("123456")); assertTrue(checkPasswordInsecure("123456"));
error("Should fail now"); fail("Should fail now");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -38,7 +38,7 @@ public class TestSpaceReuse extends TestBase { ...@@ -38,7 +38,7 @@ public class TestSpaceReuse extends TestBase {
} }
} }
if (now > first) { if (now > first) {
error("first: " + first + " now: " + now); fail("first: " + first + " now: " + now);
} }
} }
......
...@@ -61,7 +61,7 @@ public class TestTempTables extends TestBase { ...@@ -61,7 +61,7 @@ public class TestTempTables extends TestBase {
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"); fail("test_temp should have been dropped automatically");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -66,7 +66,7 @@ public class TestTransaction extends TestBase { ...@@ -66,7 +66,7 @@ public class TestTransaction extends TestBase {
Statement s2 = c2.createStatement(); Statement s2 = c2.createStatement();
try { try {
s2.executeUpdate("insert into B values('two', 1)"); s2.executeUpdate("insert into B values('two', 1)");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -193,7 +193,7 @@ public class TestTransaction extends TestBase { ...@@ -193,7 +193,7 @@ public class TestTransaction extends TestBase {
} }
} }
if (result.size() != 4) { if (result.size() != 4) {
error("Wrong result, should be NEST1.ID, NEST1.NAME, NEST2.ID, NEST2.NAME but is " + result); fail("Wrong result, should be NEST1.ID, NEST1.NAME, NEST2.ID, NEST2.NAME but is " + result);
} }
result = new Vector(); result = new Vector();
test(stat, "INSERT INTO NEST1 VALUES(1,'A')"); test(stat, "INSERT INTO NEST1 VALUES(1,'A')");
...@@ -212,14 +212,14 @@ public class TestTransaction extends TestBase { ...@@ -212,14 +212,14 @@ public class TestTransaction extends TestBase {
} }
} }
if (result.size() != 4) { if (result.size() != 4) {
error("Wrong result, should be A/1, A/2, B/1, B/2 but is " + result); fail("Wrong result, should be A/1, A/2, B/1, B/2 but is " + result);
} }
result = new Vector(); result = new Vector();
rs1 = s1.executeQuery("SELECT * FROM NEST1 ORDER BY ID"); rs1 = s1.executeQuery("SELECT * FROM NEST1 ORDER BY ID");
rs2 = s1.executeQuery("SELECT * FROM NEST2 ORDER BY ID"); rs2 = s1.executeQuery("SELECT * FROM NEST2 ORDER BY ID");
try { try {
rs1.next(); rs1.next();
error("next worked on a closed result set"); fail("next worked on a closed result set");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -230,7 +230,7 @@ public class TestTransaction extends TestBase { ...@@ -230,7 +230,7 @@ public class TestTransaction extends TestBase {
result.add(v1); result.add(v1);
} }
if (result.size() != 2) { if (result.size() != 2) {
error("Wrong result, should be A, B but is " + result); fail("Wrong result, should be A, B but is " + result);
} }
test(stat, "DROP TABLE NEST1"); test(stat, "DROP TABLE NEST1");
test(stat, "DROP TABLE NEST2"); test(stat, "DROP TABLE NEST2");
...@@ -241,7 +241,7 @@ public class TestTransaction extends TestBase { ...@@ -241,7 +241,7 @@ public class TestTransaction extends TestBase {
rs.next(); rs.next();
String s = rs.getString(1); String s = rs.getString(1);
if (s == null ? (data != null) : (!s.equals(data))) { if (s == null ? (data != null) : (!s.equals(data))) {
error("s= " + s + " should be: " + data); fail("s= " + s + " should be: " + data);
} }
} }
......
...@@ -126,7 +126,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -126,7 +126,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat.execute("DROP TRIGGER IF EXISTS INS_BEFORE"); stat.execute("DROP TRIGGER IF EXISTS INS_BEFORE");
try { try {
stat.execute("DROP TRIGGER INS_BEFORE"); stat.execute("DROP TRIGGER INS_BEFORE");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -148,7 +148,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -148,7 +148,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
set.remove(rs.getString(1)); set.remove(rs.getString(1));
} }
if (set.size() > 0) { if (set.size() > 0) {
error("set should be empty: " + set); fail("set should be empty: " + set);
} }
} }
......
...@@ -110,7 +110,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -110,7 +110,7 @@ public class TestBatchUpdates extends TestBase {
stat = conn.createStatement(); stat = conn.createStatement();
DatabaseMetaData meta = conn.getMetaData(); DatabaseMetaData meta = conn.getMetaData();
if (!meta.supportsBatchUpdates()) { if (!meta.supportsBatchUpdates()) {
error("does not support BatchUpdates"); fail("does not support BatchUpdates");
} }
stat.executeUpdate("CREATE TABLE TEST(KEY_ID INT PRIMARY KEY," stat.executeUpdate("CREATE TABLE TEST(KEY_ID INT PRIMARY KEY,"
+ "C_NAME VARCHAR(255),PRICE DECIMAL(20,2),TYPE_ID INT)"); + "C_NAME VARCHAR(255),PRICE DECIMAL(20,2),TYPE_ID INT)");
...@@ -176,7 +176,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -176,7 +176,7 @@ public class TestBatchUpdates extends TestBase {
trace("updateCount length:" + updateCountLen); trace("updateCount length:" + updateCountLen);
if (updateCountLen != 3) { if (updateCountLen != 3) {
error("updateCount: " + updateCountLen); fail("updateCount: " + updateCountLen);
} else { } else {
trace("addBatch add the SQL statements to Batch "); trace("addBatch add the SQL statements to Batch ");
} }
...@@ -213,7 +213,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -213,7 +213,7 @@ public class TestBatchUpdates extends TestBase {
updCountLength = updateCount.length; updCountLength = updateCount.length;
trace("updateCount Length:" + updCountLength); trace("updateCount Length:" + updCountLength);
if (updCountLength != 3) { if (updCountLength != 3) {
error("addBatch " + updCountLength); fail("addBatch " + updCountLength);
} else { } else {
trace("addBatch add the SQL statements to Batch "); trace("addBatch add the SQL statements to Batch ");
} }
...@@ -230,7 +230,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -230,7 +230,7 @@ public class TestBatchUpdates extends TestBase {
trace("Update Count:" + updateCount[j]); trace("Update Count:" + updateCount[j]);
trace("Returned Value : " + retValue[j]); trace("Returned Value : " + retValue[j]);
if (updateCount[j] != retValue[j]) { if (updateCount[j] != retValue[j]) {
error("j=" + j + " right:" + retValue[j]); fail("j=" + j + " right:" + retValue[j]);
} }
} }
} }
...@@ -252,7 +252,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -252,7 +252,7 @@ public class TestBatchUpdates extends TestBase {
if (updCountLength == 0) { if (updCountLength == 0) {
trace("clearBatch Method clears the current Batch "); trace("clearBatch Method clears the current Batch ");
} else { } else {
error("clearBatch " + updCountLength); fail("clearBatch " + updCountLength);
} }
} }
...@@ -272,7 +272,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -272,7 +272,7 @@ public class TestBatchUpdates extends TestBase {
if (updCountLength == 0) { if (updCountLength == 0) {
trace("clearBatch Method clears the current Batch "); trace("clearBatch Method clears the current Batch ");
} else { } else {
error("clearBatch"); fail("clearBatch");
} }
} }
...@@ -296,7 +296,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -296,7 +296,7 @@ public class TestBatchUpdates extends TestBase {
trace("Successfully Updated"); trace("Successfully Updated");
trace("updateCount Length:" + updCountLength); trace("updateCount Length:" + updCountLength);
if (updCountLength != 3) { if (updCountLength != 3) {
error("executeBatch"); fail("executeBatch");
} else { } else {
trace("executeBatch executes the Batch of SQL statements"); trace("executeBatch executes the Batch of SQL statements");
} }
...@@ -320,7 +320,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -320,7 +320,7 @@ public class TestBatchUpdates extends TestBase {
trace("UpdateCount Value:" + updateCount[j]); trace("UpdateCount Value:" + updateCount[j]);
trace("RetValue : " + retValue[j]); trace("RetValue : " + retValue[j]);
if (updateCount[j] != retValue[j]) { if (updateCount[j] != retValue[j]) {
error("j=" + j + " right:" + retValue[j]); fail("j=" + j + " right:" + retValue[j]);
} }
} }
} }
...@@ -339,7 +339,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -339,7 +339,7 @@ public class TestBatchUpdates extends TestBase {
if (updCountLength == 0) { if (updCountLength == 0) {
trace("executeBatch does not execute Empty Batch"); trace("executeBatch does not execute Empty Batch");
} else { } else {
error("executeBatch"); fail("executeBatch");
} }
} }
...@@ -360,7 +360,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -360,7 +360,7 @@ public class TestBatchUpdates extends TestBase {
if (batchExceptionFlag) { if (batchExceptionFlag) {
trace("select not allowed; correct"); trace("select not allowed; correct");
} else { } else {
error("executeBatch select"); fail("executeBatch select");
} }
} }
...@@ -380,7 +380,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -380,7 +380,7 @@ public class TestBatchUpdates extends TestBase {
trace("Successfully Updated"); trace("Successfully Updated");
trace("updateCount Length:" + updCountLength); trace("updateCount Length:" + updCountLength);
if (updCountLength != 3) { if (updCountLength != 3) {
error("executeBatch"); fail("executeBatch");
} else { } else {
trace("executeBatch executes the Batch of SQL statements"); trace("executeBatch executes the Batch of SQL statements");
} }
...@@ -395,7 +395,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -395,7 +395,7 @@ public class TestBatchUpdates extends TestBase {
for (int j = 0; j < updateCount.length; j++) { for (int j = 0; j < updateCount.length; j++) {
trace("Update Count : " + updateCount[j]); trace("Update Count : " + updateCount[j]);
if (updateCount[j] != retValue[j]) { if (updateCount[j] != retValue[j]) {
error("j=" + j + " right:" + retValue[j]); fail("j=" + j + " right:" + retValue[j]);
} }
} }
} }
...@@ -409,7 +409,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -409,7 +409,7 @@ public class TestBatchUpdates extends TestBase {
if (updCountLength == 0) { if (updCountLength == 0) {
trace("executeBatch Method does not execute the Empty Batch "); trace("executeBatch Method does not execute the Empty Batch ");
} else { } else {
error("executeBatch 0!=" + updCountLength); fail("executeBatch 0!=" + updCountLength);
} }
} }
...@@ -434,7 +434,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -434,7 +434,7 @@ public class TestBatchUpdates extends TestBase {
if (batchExceptionFlag) { if (batchExceptionFlag) {
trace("executeBatch insert duplicate; correct"); trace("executeBatch insert duplicate; correct");
} else { } else {
error("executeBatch"); fail("executeBatch");
} }
} }
...@@ -454,7 +454,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -454,7 +454,7 @@ public class TestBatchUpdates extends TestBase {
if (batchExceptionFlag) { if (batchExceptionFlag) {
trace("executeBatch select"); trace("executeBatch select");
} else { } else {
error("executeBatch"); fail("executeBatch");
} }
} }
...@@ -511,7 +511,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -511,7 +511,7 @@ public class TestBatchUpdates extends TestBase {
// Make sure that we have the correct error code for // Make sure that we have the correct error code for
// the failed update. // the failed update.
if (!(batchUpdates[1] == -3 && count == 1)) { if (!(batchUpdates[1] == -3 && count == 1)) {
error("insert failed"); fail("insert failed");
} }
} }
} }
......
...@@ -72,7 +72,7 @@ public class TestCancel extends TestBase { ...@@ -72,7 +72,7 @@ public class TestCancel extends TestBase {
stat.execute("set query_timeout 1"); stat.execute("set query_timeout 1");
try { try {
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(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -110,7 +110,7 @@ public class TestCancel extends TestBase { ...@@ -110,7 +110,7 @@ public class TestCancel extends TestBase {
assertEquals(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(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertEquals(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode()); assertEquals(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode());
} }
...@@ -127,7 +127,7 @@ public class TestCancel extends TestBase { ...@@ -127,7 +127,7 @@ public class TestCancel extends TestBase {
stat.execute("SET QUERY_TIMEOUT 10"); stat.execute("SET QUERY_TIMEOUT 10");
try { try {
stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"); stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertEquals(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode()); assertEquals(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode());
} }
...@@ -143,7 +143,7 @@ public class TestCancel extends TestBase { ...@@ -143,7 +143,7 @@ public class TestCancel extends TestBase {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
try { try {
stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"); stat.executeQuery("SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertEquals(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode()); assertEquals(ErrorCode.STATEMENT_WAS_CANCELLED, e.getErrorCode());
} }
......
...@@ -252,15 +252,15 @@ public class TestMetaData extends TestBase { ...@@ -252,15 +252,15 @@ public class TestMetaData extends TestBase {
"NUM_INPUT_PARAMS", "NUM_OUTPUT_PARAMS", "NUM_RESULT_SETS", "REMARKS", "PROCEDURE_TYPE" }, new int[] { "NUM_INPUT_PARAMS", "NUM_OUTPUT_PARAMS", "NUM_RESULT_SETS", "REMARKS", "PROCEDURE_TYPE" }, new int[] {
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER,
Types.VARCHAR, Types.SMALLINT }, null, null); Types.VARCHAR, Types.SMALLINT }, null, null);
testResultSetOrdered(rs, new String[][] { { catalog, Constants.SCHEMA_MAIN, "EXIT", "0", "0", "0", "", testResultSetOrdered(rs, new String[][] { { catalog, Constants.SCHEMA_MAIN, "EXIT", "1", "0", "0", "",
"" + DatabaseMetaData.procedureNoResult }, }); "" + DatabaseMetaData.procedureNoResult }, });
rs = meta.getProcedureColumns(null, null, null, null); rs = meta.getProcedureColumns(null, null, null, null);
testResultSetMeta(rs, 13, testResultSetMeta(rs, 15,
new String[] { "PROCEDURE_CAT", "PROCEDURE_SCHEM", "PROCEDURE_NAME", "COLUMN_NAME", "COLUMN_TYPE", new String[] { "PROCEDURE_CAT", "PROCEDURE_SCHEM", "PROCEDURE_NAME", "COLUMN_NAME", "COLUMN_TYPE",
"DATA_TYPE", "TYPE_NAME", "PRECISION", "LENGTH", "SCALE", "RADIX", "NULLABLE", "REMARKS" }, "DATA_TYPE", "TYPE_NAME", "PRECISION", "LENGTH", "SCALE", "RADIX", "NULLABLE", "REMARKS", "NUM_INPUT_PARAMS", "POS" },
new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.INTEGER, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.INTEGER,
Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.SMALLINT, Types.SMALLINT, Types.SMALLINT, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.SMALLINT, Types.SMALLINT, Types.SMALLINT,
Types.VARCHAR }, null, null); Types.VARCHAR , Types.INTEGER, Types.INTEGER}, null, null);
testResultSetOrdered(rs, new String[][] { testResultSetOrdered(rs, new String[][] {
{ catalog, Constants.SCHEMA_MAIN, "EXIT", "P1", "" + DatabaseMetaData.procedureColumnIn, { catalog, Constants.SCHEMA_MAIN, "EXIT", "P1", "" + DatabaseMetaData.procedureColumnIn,
"" + Types.INTEGER, "INTEGER", "10", "10", "0", "10", "" + DatabaseMetaData.procedureNoNulls }, "" + Types.INTEGER, "INTEGER", "10", "10", "0", "10", "" + DatabaseMetaData.procedureNoNulls },
...@@ -583,7 +583,7 @@ public class TestMetaData extends TestBase { ...@@ -583,7 +583,7 @@ public class TestMetaData extends TestBase {
"SQL" }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, "SQL" }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.VARCHAR }, null, null); Types.VARCHAR }, null, null);
if (rs.next()) { if (rs.next()) {
error("Database is not empty after dropping all tables"); fail("Database is not empty after dropping all tables");
} }
stat.executeUpdate("CREATE TABLE TEST(" + "ID INT PRIMARY KEY," + "TEXT_V VARCHAR(120)," stat.executeUpdate("CREATE TABLE TEST(" + "ID INT PRIMARY KEY," + "TEXT_V VARCHAR(120),"
+ "DEC_V DECIMAL(12,3)," + "DATE_V DATETIME," + "BLOB_V BLOB," + "CLOB_V CLOB" + ")"); + "DEC_V DECIMAL(12,3)," + "DATE_V DATETIME," + "BLOB_V BLOB," + "CLOB_V CLOB" + ")");
......
...@@ -224,7 +224,7 @@ public class TestNativeSQL extends TestBase { ...@@ -224,7 +224,7 @@ public class TestNativeSQL extends TestBase {
stat.setEscapeProcessing(false); stat.setEscapeProcessing(false);
try { try {
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"); fail("expected error if setEscapeProcessing=false");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -108,13 +108,13 @@ public class TestPreparedStatement extends TestBase { ...@@ -108,13 +108,13 @@ public class TestPreparedStatement extends TestBase {
PreparedStatement prep = conn.prepareStatement("CREATE TABLE BAD AS SELECT A"); PreparedStatement prep = conn.prepareStatement("CREATE TABLE BAD AS SELECT A");
try { try {
prep.execute(); prep.execute();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
try { try {
prep.execute(); prep.execute();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -219,7 +219,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -219,7 +219,7 @@ public class TestPreparedStatement extends TestBase {
"SELECT * FROM (SELECT ? FROM DUAL)"); "SELECT * FROM (SELECT ? FROM DUAL)");
prep.setInt(1, 1); prep.setInt(1, 1);
prep.execute(); prep.execute();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -387,20 +387,20 @@ public class TestPreparedStatement extends TestBase { ...@@ -387,20 +387,20 @@ public class TestPreparedStatement extends TestBase {
assertEquals(pm.isSigned(1), true); assertEquals(pm.isSigned(1), true);
try { try {
pm.getPrecision(0); pm.getPrecision(0);
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
try { try {
pm.getPrecision(4); pm.getPrecision(4);
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
prep.close(); prep.close();
try { try {
pm.getPrecision(1); pm.getPrecision(1);
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -509,7 +509,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -509,7 +509,7 @@ public class TestPreparedStatement extends TestBase {
assertFalse(rs.next()); assertFalse(rs.next());
try { try {
prep = conn.prepareStatement("select ? from dual union select ? from dual"); prep = conn.prepareStatement("select ? from dual union select ? from dual");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -661,7 +661,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -661,7 +661,7 @@ public class TestPreparedStatement extends TestBase {
try { try {
// supposed to be closed now // supposed to be closed now
rs.next(); rs.next();
error("getMoreResults didn't close this result set"); fail("getMoreResults didn't close this result set");
} catch (SQLException e) { } catch (SQLException e) {
trace("no error - getMoreResults is supposed to close the result set"); trace("no error - getMoreResults is supposed to close the result set");
} }
......
...@@ -296,7 +296,7 @@ public class TestResultSet extends TestBase { ...@@ -296,7 +296,7 @@ public class TestResultSet extends TestBase {
// this should break // this should break
try { try {
rs.setFetchSize(-1); rs.setFetchSize(-1);
error("fetch size -1 is not allowed"); fail("fetch size -1 is not allowed");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
trace(e.toString()); trace(e.toString());
...@@ -304,7 +304,7 @@ public class TestResultSet extends TestBase { ...@@ -304,7 +304,7 @@ public class TestResultSet extends TestBase {
trace("after try to set to -1, fetch size=" + rs.getFetchSize()); trace("after try to set to -1, fetch size=" + rs.getFetchSize());
try { try {
rs.setFetchSize(100); rs.setFetchSize(100);
error("fetch size 100 is bigger than maxrows - not allowed"); fail("fetch size 100 is bigger than maxrows - not allowed");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
trace(e.toString()); trace(e.toString());
......
...@@ -58,7 +58,7 @@ public class TestStatement extends TestBase { ...@@ -58,7 +58,7 @@ public class TestStatement extends TestBase {
int id1 = savepoint1.getSavepointId(); int id1 = savepoint1.getSavepointId();
try { try {
savepoint1.getSavepointName(); savepoint1.getSavepointName();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -70,7 +70,7 @@ public class TestStatement extends TestBase { ...@@ -70,7 +70,7 @@ public class TestStatement extends TestBase {
conn.releaseSavepoint(savepoint2a); conn.releaseSavepoint(savepoint2a);
try { try {
savepoint2a.getSavepointId(); savepoint2a.getSavepointId();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -82,7 +82,7 @@ public class TestStatement extends TestBase { ...@@ -82,7 +82,7 @@ public class TestStatement extends TestBase {
assertEquals(savepointTest.getSavepointName(), "Joe's"); assertEquals(savepointTest.getSavepointName(), "Joe's");
try { try {
savepointTest.getSavepointId(); savepointTest.getSavepointId();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -95,7 +95,7 @@ public class TestStatement extends TestBase { ...@@ -95,7 +95,7 @@ public class TestStatement extends TestBase {
assertFalse(rs.next()); assertFalse(rs.next());
try { try {
conn.rollback(savepoint2); conn.rollback(savepoint2);
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -164,7 +164,7 @@ public class TestStatement extends TestBase { ...@@ -164,7 +164,7 @@ public class TestStatement extends TestBase {
// this is supposed to throw an exception // this is supposed to throw an exception
try { try {
stat.setQueryTimeout(-1); stat.setQueryTimeout(-1);
error("setQueryTimeout(-1) didn't throw an exception"); fail("setQueryTimeout(-1) didn't throw an exception");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -189,7 +189,7 @@ public class TestStatement extends TestBase { ...@@ -189,7 +189,7 @@ public class TestStatement extends TestBase {
assertEquals(count, 1); assertEquals(count, 1);
try { try {
stat.executeUpdate("SELECT * FROM TEST"); stat.executeUpdate("SELECT * FROM TEST");
error("executeUpdate allowed SELECT"); fail("executeUpdate allowed SELECT");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
trace("no error - SELECT not allowed with executeUpdate"); trace("no error - SELECT not allowed with executeUpdate");
...@@ -216,7 +216,7 @@ public class TestStatement extends TestBase { ...@@ -216,7 +216,7 @@ public class TestStatement extends TestBase {
trace("executeQuery"); trace("executeQuery");
try { try {
stat.executeQuery("CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE VARCHAR(255))"); stat.executeQuery("CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE VARCHAR(255))");
error("executeQuery allowed CREATE TABLE"); fail("executeQuery allowed CREATE TABLE");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
trace("no error - CREATE not allowed with executeQuery"); trace("no error - CREATE not allowed with executeQuery");
...@@ -224,21 +224,21 @@ public class TestStatement extends TestBase { ...@@ -224,21 +224,21 @@ public class TestStatement extends TestBase {
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE VARCHAR(255))"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE VARCHAR(255))");
try { try {
stat.executeQuery("INSERT INTO TEST VALUES(1,'Hello')"); stat.executeQuery("INSERT INTO TEST VALUES(1,'Hello')");
error("executeQuery allowed INSERT"); fail("executeQuery allowed INSERT");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
trace("no error - INSERT not allowed with executeQuery"); trace("no error - INSERT not allowed with executeQuery");
} }
try { try {
stat.executeQuery("UPDATE TEST SET VALUE='LDBC' WHERE ID=2"); stat.executeQuery("UPDATE TEST SET VALUE='LDBC' WHERE ID=2");
error("executeQuery allowed UPDATE"); fail("executeQuery allowed UPDATE");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
trace("no error - UPDATE not allowed with executeQuery"); trace("no error - UPDATE not allowed with executeQuery");
} }
try { try {
stat.executeQuery("DELETE FROM TEST WHERE ID=3"); stat.executeQuery("DELETE FROM TEST WHERE ID=3");
error("executeQuery allowed DELETE"); fail("executeQuery allowed DELETE");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
trace("no error - DELETE not allowed with executeQuery"); trace("no error - DELETE not allowed with executeQuery");
...@@ -246,7 +246,7 @@ public class TestStatement extends TestBase { ...@@ -246,7 +246,7 @@ public class TestStatement extends TestBase {
stat.executeQuery("SELECT * FROM TEST"); stat.executeQuery("SELECT * FROM TEST");
try { try {
stat.executeQuery("DROP TABLE TEST"); stat.executeQuery("DROP TABLE TEST");
error("executeQuery allowed DROP"); fail("executeQuery allowed DROP");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
trace("no error - DROP not allowed with executeQuery"); trace("no error - DROP not allowed with executeQuery");
...@@ -257,7 +257,7 @@ public class TestStatement extends TestBase { ...@@ -257,7 +257,7 @@ public class TestStatement extends TestBase {
try { try {
// supposed to be closed now // supposed to be closed now
rs.next(); rs.next();
error("getMoreResults didn't close this result set"); fail("getMoreResults didn't close this result set");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
trace("no error - getMoreResults is supposed to close the result set"); trace("no error - getMoreResults is supposed to close the result set");
......
...@@ -59,7 +59,7 @@ public class TestTransactionIsolation extends TestBase { ...@@ -59,7 +59,7 @@ public class TestTransactionIsolation extends TestBase {
conn1.createStatement().executeUpdate("UPDATE TEST SET ID=2"); conn1.createStatement().executeUpdate("UPDATE TEST SET ID=2");
try { try {
assertSingleValue(conn2.createStatement(), "SELECT * FROM TEST", 1); assertSingleValue(conn2.createStatement(), "SELECT * FROM TEST", 1);
error("Expected lock timeout"); fail("Expected lock timeout");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -81,7 +81,7 @@ public class TestTransactionIsolation extends TestBase { ...@@ -81,7 +81,7 @@ public class TestTransactionIsolation extends TestBase {
conn2.createStatement().executeUpdate("UPDATE TEST SET ID=4"); conn2.createStatement().executeUpdate("UPDATE TEST SET ID=4");
try { try {
conn1.createStatement().executeUpdate("DELETE FROM TEST"); conn1.createStatement().executeUpdate("DELETE FROM TEST");
error("Expected lock timeout"); fail("Expected lock timeout");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -55,7 +55,7 @@ public class TestUpdatableResultSet extends TestBase { ...@@ -55,7 +55,7 @@ public class TestUpdatableResultSet extends TestBase {
try { try {
rs.insertRow(); rs.insertRow();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -85,7 +85,7 @@ public class TestZloty extends TestBase { ...@@ -85,7 +85,7 @@ public class TestZloty extends TestBase {
try { try {
prep.setBigDecimal(2, new ZlotyBigDecimal("11.0")); prep.setBigDecimal(2, new ZlotyBigDecimal("11.0"));
prep.execute(); prep.execute();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -101,7 +101,7 @@ public class TestZloty extends TestBase { ...@@ -101,7 +101,7 @@ public class TestZloty extends TestBase {
}; };
prep.setBigDecimal(2, value); prep.setBigDecimal(2, value);
prep.execute(); prep.execute();
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -40,7 +40,7 @@ public class TestMvcc1 extends TestBase { ...@@ -40,7 +40,7 @@ public class TestMvcc1 extends TestBase {
assertEquals("FALSE", rs.getString("VALUE")); assertEquals("FALSE", rs.getString("VALUE"));
try { try {
stat.execute("SET MVCC TRUE"); stat.execute("SET MVCC TRUE");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertEquals(ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1, e.getErrorCode()); assertEquals(ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1, e.getErrorCode());
} }
...@@ -105,7 +105,7 @@ public class TestMvcc1 extends TestBase { ...@@ -105,7 +105,7 @@ public class TestMvcc1 extends TestBase {
s1.execute("insert into a(code) values('one')"); s1.execute("insert into a(code) values('one')");
try { try {
s2.execute("insert into b values('un B', 1)"); s2.execute("insert into b values('un B', 1)");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -120,7 +120,7 @@ public class TestMvcc1 extends TestBase { ...@@ -120,7 +120,7 @@ public class TestMvcc1 extends TestBase {
s1.execute("insert into test values(1)"); s1.execute("insert into test values(1)");
try { try {
s2.execute("drop table test"); s2.execute("drop table test");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
// lock timeout expected // lock timeout expected
assertKnownException(e); assertKnownException(e);
...@@ -147,7 +147,7 @@ public class TestMvcc1 extends TestBase { ...@@ -147,7 +147,7 @@ public class TestMvcc1 extends TestBase {
s2.execute("select * from test for update"); s2.execute("select * from test for update");
try { try {
s1.execute("insert into test values(2, 'x')"); s1.execute("insert into test values(2, 'x')");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
// lock timeout expected // lock timeout expected
assertKnownException(e); assertKnownException(e);
...@@ -370,7 +370,7 @@ public class TestMvcc1 extends TestBase { ...@@ -370,7 +370,7 @@ public class TestMvcc1 extends TestBase {
c1.commit(); c1.commit();
try { try {
s1.execute("update test set id=2 where id=1"); s1.execute("update test set id=2 where id=1");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -32,7 +32,7 @@ public class TestNestedLoop extends TestBase { ...@@ -32,7 +32,7 @@ public class TestNestedLoop extends TestBase {
stat.executeQuery("select id from test"); stat.executeQuery("select id from test");
try { try {
rs.next(); rs.next();
error("Result set should be closed"); fail("Result set should be closed");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -40,7 +40,7 @@ public class TestNestedLoop extends TestBase { ...@@ -40,7 +40,7 @@ public class TestNestedLoop extends TestBase {
stat.close(); stat.close();
try { try {
rs.next(); rs.next();
error("Result set should be closed"); fail("Result set should be closed");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -42,7 +42,7 @@ public class TestPgServer extends TestBase { ...@@ -42,7 +42,7 @@ public class TestPgServer extends TestBase {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
try { try {
stat.execute("select ***"); stat.execute("select ***");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -46,17 +46,17 @@ public class TestKillRestart extends TestBase { ...@@ -46,17 +46,17 @@ public class TestKillRestart extends TestBase {
String s = catcher.readLine(60 * 1000); String s = catcher.readLine(60 * 1000);
// System.out.println("> " + s); // System.out.println("> " + s);
if (s == null) { if (s == null) {
error("No reply from process"); fail("No reply from process");
} else if (!s.startsWith("#")) { } else if (!s.startsWith("#")) {
// System.out.println(s); // System.out.println(s);
error("Expected: #..., got: " + s); fail("Expected: #..., got: " + s);
} else if (s.startsWith("#Running")) { } else if (s.startsWith("#Running")) {
Thread.sleep(100); Thread.sleep(100);
printTime("killing: " + i); printTime("killing: " + i);
p.destroy(); p.destroy();
break; break;
} else if (s.startsWith("#Fail")) { } else if (s.startsWith("#Fail")) {
error("Failed: " + s); fail("Failed: " + s);
} }
} }
} }
......
...@@ -58,10 +58,10 @@ public class TestKillRestartMulti extends TestBase { ...@@ -58,10 +58,10 @@ public class TestKillRestartMulti extends TestBase {
String s = catcher.readLine(5 * 60 * 1000); String s = catcher.readLine(5 * 60 * 1000);
// System.out.println("> " + s); // System.out.println("> " + s);
if (s == null) { if (s == null) {
error("No reply from process"); fail("No reply from process");
} else if (!s.startsWith("#")) { } else if (!s.startsWith("#")) {
// System.out.println(s); // System.out.println(s);
error("Expected: #..., got: " + s); fail("Expected: #..., got: " + s);
} else if (s.startsWith("#Running")) { } else if (s.startsWith("#Running")) {
int sleep = 10 + random.nextInt(100); int sleep = 10 + random.nextInt(100);
Thread.sleep(sleep); Thread.sleep(sleep);
...@@ -79,7 +79,7 @@ public class TestKillRestartMulti extends TestBase { ...@@ -79,7 +79,7 @@ public class TestKillRestartMulti extends TestBase {
} }
System.err.println(" " + a); System.err.println(" " + a);
} }
error("Failed: " + s); fail("Failed: " + s);
} }
} }
String backup = baseDir + "/killRestartMulti-" + System.currentTimeMillis() + ".zip"; String backup = baseDir + "/killRestartMulti-" + System.currentTimeMillis() + ".zip";
......
...@@ -85,7 +85,7 @@ public class TestSimpleIndex extends TestBase { ...@@ -85,7 +85,7 @@ public class TestSimpleIndex extends TestBase {
ed = true; ed = true;
} }
if (em != ed) { if (em != ed) {
error("different result: "); fail("different result: ");
} }
if (!em) { if (!em) {
execute("INSERT INTO TEST_M " + sql); execute("INSERT INTO TEST_M " + sql);
......
...@@ -264,7 +264,7 @@ select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGG ...@@ -264,7 +264,7 @@ select remarks from information_schema.triggers where trigger_name = 'TEST_TRIGG
drop trigger TEST_TRIGGER; drop trigger TEST_TRIGGER;
@reconnect; @reconnect;
create alias parse_long for "java.lang.Long.parseLong"; create alias parse_long for "java.lang.Long.parseLong(java.lang.String)";
comment on alias parse_long is 'Parse a long with base'; comment on alias parse_long is 'Parse a long with base';
select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG'; select remarks from information_schema.function_aliases where alias_name = 'PARSE_LONG';
> Parse a long with base; > Parse a long with base;
......
...@@ -53,14 +53,14 @@ public class TestExit extends TestBase implements DatabaseEventListener { ...@@ -53,14 +53,14 @@ public class TestExit extends TestBase implements DatabaseEventListener {
proc.waitFor(); proc.waitFor();
Thread.sleep(100); Thread.sleep(100);
if (!getClosedFile().exists()) { if (!getClosedFile().exists()) {
error("did not close database"); fail("did not close database");
} }
procDef = new String[] { "java", "-cp", classPath, getClass().getName(), "" + OPEN_WITHOUT_CLOSE_ON_EXIT }; procDef = new String[] { "java", "-cp", classPath, getClass().getName(), "" + OPEN_WITHOUT_CLOSE_ON_EXIT };
proc = Runtime.getRuntime().exec(procDef); proc = Runtime.getRuntime().exec(procDef);
proc.waitFor(); proc.waitFor();
Thread.sleep(100); Thread.sleep(100);
if (getClosedFile().exists()) { if (getClosedFile().exists()) {
error("closed database"); fail("closed database");
} }
} }
......
...@@ -94,7 +94,7 @@ public class TestFile extends TestBase implements DataHandler { ...@@ -94,7 +94,7 @@ public class TestFile extends TestBase implements DataHandler {
} }
if (a != b) { if (a != b) {
if (a == null || b == null) { if (a == null || b == null) {
error("only one threw an exception"); fail("only one threw an exception");
} }
} }
assertEquals(buffMem, buffFile); assertEquals(buffMem, buffFile);
......
...@@ -182,7 +182,7 @@ public class TestFileSystem extends TestBase { ...@@ -182,7 +182,7 @@ public class TestFileSystem extends TestBase {
FileObject f = fs.openFileObject(s, "rw"); FileObject f = fs.openFileObject(s, "rw");
try { try {
f.readFully(new byte[1], 0, 1); f.readFully(new byte[1], 0, 1);
error(); fail();
} catch (EOFException e) { } catch (EOFException e) {
// expected // expected
} }
......
...@@ -71,13 +71,13 @@ public class TestOverflow extends TestBase { ...@@ -71,13 +71,13 @@ public class TestOverflow extends TestBase {
void onSuccess() throws Exception { void onSuccess() throws Exception {
if (!successExpected && SysProperties.OVERFLOW_EXCEPTIONS) { if (!successExpected && SysProperties.OVERFLOW_EXCEPTIONS) {
error(); fail();
} }
} }
void onError() throws Exception { void onError() throws Exception {
if (successExpected) { if (successExpected) {
error(); fail();
} }
} }
......
...@@ -35,7 +35,7 @@ public class TestPattern extends TestBase { ...@@ -35,7 +35,7 @@ public class TestPattern extends TestBase {
boolean resultRegexp = value.matches(regexp); boolean resultRegexp = value.matches(regexp);
boolean result = comp.test(pattern, value, '\\'); boolean result = comp.test(pattern, value, '\\');
if (result != resultRegexp) { if (result != resultRegexp) {
error("Error: >" + value + "< LIKE >" + pattern + "< result=" + result + " resultReg=" + resultRegexp); fail("Error: >" + value + "< LIKE >" + pattern + "< result=" + result + " resultReg=" + resultRegexp);
} }
} }
...@@ -72,7 +72,7 @@ public class TestPattern extends TestBase { ...@@ -72,7 +72,7 @@ public class TestPattern extends TestBase {
char c = pattern.charAt(i); char c = pattern.charAt(i);
if (escape == c) { if (escape == c) {
if (i >= len) { if (i >= len) {
error("escape can't be last char"); fail("escape can't be last char");
} }
c = pattern.charAt(++i); c = pattern.charAt(++i);
buff.append('\\'); buff.append('\\');
......
...@@ -183,7 +183,7 @@ public class TestServlet extends TestBase { ...@@ -183,7 +183,7 @@ public class TestServlet extends TestBase {
try { try {
stat1.execute("SELECT * FROM T"); stat1.execute("SELECT * FROM T");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -195,7 +195,7 @@ public class TestServlet extends TestBase { ...@@ -195,7 +195,7 @@ public class TestServlet extends TestBase {
// listener must be stopped // listener must be stopped
try { try {
conn2 = DriverManager.getConnection("jdbc:h2:tcp://localhost:8888/" + baseDir + "/servlet", getUser(), getPassword()); conn2 = DriverManager.getConnection("jdbc:h2:tcp://localhost:8888/" + baseDir + "/servlet", getUser(), getPassword());
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -203,7 +203,7 @@ public class TestServlet extends TestBase { ...@@ -203,7 +203,7 @@ public class TestServlet extends TestBase {
// connection must be closed // connection must be closed
try { try {
stat1.execute("SELECT * FROM DUAL"); stat1.execute("SELECT * FROM DUAL");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -37,13 +37,13 @@ public class TestStringUtils extends TestBase { ...@@ -37,13 +37,13 @@ public class TestStringUtils extends TestBase {
assertEquals(new byte[] { (byte) 0xfa, (byte) 0xce }, ByteUtils.convertStringToBytes("FaCe")); assertEquals(new byte[] { (byte) 0xfa, (byte) 0xce }, ByteUtils.convertStringToBytes("FaCe"));
try { try {
ByteUtils.convertStringToBytes("120"); ByteUtils.convertStringToBytes("120");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
try { try {
ByteUtils.convertStringToBytes("fast"); ByteUtils.convertStringToBytes("fast");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -94,7 +94,7 @@ public class TestTools extends TestBase { ...@@ -94,7 +94,7 @@ public class TestTools extends TestBase {
assertTrue(result.indexOf("Shutting down") >= 0); assertTrue(result.indexOf("Shutting down") >= 0);
try { try {
conn = DriverManager.getConnection("jdbc:h2:ssl://localhost:9001/mem:", "sa", "sa"); conn = DriverManager.getConnection("jdbc:h2:ssl://localhost:9001/mem:", "sa", "sa");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -121,7 +121,7 @@ public class TestTools extends TestBase { ...@@ -121,7 +121,7 @@ public class TestTools extends TestBase {
stop.shutdown(); stop.shutdown();
try { try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9005/mem:", "sa", "sa"); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9005/mem:", "sa", "sa");
error(); fail();
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -409,7 +409,7 @@ public class TestTools extends TestBase { ...@@ -409,7 +409,7 @@ public class TestTools extends TestBase {
new String[] { "-ifExists", "-tcpPassword", "abc", "-baseDir", baseDir, "-tcpPort", "9192" }).start(); new String[] { "-ifExists", "-tcpPassword", "abc", "-baseDir", baseDir, "-tcpPort", "9192" }).start();
try { try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test2", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test2", "sa", "");
error("should not be able to create new db"); fail("should not be able to create new db");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -417,7 +417,7 @@ public class TestTools extends TestBase { ...@@ -417,7 +417,7 @@ public class TestTools extends TestBase {
conn.close(); conn.close();
try { try {
Server.shutdownTcpServer("tcp://localhost:9192", "", true); Server.shutdownTcpServer("tcp://localhost:9192", "", true);
error("shouldn't work and should throw an exception"); fail("shouldn't work and should throw an exception");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
...@@ -428,7 +428,7 @@ public class TestTools extends TestBase { ...@@ -428,7 +428,7 @@ public class TestTools extends TestBase {
deleteDb("test"); deleteDb("test");
try { try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", "");
error("server must have been closed"); fail("server must have been closed");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
......
...@@ -81,7 +81,7 @@ public class TestValueMemory extends TestBase implements DataHandler { ...@@ -81,7 +81,7 @@ public class TestValueMemory extends TestBase implements DataHandler {
long used = MemoryUtils.getMemoryUsed() - first; long used = MemoryUtils.getMemoryUsed() - first;
memory /= 1024; memory /= 1024;
if (used > memory * 3) { if (used > memory * 3) {
error("Type: " + type + " Used memory: " + used + " calculated: " + memory + " " + array.length + " size: " + size); fail("Type: " + type + " Used memory: " + used + " calculated: " + memory + " " + array.length + " size: " + size);
} }
} }
Value create(int type) throws SQLException { Value create(int type) throws SQLException {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论