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

Don't throw Error

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