提交 7b35cb31 authored 作者: Thomas Mueller's avatar Thomas Mueller

Don't throw Error

上级 7d7fbc8d
...@@ -75,7 +75,7 @@ public class BenchCThread { ...@@ -75,7 +75,7 @@ public class BenchCThread {
processStockLevel(); processStockLevel();
break; break;
default: default:
throw new Error("op=" + op); throw new AssertionError("op=" + op);
} }
} }
} }
......
...@@ -91,7 +91,7 @@ public class TaskProcess { ...@@ -91,7 +91,7 @@ public class TaskProcess {
} }
} }
} catch (Exception e) { } catch (Exception e) {
throw new Error("Error: " + e, e); throw new RuntimeException(e);
} }
} }
} .start(); } .start();
......
...@@ -536,12 +536,12 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -536,12 +536,12 @@ public class TestFunctions extends TestBase implements AggregateFunction {
rs.addColumn("NAME", Types.VARCHAR, 255, 0); rs.addColumn("NAME", Types.VARCHAR, 255, 0);
if (count == null) { if (count == null) {
if (ip != 0 || bp || fp != 0.0 || dp != 0.0 || sp != 0 || lp != 0 || byParam != 0) { if (ip != 0 || bp || fp != 0.0 || dp != 0.0 || sp != 0 || lp != 0 || byParam != 0) {
throw new Error("params not 0/false"); throw new AssertionError("params not 0/false");
} }
} }
if (count != null) { if (count != null) {
if (ip != 1 || !bp || fp != 1.0 || dp != 1.0 || sp != 1 || lp != 1 || byParam != 1) { if (ip != 1 || !bp || fp != 1.0 || dp != 1.0 || sp != 1 || lp != 1 || byParam != 1) {
throw new Error("params not 1/true"); throw new AssertionError("params not 1/true");
} }
if (count.intValue() >= 1) { if (count.intValue() >= 1) {
rs.addRow(0, "Hello"); rs.addRow(0, "Hello");
......
...@@ -12,7 +12,8 @@ import java.io.Serializable; ...@@ -12,7 +12,8 @@ import java.io.Serializable;
* A utility class for TestLob. * A utility class for TestLob.
*/ */
class TestLobObject implements Serializable { class TestLobObject implements Serializable {
private static final long serialVersionUID = 904356179316518715L;
private static final long serialVersionUID = 1L;
String data; String data;
TestLobObject(String data) { TestLobObject(String data) {
......
...@@ -178,7 +178,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -178,7 +178,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
} }
public void exceptionThrown(SQLException e, String sql) { public void exceptionThrown(SQLException e, String sql) {
throw new Error("unexpected: " + e + " sql: " + sql); throw new AssertionError("unexpected: " + e + " sql: " + sql);
} }
public void setProgress(int state, String name, int current, int max) { public void setProgress(int state, String name, int current, int max) {
...@@ -187,13 +187,13 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -187,13 +187,13 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
case STATE_SCAN_FILE: case STATE_SCAN_FILE:
stateName = "Scan " + name + " " + current + "/" + max; stateName = "Scan " + name + " " + current + "/" + max;
if (current > 0) { if (current > 0) {
throw new Error("unexpected: " + stateName); throw new AssertionError("unexpected: " + stateName);
} }
break; break;
case STATE_CREATE_INDEX: case STATE_CREATE_INDEX:
stateName = "Create Index " + name + " " + current + "/" + max; stateName = "Create Index " + name + " " + current + "/" + max;
if (!"SYS:SYS_ID".equals(name)) { if (!"SYS:SYS_ID".equals(name)) {
throw new Error("unexpected: " + stateName); throw new AssertionError("unexpected: " + stateName);
} }
break; break;
case STATE_RECOVER: case STATE_RECOVER:
......
...@@ -178,7 +178,7 @@ public class TestScript extends TestBase { ...@@ -178,7 +178,7 @@ public class TestScript extends TestBase {
String param = readLine(); String param = readLine();
write(param); write(param);
if (!param.equals("{")) { if (!param.equals("{")) {
throw new Error("expected '{', got " + param + " in " + sql); throw new AssertionError("expected '{', got " + param + " in " + sql);
} }
try { try {
PreparedStatement prep = conn.prepareStatement(sql); PreparedStatement prep = conn.prepareStatement(sql);
......
...@@ -139,17 +139,17 @@ public class TestSpeed extends TestBase { ...@@ -139,17 +139,17 @@ public class TestSpeed extends TestBase {
// ResultSet rs = stat.executeQuery("SELECT * FROM TEST WHERE // ResultSet rs = stat.executeQuery("SELECT * FROM TEST WHERE
// ID="+i); // ID="+i);
// if(!rs.next()) { // if(!rs.next()) {
// throw new Error("hey! i="+i); // throw new AssertionError("hey! i="+i);
// } // }
// if(rs.next()) { // if(rs.next()) {
// throw new Error("hey! i="+i); // throw new AssertionError("hey! i="+i);
// } // }
} }
// for(int i=0; i<max; i++) { // for(int i=0; i<max; i++) {
// stat.execute("DELETE FROM TEST WHERE ID="+i); // stat.execute("DELETE FROM TEST WHERE ID="+i);
// ResultSet rs = stat.executeQuery("SELECT * FROM TEST WHERE ID="+i); // ResultSet rs = stat.executeQuery("SELECT * FROM TEST WHERE ID="+i);
// if(rs.next()) { // if(rs.next()) {
// throw new Error("hey!"); // throw new AssertionError("hey!");
// } // }
// } // }
......
...@@ -164,23 +164,23 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -164,23 +164,23 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
public void fire(Connection conn, Object[] oldRow, Object[] newRow) { public void fire(Connection conn, Object[] oldRow, Object[] newRow) {
if (mustNotCallTrigger) { if (mustNotCallTrigger) {
throw new Error("must not be called now"); throw new AssertionError("must not be called now");
} }
if (conn == null) { if (conn == null) {
throw new Error("connection is null"); throw new AssertionError("connection is null");
} }
if (triggerName.startsWith("INS_BEFORE")) { if (triggerName.startsWith("INS_BEFORE")) {
newRow[1] = newRow[1] + "-updated"; newRow[1] = newRow[1] + "-updated";
} else if (triggerName.startsWith("INS_AFTER")) { } else if (triggerName.startsWith("INS_AFTER")) {
if (!newRow[1].toString().endsWith("-updated")) { if (!newRow[1].toString().endsWith("-updated")) {
throw new Error("supposed to be updated"); throw new AssertionError("supposed to be updated");
} }
checkCommit(conn); checkCommit(conn);
} else if (triggerName.startsWith("UPD_BEFORE")) { } else if (triggerName.startsWith("UPD_BEFORE")) {
newRow[1] = newRow[1] + "-updated2"; newRow[1] = newRow[1] + "-updated2";
} else if (triggerName.startsWith("UPD_AFTER")) { } else if (triggerName.startsWith("UPD_AFTER")) {
if (!newRow[1].toString().endsWith("-updated2")) { if (!newRow[1].toString().endsWith("-updated2")) {
throw new Error("supposed to be updated2"); throw new AssertionError("supposed to be updated2");
} }
checkCommit(conn); checkCommit(conn);
} }
...@@ -189,22 +189,22 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -189,22 +189,22 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
private void checkCommit(Connection conn) { private void checkCommit(Connection conn) {
try { try {
conn.commit(); conn.commit();
throw new Error("Commit must not work here"); throw new AssertionError("Commit must not work here");
} catch (SQLException e) { } catch (SQLException e) {
try { try {
assertKnownException(e); assertKnownException(e);
} catch (Exception e2) { } catch (Exception e2) {
throw new Error("Unexpected: " + e.toString()); throw new AssertionError("Unexpected: " + e.toString());
} }
} }
try { try {
conn.createStatement().execute("CREATE TABLE X(ID INT)"); conn.createStatement().execute("CREATE TABLE X(ID INT)");
throw new Error("CREATE TABLE WORKED, but implicitly commits"); throw new AssertionError("CREATE TABLE WORKED, but implicitly commits");
} catch (SQLException e) { } catch (SQLException e) {
try { try {
assertKnownException(e); assertKnownException(e);
} catch (Exception e2) { } catch (Exception e2) {
throw new Error("Unexpected: " + e.toString()); throw new AssertionError("Unexpected: " + e.toString());
} }
} }
} }
...@@ -212,13 +212,13 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -212,13 +212,13 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
public void init(Connection conn, String schemaName, String triggerName, String tableName, boolean before, int type) { public void init(Connection conn, String schemaName, String triggerName, String tableName, boolean before, int type) {
this.triggerName = triggerName; this.triggerName = triggerName;
if (!"TEST".equals(tableName)) { if (!"TEST".equals(tableName)) {
throw new Error("supposed to be TEST"); throw new AssertionError("supposed to be TEST");
} }
if ((triggerName.endsWith("AFTER") && before) || (triggerName.endsWith("BEFORE") && !before)) { if ((triggerName.endsWith("AFTER") && before) || (triggerName.endsWith("BEFORE") && !before)) {
throw new Error("triggerName: " + triggerName + " before:" + before); throw new AssertionError("triggerName: " + triggerName + " before:" + before);
} }
if ((triggerName.startsWith("UPD") && type != UPDATE) || (triggerName.startsWith("INS") && type != INSERT) || (triggerName.startsWith("DEL") && type != DELETE)) { if ((triggerName.startsWith("UPD") && type != UPDATE) || (triggerName.startsWith("INS") && type != INSERT) || (triggerName.startsWith("DEL") && type != DELETE)) {
throw new Error("triggerName: " + triggerName + " type:" + type); throw new AssertionError("triggerName: " + triggerName + " type:" + type);
} }
} }
......
...@@ -40,7 +40,7 @@ public class TestZloty extends TestBase { ...@@ -40,7 +40,7 @@ public class TestZloty extends TestBase {
*/ */
private static class ZlotyBigDecimal extends BigDecimal { private static class ZlotyBigDecimal extends BigDecimal {
private static final long serialVersionUID = -8004563653683501484L; private static final long serialVersionUID = 1L;
public ZlotyBigDecimal(String s) { public ZlotyBigDecimal(String s) {
super(s); super(s);
...@@ -103,7 +103,8 @@ public class TestZloty extends TestBase { ...@@ -103,7 +103,8 @@ public class TestZloty extends TestBase {
prep.setInt(1, 3); prep.setInt(1, 3);
try { try {
BigDecimal value = new BigDecimal("12.100000") { BigDecimal value = new BigDecimal("12.100000") {
private static final long serialVersionUID = -7909023971521750844L;
private static final long serialVersionUID = 1L;
public String toString() { public String toString() {
return "12,100000 EURO"; return "12,100000 EURO";
......
...@@ -160,7 +160,7 @@ public class TestBtreeIndex extends TestBase { ...@@ -160,7 +160,7 @@ public class TestBtreeIndex extends TestBase {
//while(rs2.next()) { //while(rs2.next()) {
// System.out.println(rs2.getString(1)); // System.out.println(rs2.getString(1));
//} //}
//if (true) throw new Error("stop"); //if (true) throw new AssertionError("stop");
// //
testCount = 0; testCount = 0;
while (rs.next() && rs2.next()) { while (rs.next() && rs2.next()) {
......
...@@ -67,7 +67,7 @@ public class TestMultiThreaded extends TestBase { ...@@ -67,7 +67,7 @@ public class TestMultiThreaded extends TestBase {
"DELETE FROM TEST WHERE NAME = '"+ id +"' AND ROWNUM()<2"); "DELETE FROM TEST WHERE NAME = '"+ id +"' AND ROWNUM()<2");
traceThread("delete done"); traceThread("delete done");
if (updateCount != 1) { if (updateCount != 1) {
throw new Error("Expected: 1 Deleted: " + updateCount); throw new AssertionError("Expected: 1 Deleted: " + updateCount);
} }
count--; count--;
} }
...@@ -80,7 +80,7 @@ public class TestMultiThreaded extends TestBase { ...@@ -80,7 +80,7 @@ public class TestMultiThreaded extends TestBase {
rs.next(); rs.next();
int got = rs.getInt(1); int got = rs.getInt(1);
if (got != count) { if (got != count) {
throw new Error("Expected: " + count + " got: " + got); throw new AssertionError("Expected: " + count + " got: " + got);
} }
break; break;
case 3: case 3:
......
...@@ -110,7 +110,7 @@ public class TestTimer extends TestBase { ...@@ -110,7 +110,7 @@ public class TestTimer extends TestBase {
} }
if (real != count) { if (real != count) {
println("real count: " + real); println("real count: " + real);
throw new Error("COUNT(*)=" + count + " SELECT=" + real); throw new AssertionError("COUNT(*)=" + count + " SELECT=" + real);
} }
rs = stat.executeQuery("SCRIPT"); rs = stat.executeQuery("SCRIPT");
while (rs.next()) { while (rs.next()) {
......
...@@ -64,7 +64,7 @@ class Column { ...@@ -64,7 +64,7 @@ class Column {
case DataType.TYPE_BOOLEAN: case DataType.TYPE_BOOLEAN:
break; break;
default: default:
throw new Error("type=" + type); throw new AssertionError("type=" + type);
} }
} }
...@@ -103,10 +103,10 @@ class Column { ...@@ -103,10 +103,10 @@ class Column {
case Types.LONGVARBINARY: case Types.LONGVARBINARY:
return false; return false;
default: default:
throw new Error("type=" + type); throw new AssertionError("type=" + type);
} }
default: default:
throw new Error("type=" + type); throw new AssertionError("type=" + type);
} }
} }
...@@ -155,7 +155,7 @@ class Column { ...@@ -155,7 +155,7 @@ class Column {
case Types.BIT: case Types.BIT:
return "BOOLEAN"; return "BOOLEAN";
default: default:
throw new Error("type=" + type); throw new AssertionError("type=" + type);
} }
} }
......
...@@ -374,7 +374,7 @@ class Command { ...@@ -374,7 +374,7 @@ class Command {
result = new Result("rollback"); result = new Result("rollback");
break; break;
default: default:
throw new Error("internal"); throw new AssertionError("type=" + type);
} }
} catch (SQLException e) { } catch (SQLException e) {
result = new Result("", e); result = new Result("", e);
......
...@@ -67,7 +67,7 @@ class DbConnection implements DbInterface { ...@@ -67,7 +67,7 @@ class DbConnection implements DbInterface {
} }
// could not drop any table and still tables to drop // could not drop any table and still tables to drop
if (dropped == 0 && tables.size() > 0) { if (dropped == 0 && tables.size() > 0) {
throw new Error("Cannot drop " + tables); throw new AssertionError("Cannot drop " + tables);
} }
} }
} }
......
...@@ -372,7 +372,7 @@ public class Expression { ...@@ -372,7 +372,7 @@ public class Expression {
} }
public String toString() { public String toString() {
throw new Error("hey!"); throw new AssertionError();
} }
} }
...@@ -103,7 +103,7 @@ class Result implements Comparable<Result> { ...@@ -103,7 +103,7 @@ class Result implements Comparable<Result> {
} }
return result + "}"; return result + "}";
default: default:
throw new Error("internal"); throw new AssertionError("type=" + type);
} }
} }
...@@ -122,7 +122,7 @@ class Result implements Comparable<Result> { ...@@ -122,7 +122,7 @@ class Result implements Comparable<Result> {
case RESULT_SET: case RESULT_SET:
return toString().compareTo(r.toString()); return toString().compareTo(r.toString());
default: default:
throw new Error("internal"); throw new AssertionError("type=" + type);
} }
} }
......
...@@ -235,9 +235,9 @@ public class TestSynth extends TestBase { ...@@ -235,9 +235,9 @@ public class TestSynth extends TestBase {
Result copy = results.get(i); Result copy = results.get(i);
if (original.compareTo(copy) != 0) { if (original.compareTo(copy) != 0) {
if (showError) { if (showError) {
throw new Error("Results don't match: original (0): \r\n" + original + "\r\n" + "other:\r\n" + copy); throw new AssertionError("Results don't match: original (0): \r\n" + original + "\r\n" + "other:\r\n" + copy);
} }
throw new Error("Results don't match"); throw new AssertionError("Results don't match");
} }
} }
} }
......
...@@ -69,7 +69,7 @@ public class Value { ...@@ -69,7 +69,7 @@ public class Value {
case Types.BIT: case Types.BIT:
return (String) data; return (String) data;
default: default:
throw new Error("type=" + type); throw new AssertionError("type=" + type);
} }
} }
...@@ -189,7 +189,7 @@ public class Value { ...@@ -189,7 +189,7 @@ public class Value {
data = rs.getBoolean(index) ? "TRUE" : "FALSE"; data = rs.getBoolean(index) ? "TRUE" : "FALSE";
break; break;
default: default:
throw new Error("type=" + type); throw new AssertionError("type=" + type);
} }
if (rs.wasNull()) { if (rs.wasNull()) {
data = null; data = null;
...@@ -248,7 +248,7 @@ public class Value { ...@@ -248,7 +248,7 @@ public class Value {
data = config.random().getBoolean(50) ? "TRUE" : "FALSE"; data = config.random().getBoolean(50) ? "TRUE" : "FALSE";
break; break;
default: default:
throw new Error("type=" + type); throw new AssertionError("type=" + type);
} }
return new Value(config, type, data); return new Value(config, type, data);
} }
...@@ -289,7 +289,7 @@ public class Value { ...@@ -289,7 +289,7 @@ public class Value {
// private int compareTo(Object o) { // private int compareTo(Object o) {
// Value v = (Value) o; // Value v = (Value) o;
// if (type != v.type) { // if (type != v.type) {
// throw new Error("compare " + type + // throw new AssertionError("compare " + type +
// " " + v.type + " " + data + " " + v.data); // " " + v.type + " " + data + " " + v.data);
// } // }
// if (data == null) { // if (data == null) {
...@@ -312,7 +312,7 @@ public class Value { ...@@ -312,7 +312,7 @@ public class Value {
// case Types.INTEGER: // case Types.INTEGER:
// return ((Integer) data).compareTo((Integer) v.data); // return ((Integer) data).compareTo((Integer) v.data);
// default: // default:
// throw new Error("type=" + type); // throw new AssertionError("type=" + type);
// } // }
// } // }
......
...@@ -70,19 +70,18 @@ public class TestMultiNewsSimple extends TestMultiThread { ...@@ -70,19 +70,18 @@ public class TestMultiNewsSimple extends TestMultiThread {
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
if (!rs.next()) { if (!rs.next()) {
System.out.println("No row found"); System.out.println("No row found");
// throw new Error("No row found"); // throw new AssertionError("No row found");
} }
if (rs.next()) { if (rs.next()) {
System.out.println("Multiple rows found"); System.out.println("Multiple rows found");
// throw new Error("Multiple rows found"); // throw new AssertionError("Multiple rows found");
} }
} }
} }
} }
void finalTest() { void finalTest() {
// TODO Auto-generated method stub // nothing to do
} }
} }
...@@ -171,7 +171,7 @@ class Parser { ...@@ -171,7 +171,7 @@ class Parser {
private void read(String s) { private void read(String s) {
if (!readIf(s)) { if (!readIf(s)) {
throw new Error("Expected: " + s + " got: " + token + " in " throw new RuntimeException("Expected: " + s + " got: " + token + " in "
+ line); + line);
} }
} }
...@@ -182,7 +182,7 @@ class Parser { ...@@ -182,7 +182,7 @@ class Parser {
try { try {
s = StringUtils.javaDecode(s.substring(1, s.length() - 1)); s = StringUtils.javaDecode(s.substring(1, s.length() - 1));
} catch (SQLException e) { } catch (SQLException e) {
throw new Error(e); throw new RuntimeException(e);
} }
return new Arg(String.class, s); return new Arg(String.class, s);
} else if (tokenType == NUMBER) { } else if (tokenType == NUMBER) {
...@@ -206,7 +206,7 @@ class Parser { ...@@ -206,7 +206,7 @@ class Parser {
} else if (readIf("false")) { } else if (readIf("false")) {
return new Arg(boolean.class, Boolean.FALSE); return new Arg(boolean.class, Boolean.FALSE);
} else if (readIf("null")) { } else if (readIf("null")) {
throw new Error( throw new RuntimeException(
"Null: class not specified. Example: (java.lang.String)null"); "Null: class not specified. Example: (java.lang.String)null");
} else if (readIf("new")) { } else if (readIf("new")) {
if (readIf("String")) { if (readIf("String")) {
...@@ -227,7 +227,7 @@ class Parser { ...@@ -227,7 +227,7 @@ class Parser {
read(")"); read(")");
return new Arg(BigDecimal.class, value); return new Arg(BigDecimal.class, value);
} else { } else {
throw new Error("Unsupported constructor: " + readToken()); throw new RuntimeException("Unsupported constructor: " + readToken());
} }
} }
String name = readToken(); String name = readToken();
...@@ -248,7 +248,7 @@ class Parser { ...@@ -248,7 +248,7 @@ class Parser {
String number = readToken(); String number = readToken();
return new Arg(short.class, new Short(Short.parseShort(number))); return new Arg(short.class, new Short(Short.parseShort(number)));
} else { } else {
throw new Error("Value expected, got: " + readToken() + " in " throw new RuntimeException("Value expected, got: " + readToken() + " in "
+ line); + line);
} }
} }
......
...@@ -87,7 +87,7 @@ public class Player { ...@@ -87,7 +87,7 @@ public class Player {
if ("-trace".equals(args[i])) { if ("-trace".equals(args[i])) {
trace = true; trace = true;
} else { } else {
throw new Error("Unknown setting: " + args[i]); throw new RuntimeException("Unknown setting: " + args[i]);
} }
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -153,7 +153,7 @@ public class Player { ...@@ -153,7 +153,7 @@ public class Player {
// ignore // ignore
} }
} }
throw new Error("Class not found: " + className); throw new RuntimeException("Class not found: " + className);
} }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论