db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fuzzylo...@apache.org
Subject svn commit: r515297 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
Date Tue, 06 Mar 2007 20:52:57 GMT
Author: fuzzylogic
Date: Tue Mar  6 12:52:57 2007
New Revision: 515297

URL: http://svn.apache.org/viewvc?view=rev&rev=515297
Log:
DERBY-2404: Remove hardcoded hostname / port in BadConnectionTest, get
the hostname and port from TestConfiguration at setUp time instead.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java?view=diff&rev=515297&r1=515296&r2=515297
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
Tue Mar  6 12:52:57 2007
@@ -38,11 +38,19 @@
 
 public class BadConnectionTest extends BaseJDBCTestCase
 {
-	
+	private static String host;
+	private static int port;
+
 	public void setUp() throws SQLException
 	{
 		// get the default connection so the driver is loaded.
+		//
+		// host and port are set here, if set at the time the
+		// class is instantiated, they will get the default 
+		// embedded 'port' of -1.
 		Connection c = getConnection();
+		host = TestConfiguration.getCurrent().getHostName();
+		port = TestConfiguration.getCurrent().getPort();
 		c.close();
 	}
 	
@@ -53,7 +61,8 @@
 	public void testNoUserOrPassword()
 	{
 		try {
-			Connection c = DriverManager.getConnection("jdbc:derby://localhost:1527/testbase");
+			Connection c = DriverManager.getConnection(
+					"jdbc:derby://" + host + ":" + port + "/testbase");
 		} catch (SQLException e) {
 			assertSQLState("08004", e);
 			assertEquals(-4499, e.getErrorCode());
@@ -70,7 +79,8 @@
 			Properties p = new Properties();
 			p.put("user", "admin");
 			p.put("password", "admin");
-			Connection c = DriverManager.getConnection("jdbc:derby://localhost:1527/testbase", p);
+			Connection c = DriverManager.getConnection(
+					"jdbc:derby://" + host + ":" + port + "/testbase", p);
 		} catch (SQLException e)
 		{
 			assertSQLState("08004", e);
@@ -88,7 +98,8 @@
 	public void testBadConnectionAttribute()
 	{
 		try {
-			Connection c = DriverManager.getConnection("jdbc:derby://localhost:1527/badAttribute;upgrade=notValidValue");
+			Connection c = DriverManager.getConnection(
+					"jdbc:derby://" + host + ":" + port + "/badAttribute;upgrade=notValidValue");
 		} catch (SQLException e)
 		{
 			assertSQLState("XJ05B", e);



Mime
View raw message