Permalink
Browse files

test: DataSource.getConnection().unwrap(PGConnection.class)

fixes #573
  • Loading branch information...
davecramer authored and vlsi committed May 19, 2016
1 parent 6b3f2e0 commit f6b176ed6e7c2bbec5be294e3d419d624652747d
Showing with 14 additions and 0 deletions.
  1. +14 −0 pgjdbc/src/test/java/org/postgresql/test/jdbc4/WrapperTest.java
@@ -10,6 +10,7 @@

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

import junit.framework.TestCase;
@@ -75,6 +76,19 @@ public void testConnectionUnwrapPGConnection() throws SQLException {
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 {
assertFalse(_statement.isWrapperFor(PrivateInterface.class));
}

0 comments on commit f6b176e

Please sign in to comment.