List:Commits« Previous MessageNext Message »
From:mmatthews Date:August 29 2007 3:23pm
Subject:Connector/J commit: r6513 - branches/branch_5_1/connector-j/src/testsuite/regression
View as plain text  
Modified:
   branches/branch_5_1/connector-j/src/testsuite/regression/BlobRegressionTest.java
   branches/branch_5_1/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java
   branches/branch_5_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
   branches/branch_5_1/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
   branches/branch_5_1/connector-j/src/testsuite/regression/MicroPerformanceRegressionTest.java
   branches/branch_5_1/connector-j/src/testsuite/regression/PooledConnectionRegressionTest.java
   branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
   branches/branch_5_1/connector-j/src/testsuite/regression/StatementRegressionTest.java
Log:
Merges from 5.0.

Modified: branches/branch_5_1/connector-j/src/testsuite/regression/BlobRegressionTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/regression/BlobRegressionTest.java	2007-08-29 15:15:22 UTC (rev 6512)
+++ branches/branch_5_1/connector-j/src/testsuite/regression/BlobRegressionTest.java	2007-08-29 15:23:58 UTC (rev 6513)
@@ -27,9 +27,13 @@
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.StringReader;
 import java.sql.Blob;
 import java.sql.Connection;
+import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.Statement;

Modified: branches/branch_5_1/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java	2007-08-29 15:15:22 UTC (rev 6512)
+++ branches/branch_5_1/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java	2007-08-29 15:23:58 UTC (rev 6513)
@@ -604,7 +604,7 @@
 				.executeUpdate("DROP PROCEDURE IF EXISTS testBug12417");
 				this.stmt.executeUpdate("CREATE PROCEDURE testBug12417()\n"
 						+ "BEGIN\n" + "SELECT 1;" + "end\n");
-				ucCatalogConn = getConnectionWithProps((String)null);
+				ucCatalogConn = getConnectionWithProps((Properties)null);
 				ucCatalogConn.setCatalog(this.conn.getCatalog().toUpperCase());
 				ucCatalogConn.prepareCall("{call testBug12417()}");
 			} finally {
@@ -852,7 +852,8 @@
 				assertEquals(100, rs.getInt(2));
 			}
 
