private static TransactionContext requireCurrentTransactionContext() { TransactionContext txContext = TransactionContextHolder.getCurrentTransactionContext(); if (txContext == null) { throw new IllegalStateException("TransactionContext is not active"); } return txContext; }
/** * Determine whether a test-managed transaction is currently <em>active</em>. * * @return {@code true} if a test-managed transaction is currently active * @see #start() * @see #end() */ public static boolean isActive() { TransactionContext transactionContext = TransactionContextHolder.getCurrentTransactionContext(); if (transactionContext != null) { TransactionStatus transactionStatus = transactionContext.getTransactionStatus(); return (transactionStatus != null) && (!transactionStatus.isCompleted()); } // else return false; }