List:Commits« Previous MessageNext Message »
From:mmatthews Date:June 30 2006 4:04pm
Subject:Connector/J commit: r5457 - branches/branch_5_0/connector-j/src/testsuite/regression
View as plain text  
Modified:
   branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
Log:
Better test for bug 20687, that works when server isn't capable of server-side prepared statements.

Modified: branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
--- branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java	2006-06-30 00:01:36 UTC (rev 5456)
+++ branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java	2006-06-30 16:04:28 UTC (rev 5457)
@@ -3252,24 +3252,39 @@
 	 * @throws Exception if the test fails.
 	 */
 	public void testBug20687() throws Exception {
-		createTable("testBug20687", "(field1 int)");
-		Connection poolingConn = null;
-		
-		Properties props = new Properties();
-		props.setProperty("cachePrepStmts", "true");
-		
-		try {
-			poolingConn = getConnectionWithProps(props);
-			PreparedStatement pstmt1 = poolingConn.prepareStatement("SELECT field1 FROM testBug20687");
-			pstmt1.executeQuery();
-			pstmt1.close();
+		if (versionMeetsMinimum(5, 0)) {
+			createTable("testBug20687", "(field1 int)");
+			Connection poolingConn = null;
 			
-			PreparedStatement pstmt2 = poolingConn.prepareStatement("SELECT field1 FROM testBug20687");
-			pstmt2.executeQuery();
-			assertSame(pstmt1, pstmt2);
-			pstmt2.close();
-		} finally {
+			Properties props = new Properties();
+			props.setProperty("cachePrepStmts", "true");
 			
+			PreparedStatement pstmt1 = null;
+			PreparedStatement pstmt2  = null;
+			
+			try {
+				poolingConn = getConnectionWithProps(props);
+				pstmt1 = poolingConn.prepareStatement("SELECT field1 FROM testBug20687");
+				pstmt1.executeQuery();
+				pstmt1.close();
+				
+				pstmt2 = poolingConn.prepareStatement("SELECT field1 FROM testBug20687");
+				pstmt2.executeQuery();
+				assertTrue(pstmt1 == pstmt2);
+				pstmt2.close();
+			} finally {
+				if (pstmt1 != null) {
+					pstmt1.close();
+				}
+				
+				if (pstmt2 != null) {
+					pstmt2.close();
+				}
+				
+				if (poolingConn != null) {
+					poolingConn.close();
+				}
+			}
 		}
 	}
 	

Thread
Connector/J commit: r5457 - branches/branch_5_0/connector-j/src/testsuite/regressionmmatthews30 Jun