From eb7efe3ea3a94b3a4a0be6c10d6e45c1aaf9b408 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Tue, 10 Oct 2017 11:10:08 -0700 Subject: [PATCH] Modified bvtTests to be able to test resultSet closing explicitly. --- .../microsoft/sqlserver/jdbc/bvt/bvtTest.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java index 90ba5d0ac..eaad85365 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/bvt/bvtTest.java @@ -361,10 +361,11 @@ public void testTwoResultsetsDifferentStmt() throws SQLException { try (DBConnection conn = new DBConnection(connectionString); DBStatement stmt1 = conn.createStatement(); - DBStatement stmt2 = conn.createStatement(); - DBResultSet rs1 = stmt1.executeQuery(query); - DBResultSet rs2 = stmt2.executeQuery(query2)) { + DBStatement stmt2 = conn.createStatement()) { + DBResultSet rs1 = stmt1.executeQuery(query); + DBResultSet rs2 = stmt2.executeQuery(query2); + // Interleave resultset calls rs1.next(); rs1.verifyCurrentRow(table1); @@ -373,8 +374,10 @@ public void testTwoResultsetsDifferentStmt() throws SQLException { rs1.next(); rs1.verifyCurrentRow(table1); rs1.verify(table1); + rs1.close(); rs2.next(); rs2.verify(table2); + rs2.close(); } } @@ -390,10 +393,10 @@ public void testTwoResultsetsSameStmt() throws SQLException { String query2 = "SELECT * FROM " + table2.getEscapedTableName(); try (DBConnection conn = new DBConnection(connectionString); - DBStatement stmt = conn.createStatement(); - DBResultSet rs1 = stmt.executeQuery(query); - DBResultSet rs2 = stmt.executeQuery(query2)) { + DBStatement stmt = conn.createStatement()) { + DBResultSet rs1 = stmt.executeQuery(query); + DBResultSet rs2 = stmt.executeQuery(query2); // Interleave resultset calls. rs is expected to be closed try { rs1.next(); @@ -409,8 +412,10 @@ public void testTwoResultsetsSameStmt() throws SQLException { catch (SQLException e) { assertEquals(e.toString(), "com.microsoft.sqlserver.jdbc.SQLServerException: The result set is closed."); } + rs1.close(); rs2.next(); rs2.verify(table2); + rs2.close(); } }