use of io.seata.rm.datasource.mock.MockLockConflictConnectionProxy in project seata by seata.
the class SelectForUpdateExecutorTest method testDoExecute.
@Test
public void testDoExecute() throws Throwable {
Assertions.assertThrows(RuntimeException.class, () -> selectForUpdateExecutor.doExecute((Object) null));
RootContext.bind("xid");
Assertions.assertDoesNotThrow(() -> {
selectForUpdateExecutor.doExecute((Object) null);
});
RootContext.unbind();
RootContext.bindGlobalLockFlag();
Assertions.assertDoesNotThrow(() -> {
selectForUpdateExecutor.doExecute((Object) null);
});
RootContext.unbindGlobalLockFlag();
connectionProxy = new MockLockConflictConnectionProxy(connectionProxy.getDataSourceProxy(), connectionProxy.getTargetConnection());
statementProxy = new StatementProxy(connectionProxy, statementProxy.getTargetStatement());
statementProxy.getTargetStatement().getConnection().setAutoCommit(false);
String sql = "select * from dual";
List<SQLStatement> asts = SQLUtils.parseStatements(sql, JdbcConstants.MYSQL);
MySQLSelectForUpdateRecognizer recognizer = new MySQLSelectForUpdateRecognizer(sql, asts.get(0));
selectForUpdateExecutor = new SelectForUpdateExecutor(statementProxy, (statement, args) -> null, recognizer);
RootContext.bind("xid");
Assertions.assertThrows(LockWaitTimeoutException.class, () -> selectForUpdateExecutor.doExecute((Object) null));
RootContext.unbind();
}
Aggregations