From: Dave Cramer Date: Fri, 5 Dec 2003 21:06:12 +0000 (+0000) Subject: patch from Kris Jurka to allow the server end port to be specified when running X-Git-Tag: REL7_4_1~63 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dfaf736bc7715cf31e6845364b0b6ca215d0ce1a;p=postgresql patch from Kris Jurka to allow the server end port to be specified when running regression tests, this is a backpatch to 7.4 --- diff --git a/src/interfaces/jdbc/org/postgresql/test/TestUtil.java b/src/interfaces/jdbc/org/postgresql/test/TestUtil.java index 930215ed38..6b139435a5 100644 --- a/src/interfaces/jdbc/org/postgresql/test/TestUtil.java +++ b/src/interfaces/jdbc/org/postgresql/test/TestUtil.java @@ -12,6 +12,30 @@ public class TestUtil * Returns the Test database JDBC URL */ public static String getURL() + { + return "jdbc:postgresql://"+getServer()+":"+getPort()+"/"+getDatabase(); + } + + /* + * Returns the Test server + */ + public static String getServer() + { + return System.getProperty("server"); + } + + /* + * Returns the Test port + */ + public static int getPort() + { + return Integer.parseInt(System.getProperty("port")); + } + + /* + * Returns the Test database + */ + public static String getDatabase() { return System.getProperty("database"); } diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java index 8f84193990..ef5823d18f 100644 --- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java +++ b/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java @@ -11,7 +11,7 @@ import java.sql.*; * interface to the PooledConnection is through the CPDS. * * @author Aaron Mulder (ammulder@chariotsolutions.com) - * @version $Revision: 1.6 $ + * @version $Revision: 1.6.4.1 $ */ public class ConnectionPoolTest extends BaseDataSourceTest { @@ -31,16 +31,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest if (bds == null) { bds = new ConnectionPool(); - String db = TestUtil.getURL(); - if (db.indexOf('/') > -1) - { - db = db.substring(db.lastIndexOf('/') + 1); - } - else if (db.indexOf(':') > -1) - { - db = db.substring(db.lastIndexOf(':') + 1); - } - bds.setDatabaseName(db); + bds.setServerName(TestUtil.getServer()); + bds.setPortNumber(TestUtil.getPort()); + bds.setDatabaseName(TestUtil.getDatabase()); bds.setUser(TestUtil.getUser()); bds.setPassword(TestUtil.getPassword()); } diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/PoolingDataSourceTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/PoolingDataSourceTest.java index 9b08eca7d0..701f835332 100644 --- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/PoolingDataSourceTest.java +++ b/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/PoolingDataSourceTest.java @@ -9,7 +9,7 @@ import org.postgresql.jdbc2.optional.BaseDataSource; * Minimal tests for pooling DataSource. Needs many more. * * @author Aaron Mulder (ammulder@chariotsolutions.com) - * @version $Revision: 1.1 $ + * @version $Revision: 1.1.6.1 $ */ public class PoolingDataSourceTest extends BaseDataSourceTest { @@ -40,16 +40,9 @@ public class PoolingDataSourceTest extends BaseDataSourceTest if (bds == null) { bds = new PoolingDataSource(); - String db = TestUtil.getURL(); - if (db.indexOf('/') > -1) - { - db = db.substring(db.lastIndexOf('/') + 1); - } - else if (db.indexOf(':') > -1) - { - db = db.substring(db.lastIndexOf(':') + 1); - } - bds.setDatabaseName(db); + bds.setServerName(TestUtil.getServer()); + bds.setPortNumber(TestUtil.getPort()); + bds.setDatabaseName(TestUtil.getDatabase()); bds.setUser(TestUtil.getUser()); bds.setPassword(TestUtil.getPassword()); ((PoolingDataSource) bds).setDataSourceName(DS_NAME); diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java index b5c3e100ec..a33e6458a4 100644 --- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java +++ b/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java @@ -8,7 +8,7 @@ import org.postgresql.jdbc2.optional.SimpleDataSource; * configuration logic. * * @author Aaron Mulder (ammulder@chariotsolutions.com) - * @version $Revision: 1.3 $ + * @version $Revision: 1.3.6.1 $ */ public class SimpleDataSourceTest extends BaseDataSourceTest { @@ -28,16 +28,9 @@ public class SimpleDataSourceTest extends BaseDataSourceTest if (bds == null) { bds = new SimpleDataSource(); - String db = TestUtil.getURL(); - if (db.indexOf('/') > -1) - { - db = db.substring(db.lastIndexOf('/') + 1); - } - else if (db.indexOf(':') > -1) - { - db = db.substring(db.lastIndexOf(':') + 1); - } - bds.setDatabaseName(db); + bds.setServerName(TestUtil.getServer()); + bds.setPortNumber(TestUtil.getPort()); + bds.setDatabaseName(TestUtil.getDatabase()); bds.setUser(TestUtil.getUser()); bds.setPassword(TestUtil.getPassword()); } diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3ConnectionPoolTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3ConnectionPoolTest.java index f679c48f77..6fe6cc73df 100644 --- a/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3ConnectionPoolTest.java +++ b/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3ConnectionPoolTest.java @@ -12,7 +12,7 @@ import javax.sql.PooledConnection; * Tests JDBC3 implementation of ConnectionPoolDataSource. * * @author Aaron Mulder (ammulder@chariotsolutions.com) - * @version $Revision: 1.2 $ + * @version $Revision: 1.2.4.1 $ */ public class Jdbc3ConnectionPoolTest extends ConnectionPoolTest { @@ -29,16 +29,9 @@ public class Jdbc3ConnectionPoolTest extends ConnectionPoolTest if (bds == null) { bds = new Jdbc3ConnectionPool(); - String db = TestUtil.getURL(); - if (db.indexOf('/') > -1) - { - db = db.substring(db.lastIndexOf('/') + 1); - } - else if (db.indexOf(':') > -1) - { - db = db.substring(db.lastIndexOf(':') + 1); - } - bds.setDatabaseName(db); + bds.setServerName(TestUtil.getServer()); + bds.setPortNumber(TestUtil.getPort()); + bds.setDatabaseName(TestUtil.getDatabase()); bds.setUser(TestUtil.getUser()); bds.setPassword(TestUtil.getPassword()); } diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3PoolingDataSourceTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3PoolingDataSourceTest.java index 55374cb1b8..17220b3954 100644 --- a/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3PoolingDataSourceTest.java +++ b/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3PoolingDataSourceTest.java @@ -13,7 +13,7 @@ import org.postgresql.jdbc2.optional.PoolingDataSource; * Minimal tests for JDBC3 pooling DataSource. Needs many more. * * @author Aaron Mulder (ammulder@chariotsolutions.com) - * @version $Revision: 1.1 $ + * @version $Revision: 1.1.6.1 $ */ public class Jdbc3PoolingDataSourceTest extends PoolingDataSourceTest { @@ -42,15 +42,9 @@ public class Jdbc3PoolingDataSourceTest extends PoolingDataSourceTest private void configureDataSource(PoolingDataSource source) { String db = TestUtil.getURL(); - if (db.indexOf('/') > -1) - { - db = db.substring(db.lastIndexOf('/') + 1); - } - else if (db.indexOf(':') > -1) - { - db = db.substring(db.lastIndexOf(':') + 1); - } - source.setDatabaseName(db); + source.setServerName(TestUtil.getServer()); + source.setPortNumber(TestUtil.getPort()); + source.setDatabaseName(TestUtil.getDatabase()); source.setUser(TestUtil.getUser()); source.setPassword(TestUtil.getPassword()); source.setDataSourceName(DS_NAME); diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3SimpleDataSourceTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3SimpleDataSourceTest.java index cef4c83f65..5bf45978f7 100644 --- a/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3SimpleDataSourceTest.java +++ b/src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3SimpleDataSourceTest.java @@ -10,7 +10,7 @@ import org.postgresql.jdbc3.*; * Tests JDBC3 non-pooling DataSource. * * @author Aaron Mulder (ammulder@chariotsolutions.com) - * @version $Revision: 1.1 $ + * @version $Revision: 1.1.6.1 $ */ public class Jdbc3SimpleDataSourceTest extends SimpleDataSourceTest { /** @@ -29,16 +29,9 @@ public class Jdbc3SimpleDataSourceTest extends SimpleDataSourceTest { if (bds == null) { bds = new Jdbc3SimpleDataSource(); - String db = TestUtil.getURL(); - if (db.indexOf('/') > -1) - { - db = db.substring(db.lastIndexOf('/') + 1); - } - else if (db.indexOf(':') > -1) - { - db = db.substring(db.lastIndexOf(':') + 1); - } - bds.setDatabaseName(db); + bds.setServerName(TestUtil.getServer()); + bds.setPortNumber(TestUtil.getPort()); + bds.setDatabaseName(TestUtil.getDatabase()); bds.setUser(TestUtil.getUser()); bds.setPassword(TestUtil.getPassword()); }