use of org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider in project neo4j by neo4j.
the class BoltV4MachineRoom method newMachineWithTransactionSPI.
public static BoltStateMachine newMachineWithTransactionSPI(TransactionStateMachineSPI transactionSPI) throws BoltConnectionFatality, BoltIOException {
BoltStateMachineSPI spi = mock(BoltStateMachineSPI.class, RETURNS_MOCKS);
TransactionStateMachineSPIProvider transactionSPIProvider = mock(TransactionStateMachineSPIProvider.class);
var memoryTracker = mock(MemoryTracker.class);
when(transactionSPIProvider.getTransactionStateMachineSPI(any(String.class), any(StatementProcessorReleaseManager.class))).thenReturn(transactionSPI);
when(spi.transactionStateMachineSPIProvider()).thenReturn(transactionSPIProvider);
BoltChannel boltChannel = BoltTestUtil.newTestBoltChannel();
BoltStateMachine machine = new BoltStateMachineV4(spi, boltChannel, Clock.systemUTC(), mock(DefaultDatabaseResolver.class), MapValue.EMPTY, memoryTracker);
init(machine);
return machine;
}
use of org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider in project neo4j by neo4j.
the class DefaultDatabaseTransactionStateMachineSPIProviderTest method shouldErrorIfDatabaseNotFound.
@Test
void shouldErrorIfDatabaseNotFound() {
DatabaseManagementService managementService = managementServiceWithDatabase("database");
TransactionStateMachineSPIProvider spiProvider = newSpiProvider(managementService);
BoltProtocolBreachFatality error = assertThrows(BoltProtocolBreachFatality.class, () -> spiProvider.getTransactionStateMachineSPI("database", mock(StatementProcessorReleaseManager.class)));
assertThat(error.getMessage()).contains("Database selection by name not supported by Bolt protocol version lower than BoltV4.");
}
use of org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider 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.TransactionStateMachineSPIProvider in project neo4j by neo4j.
the class BoltStateMachineContextImpl method initStatementProcessorProvider.
@Override
public void initStatementProcessorProvider(AuthenticationResult authResult, RoutingContext routingContext) {
TransactionStateMachineSPIProvider transactionSpiProvider = spi.transactionStateMachineSPIProvider();
setStatementProcessorProvider(new StatementProcessorProvider(authResult, transactionSpiProvider, clock, this, routingContext, memoryTracker));
}
use of org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider 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