@Test
public void rolledBackIfTransactionMarkedRollbackOnly() {

  Transactional transactional = createNiceMock(Transactional.class);
  EntityTransaction transaction = createStrictMock(EntityTransaction.class);
  expect(transaction.getRollbackOnly()).andReturn(true);
  transaction.rollback();
  replayAll();
  boolean canCommit = rollbackIfNecessary(transactional, null, transaction);
  Assert.assertFalse("Should be rolled back, since transaction was marked rollback-only", canCommit);
  verifyAll();
}