@Test
public void rolledBackForKnownException() {

  Transactional transactional = createNiceMock(Transactional.class);
  EntityTransaction transaction = createStrictMock(EntityTransaction.class);
  expect(transaction.getRollbackOnly()).andReturn(false);
  expect(transactional.rollbackOn()).andReturn(asArray(NullPointerException.class, IllegalArgumentException.class));
  expect(transactional.ignore()).andReturn(asArray());
  transaction.rollback();
  replayAll();
  boolean canCommit = rollbackIfNecessary(transactional, new IllegalArgumentException("rolling back"), transaction);
  Assert.assertFalse("Should be rolled back, since exception matches rollbackOn clause", canCommit);
  verifyAll();
}