MySQLXAConnectionWrapper implements XAConnectionWrapper { @SneakyThrows(ReflectiveOperationException.class) @Override public XAConnection wrap(final XADataSource xaDataSource, final Connection connection) { Connection physicalConnection = unwrapPhysicalConnection(xaDataSource.getClass().getName(), connection); Method method = xaDataSource.getClass().getDeclaredMethod("wrapConnection", Connection.class); method.setAccessible(true); return (XAConnection) method.invoke(xaDataSource, physicalConnection); }  @SneakyThrows(ReflectiveOperationException.class) @Override XAConnection wrap(final XADataSource xaDataSource, final Connection connection);  }
@Test public void assertCreateMySQLConnection() throws SQLException { XAConnection actual = new MySQLXAConnectionWrapper().wrap(xaDataSource, connection); assertThat(actual.getXAResource(), instanceOf(XAResource.class)); assertThat(actual.getConnection(), instanceOf(Connection.class)); }