  @Test
  public void beginAndRollbackTransaction() throws Exception {

    transactionFactory.expectNoTransaction();
    transactionFactory.expectBeginTransaction();
    transactionFactory.expectSetRollbackOnly();
    transactionFactory.expectRollbackTransaction();
    transactionFactory.replay();


    try {

      // a mock that expects two proceed calls and returns the read only interceptor.

      final InvocationContext mock = createMock(InvocationContext.class);

      expect(mock.proceed()).andAnswer(new IAnswer<Object>() {
        public Object answer() throws Throwable {
          return readOnlyInterceptor.markReadOnly(mock);
        }
      });

      expect(mock.proceed()).andReturn(null);
      replay(mock);

      txInterceptor.applyTransaction(mock);

      verify(mock);
    } finally {
      transactionFactory.verify();
    }
  }