Modified:
branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
Log:
Added tests to insure proper behavior for BUG#24706 (it wasn't repeatable in 5.0, but we don't want a regression either).
Modified: branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
===================================================================
--- branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-01-10 18:57:48 UTC (rev 6286)
+++ branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-01-10 21:04:31 UTC (rev 6287)
@@ -46,6 +46,7 @@
import com.mysql.jdbc.NonRegisteringDriver;
import com.mysql.jdbc.ReplicationConnection;
import com.mysql.jdbc.ReplicationDriver;
+import com.mysql.jdbc.log.StandardLogger;
/**
* Regression tests for Connections
@@ -1793,6 +1794,56 @@
}
/**
+ * Tests to insure proper behavior for BUG#24706.
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testBug24706() throws Exception {
+ Properties props = new Properties();
+ props.setProperty("elideSetAutoCommits", "true");
+ props.setProperty("logger", "StandardLogger");
+ props.setProperty("profileSQL", "true");
+ Connection c = null;
+
+ StringBuffer logBuf = new StringBuffer();
+
+ StandardLogger.bufferedLog = logBuf;
+
+ try {
+ c = getConnectionWithProps(props);
+ c.setAutoCommit(true);
+ c.createStatement().execute("SELECT 1");
+ c.setAutoCommit(true);
+ c.setAutoCommit(false);
+ c.createStatement().execute("SELECT 1");
+ c.setAutoCommit(false);
+
+ // We should only see _one_ "set autocommit=" sent to the server
+
+ String log = logBuf.toString();
+ int searchFrom = 0;
+ int count = 0;
+ int found = 0;
+
+ while ((found = log.indexOf("SET autocommit=", searchFrom)) != -1) {
+ searchFrom = found + 1;
+ count++;
+ }
+
+ // The SELECT doesn't actually start a transaction, so being pedantic the
+ // driver issues SET autocommit=0 again in this case.
+ assertEquals(2, count);
+ } finally {
+ StandardLogger.bufferedLog = null;
+
+ if (c != null) {
+ c.close();
+ }
+
+ }
+ }
+
+ /**
* Tests fix for BUG#25514 - Timer instance used for Statement.setQueryTimeout()
* created per-connection, rather than per-VM, causing memory leak.
*
Modified: trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-01-10 18:57:48 UTC (rev 6286)
+++ trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-01-10 21:04:31 UTC (rev 6287)
@@ -46,6 +46,7 @@
import com.mysql.jdbc.NonRegisteringDriver;
import com.mysql.jdbc.ReplicationConnection;
import com.mysql.jdbc.ReplicationDriver;
+import com.mysql.jdbc.log.StandardLogger;
/**
* Regression tests for Connections
@@ -1841,4 +1842,54 @@
return count;
}
+
+ /**
+ * Tests to insure proper behavior for BUG#24706.
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testBug24706() throws Exception {
+ Properties props = new Properties();
+ props.setProperty("elideSetAutoCommits", "true");
+ props.setProperty("logger", "StandardLogger");
+ props.setProperty("profileSQL", "true");
+ Connection c = null;
+
+ StringBuffer logBuf = new StringBuffer();
+
+ StandardLogger.bufferedLog = logBuf;
+
+ try {
+ c = getConnectionWithProps(props);
+ c.setAutoCommit(true);
+ c.createStatement().execute("SELECT 1");
+ c.setAutoCommit(true);
+ c.setAutoCommit(false);
+ c.createStatement().execute("SELECT 1");
+ c.setAutoCommit(false);
+
+ // We should only see _one_ "set autocommit=" sent to the server
+
+ String log = logBuf.toString();
+ int searchFrom = 0;
+ int count = 0;
+ int found = 0;
+
+ while ((found = log.indexOf("SET autocommit=", searchFrom)) != -1) {
+ searchFrom = found + 1;
+ count++;
+ }
+
+ // The SELECT doesn't actually start a transaction, so being pedantic the
+ // driver issues SET autocommit=0 again in this case.
+ assertEquals(2, count);
+ } finally {
+ StandardLogger.bufferedLog = null;
+
+ if (c != null) {
+ c.close();
+ }
+
+ }
+ }
}
Thread |
---|
• Connector/J commit: r6287 - branches/branch_5_0/connector-j/src/testsuite/regression trunk/connector-j/src/testsuite/regression | mmatthews | 10 Jan |