Skip to content

Commit

Permalink
test: speedup DriverTest.testConnectFailover by adding a connect time…
Browse files Browse the repository at this point in the history
…out of 5 seconds
  • Loading branch information
vlsi committed Dec 20, 2015
1 parent 410a662 commit ed1a916
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pgjdbc/src/test/java/org/postgresql/test/jdbc2/DriverTest.java
Expand Up @@ -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
Expand All @@ -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();

}

/*
Expand Down

0 comments on commit ed1a916

Please sign in to comment.