ConnectionProxy extends AbstractConnectionProxy { public void bind(String xid) { context.bind(xid); } ConnectionProxy(DataSourceProxy dataSourceProxy, Connection targetConnection); ConnectionContext getContext(); void bind(String xid); void setGlobalLockRequire(boolean isLock); boolean isGlobalLockRequire(); void checkLock(String lockKeys); boolean lockQuery(String lockKeys); void appendUndoLog(SQLUndoLog sqlUndoLog); void appendLockKey(String lockKey); @Override void commit(); @Override void rollback(); @Override void setAutoCommit(boolean autoCommit);  }
@Test public void testLockRetryPolicyRollbackOnConflict() throws Exception { boolean oldBranchRollbackFlag = (boolean) branchRollbackFlagField.get(null); branchRollbackFlagField.set(null, true); ConnectionProxy connectionProxy = new ConnectionProxy(dataSourceProxy, null); connectionProxy.bind(TEST_XID); Assertions.assertThrows(LockConflictException.class, connectionProxy::commit); branchRollbackFlagField.set(null, oldBranchRollbackFlag); }
@Test public void testLockRetryPolicyNotRollbackOnConflict() throws Exception { boolean oldBranchRollbackFlag = (boolean) branchRollbackFlagField.get(null); branchRollbackFlagField.set(null, false); ConnectionProxy connectionProxy = new ConnectionProxy(dataSourceProxy, null); connectionProxy.bind(TEST_XID); Assertions.assertThrows(LockWaitTimeoutException.class, connectionProxy::commit); branchRollbackFlagField.set(null, oldBranchRollbackFlag); }