Changeset: 559aa626b550 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=559aa626b550
Modified Files:
tests/JDBC_API_Tester.java
Branch: default
Log Message:
Improved code and implemented all tests.
diffs (truncated from 1445 to 300 lines):
diff --git a/tests/JDBC_API_Tester.java b/tests/JDBC_API_Tester.java
--- a/tests/JDBC_API_Tester.java
+++ b/tests/JDBC_API_Tester.java
@@ -37,7 +37,7 @@ import org.monetdb.jdbc.types.URL;
*/
final public class JDBC_API_Tester {
StringBuilder sb; // buffer to collect the test output
- static int sbInitLen = 3266;
+ final static int sbInitLen = 3416;
Connection con; // main connection shared by all tests
public static void main(String[] args) throws Exception {
@@ -182,14 +182,14 @@ final public class JDBC_API_Tester {
stmt.executeQuery("SELECT COUNT(*) FROM
doesnotexist;"); // let's trigger an error
} catch (SQLException e) {
// e.printStackTrace();
- sb.append("Expected error: " + e).append("\n");
+ sb.append("Expected error: ").append(e).append("\n");
try {
// test calling conn.isValid()
- sb.append("Validating connection: con.isValid?
" + con.isValid(30));
+ sb.append("Validating connection: con.isValid?
").append(con.isValid(30));
// Can we rollback on this connection without
causing an error?
con.rollback();
} catch (SQLException e2) {
- sb.append("UnExpected error: " + e2);
+ sb.append("UnExpected error: ").append(e2);
}
}
@@ -232,7 +232,7 @@ final public class JDBC_API_Tester {
Statement stmt = null;
try {
// >> true: auto commit should be on by default
- sb.append("0. true\t" +
con.getAutoCommit()).append("\n");
+ sb.append("0.
true\t").append(con.getAutoCommit()).append("\n");
stmt = con.createStatement();
// sending big script with many simple queries
@@ -247,7 +247,7 @@ final public class JDBC_API_Tester {
sb.append("Error: found an update count for a
SELECT query").append("\n");
}
if (i != size) {
- sb.append("Error: expecting " + size + "
tuples, only got " + i).append("\n");
+ sb.append("Error: expecting
").append(size).append(" tuples, only got ").append(i).append("\n");
}
sb.append("2. queries processed").append("\n");
} catch (SQLException e) {
@@ -323,7 +323,7 @@ final public class JDBC_API_Tester {
try {
con.setAutoCommit(false);
// >> true: auto commit should be off by now
- sb.append("0. true\t" +
con.getAutoCommit()).append("\n");
+ sb.append("0.
true\t").append(con.getAutoCommit()).append("\n");
stmt1 = con.createStatement();
// test commit by checking if a change is visible in
another connection
@@ -349,7 +349,7 @@ final public class JDBC_API_Tester {
if (i == 21) {
sb.append("passed");
} else {
- sb.append("got " + i + " records!!!");
+ sb.append("got ").append(i).append("
records!!!");
}
sb.append("\n");
@@ -370,7 +370,7 @@ final public class JDBC_API_Tester {
if (i == 10) {
sb.append("passed");
} else {
- sb.append("got " + i + " records!!!");
+ sb.append("got ").append(i).append("
records!!!");
}
sb.append("\n");
@@ -387,7 +387,7 @@ final public class JDBC_API_Tester {
if (i == 10) {
sb.append("passed");
} else {
- sb.append("got " + i + " records!!!");
+ sb.append("got ").append(i).append("
records!!!");
}
sb.append("\n");
@@ -426,7 +426,7 @@ final public class JDBC_API_Tester {
ResultSet rs = null;
try {
// >> true: auto commit should be on by default
- sb.append("0. true\t" +
con.getAutoCommit()).append("\n");
+ sb.append("0.
true\t").append(con.getAutoCommit()).append("\n");
// savepoints require a non-autocommit connection
try {
@@ -434,13 +434,13 @@ final public class JDBC_API_Tester {
con.setSavepoint();
sb.append("passed !!");
} catch (SQLException e) {
- sb.append("expected msg: " + e.getMessage());
+ sb.append("expected msg:
").append(e.getMessage());
}
sb.append("\n");
con.setAutoCommit(false);
// >> true: auto commit should be on by default
- sb.append("0. false\t" +
con.getAutoCommit()).append("\n");
+ sb.append("0.
false\t").append(con.getAutoCommit()).append("\n");
sb.append("2. savepoint...");
/* make a savepoint, and discard it */
@@ -457,13 +457,13 @@ final public class JDBC_API_Tester {
rs = stmt.executeQuery("SELECT id FROM
table_Test_Csavepoints");
int i = 0;
int items = 0;
- sb.append("4. table " + items + " items");
+ sb.append("4. table ").append(items).append(" items");
while (rs.next()) {
sb.append(", ").append(rs.getString("id"));
i++;
}
if (i != items) {
- sb.append(" FAILED (" + i + ")");
+ sb.append(" FAILED (").append(i).append(")");
}
sb.append(" passed").append("\n");
@@ -478,13 +478,13 @@ final public class JDBC_API_Tester {
rs = stmt.executeQuery("SELECT id FROM
table_Test_Csavepoints");
i = 0;
items = 3;
- sb.append("6. table " + items + " items");
+ sb.append("6. table ").append(items).append(" items");
while (rs.next()) {
- sb.append(", " + rs.getString("id"));
+ sb.append(", ").append(rs.getString("id"));
i++;
}
if (i != items) {
- sb.append(" FAILED (" + i + ")");
+ sb.append(" FAILED (").append(i).append(")");
}
sb.append(" passed").append("\n");
@@ -495,13 +495,13 @@ final public class JDBC_API_Tester {
rs = stmt.executeQuery("SELECT id FROM
table_Test_Csavepoints");
i = 0;
items = 3;
- sb.append("8. table " + items + " items");
+ sb.append("8. table ").append(items).append(" items");
while (rs.next()) {
- sb.append(", " + rs.getString("id"));
+ sb.append(", ").append(rs.getString("id"));
i++;
}
if (i != items) {
- sb.append(" FAILED (" + i + ") :(");
+ sb.append(" FAILED (").append(i).append(") :(");
}
sb.append(" passed").append("\n");
@@ -512,13 +512,13 @@ final public class JDBC_API_Tester {
rs = stmt.executeQuery("SELECT id FROM
table_Test_Csavepoints");
i = 0;
items = 0;
- sb.append("10. table " + items + " items");
+ sb.append("10. table ").append(items).append(" items");
while (rs.next()) {
- sb.append(", " + rs.getString("id"));
+ sb.append(", ").append(rs.getString("id"));
i++;
}
if (i != items) {
- sb.append(" FAILED (" + i + ") :(");
+ sb.append(" FAILED (").append(i).append(") :(");
}
sb.append(" passed");
@@ -557,7 +557,7 @@ final public class JDBC_API_Tester {
sb.append("passed");
} catch (SQLException e) {
// this means we get what we expect
- sb.append("failed as expected: " + e.getMessage());
+ sb.append("failed as expected:
").append(e.getMessage());
}
sb.append("\n");
@@ -565,7 +565,7 @@ final public class JDBC_API_Tester {
// turn off auto commit
con.setAutoCommit(false);
// >> false: we just disabled it
- sb.append("2. false\t" +
con.getAutoCommit()).append("\n");
+ sb.append("2.
false\t").append(con.getAutoCommit()).append("\n");
// a change would not be visible now
sb.append("3. commit...");
@@ -589,7 +589,7 @@ final public class JDBC_API_Tester {
// turn off auto commit
con.setAutoCommit(true);
// >> false: we just disabled it
- sb.append("6. true\t" +
con.getAutoCommit()).append("\n");
+ sb.append("6.
true\t").append(con.getAutoCommit()).append("\n");
stmt = con.createStatement();
sb.append("7. start transaction...");
@@ -600,7 +600,7 @@ final public class JDBC_API_Tester {
con.commit();
sb.append("passed").append("\n");
- sb.append("9. true\t" + con.getAutoCommit());
+ sb.append("9. true\t").append(con.getAutoCommit());
sb.append("\n");
sb.append("10. start transaction...");
@@ -611,7 +611,7 @@ final public class JDBC_API_Tester {
con.rollback();
sb.append("passed").append("\n");
- sb.append("12. true\t" + con.getAutoCommit());
+ sb.append("12. true\t").append(con.getAutoCommit());
} catch (SQLException e) {
sb.append("FAILED: ").append(e.getMessage());
}
@@ -624,7 +624,7 @@ final public class JDBC_API_Tester {
sb.append("passed");
} catch (SQLException e) {
// this means we get what we expect
- sb.append("failed as expected: " + e.getMessage());
+ sb.append("failed as expected:
").append(e.getMessage());
}
sb.append("\n");
@@ -726,6 +726,7 @@ final public class JDBC_API_Tester {
sb.setLength(0); // clear the output log buffer
} catch (SQLException e) {
+ sb.setLength(0); // clear the output log buffer
sb.append("FAILED:
").append(e.getMessage()).append("\n");
}
@@ -766,14 +767,14 @@ final public class JDBC_API_Tester {
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM _tables");
- sb.append("Statement fetch size before set: " +
stmt.getFetchSize()).append("\n");
- sb.append("ResultSet fetch size before set: " +
rs.getFetchSize()).append("\n");
+ sb.append("Statement fetch size before set:
").append(stmt.getFetchSize()).append("\n");
+ sb.append("ResultSet fetch size before set:
").append(rs.getFetchSize()).append("\n");
stmt.setFetchSize(40);
rs.setFetchSize(16384);
- sb.append("Statement fetch size after set: " +
stmt.getFetchSize()).append("\n");
- sb.append("ResultSet fetch size after set: " +
rs.getFetchSize()).append("\n");
+ sb.append("Statement fetch size after set:
").append(stmt.getFetchSize()).append("\n");
+ sb.append("ResultSet fetch size after set:
").append(rs.getFetchSize()).append("\n");
} catch (SQLException e) {
sb.append("FAILED:
").append(e.getMessage()).append("\n");
@@ -795,7 +796,7 @@ final public class JDBC_API_Tester {
try {
con.setAutoCommit(false);
// >> false: auto commit was just switched off
- sb.append("0. false\t" +
con.getAutoCommit()).append("\n");
+ sb.append("0.
false\t").append(con.getAutoCommit()).append("\n");
stmt = con.createStatement();
stmt.executeUpdate(
@@ -829,7 +830,7 @@ final public class JDBC_API_Tester {
sb.append("there are no keys!").append("\n");
} else {
while (keys.next()) {
- sb.append("generated key index: " +
keys.getInt(1)).append("\n");
+ sb.append("generated key index:
").append(keys.getInt(1)).append("\n");
}
if (keys.getStatement() == null) {
sb.append("ResultSet.getStatement()
should never return null!").append("\n");
@@ -863,7 +864,7 @@ final public class JDBC_API_Tester {
try {
con.setAutoCommit(false);
// >> false: auto commit was just switched off
- sb.append("0. false\t" +
con.getAutoCommit()).append("\n");
+ sb.append("0.
false\t").append(con.getAutoCommit()).append("\n");
stmt = con.createStatement();
sb.append("1. creating test table...");
@@ -923,7 +924,7 @@ final public class JDBC_API_Tester {
Integer i = (Integer) rs.getObject(3);
Long bi = (Long) rs.getObject(4);
- sb.append(" Retrieved row data: ti=" + ti + "
si=" + si + " i=" + i + " bi=" + bi).append("\n");
+ sb.append(" Retrieved row data:
ti=").append(ti).append(" si=").append(si).append(" i=").append(i).append("
bi=").append(bi).append("\n");
}
sb.append("3b. closing ResultSet...");
@@ -981,7 +982,7 @@ final public class JDBC_API_Tester {
ResultSet rs = null;
try {
// >> true: auto commit should be on
- sb.append("0. true\t" +
con.getAutoCommit()).append("\n");
+ sb.append("0.
true\t").append(con.getAutoCommit()).append("\n");
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list