Unverified 提交 5f105925 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #993 from katzyn/misc

Fix some compiler warnings and improve assert*() methods
......@@ -244,7 +244,7 @@ public class Comparison extends Condition {
result = l == ValueNull.INSTANCE;
break;
case IS_NOT_NULL:
result = !(l == ValueNull.INSTANCE);
result = l != ValueNull.INSTANCE;
break;
default:
throw DbException.throwInternalError("type=" + compareType);
......@@ -275,7 +275,7 @@ public class Comparison extends Condition {
return ValueBoolean.get(result);
}
private String[] getEnumerators(Value left, Value right) {
private static String[] getEnumerators(Value left, Value right) {
if (left.getType() == Value.ENUM) {
return ((ValueEnum) left).getEnumerators();
} else if (right.getType() == Value.ENUM) {
......
......@@ -956,7 +956,7 @@ public class Function extends Expression implements FunctionCall {
result = v0;
for (int i = 0; i < args.length; i++) {
Value v = getNullOrValue(session, args, values, i);
if (!(v == ValueNull.INSTANCE)) {
if (v != ValueNull.INSTANCE) {
result = v.convertTo(dataType);
break;
}
......@@ -968,7 +968,7 @@ public class Function extends Expression implements FunctionCall {
result = ValueNull.INSTANCE;
for (int i = 0; i < args.length; i++) {
Value v = getNullOrValue(session, args, values, i);
if (!(v == ValueNull.INSTANCE)) {
if (v != ValueNull.INSTANCE) {
v = v.convertTo(dataType);
if (result == ValueNull.INSTANCE) {
result = v;
......@@ -1005,7 +1005,7 @@ public class Function extends Expression implements FunctionCall {
// (expr, when, then, else)
// (expr, when, then, when, then)
// (expr, when, then, when, then, else)
if (!(v0 == ValueNull.INSTANCE)) {
if (v0 != ValueNull.INSTANCE) {
for (int i = 1, len = args.length - 1; i < len; i += 2) {
Value when = args[i].getValue(session);
if (database.areEqual(v0, when)) {
......
......@@ -222,8 +222,7 @@ public class MVStoreTool {
if (mapId == 0 && details) {
ByteBuffer data;
if (compressed) {
boolean fast = !((type & DataUtils.PAGE_COMPRESSED_HIGH) ==
DataUtils.PAGE_COMPRESSED_HIGH);
boolean fast = (type & DataUtils.PAGE_COMPRESSED_HIGH) != DataUtils.PAGE_COMPRESSED_HIGH;
Compressor compressor = getCompressor(fast);
int lenAdd = DataUtils.readVarInt(chunk);
int compLen = pageSize + start - chunk.position();
......
......@@ -177,7 +177,7 @@ public class JdbcUtils {
if (classFactory.match(className)) {
try {
Class<?> userClass = classFactory.loadClass(className);
if (!(userClass == null)) {
if (userClass != null) {
return (Class<Z>) userClass;
}
} catch (Exception e) {
......
......@@ -716,11 +716,7 @@ public abstract class TestBase {
* @throws AssertionError if the values are not equal
*/
public void assertEquals(Object expected, Object actual) {
if (expected == null || actual == null) {
assertTrue(expected == actual);
return;
}
if (!expected.equals(actual)) {
if (!Objects.equals(expected, actual)) {
fail(" expected: " + expected + " actual: " + actual);
}
}
......@@ -961,7 +957,9 @@ public abstract class TestBase {
* @throws AssertionError if the condition is false
*/
public void assertTrue(boolean condition) {
assertTrue("Expected: true got: false", condition);
if (!condition) {
fail("Expected: true got: false");
}
}
/**
......@@ -976,6 +974,31 @@ public abstract class TestBase {
}
}
/**
* Check that the passed object is not null.
*
* @param obj the object
* @throws AssertionError if the condition is false
*/
public void assertNotNull(Object obj) {
if (obj == null) {
fail("Expected: not null got: null");
}
}
/**
* Check that the passed object is not null.
*
* @param message the message to print if the condition is false
* @param obj the object
* @throws AssertionError if the condition is false
*/
public void assertNotNull(String message, Object obj) {
if (obj == null) {
fail(message);
}
}
/**
* Check that the passed boolean is true.
*
......@@ -996,7 +1019,9 @@ public abstract class TestBase {
* @throws AssertionError if the condition is true
*/
protected void assertFalse(boolean value) {
assertFalse("Expected: false got: true", value);
if (value) {
fail("Expected: false got: true");
}
}
/**
......
......@@ -57,7 +57,7 @@ public abstract class AbstractBaseForCommonTableExpressions extends TestBase {
rs = prep.executeQuery();
for (int columnIndex = 1; columnIndex <= rs.getMetaData().getColumnCount(); columnIndex++) {
assertTrue(rs.getMetaData().getColumnLabel(columnIndex) != null);
assertNotNull(rs.getMetaData().getColumnLabel(columnIndex));
assertEquals(expectedColumnNames[columnIndex - 1], rs.getMetaData().getColumnLabel(columnIndex));
assertEquals(
"wrong type of column " + rs.getMetaData().getColumnLabel(columnIndex) + " on iteration #"
......
......@@ -390,7 +390,7 @@ public class TestDeadlock extends TestBase {
}
private void checkDeadlock() throws SQLException {
assertTrue(lastException != null);
assertNotNull(lastException);
assertKnownException(lastException);
assertEquals(ErrorCode.DEADLOCK_1, lastException.getErrorCode());
SQLException e2 = lastException.getNextException();
......
......@@ -520,7 +520,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
stat.execute("delete from test");
rs = stat.executeQuery("call transaction_id()");
rs.next();
assertTrue(rs.getString(1) != null);
assertNotNull(rs.getString(1));
stat.execute("drop table test");
conn.close();
}
......
......@@ -130,7 +130,7 @@ public class TestReadOnly extends TestBase {
File f = File.createTempFile("test", "temp");
assertTrue(f.canWrite());
f.setReadOnly();
assertTrue(!f.canWrite());
assertFalse(f.canWrite());
f.delete();
f = File.createTempFile("test", "temp");
......@@ -138,7 +138,7 @@ public class TestReadOnly extends TestBase {
r.write(1);
f.setReadOnly();
r.close();
assertTrue(!f.canWrite());
assertFalse(f.canWrite());
f.delete();
deleteDb("readonlyFiles");
......@@ -147,7 +147,7 @@ public class TestReadOnly extends TestBase {
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
stat.execute("INSERT INTO TEST VALUES(1, 'Hello')");
stat.execute("INSERT INTO TEST VALUES(2, 'World')");
assertTrue(!conn.isReadOnly());
assertFalse(conn.isReadOnly());
conn.close();
if (setReadOnly) {
......
......@@ -350,7 +350,7 @@ public class TestRunscript extends TestBase implements Trigger {
Thread.sleep(200);
stat.cancel();
SQLException e = (SQLException) task.getException();
assertTrue(e != null);
assertNotNull(e);
assertEquals(ErrorCode.STATEMENT_WAS_CANCELED, e.getErrorCode());
stat.execute("set throttle 1000");
......@@ -367,7 +367,7 @@ public class TestRunscript extends TestBase implements Trigger {
Thread.sleep(200);
stat.cancel();
e = (SQLException) task.getException();
assertTrue(e != null);
assertNotNull(e);
assertEquals(ErrorCode.STATEMENT_WAS_CANCELED, e.getErrorCode());
conn.close();
......
......@@ -914,7 +914,7 @@ public class TestSpatial extends TestBase {
count++;
int id = rs.getInt(1);
if (id == 3 || id == 6) {
assertTrue(rs.getObject(2) != null);
assertNotNull(rs.getObject(2));
} else {
assertNull(rs.getObject(2));
}
......@@ -933,7 +933,7 @@ public class TestSpatial extends TestBase {
count = 0;
while (rs.next()) {
count++;
assertTrue(rs.getObject(2) != null);
assertNotNull(rs.getObject(2));
}
assertEquals(2, count);
......
......@@ -184,7 +184,7 @@ public class TestSynonymForTable extends TestBase {
assertEquals("BACKINGTABLE", synonyms.getString("SYNONYM_FOR"));
assertEquals("VALID", synonyms.getString("STATUS"));
assertEquals("", synonyms.getString("REMARKS"));
assertTrue(synonyms.getString("ID") != null);
assertNotNull(synonyms.getString("ID"));
assertFalse(synonyms.next());
conn.close();
}
......
......@@ -507,7 +507,7 @@ public class TestTableEngines extends TestBase {
stat.executeUpdate("CREATE TABLE T(ID INT AFFINITY PRIMARY KEY, NAME VARCHAR, AGE INT)" +
" ENGINE \"" + AffinityTableEngine.class.getName() + "\"");
Table tbl = AffinityTableEngine.createdTbl;
assertTrue(tbl != null);
assertNotNull(tbl);
assertEquals(3, tbl.getIndexes().size());
Index aff = tbl.getIndexes().get(2);
assertTrue(aff.getIndexType().isAffinity());
......
......@@ -75,7 +75,7 @@ public class UpdateTest extends TestBase {
Order ourUpdatedOrder = db.from(o).where(o.orderDate)
.is(valueOf("2007-01-03")).selectFirst();
assertTrue("updated order not found", ourUpdatedOrder != null);
assertNotNull("updated order not found", ourUpdatedOrder);
// undo update
ourOrder.orderDate = valueOf("2007-01-02");
......@@ -113,7 +113,7 @@ public class UpdateTest extends TestBase {
Order ourUpdatedOrder = db.from(o).where(o.orderDate)
.is(valueOf("2007-01-03")).selectFirst();
assertTrue("updated order not found", ourUpdatedOrder != null);
assertNotNull("updated order not found", ourUpdatedOrder);
// undo update
ourOrder.orderDate = valueOf("2007-01-02");
......
......@@ -79,13 +79,13 @@ public class TestBatchUpdates extends TestBase {
} catch (SQLException e) {
assertContains(e.toString(), "TEST_Y");
e = e.getNextException();
assertTrue(e != null);
assertNotNull(e);
assertContains(e.toString(), "TEST_Y");
e = e.getNextException();
assertTrue(e != null);
assertNotNull(e);
assertContains(e.toString(), "TEST_X");
e = e.getNextException();
assertTrue(e == null);
assertNull(e);
}
stat.execute("create table test(id int)");
PreparedStatement prep = conn.prepareStatement("insert into test values(?)");
......@@ -98,13 +98,13 @@ public class TestBatchUpdates extends TestBase {
} catch (SQLException e) {
assertContains(e.toString(), "TEST_Y");
e = e.getNextException();
assertTrue(e != null);
assertNotNull(e);
assertContains(e.toString(), "TEST_Y");
e = e.getNextException();
assertTrue(e != null);
assertNotNull(e);
assertContains(e.toString(), "TEST_X");
e = e.getNextException();
assertTrue(e == null);
assertNull(e);
}
stat.execute("drop table test");
conn.close();
......@@ -542,7 +542,7 @@ public class TestBatchUpdates extends TestBase {
trace("Count val is: " + count);
// make sure that we have the correct error code for
// the failed update.
if (!(batchUpdates[1] == -3 && count == 1)) {
if (batchUpdates[1] != -3 || count != 1) {
fail("insert failed");
}
}
......
......@@ -143,7 +143,7 @@ public class TestDatabaseEventListener extends TestBase {
MyDatabaseEventListener.class.getName());
conn = org.h2.Driver.load().connect(url, p);
conn.close();
assertTrue(!calledCreateIndex);
assertFalse(calledCreateIndex);
}
private void testIndexNotRebuilt() throws SQLException {
......@@ -176,7 +176,7 @@ public class TestDatabaseEventListener extends TestBase {
MyDatabaseEventListener.class.getName());
conn = org.h2.Driver.load().connect(url, p);
conn.close();
assertTrue(!calledCreateIndex);
assertFalse(calledCreateIndex);
}
private void testCloseLog0(boolean shutdown) throws SQLException {
......@@ -205,7 +205,7 @@ public class TestDatabaseEventListener extends TestBase {
conn = org.h2.Driver.load().connect(url, p);
conn.close();
if (calledOpened) {
assertTrue(!calledScan);
assertFalse(calledScan);
}
}
......
......@@ -130,19 +130,19 @@ public class TestGetGeneratedKeys extends TestBase {
rs.next();
assertEquals(1L, rs.getLong(1));
UUID u1 = (UUID) rs.getObject(2);
assertTrue(u1 != null);
assertNotNull(u1);
rs.next();
assertEquals(2L, rs.getLong(1));
UUID u2 = (UUID) rs.getObject(2);
assertTrue(u2 != null);
assertNotNull(u2);
rs.next();
assertEquals(3L, rs.getLong(1));
UUID u3 = (UUID) rs.getObject(2);
assertTrue(u3 != null);
assertNotNull(u3);
rs.next();
assertEquals(4L, rs.getLong(1));
UUID u4 = (UUID) rs.getObject(2);
assertTrue(u4 != null);
assertNotNull(u4);
assertFalse(rs.next());
assertFalse(u1.equals(u2));
assertFalse(u2.equals(u3));
......
......@@ -127,7 +127,7 @@ public class TestMetaData extends TestBase {
rs = stat.executeQuery("select 1 from dual");
rs.next();
rsMeta = rs.getMetaData();
assertTrue(rsMeta.getCatalogName(1) != null);
assertNotNull(rsMeta.getCatalogName(1));
assertEquals("1", rsMeta.getColumnLabel(1));
assertEquals("1", rsMeta.getColumnName(1));
assertEquals("", rsMeta.getSchemaName(1));
......@@ -367,7 +367,7 @@ public class TestMetaData extends TestBase {
assertTrue(dr.jdbcCompliant());
assertEquals(0, dr.getPropertyInfo(null, null).length);
assertTrue(dr.connect("jdbc:test:false", null) == null);
assertNull(dr.connect("jdbc:test:false", null));
assertTrue(meta.getNumericFunctions().length() > 0);
assertTrue(meta.getStringFunctions().length() > 0);
......@@ -994,9 +994,9 @@ public class TestMetaData extends TestBase {
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }, null, null);
assertTrue(conn.getWarnings() == null);
assertNull(conn.getWarnings());
conn.clearWarnings();
assertTrue(conn.getWarnings() == null);
assertNull(conn.getWarnings());
conn.close();
}
......@@ -1050,7 +1050,7 @@ public class TestMetaData extends TestBase {
rs = meta.getTables(null, Constants.SCHEMA_MAIN,
null, new String[] { "TABLE" });
assertTrue(rs.getStatement() == null);
assertNull(rs.getStatement());
rs.next();
assertEquals("TEST", rs.getString("TABLE_NAME"));
assertFalse(rs.next());
......
......@@ -404,7 +404,7 @@ public class TestPreparedStatement extends TestBase {
Thread.sleep(100);
prep.cancel();
SQLException e = (SQLException) t.getException();
assertTrue(e != null);
assertNotNull(e);
assertEquals(ErrorCode.STATEMENT_WAS_CANCELED, e.getErrorCode());
prep.setInt(1, 1);
prep.setInt(2, 1);
......@@ -618,7 +618,7 @@ public class TestPreparedStatement extends TestBase {
rs.next();
Object o = rs.getObject(2);
assertTrue(o instanceof byte[]);
assertTrue(rs.getObject(3) == null);
assertNull(rs.getObject(3));
rs.next();
o = rs.getObject(2);
assertTrue(o instanceof byte[]);
......@@ -1446,9 +1446,9 @@ public class TestPreparedStatement extends TestBase {
assertEquals(ascii2, rs.getString(3));
assertFalse(rs.next());
assertTrue(prep.getWarnings() == null);
assertNull(prep.getWarnings());
prep.clearWarnings();
assertTrue(prep.getWarnings() == null);
assertNull(prep.getWarnings());
assertTrue(conn == prep.getConnection());
}
......@@ -1534,12 +1534,12 @@ public class TestPreparedStatement extends TestBase {
java.math.BigDecimal x = rs.getBigDecimal(1);
trace("v=" + v + " x=" + x);
if (v == null) {
assertTrue(x == null);
assertNull(x);
} else {
assertTrue(x.compareTo(new java.math.BigDecimal(v)) == 0);
}
}
assertTrue(!rs.next());
assertFalse(rs.next());
}
private void testColumnMetaDataWithEquals(Connection conn)
......
......@@ -204,7 +204,7 @@ public class TestStatement extends TestBase {
assertEquals(ResultSet.CONCUR_READ_ONLY,
stat2.getResultSetConcurrency());
assertEquals(0, stat.getMaxFieldSize());
assertTrue(!((JdbcStatement) stat2).isClosed());
assertFalse(((JdbcStatement) stat2).isClosed());
stat2.close();
assertTrue(((JdbcStatement) stat2).isClosed());
......@@ -279,19 +279,19 @@ public class TestStatement extends TestBase {
trace("execute");
result = stat.execute(
"CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE VARCHAR(255))");
assertTrue(!result);
assertFalse(result);
result = stat.execute("INSERT INTO TEST VALUES(1,'Hello')");
assertTrue(!result);
assertFalse(result);
result = stat.execute("INSERT INTO TEST(VALUE,ID) VALUES('JDBC',2)");
assertTrue(!result);
assertFalse(result);
result = stat.execute("UPDATE TEST SET VALUE='LDBC' WHERE ID=2");
assertTrue(!result);
assertFalse(result);
result = stat.execute("DELETE FROM TEST WHERE ID=3");
assertTrue(!result);
assertFalse(result);
result = stat.execute("SELECT * FROM TEST");
assertTrue(result);
result = stat.execute("DROP TABLE TEST");
assertTrue(!result);
assertFalse(result);
assertThrows(ErrorCode.METHOD_ONLY_ALLOWED_FOR_QUERY, stat).
executeQuery("CREATE TABLE TEST(ID INT PRIMARY KEY,VALUE VARCHAR(255))");
......@@ -324,9 +324,9 @@ public class TestStatement extends TestBase {
stat.execute("DROP TABLE TEST");
stat.executeUpdate("DROP TABLE IF EXISTS TEST");
assertTrue(stat.getWarnings() == null);
assertNull(stat.getWarnings());
stat.clearWarnings();
assertTrue(stat.getWarnings() == null);
assertNull(stat.getWarnings());
assertTrue(conn == stat.getConnection());
assertEquals("SOME_ID", statBC.enquoteIdentifier("SOME_ID", false));
......
......@@ -148,13 +148,13 @@ public class TestXA extends TestBase {
XAResource res = xa.getXAResource();
res.start(xid, XAResource.TMNOFLAGS);
assertTrue(!c.getAutoCommit());
assertFalse(c.getAutoCommit());
res.end(xid, XAResource.TMSUCCESS);
res.commit(xid, true);
assertTrue(c.getAutoCommit());
res.start(xid, XAResource.TMNOFLAGS);
assertTrue(!c.getAutoCommit());
assertFalse(c.getAutoCommit());
res.end(xid, XAResource.TMFAIL);
res.rollback(xid);
assertTrue(c.getAutoCommit());
......@@ -193,7 +193,7 @@ public class TestXA extends TestBase {
xa.getXAResource().start(xid,
XAResource.TMNOFLAGS);
Connection c = xa.getConnection();
assertTrue(!c.getAutoCommit());
assertFalse(c.getAutoCommit());
c.close();
xa.close();
}
......
......@@ -69,7 +69,7 @@ public class RecoverLobTest extends TestBase {
int id = rs.getInt(1);
String data = rs.getString(2);
assertTrue(data != null);
assertNotNull(data);
assertTrue(data.length() == 10000 * id);
}
......
......@@ -449,8 +449,8 @@ public class TestCacheLIRS extends TestBase {
Integer x = test.get(i);
Integer y = test.peek(i);
if (i < size / 2) {
assertTrue("i: " + i, x != null);
assertTrue("i: " + i, y != null);
assertNotNull("i: " + i, x);
assertNotNull("i: " + i, y);
assertEquals(i * 10, x.intValue());
assertEquals(i * 10, y.intValue());
} else {
......@@ -469,7 +469,7 @@ public class TestCacheLIRS extends TestBase {
for (int i = 0; i < size; i++) {
Integer x = test.get(i);
if (i < size / 2 || i == size - 1) {
assertTrue("i: " + i, x != null);
assertNotNull("i: " + i, x);
assertEquals(i * 10, x.intValue());
} else {
assertNull(x);
......
......@@ -378,8 +378,8 @@ public class TestCacheLongKeyLIRS extends TestBase {
Integer x = test.get(i);
Integer y = test.peek(i);
if (i < size / 2) {
assertTrue("i: " + i, x != null);
assertTrue("i: " + i, y != null);
assertNotNull("i: " + i, x);
assertNotNull("i: " + i, y);
assertEquals(i * 10, x.intValue());
assertEquals(i * 10, y.intValue());
} else {
......@@ -398,7 +398,7 @@ public class TestCacheLongKeyLIRS extends TestBase {
for (int i = 0; i < size; i++) {
Integer x = test.get(i);
if (i < size / 2 || i == size - 1 || i == size - 2) {
assertTrue("i: " + i, x != null);
assertNotNull("i: " + i, x);
assertEquals(i * 10, x.intValue());
} else {
assertNull(x);
......
......@@ -141,7 +141,7 @@ public class TestDataUtils extends TestBase {
}
try {
HashMap<String, String> map = DataUtils.parseMap(buff.toString());
assertFalse(map == null);
assertNotNull(map);
// ok
} catch (IllegalStateException e) {
// ok - but not another exception
......
......@@ -134,7 +134,7 @@ public class TestMVRTree extends TestMVStore {
for (SpatialKey k; it.hasNext();) {
k = it.next();
// System.out.println(k + ": " + r.get(k));
assertTrue(k != null);
assertNotNull(k);
}
s.close();
}
......@@ -181,7 +181,7 @@ public class TestMVRTree extends TestMVStore {
assertEquals(len, r.size());
int count = 0;
for (SpatialKey k : r.keySet()) {
assertTrue(r.get(k) != null);
assertNotNull(r.get(k));
count++;
}
assertEquals(len, count);
......@@ -413,7 +413,7 @@ public class TestMVRTree extends TestMVStore {
while (it.hasNext()) {
SpatialKey n = it.next();
String a = map.get(n);
assertFalse(a == null);
assertNotNull(a);
}
break;
}
......@@ -424,7 +424,7 @@ public class TestMVRTree extends TestMVStore {
while (it.hasNext()) {
SpatialKey n = it.next();
String a = map.get(n);
assertFalse(a == null);
assertNotNull(a);
}
break;
}
......
......@@ -528,7 +528,7 @@ public class TestMVStore extends TestBase {
sleep(10);
}
Throwable e = exRef.get();
assertTrue(e != null);
assertNotNull(e);
assertEquals(DataUtils.ERROR_WRITING_FAILED,
DataUtils.getErrorCode(e.getMessage()));
} catch (IllegalStateException e) {
......@@ -894,7 +894,7 @@ public class TestMVStore extends TestBase {
s.close();
s = openStore(fileName);
Object test = s.getStoreHeader().get("test");
assertFalse(test == null);
assertNotNull(test);
assertEquals("123", test.toString());
s.close();
}
......@@ -1506,8 +1506,8 @@ public class TestMVStore extends TestBase {
s.setRetentionTime(45000);
assertEquals(2, s.getCurrentVersion());
meta = s.getMetaMap();
assertTrue(meta.get("name.data") != null);
assertTrue(meta.get("name.data0") != null);
assertNotNull(meta.get("name.data"));
assertNotNull(meta.get("name.data0"));
assertNull(meta.get("name.data1"));
m = s.openMap("data");
m0 = s.openMap("data0");
......
......@@ -174,7 +174,7 @@ public class TestMVStoreBenchmark extends TestBase {
for (int a = 0; a < 5; a++) {
for (int i = 0; i < size; i++) {
String x = map.get(i);
assertTrue(x != null);
assertNotNull(x);
}
}
for (int i = 0; i < size; i++) {
......
......@@ -180,7 +180,7 @@ public class TestMVTableEngine extends TestBase {
stat.execute("checkpoint");
stat.execute("shutdown immediately");
Exception ex = t.getException();
assertTrue(ex != null);
assertNotNull(ex);
try {
conn.close();
} catch (Exception e) {
......
......@@ -860,7 +860,7 @@ public class TestTransactionStore extends TestBase {
assertNull(map.get(x));
}
} catch (SQLException e) {
assertTrue(map.get(x) != null);
assertNotNull(map.get(x));
assertFalse(map.tryRemove(x));
// PostgreSQL needs to rollback
buff.append(" -> rollback");
......
......@@ -50,7 +50,7 @@ public class TestClassLoaderLeak extends TestBase {
Thread.sleep(10);
}
ClassLoader cl = ref.get();
assertTrue(cl == null);
assertNull(cl);
// fill the memory, so a heap dump is created
// using -XX:+HeapDumpOnOutOfMemoryError
// which can be analyzed using EclipseMAT
......
......@@ -219,16 +219,16 @@ public class TestFileSystem extends TestBase {
String resource = "org/h2/test/scripts/testSimple.in.txt";
InputStream in;
in = getClass().getResourceAsStream("/" + resource);
assertTrue(in != null);
assertNotNull(in);
in.close();
in = getClass().getClassLoader().getResourceAsStream(resource);
assertTrue(in != null);
assertNotNull(in);
in.close();
in = FileUtils.newInputStream("classpath:" + resource);
assertTrue(in != null);
assertNotNull(in);
in.close();
in = FileUtils.newInputStream("classpath:/" + resource);
assertTrue(in != null);
assertNotNull(in);
in.close();
}
......@@ -320,7 +320,7 @@ public class TestFileSystem extends TestBase {
for (String f : FileUtils.newDirectoryStream(
"zip:" + getBaseDir() + "/fsJar.zip")) {
assertFalse(FileUtils.isAbsolute(f));
assertTrue(!FileUtils.isDirectory(f));
assertFalse(FileUtils.isDirectory(f));
assertTrue(FileUtils.size(f) > 0);
assertTrue(f.endsWith(FileUtils.getName(f)));
assertEquals(0, FileUtils.lastModified(f));
......@@ -599,7 +599,7 @@ public class TestFileSystem extends TestBase {
IOUtils.copyFiles(fsBase + "/test", fsBase + "/test3");
FileUtils.move(fsBase + "/test3", fsBase + "/test2");
FileUtils.move(fsBase + "/test2", fsBase + "/test2");
assertTrue(!FileUtils.exists(fsBase + "/test3"));
assertFalse(FileUtils.exists(fsBase + "/test3"));
assertTrue(FileUtils.exists(fsBase + "/test2"));
assertEquals(10000, FileUtils.size(fsBase + "/test2"));
byte[] buffer2 = new byte[10000];
......@@ -624,7 +624,7 @@ public class TestFileSystem extends TestBase {
assertTrue(FileUtils.isDirectory(fsBase + "/testDir"));
if (!fsBase.startsWith("jdbc:")) {
FileUtils.deleteRecursive(fsBase + "/testDir", false);
assertTrue(!FileUtils.exists(fsBase + "/testDir"));
assertFalse(FileUtils.exists(fsBase + "/testDir"));
}
}
}
......
......@@ -125,7 +125,7 @@ public class TestNetUtils extends TestBase {
closeSilently(socket);
closeSilently(serverSocket);
if (task != null) {
assertTrue(task.getException() != null);
assertNotNull(task.getException());
assertEquals(javax.net.ssl.SSLHandshakeException.class.getName(),
task.getException().getClass().getName());
assertContains(task.getException().getMessage(), "certificate_unknown");
......
......@@ -476,7 +476,7 @@ public class TestTools extends TestBase {
assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection());
assertEquals(0, rs.getFetchSize());
assertEquals(ResultSet.TYPE_SCROLL_INSENSITIVE, rs.getType());
assertTrue(rs.getStatement() == null);
assertNull(rs.getStatement());
assertFalse(rs.isClosed());
rs.beforeFirst();
......@@ -760,7 +760,7 @@ public class TestTools extends TestBase {
assertEquals(Double.MIN_VALUE, rs.getDouble("b"));
assertEquals(Long.MIN_VALUE, rs.getLong("c"));
assertEquals(Short.MIN_VALUE, rs.getShort("d"));
assertTrue(!rs.getBoolean("e"));
assertFalse(rs.getBoolean("e"));
assertEquals(new byte[] { (byte) 10, (byte) 20 }, rs.getBytes("f"));
assertEquals("2007-12-31", rs.getString("g"));
assertEquals("23:59:59", rs.getString("h"));
......@@ -902,8 +902,8 @@ public class TestTools extends TestBase {
"SELECT * FROM TEST ORDER BY ID");
rs.next();
assertEquals(1, rs.getInt(1));
assertTrue(rs.getString(2) == null);
assertTrue(rs.getString(3) == null);
assertNull(rs.getString(2));
assertNull(rs.getString(3));
rs.next();
assertEquals(2, rs.getInt(1));
assertEquals("face", rs.getString(2));
......
......@@ -302,7 +302,7 @@ public class TestValue extends TestBase {
for (int i = 0; i < d.length - 1; i++) {
assertTrue(values[i].compareTypeSafe(values[i+1], null) < 0);
assertTrue(values[i + 1].compareTypeSafe(values[i], null) > 0);
assertTrue(!values[i].equals(values[i+1]));
assertFalse(values[i].equals(values[i+1]));
}
}
......
......@@ -47,7 +47,7 @@ public class TestColumnNamer extends TestBase {
for (String id : ids) {
Expression columnExp = ValueExpression.getDefault();
String newColumnName = columnNamer.getColumnName(columnExp, index + 1, id);
assertTrue(newColumnName != null);
assertNotNull(newColumnName);
assertTrue(newColumnName.length() <= 30);
assertTrue(newColumnName.length() >= 1);
assertEquals(newColumnName, expectedColumnName[index]);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论