You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2007/11/30 19:30:52 UTC

svn commit: r599896 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java

Author: djd
Date: Fri Nov 30 10:30:50 2007
New Revision: 599896

URL: http://svn.apache.org/viewvc?rev=599896&view=rev
Log:
Cleanup derbynet/BadConnectionTest including adding fail() asserts if a connection attempt succeeds

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?rev=599896&r1=599895&r2=599896&view=diff
==============================================================================
--- 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 Fri Nov 30 10:30:50 2007
@@ -38,20 +38,10 @@
 
 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();
+		getConnection().close();
 	}
 	
 	/**
@@ -62,7 +52,9 @@
 	{
 		try {
 			Connection c = DriverManager.getConnection(
-					"jdbc:derby://" + host + ":" + port + "/testbase");
+					"jdbc:derby://" + getTestConfiguration().getHostName()
+                    + ":" + getTestConfiguration().getPort() + "/testbase");
+            fail("Connection with no user or password succeeded");
 		} catch (SQLException e) {
 			assertSQLState("08004", e);
 			assertEquals(40000, e.getErrorCode());
@@ -80,7 +72,9 @@
 			p.put("user", "admin");
 			p.put("password", "admin");
 			Connection c = DriverManager.getConnection(
-					"jdbc:derby://" + host + ":" + port + "/testbase", p);
+					"jdbc:derby://" + getTestConfiguration().getHostName()
+                    + ":" + getTestConfiguration().getPort() + "/testbase", p);
+            fail("Connection with no database succeeded");
 		} catch (SQLException e)
 		{
 			assertSQLState("08004", e);
@@ -99,7 +93,9 @@
 	{
 		try {
 			Connection c = DriverManager.getConnection(
-					"jdbc:derby://" + host + ":" + port + "/badAttribute;upgrade=notValidValue");
+					"jdbc:derby://" + getTestConfiguration().getHostName()
+                    + ":" + getTestConfiguration().getPort() + "/badAttribute;upgrade=notValidValue");
+            fail("Connection with bad atttributes succeeded");
 		} catch (SQLException e)
 		{
 			assertSQLState("XJ05B", e);
@@ -114,7 +110,6 @@
 	
 	public static Test suite()
 	{
-		return TestConfiguration.clientServerDecorator(
-			new TestSuite(BadConnectionTest.class, "BadConnection"));
+		return TestConfiguration.clientServerSuite(BadConnectionTest.class);
 	}
 }