Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.PGStatement;
import org.postgresql.ds.PGSimpleDataSource;
import org.postgresql.test.TestUtil;

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

public void testConnectionUnwrapPGDataSource() throws SQLException {
PGSimpleDataSource dataSource = new PGSimpleDataSource();
assertNotNull(dataSource);
dataSource.setDatabaseName(TestUtil.getDatabase());
dataSource.setServerName(TestUtil.getServer());
dataSource.setPortNumber(TestUtil.getPort());
Connection connection = dataSource.getConnection(TestUtil.getUser(),TestUtil.getPassword());
assertNotNull(connection);
Object v=connection.unwrap(PGConnection.class);
assertNotNull(v);
assertTrue(v instanceof PGConnection);

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