use of org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPI in project neo4j by neo4j.
the class TransactionStateMachineTest method shouldCloseResultHandlesWhenExecutionFailsInExplicitTransaction.
@Test
void shouldCloseResultHandlesWhenExecutionFailsInExplicitTransaction() throws Exception {
BoltTransaction transaction = newTransaction();
BoltResultHandle resultHandle = newResultHandle(new RuntimeException("some error"));
TransactionStateMachineSPI stateMachineSPI = newTransactionStateMachineSPI(transaction, resultHandle);
TransactionStateMachine stateMachine = newTransactionStateMachine(stateMachineSPI);
RuntimeException e = assertThrows(RuntimeException.class, () -> {
beginTx(stateMachine);
stateMachine.run("SOME STATEMENT", null);
});
assertEquals("some error", e.getMessage());
assertThat(stateMachine.ctx.statementOutcomes.entrySet()).hasSize(0);
assertNotNull(stateMachine.ctx.currentTransaction);
}
use of org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPI in project neo4j by neo4j.
the class TransactionStateMachineTest method shouldCloseResultAndTransactionHandlesWhenExecutionFails.
@Test
void shouldCloseResultAndTransactionHandlesWhenExecutionFails() throws Exception {
BoltTransaction transaction = newTransaction();
BoltResultHandle resultHandle = newResultHandle(new RuntimeException("some error"));
TransactionStateMachineSPI stateMachineSPI = newTransactionStateMachineSPI(transaction, resultHandle);
TransactionStateMachine stateMachine = newTransactionStateMachine(stateMachineSPI);
RuntimeException e = assertThrows(RuntimeException.class, () -> stateMachine.run("SOME STATEMENT", null));
assertEquals("some error", e.getMessage());
assertThat(stateMachine.ctx.statementOutcomes.entrySet()).hasSize(0);
assertNull(stateMachine.ctx.currentTransaction);
}
use of org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPI in project neo4j by neo4j.
the class StatementProcessorProvider method getStatementProcessor.
public StatementProcessor getStatementProcessor(String databaseName) throws BoltProtocolBreachFatality, BoltIOException {
memoryTracker.allocateHeap(TransactionStateMachine.SHALLOW_SIZE);
TransactionStateMachineSPI transactionSPI = spiProvider.getTransactionStateMachineSPI(databaseName, resourceReleaseManger);
return new TransactionStateMachine(databaseName, transactionSPI, authResult, clock, routingContext);
}
use of org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPI in project neo4j by neo4j.
the class TransactionStateMachineSPIProviderV4Test method shouldReturnTransactionStateMachineSPIIfDatabaseExists.
@Test
void shouldReturnTransactionStateMachineSPIIfDatabaseExists() throws Throwable {
String databaseName = "database";
DatabaseManagementService managementService = managementService(databaseName);
TransactionStateMachineSPIProvider spiProvider = newSpiProvider(managementService);
TransactionStateMachineSPI spi = spiProvider.getTransactionStateMachineSPI(databaseName, mock(StatementProcessorReleaseManager.class));
assertThat(spi).isInstanceOf(TransactionStateMachineV4SPI.class);
}
use of org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPI in project neo4j by neo4j.
the class DefaultDatabaseTransactionStateMachineSPIProviderTest method shouldReturnDefaultTransactionStateMachineSPIWithEmptyDatabaseName.
@Test
void shouldReturnDefaultTransactionStateMachineSPIWithEmptyDatabaseName() throws Throwable {
DatabaseManagementService managementService = managementServiceWithDatabase("neo4j");
TransactionStateMachineSPIProvider spiProvider = newSpiProvider(managementService);
TransactionStateMachineSPI spi = spiProvider.getTransactionStateMachineSPI(ABSENT_DB_NAME, mock(StatementProcessorReleaseManager.class));
assertThat(spi).isInstanceOf(TransactionStateMachineSPI.class);
}
Aggregations