PostgreSQLXAConnectionWrapper implements XAConnectionWrapper { @SneakyThrows({SQLException.class, ClassNotFoundException.class}) @Override public XAConnection wrap(final XADataSource xaDataSource, final Connection connection) { BaseConnection physicalConnection = (BaseConnection) connection.unwrap(Class.forName("org.postgresql.core.BaseConnection")); return new PGXAConnection(physicalConnection); }  @SneakyThrows({SQLException.class, ClassNotFoundException.class}) @Override XAConnection wrap(final XADataSource xaDataSource, final Connection connection);  }
@Test public void assertCreatePostgreSQLConnection() throws SQLException { XAConnection actual = new PostgreSQLXAConnectionWrapper().wrap(xaDataSource, connection); assertThat(actual.getXAResource(), instanceOf(XAResource.class)); assertThat(actual.getConnection(), instanceOf(Connection.class)); }