OracleXAConnectionWrapper implements XAConnectionWrapper { @SuppressWarnings("unchecked") @SneakyThrows({SQLException.class, ReflectiveOperationException.class}) @Override public XAConnection wrap(final XADataSource xaDataSource, final Connection connection) { Connection physicalConnection = (Connection) connection.unwrap(Class.forName("oracle.jdbc.internal.OracleConnection")); Class clazz = Class.forName("oracle.jdbc.xa.client.OracleXAConnection"); Constructor constructor = clazz.getConstructor(Connection.class); return (XAConnection) constructor.newInstance(physicalConnection); }  @SuppressWarnings("unchecked") @SneakyThrows({SQLException.class, ReflectiveOperationException.class}) @Override XAConnection wrap(final XADataSource xaDataSource, final Connection connection);  }
@Test @Ignore("oracle jdbc driver is not import because of the limitations of license") public void assertCreateOracleConnection() throws SQLException { XAConnection actual = new OracleXAConnectionWrapper().wrap(xaDataSource, connection); assertThat(actual.getXAResource(), instanceOf(XAResource.class)); assertThat(actual.getConnection(), instanceOf(Connection.class)); }