-			assertEquals(-1, this.pstmt.getClass().getName().indexOf("Server"));
+			assertEquals(this.pstmt.getClass().getName(),
+					com.mysql.jdbc.PreparedStatement.class.getName());
 
 		} finally {
 			closeMemberJDBCResources();
@@ -981,6 +982,10 @@
 		if (!serverSupportsStoredProcedures()) {
 			return; // no stored procs
 		}
+		
+		if (isRunningOnJdk131()) {
+			return; // no such method to test
+		}
 
 		createProcedure("spbug25715", "(INOUT mblob MEDIUMBLOB)" + "BEGIN"
 				+ " SELECT 1 FROM DUAL WHERE 1=0;" + "\nEND");

Modified: branches/branch_5_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java	2007-08-29 15:15:22 UTC (rev 6512)
+++ branches/branch_5_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java	2007-08-29 15:23:58 UTC (rev 6513)
@@ -312,7 +312,7 @@
 
 		boolean isReadOnly = reconnectableConn.isReadOnly();
 
-		Connection killConn = getConnectionWithProps((String)null);
+		Connection killConn = getConnectionWithProps((Properties)null);
 
 		killConn.createStatement().executeUpdate("KILL " + connectionId);
 		Thread.sleep(2000);
@@ -1878,7 +1878,7 @@
 	public void testBug25514() throws Exception {
 
 		for (int i = 0; i < 10; i++) {
-			getConnectionWithProps((String)null).close();
+			getConnectionWithProps((Properties)null).close();
 		}
 		
 		ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
@@ -2052,7 +2052,7 @@
 			loggedConn.getTransactionIsolation();
 			
 			if (versionMeetsMinimum(4, 0, 3)) {
-				assertEquals(-1, logBuf.indexOf("SHOW VARIABLES LIKE 'tx_isolation'"));
+				assertEquals(-1, logBuf.toString().indexOf("SHOW VARIABLES LIKE 'tx_isolation'"));
 			}
 		} finally {
 			if (loggedConn != null) {

Modified: branches/branch_5_1/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2007-08-29 15:15:22 UTC (rev 6512)
+++ branches/branch_5_1/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2007-08-29 15:23:58 UTC (rev 6513)
@@ -1543,6 +1543,50 @@
 	}
 
 	/**
+	 * Tests fix for BUG#21267, ParameterMetaData throws NullPointerException
+	 * when prepared SQL actually has a syntax error
+	 * 
+	 * @throws Exception
+	 */
+	public void testBug21267() throws Exception {
+		if (isRunningOnJdk131()) {
+			return; // no parameter metadata on JDK-1.3.1
+		}
+		
+		createTable(
+				"bug21267",
+				"(`Col1` int(11) NOT NULL,`Col2` varchar(45) default NULL,`Col3` varchar(45) default NULL,PRIMARY KEY  (`Col1`))");
+
+		try {
+			this.pstmt = this.conn
+					.prepareStatement("SELECT Col1, Col2,Col4 FROM bug21267 WHERE Col1=?");
+			this.pstmt.setInt(1, 1);
+
+			java.sql.ParameterMetaData psMeta = this.pstmt
+					.getParameterMetaData();
+
+			try {
+				assertEquals(0, psMeta.getParameterType(1));
+			} catch (SQLException sqlEx) {
+				assertEquals(SQLError.SQL_STATE_DRIVER_NOT_CAPABLE, sqlEx.getSQLState());
+			}
+			
+			this.pstmt.close();
+			
+			Properties props = new Properties();
+			props.setProperty("generateSimpleParameterMetadata", "true");
+			
+			this.pstmt = getConnectionWithProps(props).prepareStatement("SELECT Col1, Col2,Col4 FROM bug21267 WHERE Col1=?");
+			
+			psMeta = this.pstmt.getParameterMetaData();
+			
+			assertEquals(Types.VARCHAR, psMeta.getParameterType(1));
+		} finally {
+			closeMemberJDBCResources();
+		}
+	}
+
+	/**
 	 * Tests fix for BUG#21544 - When using information_schema for metadata, 
 	 * COLUMN_SIZE for getColumns() is not clamped to range of 
 	 * java.lang.Integer as is the case when not using 
@@ -1690,7 +1734,7 @@
 	}
 	
 	public void testCharacterSetForDBMD() throws Exception {
-		if (versionMeetsMinimum(5, 0)) {
+		if (versionMeetsMinimum(4, 0)) {
 			// server is broken, fixed in 5.2/6.0?
 			
 			if (!versionMeetsMinimum(5, 2)) {
@@ -1886,50 +1930,6 @@
 	}
 
 	/**
-	 * Tests fix for BUG#21267, ParameterMetaData throws NullPointerException
-	 * when prepared SQL actually has a syntax error
-	 * 
-	 * @throws Exception
-	 */
-	public void testBug21267() throws Exception {
-		if (isRunningOnJdk131()) {
-			return; // no parameter metadata on JDK-1.3.1
-		}
-		
-		createTable(
-				"bug21267",
-				"(`Col1` int(11) NOT NULL,`Col2` varchar(45) default NULL,`Col3` varchar(45) default NULL,PRIMARY KEY  (`Col1`))");
-	
-		try {
-			this.pstmt = this.conn
-					.prepareStatement("SELECT Col1, Col2,Col4 FROM bug21267 WHERE Col1=?");
-			this.pstmt.setInt(1, 1);
-	
-			java.sql.ParameterMetaData psMeta = this.pstmt
-					.getParameterMetaData();
-	
-			try {
-				assertEquals(0, psMeta.getParameterType(1));
-			} catch (SQLException sqlEx) {
-				assertEquals(SQLError.SQL_STATE_DRIVER_NOT_CAPABLE, sqlEx.getSQLState());
-			}
-			
-			this.pstmt.close();
-			
-			Properties props = new Properties();
-			props.setProperty("generateSimpleParameterMetadata", "true");
-			
-			this.pstmt = getConnectionWithProps(props).prepareStatement("SELECT Col1, Col2,Col4 FROM bug21267 WHERE Col1=?");
-			
-			psMeta = this.pstmt.getParameterMetaData();
-			
-			assertEquals(Types.VARCHAR, psMeta.getParameterType(1));
-		} finally {
-			closeMemberJDBCResources();
-		}
-	}
-
-	/**
 	 * Tests fix for BUG#25624 - Whitespace surrounding storage/size specifiers in stored procedure
 	 * declaration causes NumberFormatException to be thrown when calling stored procedure.
 	 * 

Modified: branches/branch_5_1/connector-j/src/testsuite/regression/MicroPerformanceRegressionTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/regression/MicroPerformanceRegressionTest.java	2007-08-29 15:15:22 UTC (rev 6512)
+++ branches/branch_5_1/connector-j/src/testsuite/regression/MicroPerformanceRegressionTest.java	2007-08-29 15:23:58 UTC (rev 6513)
@@ -29,6 +29,7 @@
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 
 import testsuite.BaseTestCase;

Modified: branches/branch_5_1/connector-j/src/testsuite/regression/PooledConnectionRegressionTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/regression/PooledConnectionRegressionTest.java	2007-08-29 15:15:22 UTC (rev 6512)
+++ branches/branch_5_1/connector-j/src/testsuite/regression/PooledConnectionRegressionTest.java	2007-08-29 15:23:58 UTC (rev 6513)
@@ -174,9 +174,7 @@
 	/**
 	 * After the test is run.
 	 */
-	public void tearDown() throws Exception {
-		super.tearDown();
-		
+	public void tearDown() {
 		this.cpds = null;
 	}
 

Modified: branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java	2007-08-29 15:15:22 UTC (rev 6512)
+++ branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java	2007-08-29 15:23:58 UTC (rev 6513)
@@ -25,6 +25,7 @@
 package testsuite.regression;
 
 import java.io.Reader;
+import java.lang.reflect.Array;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
@@ -4353,6 +4354,8 @@
 			checkUpdatabilityMessage(sqlEx, 
 					messageToCheck);
 		}
+
+		this.rs.close();
 	}
 	
 	private void checkUpdatabilityMessage(SQLException sqlEx,
@@ -4368,4 +4371,30 @@
 				+ localizedMessage + "', instead found:\n\n" + message,
 				message.indexOf(localizedMessage) != -1);
 	}
