List:Commits« Previous MessageNext Message »
From:mmatthews Date:June 7 2007 3:37pm
Subject:Connector/J commit: r6447 - branches/branch_5_1/connector-j/src/testsuite/simple
View as plain text  
Modified:
   branches/branch_5_1/connector-j/src/testsuite/simple/StatementsTest.java
Log:
Tests for PreparedStatementBindings

Modified: branches/branch_5_1/connector-j/src/testsuite/simple/StatementsTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/simple/StatementsTest.java	2007-06-07 15:30:07 UTC (rev 6446)
+++ branches/branch_5_1/connector-j/src/testsuite/simple/StatementsTest.java	2007-06-07 15:37:52 UTC (rev 6447)
@@ -49,6 +49,7 @@
 import testsuite.BaseTestCase;
 
 import com.mysql.jdbc.NotImplemented;
+import com.mysql.jdbc.ParameterBindings;
 import com.mysql.jdbc.SQLError;
 import com.mysql.jdbc.StringUtils;
 
@@ -1784,4 +1785,41 @@
 			}
 		}
 	}
+	
+	public void testParameterBindings() throws Exception {
+		// Need to check character set stuff, so need a new connection
+		Connection utfConn = getConnectionWithProps("characterEncoding=utf-8");
+		
+		java.util.Date now = new java.util.Date();
+
+		Object[] valuesToTest = new Object[] {
+				new Byte(Byte.MIN_VALUE),
+				new Short(Short.MIN_VALUE),
+				new Integer(Integer.MIN_VALUE),
+				new Long(Long.MIN_VALUE),
+				new Double(Double.MIN_VALUE),
+				"\u4E2D\u6587",
+				new BigDecimal(Math.PI), 
+				null, // to test isNull
+				now // to test serialization
+		};
+		
+		StringBuffer statementText = new StringBuffer("SELECT ?");
+		
+		for (int i = 1; i < valuesToTest.length; i++) {
+			statementText.append(",?");
+		}
+		
+		this.pstmt = utfConn.prepareStatement(statementText.toString());
+		
+		for (int i = 0; i < valuesToTest.length; i++) {
+			this.pstmt.setObject(i + 1, valuesToTest[i]);
+		}
+		
+		ParameterBindings bindings = ((com.mysql.jdbc.PreparedStatement)this.pstmt).getParameterBindings();
+		
+		for (int i = 0; i < valuesToTest.length; i++) {
+			assertEquals(bindings.getObject(i + 1), valuesToTest[i]);
+		}
+	}
 }

Thread
Connector/J commit: r6447 - branches/branch_5_1/connector-j/src/testsuite/simplemmatthews7 Jun