test: 添加事务异常测试用例

This commit is contained in:
2026-06-05 22:05:27 +08:00
parent 0b3675d3a4
commit 721d0bbd5e

View File

@@ -231,4 +231,15 @@ class TransactionTest extends BaseH2Test {
assertThrows(Exception.class, () ->
template.transaction().execute(null));
}
// ==================== TransactionException ====================
@Test
@DisplayName("TransactionException双参构造器")
void testTransactionExceptionWithMessage() {
RuntimeException cause = new RuntimeException("原始异常");
TransactionException ex = new TransactionException("自定义消息", cause);
assertEquals("自定义消息", ex.getMessage());
assertSame(cause, ex.getCause());
}
}