Changeset: 21d03f7f4cf4 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/21d03f7f4cf4
Modified Files:
        src/test/java/JDBC_API_Tester.java
        src/test/java/org/monetdb/jdbc/ApiTests.java
Branch: default
Log Message:

Convert Test_PSsomeamount() -> ApiTests#testPreparedSomeAmount()


diffs (72 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
@@ -1023,44 +1023,6 @@ public final class JDBC_API_Tester exten
                compareExpectedOutput("Test_DBCmetadata", "");
        }
 
-       @Test
-       public void Test_PSsomeamount() {
-               sb.setLength(0);        // clear the output log buffer
-
-               PreparedStatement pstmt = null;
-               ResultSet rs = null;
-               try {
-                       // >> true: auto commit should be on
-                       sb.append("0. 
true\t").append(con.getAutoCommit()).append("\n");
-
-                       sb.append("1. Preparing and executing a unique 
statement\n");
-                       for (int i = 0; i < 120; i++) {
-                               pstmt = con.prepareStatement("select " + i + ", 
" + i + " = ?");
-                               pstmt.setInt(1, i);
-                               rs = pstmt.executeQuery();
-                               if (rs != null && rs.next() && i % 20 == 0) {
-                                       sb.append(rs.getInt(1)).append(", 
").append(rs.getBoolean(2)).append("\n");
-                               }
-                               /* next call should cause resources on the 
server to be freed */
-                               pstmt.close();
-                       }
-               } catch (SQLException e) {
-                       sb.append("FAILED: 
").append(e.getMessage()).append("\n");
-               }
-
-               closeStmtResSet(pstmt, rs);
-
-               compareExpectedOutput("Test_PSsomeamount",
-                       "0. true        true\n" +
-                       "1. Preparing and executing a unique statement\n" +
-                       "0, true\n" +
-                       "20, true\n" +
-                       "40, true\n" +
-                       "60, true\n" +
-                       "80, true\n" +
-                       "100, true\n");
-       }
-
        /* Create a lot of PreparedStatements, to emulate webloads such as 
those from Hibernate. */
        /* this test is same as Test_PSsomeamount() but for many more 
PreparedStatements to stress the server */
        @Test
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
@@ -1242,4 +1242,20 @@ public class ApiTests {
                        assertNotEquals(0, count); // stop complaints about 
neccessary loop
                }
        }
+
+       @Test
+       public void testPreparedSomeAmount() throws SQLException {
+               for (int i = 0; i < 120; i++) {
+                       String query = String.format("SELECT %d, %d = ?", i, i);
+                       try (PreparedStatement ps = 
conn.prepareStatement(query)) {
+                               ps.setInt(1, i);
+                               try (ResultSet rs = ps.executeQuery()) {
+                                       assertTrue(rs.next());
+                                       assertEquals(i, rs.getInt(1));
+                                       assertTrue(rs.getBoolean(2));
+                                       assertFalse(rs.next());
+                               }
+                       }
+               }
+       }
 }
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to