Skip to content

Commit

Permalink
test: DataSource.getConnection().unwrap(PGConnection.class)
Browse files Browse the repository at this point in the history
fixes #573
  • Loading branch information
davecramer authored and vlsi committed Jul 11, 2016
1 parent 6b3f2e0 commit f6b176e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pgjdbc/src/test/java/org/postgresql/test/jdbc4/WrapperTest.java
Expand Up @@ -10,6 +10,7 @@


import org.postgresql.PGConnection; import org.postgresql.PGConnection;
import org.postgresql.PGStatement; import org.postgresql.PGStatement;
import org.postgresql.ds.PGSimpleDataSource;
import org.postgresql.test.TestUtil; import org.postgresql.test.TestUtil;


import junit.framework.TestCase; import junit.framework.TestCase;
Expand Down Expand Up @@ -75,6 +76,19 @@ public void testConnectionUnwrapPGConnection() throws SQLException {
assertTrue(v instanceof PGConnection); assertTrue(v instanceof PGConnection);
} }


public void testConnectionUnwrapPGDataSource() throws SQLException {
PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setDatabaseName(TestUtil.getDatabase());
dataSource.setServerName(TestUtil.getServer());
dataSource.setPortNumber(TestUtil.getPort());
Connection connection = dataSource.getConnection(TestUtil.getUser(), TestUtil.getPassword());
assertNotNull("Unable to obtain a connection from PGSimpleDataSource", connection);
Object v = connection.unwrap(PGConnection.class);
assertTrue("connection.unwrap(PGConnection.class) should return PGConnection instance"
+ ", actual instance is " + v,
v instanceof PGConnection);
}

public void testStatementIsWrapperForPrivate() throws SQLException { public void testStatementIsWrapperForPrivate() throws SQLException {
assertFalse(_statement.isWrapperFor(PrivateInterface.class)); assertFalse(_statement.isWrapperFor(PrivateInterface.class));
} }
Expand Down

0 comments on commit f6b176e

Please sign in to comment.