This is an automated email from the git hooks/post-receive script. ebourg-guest pushed a commit to annotated tag REL9_3_1100 in repository libpostgresql-jdbc-java.
commit 816f50179f3bb65ece81f739b411fb1405a78f67 Author: Justin Santa Barbara <[email protected]> Date: Mon Feb 25 07:57:24 2013 -0800 Added unit test for wrapper functions --- org/postgresql/test/jdbc4/Jdbc4TestSuite.java | 1 + org/postgresql/test/jdbc4/WrapperTest.java | 107 ++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/org/postgresql/test/jdbc4/Jdbc4TestSuite.java b/org/postgresql/test/jdbc4/Jdbc4TestSuite.java index b54d970..0bf8b30 100644 --- a/org/postgresql/test/jdbc4/Jdbc4TestSuite.java +++ b/org/postgresql/test/jdbc4/Jdbc4TestSuite.java @@ -30,6 +30,7 @@ public class Jdbc4TestSuite extends TestSuite suite.addTestSuite(DatabaseMetaDataTest.class); suite.addTestSuite(ArrayTest.class); suite.addTestSuite(ConnectionTest.class); + suite.addTestSuite(WrapperTest.class); Connection connection = TestUtil.openDB(); try diff --git a/org/postgresql/test/jdbc4/WrapperTest.java b/org/postgresql/test/jdbc4/WrapperTest.java new file mode 100644 index 0000000..6351319 --- /dev/null +++ b/org/postgresql/test/jdbc4/WrapperTest.java @@ -0,0 +1,107 @@ +/*------------------------------------------------------------------------- +* +* Copyright (c) 2007-2013, PostgreSQL Global Development Group +* +* +*------------------------------------------------------------------------- +*/ +package org.postgresql.test.jdbc4; + +import java.sql.*; +import junit.framework.TestCase; + +import org.postgresql.PGConnection; +import org.postgresql.PGStatement; +import org.postgresql.test.TestUtil; + +public class WrapperTest extends TestCase { + + private Connection _conn; + private Statement _statement; + + public WrapperTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + _conn = TestUtil.openDB(); + _statement = _conn.prepareStatement("SELECT 1"); + } + + protected void tearDown() throws SQLException { + _statement.close(); + TestUtil.closeDB(_conn); + } + + /** + * This interface is private, and so cannot be supported by any wrapper + * + */ + private static interface PrivateInterface { + }; + + public void testConnectionIsWrapperForPrivate() throws SQLException { + assertFalse(_conn.isWrapperFor(PrivateInterface.class)); + } + + public void testConnectionIsWrapperForConnection() throws SQLException { + assertTrue(_conn.isWrapperFor(Connection.class)); + } + + public void testConnectionIsWrapperForPGConnection() throws SQLException { + assertTrue(_conn.isWrapperFor(PGConnection.class)); + } + + public void testConnectionUnwrapPrivate() throws SQLException { + try { + _conn.unwrap(PrivateInterface.class); + fail("unwrap of non-wrapped interface should fail"); + } catch (SQLException e) { + } + } + + public void testConnectionUnwrapConnection() throws SQLException { + Object v = _conn.unwrap(Connection.class); + assertNotNull(v); + assertTrue(v instanceof Connection); + } + + public void testConnectionUnwrapPGConnection() throws SQLException { + Object v = _conn.unwrap(PGConnection.class); + assertNotNull(v); + assertTrue(v instanceof PGConnection); + } + + public void testStatementIsWrapperForPrivate() throws SQLException { + assertFalse(_statement.isWrapperFor(PrivateInterface.class)); + } + + public void testStatementIsWrapperForStatement() throws SQLException { + assertTrue(_statement.isWrapperFor(Statement.class)); + } + + public void testStatementIsWrapperForPGStatement() throws SQLException { + assertTrue(_statement.isWrapperFor(PGStatement.class)); + } + + public void testStatementUnwrapPrivate() throws SQLException { + try { + _statement.unwrap(PrivateInterface.class); + fail("unwrap of non-wrapped interface should fail"); + } catch (SQLException e) { + } + } + + public void testStatementUnwrapStatement() throws SQLException { + Object v = _statement.unwrap(Statement.class); + assertNotNull(v); + assertTrue(v instanceof Statement); + } + + public void testStatementUnwrapPGStatement() throws SQLException { + Object v = _statement.unwrap(PGStatement.class); + assertNotNull(v); + assertTrue(v instanceof PGStatement); + } + +} -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

