use of org.apache.aries.tx.control.jdbc.xa.connection.impl.XAConnectionWrapper in project aries by apache.
the class XATxContextBindingEntityManagerTest method testActiveTransactionWrappedXAConnection.
@Test
public void testActiveTransactionWrappedXAConnection() throws SQLException {
XAConnection con = Mockito.mock(XAConnection.class);
Connection raw = Mockito.mock(Connection.class);
Mockito.when(con.getXAResource()).thenReturn(xaResource);
Mockito.when(con.getConnection()).thenReturn(raw);
XAConnectionWrapper value = new XAConnectionWrapper(con);
Mockito.when(rawEm.unwrap(Connection.class)).thenReturn(value);
setupActiveTransaction();
em.isOpen();
em.isOpen();
Mockito.verify(rawEm, times(2)).isOpen();
Mockito.verify(rawEm).joinTransaction();
checkPostCompletion(null);
}
use of org.apache.aries.tx.control.jdbc.xa.connection.impl.XAConnectionWrapper in project aries by apache.
the class XATxContextBindingEntityManagerTest method testActiveTransactionUnwrappableXAConnectionWrapper.
@Test
public void testActiveTransactionUnwrappableXAConnectionWrapper() throws SQLException {
XAConnection xaCon = Mockito.mock(XAConnection.class);
Mockito.when(xaCon.getXAResource()).thenReturn(xaResource);
Connection con = Mockito.mock(Connection.class);
XAConnectionWrapper toReturn = new XAConnectionWrapper(xaCon);
Mockito.when(con.unwrap(XAConnectionWrapper.class)).thenReturn(toReturn);
Mockito.when(con.isWrapperFor(XAConnectionWrapper.class)).thenReturn(true);
Mockito.when(rawEm.unwrap(Connection.class)).thenReturn(con);
setupActiveTransaction();
em.isOpen();
em.isOpen();
Mockito.verify(rawEm, times(2)).isOpen();
Mockito.verify(rawEm).joinTransaction();
checkPostCompletion(null);
}
Aggregations