Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
test: DataSource.getConnection().unwrap(PGConnection.class)
- Loading branch information
Showing
with
14 additions
and
0 deletions.
-
+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)); |
|
|
} |
|
|