use of org.neo4j.kernel.impl.coreapi.TopLevelTransaction in project neo4j by neo4j.
the class TopLevelTransactionTest method shouldShowTransactionTerminatedExceptionAsTransient.
@Test
public void shouldShowTransactionTerminatedExceptionAsTransient() throws Exception {
KernelTransaction kernelTransaction = mock(KernelTransaction.class);
doReturn(true).when(kernelTransaction).isOpen();
RuntimeException error = new TransactionTerminatedException(Status.Transaction.Terminated);
doThrow(error).when(kernelTransaction).close();
ThreadToStatementContextBridge bridge = new ThreadToStatementContextBridge();
TopLevelTransaction transaction = new TopLevelTransaction(kernelTransaction, bridge);
transaction.success();
try {
transaction.close();
fail("Should have failed");
} catch (Exception e) {
assertThat(e, instanceOf(TransientTransactionFailureException.class));
assertSame(error, e.getCause());
}
}
use of org.neo4j.kernel.impl.coreapi.TopLevelTransaction in project neo4j by neo4j.
the class GraphDatabaseFacadeTest method executeQueryStartDefaultTransaction.
@Test
public void executeQueryStartDefaultTransaction() {
KernelTransaction kernelTransaction = mock(KernelTransaction.class);
InternalTransaction transaction = new TopLevelTransaction(kernelTransaction, null);
when(queryService.beginTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED)).thenReturn(transaction);
graphDatabaseFacade.execute("create (n)");
graphDatabaseFacade.execute("create (n)", new HashMap<>());
long timeout = Config.embeddedDefaults().get(GraphDatabaseSettings.transaction_timeout);
verify(spi, times(2)).beginTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED, timeout);
}
Aggregations