Permalink
Browse files

test: speedup DriverTest.testConnectFailover by adding a connect time…

…out of 5 seconds
  • Loading branch information...
vlsi committed Dec 20, 2015
1 parent 410a662 commit ed1a91644fb070d0ea3347b97f79102ccfb7d66d
Showing with 12 additions and 7 deletions.
  1. +12 −7 pgjdbc/src/test/java/org/postgresql/test/jdbc2/DriverTest.java
@@ -75,10 +75,7 @@ private void verifyUrl(Driver drv, String url, String hosts, String ports, Strin
assertEquals(url, ports, p.getProperty("PGPORT"));
}
/*
* Tests parseURL (internal)
*/
/*
/**
* Tests the connect method by connecting to the test database
*/
public void testConnect() throws Exception
@@ -96,11 +93,19 @@ public void testConnect() throws Exception
con.close();
// Test with failover url
String url = "jdbc:postgresql://invalidhost.not.here," + TestUtil.getServer() + ":" + TestUtil.getPort() + "/" + TestUtil.getDatabase();
con = DriverManager.getConnection(url, TestUtil.getUser(), TestUtil.getPassword());
}
/**
* Tests that pgjdbc performs connection failover if unable to connect to the first host in the URL.
*
* @throws Exception if something wrong happens
*/
public void testConnectFailover() throws Exception
{
String url = "jdbc:postgresql://invalidhost.not.here," + TestUtil.getServer() + ":" + TestUtil.getPort() + "/" + TestUtil.getDatabase() + "?connectTimeout=5";
Connection con = DriverManager.getConnection(url, TestUtil.getUser(), TestUtil.getPassword());
assertNotNull(con);
con.close();
}
/*

0 comments on commit ed1a916

Please sign in to comment.