List:Internals« Previous MessageNext Message »
From:mmatthews Date:August 2 2005 6:03pm
Subject:Connector/J commit: r4010 - branches/branch_3_1/connector-j/src/testsuite/regression
View as plain text  
Modified:
   branches/branch_3_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
Log:
Fixes for Eric's tests.

Modified: branches/branch_3_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
===================================================================
--- branches/branch_3_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java	2005-08-02 18:01:20 UTC (rev 4009)
+++ branches/branch_3_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java	2005-08-02 18:03:33 UTC (rev 4010)
@@ -929,26 +929,40 @@
 	}
 
 	public void testBug8643() throws Exception {
-		/*
-		 * TODO mark, we should fix this so the ports are not hard coded.
-		 */
-		String port1 = "3306";
-		String port2 = "3308";
-		String url = "jdbc:mysql://localhost:" + port1 + ",localhost:" + port2
-				+ "/test";
-		Properties props = new Properties();
-		props.put("autoReconnect", "true");
-		props.put("roundRobinLoadBalance", "true");
-		props.put("failOverReadOnly", "false");
+		StringBuffer urlBuf = new StringBuffer("jdbc:mysql://");
+		Properties defaultProps = getPropertiesFromTestsuiteUrl();
+		String hostname = defaultProps.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY);
+		String portNumber = defaultProps.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY);
+		
+		for (int i = 0; i < 2; i++) {
+			urlBuf.append(hostname);
+			urlBuf.append(":");
+			urlBuf.append(portNumber);
+			
+			if (i == 0) {
+				urlBuf.append(",");
+			}
+		}
+		
+		urlBuf.append("/");
+		
+		defaultProps.remove(NonRegisteringDriver.HOST_PROPERTY_KEY);
+		defaultProps.remove(NonRegisteringDriver.PORT_PROPERTY_KEY);
+		
+		
+		
+		defaultProps.put("autoReconnect", "true");
+		defaultProps.put("roundRobinLoadBalance", "true");
+		defaultProps.put("failOverReadOnly", "false");
 
 		Connection con = null;
 		try {
-			con = DriverManager.getConnection(url, props);
+			con = DriverManager.getConnection(urlBuf.toString(), defaultProps);
 			Statement stmt1 = con.createStatement();
 
 			ResultSet rs1 = stmt1.executeQuery("show variables like 'port'");
 			rs1.next();
-			assertEquals(port1, rs1.getString(2));
+			assertEquals(portNumber, rs1.getString(2));
 
 			rs1 = stmt1.executeQuery("select connection_id()");
 			rs1.next();
@@ -961,7 +975,7 @@
 				rs1 = stmt1.executeQuery("show variables like 'port'");
 			}
 			rs1.next();
-			assertEquals(port2, rs1.getString(2));
+			assertEquals(portNumber, rs1.getString(2));
 			rs1 = stmt1.executeQuery("select connection_id()");
 			rs1.next();
 			originalConnectionId = rs1.getString(1);
@@ -973,7 +987,7 @@
 				rs1 = stmt1.executeQuery("show variables like 'port'");
 			}
 			rs1.next();
-			assertEquals(port1, rs1.getString(2));
+			assertEquals(portNumber, rs1.getString(2));
 		} finally {
 			if (con != null) {
 				try {

Thread
Connector/J commit: r4010 - branches/branch_3_1/connector-j/src/testsuite/regressionmmatthews2 Aug