+
+	public void testBug24886() throws Exception {
+	    Properties props = new Properties();
+	    props.setProperty("blobsAreStrings", "true");
+
+	    Connection noBlobConn = getConnectionWithProps(props);
+
+	    createTable("testBug24886", "(sepallength double,"
+	            + "sepalwidth double,"
+	            + "petallength double,"
+	            + "petalwidth double,"
+	            + "Class mediumtext, "
+	            + "fy TIMESTAMP)");
+
+	    noBlobConn.createStatement().executeUpdate("INSERT INTO testBug24886 VALUES (1,2,3,4,'1234', now()),(5,6,7,8,'12345678', now())");
+	    this.rs = noBlobConn.createStatement().executeQuery("SELECT concat(Class,petallength), COUNT(*) FROM `testBug24886` GROUP BY `concat(Class,petallength)`");
+	    this.rs.next();
+	    assertEquals("java.lang.String", this.rs.getObject(1).getClass().getName());
+
+	    props.clear();
+	    props.setProperty("functionsNeverReturnBlobs", "true");
+	    noBlobConn = getConnectionWithProps(props);
+	    this.rs = noBlobConn.createStatement().executeQuery("SELECT concat(Class,petallength), COUNT(*) FROM `testBug24886` GROUP BY `concat(Class,petallength)`");
+        this.rs.next();
+        assertEquals("java.lang.String", this.rs.getObject(1).getClass().getName());
+	}
 }
\ No newline at end of file

Modified: branches/branch_5_1/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/regression/StatementRegressionTest.java	2007-08-29 15:15:22 UTC (rev 6512)
+++ branches/branch_5_1/connector-j/src/testsuite/regression/StatementRegressionTest.java	2007-08-29 15:23:58 UTC (rev 6513)
@@ -440,7 +440,7 @@
 		Statement stmt2 = null;
 
 		try {
-			conn2 = getConnectionWithProps((String)null);
+			conn2 = getConnectionWithProps((Properties)null);
 			stmt2 = conn2.createStatement();
 
 			conn2.close();
@@ -2757,7 +2757,7 @@
 
 	public void testServerPrepStmtDeadlock() throws Exception {
 
-		Connection c = getConnectionWithProps((String)null);
+		Connection c = getConnectionWithProps((Properties)null);
 
 		Thread testThread1 = new PrepareThread(c);
 		Thread testThread2 = new PrepareThread(c);
@@ -4029,4 +4029,50 @@
 			closeMemberJDBCResources();
 		}
 	}
+	
+	/**
+	 * Tests fix for BUG#30550 - executeBatch() on an empty
+	 * batch when there are no elements in the batch causes a
+	 * divide-by-zero error when rewriting is enabled.
+	 * 
+	 * @throws Exception if the test fails
+	 */
+	public void testBug30550() throws Exception {
+		createTable("testBug30550", "(field1 int)");
+
+		Connection rewriteConn = getConnectionWithProps("rewriteBatchedStatements=true");
+		PreparedStatement batchPStmt = null;
+		Statement batchStmt = null;
+		
+		try {
+			batchStmt = rewriteConn.createStatement();
+			assertEquals(0, batchStmt.executeBatch().length);
+			
+			batchStmt.addBatch("INSERT INTO testBug30550 VALUES (1)");
+			int[] counts = batchStmt.executeBatch();
+			assertEquals(1, counts.length);
+			assertEquals(1, counts[0]);
+			assertEquals(0, batchStmt.executeBatch().length);
+			
+			batchPStmt = rewriteConn.prepareStatement("INSERT INTO testBug30550 VALUES (?)");
+			batchPStmt.setInt(1, 1);
+			assertEquals(0, batchPStmt.executeBatch().length);
+			batchPStmt.addBatch();
+			counts = batchPStmt.executeBatch();
+			assertEquals(1, counts.length);
+			assertEquals(1, counts[0]);
+			assertEquals(0, batchPStmt.executeBatch().length);
+		} finally {
+			if (batchPStmt != null) {
+				batchPStmt.close();
+	}
+			
+			if (batchStmt != null) {
+				batchStmt.close();
 }
+			if (rewriteConn != null) {
+				rewriteConn.close();
+			}
+		}
+	}
+}
\ No newline at end of file

Thread
Connector/J commit: r6513 - branches/branch_5_1/connector-j/src/testsuite/regressionmmatthews29 Aug