Changeset: 634e34d4cbaf for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/634e34d4cbaf
Modified Files:
src/test/java/JDBC_API_Tester.java
src/test/java/org/monetdb/jdbc/ApiTests.java
Branch: default
Log Message:
Convert Test_PStypes() -> ApiTests#testBug1757923()
diffs (144 lines):
diff --git a/src/test/java/JDBC_API_Tester.java
b/src/test/java/JDBC_API_Tester.java
--- a/src/test/java/JDBC_API_Tester.java
+++ b/src/test/java/JDBC_API_Tester.java
@@ -1237,83 +1237,6 @@ public final class JDBC_API_Tester exten
}
@Test
- public void Test_PStypes() {
- sb.setLength(0); // clear the output log buffer
-
- Statement stmt = null;
- PreparedStatement pstmt = null;
- try {
- con.setAutoCommit(false);
- // >> false: auto commit should be off now
- sb.append("0.
false\t").append(con.getAutoCommit()).append("\n");
-
- stmt = con.createStatement();
- int updates = stmt.executeUpdate(
- "CREATE TABLE htmtest (" +
- " htmid bigint NOT NULL," +
- " ra double ," +
- " decl double ," +
- " dra double ," +
- " ddecl double ," +
- " flux double ," +
- " dflux double ," +
- " freq double ," +
- " bw double ," +
- " type decimal(1,0)," +
- " imageurl url(100)," +
- " comment varchar(100)," +
- " CONSTRAINT htmtest_htmid_pkey PRIMARY
KEY (htmid)" +
- ")" );
- if (updates != 0)
- sb.append("1. Expected 0 got
").append(updates).append(" instead\n");
-
- // index is not used, but the original bug had it too
- updates = stmt.executeUpdate("CREATE INDEX htmid ON
htmtest (htmid)");
- if (updates != 0)
- sb.append("1. Expected 0 got
").append(updates).append(" instead\n");
-
- stmt.close();
-
- pstmt = con.prepareStatement("INSERT INTO HTMTEST
(HTMID,RA,DECL,FLUX,COMMENT) VALUES (?,?,?,?,?)");
- sb.append("1. inserting a record...");
- pstmt.setLong(1, 1L);
- pstmt.setFloat(2, (float)1.2);
- pstmt.setDouble(3, 2.4);
- pstmt.setDouble(4, 3.2);
- pstmt.setString(5, "vlavbla");
- pstmt.executeUpdate();
- sb.append("success\n");
-
- // try an update like bug #1757923
- pstmt = con.prepareStatement("UPDATE HTMTEST set
COMMENT=?, TYPE=? WHERE HTMID=?");
- sb.append("2. updating record...");
- pstmt.setString(1, "some update");
- pstmt.setObject(2, (float)3.2);
- pstmt.setLong(3, 1L);
- pstmt.executeUpdate();
- sb.append("success\n");
-
- pstmt.close();
-
- con.rollback();
- con.setAutoCommit(true);
- // >> true: auto commit was just switched on
- sb.append("0.
true\t").append(con.getAutoCommit()).append("\n");
- } catch (SQLException e) {
- sb.append("FAILED:
").append(e.getMessage()).append("\n");
- }
-
- closeStmtResSet(stmt, null);
- closeStmtResSet(pstmt, null);
-
- compareExpectedOutput("Test_PStypes",
- "0. false false\n" +
- "1. inserting a record...success\n" +
- "2. updating record...success\n" +
- "0. true true\n");
- }
-
- @Test
public void Test_CallableStmt() {
sb.setLength(0); // clear the output log buffer
diff --git a/src/test/java/org/monetdb/jdbc/ApiTests.java
b/src/test/java/org/monetdb/jdbc/ApiTests.java
--- a/src/test/java/org/monetdb/jdbc/ApiTests.java
+++ b/src/test/java/org/monetdb/jdbc/ApiTests.java
@@ -1313,4 +1313,53 @@ public class ApiTests {
conn.rollback();
conn.setAutoCommit(true);
}
+
+ @Test
+ public void testBug1757923() throws SQLException {
+ // #1757923 is probably from the Sourceforge-era!
+
+ conn.setAutoCommit(false);
+ stmt.execute("" +
+ "DROP TABLE IF EXISTS
htmtest;\n" +
+ "CREATE TABLE htmtest (\n" +
+ " htmid bigint
NOT NULL,\n" +
+ " ra double ,\n" +
+ " decl double ,\n" +
+ " dra double ,\n" +
+ " ddecl double ,\n" +
+ " flux double ,\n" +
+ " dflux double ,\n" +
+ " freq double ,\n" +
+ " bw double ,\n" +
+ " type
decimal(1,0),\n" +
+ " imageurl url(100),\n" +
+ " comment
varchar(100),\n" +
+ " CONSTRAINT
htmtest_htmid_pkey PRIMARY KEY (htmid)\n" +
+ ");\n" +
+ "CREATE INDEX htmid ON htmtest
(htmid);");
+
+ String insert = "INSERT INTO HTMTEST
(HTMID,RA,DECL,FLUX,COMMENT) VALUES (?,?,?,?,?)";
+ String update = "UPDATE HTMTEST set COMMENT=?, TYPE=? WHERE
HTMID=?";
+ try (PreparedStatement ps1 = conn.prepareStatement(insert)) {
+ ps1.setLong(1, 1L);
+ ps1.setFloat(2, (float) 1.2);
+ ps1.setDouble(3, 2.4);
+ ps1.setDouble(4, 3.2);
+ ps1.setString(5, "vlavbla");
+ ps1.executeUpdate();
+
+ try (PreparedStatement ps2 =
conn.prepareStatement(update)) {
+ ps2.setString(1, "some update");
+ ps2.setObject(2, (float)3.2);
+ ps2.setLong(3, 1L);
+ ps2.executeUpdate();
+
+ // Unfortunately the original test does not
mention
+ // what went wrong here
+ }
+ }
+
+ conn.rollback();
+ conn.setAutoCommit(true);
+ }
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]