CatTransactionMonitor implements TransactionMonitor { @Override public void logTransaction(String type, String name, Task task) throws Exception { Transaction transaction = Cat.newTransaction(type, name); try{ task.go(); transaction.setStatus(Transaction.SUCCESS); }catch(Exception th){ transaction.setStatus(th); throw th; }finally{ transaction.complete(); } }  @Override void logTransactionSwallowException(String type, String name, Task task); @Override void logTransaction(String type, String name, Task task); @Override V logTransaction(String type, String name, Callable<V> task); @Override V logTransactionSwallowException(String type, String name, Callable<V> task); static Logger logger; }
@Test public void testSuccess() throws Throwable{ CatTransactionMonitor monitor = new CatTransactionMonitor(); monitor.logTransaction("test", getTestName(), new Task() { @Override public void go() throws Exception { } }); }
@Test public void testFailure() throws Throwable{ CatTransactionMonitor monitor = new CatTransactionMonitor(); monitor.logTransaction("test", getTestName(), new Task() { @Override public void go() throws Exception { throw new Exception("just fail"); } }); }