Package bitronix.tm.mock.events

Examples of bitronix.tm.mock.events.EventRecorder


        // Setup mock XAConnection
        final XAConnection mockXAConnection = mock(XAConnection.class);
        // Handle XAConnection.close(), first time we answer, after that we throw
        doAnswer(new Answer<Object>() {
      public Object answer(InvocationOnMock invocation) throws Throwable {
        EventRecorder eventRecorder = EventRecorder.getEventRecorder(mockXAConnection);
        eventRecorder.addEvent(new XAConnectionCloseEvent(mockXAConnection));
        return null;
      }
    }).doThrow(new SQLException("XAConnection is already closed")).when(mockXAConnection).close();

        when(mockXAConnection.getXAResource()).thenReturn(xaResource);
View Full Code Here


        when(mockConnection.prepareCall(anyString(), anyInt(), anyInt(), anyInt())).thenReturn(mockCallableStatement);

        // Handle Connection.close()
        doAnswer(new Answer() {
      public Object answer(InvocationOnMock invocation) throws Throwable {
        EventRecorder eventRecorder = EventRecorder.getEventRecorder(mockConnection);
        eventRecorder.addEvent(new ConnectionCloseEvent(mockConnection));
        return null;
      }
        }).doThrow(new SQLException("Connection is already closed")).when(mockConnection).close();

        // Handle Connection.commit()
        doAnswer(new Answer() {
      public Object answer(InvocationOnMock invocation) throws Throwable {
        EventRecorder eventRecorder = EventRecorder.getEventRecorder(mockConnection);
        eventRecorder.addEvent(new LocalCommitEvent(mockConnection, new Exception()));
        return null;
      }
        }).doThrow(new SQLException("Transaction already commited")).when(mockConnection).commit();

        // Handle Connection.rollback()
        doAnswer(new Answer() {
      public Object answer(InvocationOnMock invocation) throws Throwable {
        EventRecorder eventRecorder = EventRecorder.getEventRecorder(mockConnection);
        eventRecorder.addEvent(new LocalRollbackEvent(mockConnection, new Exception()));
        return null;
      }
        }).doThrow(new SQLException("Transaction already rolledback")).when(mockConnection).rollback();

        return mockConnection;
View Full Code Here

TOP

Related Classes of bitronix.tm.mock.events.EventRecorder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.