Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b720fa9

Browse files
author
Dave Cramer
committed
patch for rs.previous and test case as well as patch for allowing server and port to be specified in test cases
1 parent efea5da commit b720fa9

9 files changed

+42
-68
lines changed

src/interfaces/jdbc/build.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
This file now requires Ant 1.4.1. 2002-04-18
88
9-
$Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/build.xml,v 1.36 2003/08/24 22:10:09 barry Exp $
9+
$Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/build.xml,v 1.37 2003/11/03 15:28:26 davec Exp $
1010
1111
-->
1212

@@ -305,7 +305,9 @@
305305
<!-- This compiles and executes the JUnit tests -->
306306

307307
<!-- defaults for the tests - override these if required -->
308-
<property name="database" value="jdbc:postgresql:test" />
308+
<property name="server" value="localhost" />
309+
<property name="port" value="${def_pgport}" />
310+
<property name="database" value="test" />
309311
<property name="username" value="test" />
310312
<!-- Password must be something. Doesn't matter if trust is used! -->
311313
<property name="password" value="password" />
@@ -337,6 +339,8 @@
337339
<junit>
338340
<formatter type="brief" usefile="false"/>
339341

342+
<sysproperty key="server" value="${server}" />
343+
<sysproperty key="port" value="${port}" />
340344
<sysproperty key="database" value="${database}" />
341345
<sysproperty key="username" value="${username}" />
342346
<sysproperty key="password" value="${password}" />

src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Copyright (c) 2003, PostgreSQL Global Development Group
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.25 2003/10/29 02:39:09 davec Exp $
12+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.26 2003/11/03 15:28:26 davec Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -493,6 +493,7 @@ public boolean previous() throws SQLException
493493
if (--current_row < 0)
494494
return false;
495495
this_row = (byte[][]) rows.elementAt(current_row);
496+
rowBuffer = new byte[this_row.length][];
496497
System.arraycopy(this_row, 0, rowBuffer, 0, this_row.length);
497498
return true;
498499
}

src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ protected void tearDown() throws Exception
8383
TestUtil.closeDB(con);
8484
}
8585

86+
public void testBackward() throws Exception
87+
{
88+
Statement stmt = con.createStatement();
89+
ResultSet rs = stmt.executeQuery("SELECT * FROM testrs");
90+
rs.afterLast();
91+
assertTrue(rs.previous());
92+
rs.close();
93+
stmt.close();
94+
}
95+
8696
public void testAbsolute() throws Exception
8797
{
8898
Statement stmt = con.createStatement();

src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java

+4-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* interface to the PooledConnection is through the CPDS.
1212
*
1313
* @author Aaron Mulder (ammulder@chariotsolutions.com)
14-
* @version $Revision: 1.6 $
14+
* @version $Revision: 1.7 $
1515
*/
1616
public class ConnectionPoolTest extends BaseDataSourceTest
1717
{
@@ -31,16 +31,9 @@ protected void initializeDataSource()
3131
if (bds == null)
3232
{
3333
bds = new ConnectionPool();
34-
String db = TestUtil.getURL();
35-
if (db.indexOf('/') > -1)
36-
{
37-
db = db.substring(db.lastIndexOf('/') + 1);
38-
}
39-
else if (db.indexOf(':') > -1)
40-
{
41-
db = db.substring(db.lastIndexOf(':') + 1);
42-
}
43-
bds.setDatabaseName(db);
34+
bds.setServerName(TestUtil.getServer());
35+
bds.setPortNumber(TestUtil.getPort());
36+
bds.setDatabaseName(TestUtil.getDatabase());
4437
bds.setUser(TestUtil.getUser());
4538
bds.setPassword(TestUtil.getPassword());
4639
}

src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/PoolingDataSourceTest.java

+4-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Minimal tests for pooling DataSource. Needs many more.
1010
*
1111
* @author Aaron Mulder (ammulder@chariotsolutions.com)
12-
* @version $Revision: 1.1 $
12+
* @version $Revision: 1.2 $
1313
*/
1414
public class PoolingDataSourceTest extends BaseDataSourceTest
1515
{
@@ -40,16 +40,9 @@ protected void initializeDataSource()
4040
if (bds == null)
4141
{
4242
bds = new PoolingDataSource();
43-
String db = TestUtil.getURL();
44-
if (db.indexOf('/') > -1)
45-
{
46-
db = db.substring(db.lastIndexOf('/') + 1);
47-
}
48-
else if (db.indexOf(':') > -1)
49-
{
50-
db = db.substring(db.lastIndexOf(':') + 1);
51-
}
52-
bds.setDatabaseName(db);
43+
bds.setServerName(TestUtil.getServer());
44+
bds.setPortNumber(TestUtil.getPort());
45+
bds.setDatabaseName(TestUtil.getDatabase());
5346
bds.setUser(TestUtil.getUser());
5447
bds.setPassword(TestUtil.getPassword());
5548
((PoolingDataSource) bds).setDataSourceName(DS_NAME);

src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java

+4-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* configuration logic.
99
*
1010
* @author Aaron Mulder (ammulder@chariotsolutions.com)
11-
* @version $Revision: 1.3 $
11+
* @version $Revision: 1.4 $
1212
*/
1313
public class SimpleDataSourceTest extends BaseDataSourceTest
1414
{
@@ -28,16 +28,9 @@ protected void initializeDataSource()
2828
if (bds == null)
2929
{
3030
bds = new SimpleDataSource();
31-
String db = TestUtil.getURL();
32-
if (db.indexOf('/') > -1)
33-
{
34-
db = db.substring(db.lastIndexOf('/') + 1);
35-
}
36-
else if (db.indexOf(':') > -1)
37-
{
38-
db = db.substring(db.lastIndexOf(':') + 1);
39-
}
40-
bds.setDatabaseName(db);
31+
bds.setServerName(TestUtil.getServer());
32+
bds.setPortNumber(TestUtil.getPort());
33+
bds.setDatabaseName(TestUtil.getDatabase());
4134
bds.setUser(TestUtil.getUser());
4235
bds.setPassword(TestUtil.getPassword());
4336
}

src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3ConnectionPoolTest.java

+4-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Tests JDBC3 implementation of ConnectionPoolDataSource.
1313
*
1414
* @author Aaron Mulder (ammulder@chariotsolutions.com)
15-
* @version $Revision: 1.2 $
15+
* @version $Revision: 1.3 $
1616
*/
1717
public class Jdbc3ConnectionPoolTest extends ConnectionPoolTest
1818
{
@@ -29,16 +29,9 @@ protected void initializeDataSource()
2929
if (bds == null)
3030
{
3131
bds = new Jdbc3ConnectionPool();
32-
String db = TestUtil.getURL();
33-
if (db.indexOf('/') > -1)
34-
{
35-
db = db.substring(db.lastIndexOf('/') + 1);
36-
}
37-
else if (db.indexOf(':') > -1)
38-
{
39-
db = db.substring(db.lastIndexOf(':') + 1);
40-
}
41-
bds.setDatabaseName(db);
32+
bds.setServerName(TestUtil.getServer());
33+
bds.setPortNumber(TestUtil.getPort());
34+
bds.setDatabaseName(TestUtil.getDatabase());
4235
bds.setUser(TestUtil.getUser());
4336
bds.setPassword(TestUtil.getPassword());
4437
}

src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3PoolingDataSourceTest.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Minimal tests for JDBC3 pooling DataSource. Needs many more.
1414
*
1515
* @author Aaron Mulder (ammulder@chariotsolutions.com)
16-
* @version $Revision: 1.1 $
16+
* @version $Revision: 1.2 $
1717
*/
1818
public class Jdbc3PoolingDataSourceTest extends PoolingDataSourceTest
1919
{
@@ -42,15 +42,9 @@ protected void initializeDataSource()
4242
private void configureDataSource(PoolingDataSource source)
4343
{
4444
String db = TestUtil.getURL();
45-
if (db.indexOf('/') > -1)
46-
{
47-
db = db.substring(db.lastIndexOf('/') + 1);
48-
}
49-
else if (db.indexOf(':') > -1)
50-
{
51-
db = db.substring(db.lastIndexOf(':') + 1);
52-
}
53-
source.setDatabaseName(db);
45+
source.setServerName(TestUtil.getServer());
46+
source.setPortNumber(TestUtil.getPort());
47+
source.setDatabaseName(TestUtil.getDatabase());
5448
source.setUser(TestUtil.getUser());
5549
source.setPassword(TestUtil.getPassword());
5650
source.setDataSourceName(DS_NAME);

src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3SimpleDataSourceTest.java

+4-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Tests JDBC3 non-pooling DataSource.
1111
*
1212
* @author Aaron Mulder (ammulder@chariotsolutions.com)
13-
* @version $Revision: 1.1 $
13+
* @version $Revision: 1.2 $
1414
*/
1515
public class Jdbc3SimpleDataSourceTest extends SimpleDataSourceTest {
1616
/**
@@ -29,16 +29,9 @@ protected void initializeDataSource()
2929
if (bds == null)
3030
{
3131
bds = new Jdbc3SimpleDataSource();
32-
String db = TestUtil.getURL();
33-
if (db.indexOf('/') > -1)
34-
{
35-
db = db.substring(db.lastIndexOf('/') + 1);
36-
}
37-
else if (db.indexOf(':') > -1)
38-
{
39-
db = db.substring(db.lastIndexOf(':') + 1);
40-
}
41-
bds.setDatabaseName(db);
32+
bds.setServerName(TestUtil.getServer());
33+
bds.setPortNumber(TestUtil.getPort());
34+
bds.setDatabaseName(TestUtil.getDatabase());
4235
bds.setUser(TestUtil.getUser());
4336
bds.setPassword(TestUtil.getPassword());
4437
}

0 commit comments

Comments
 (0)