Search in sources :

Example 1 with TransactionStateMachineSPIProvider

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;
}
Also used : StatementProcessorReleaseManager(org.neo4j.bolt.runtime.statemachine.StatementProcessorReleaseManager) BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) BoltChannel(org.neo4j.bolt.BoltChannel) BoltStateMachineV4(org.neo4j.bolt.v4.BoltStateMachineV4) DefaultDatabaseResolver(org.neo4j.kernel.database.DefaultDatabaseResolver) BoltStateMachineSPI(org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI) TransactionStateMachineSPIProvider(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider)

Example 2 with TransactionStateMachineSPIProvider

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.");
}
Also used : DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) TransactionStateMachineSPIProvider(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider) BoltProtocolBreachFatality(org.neo4j.bolt.runtime.BoltProtocolBreachFatality) Test(org.junit.jupiter.api.Test)

Example 3 with TransactionStateMachineSPIProvider

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);
}
Also used : StatementProcessorReleaseManager(org.neo4j.bolt.runtime.statemachine.StatementProcessorReleaseManager) TransactionStateMachineSPI(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPI) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) TransactionStateMachineSPIProvider(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider) Test(org.junit.jupiter.api.Test)

Example 4 with TransactionStateMachineSPIProvider

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));
}
Also used : TransactionStateMachineSPIProvider(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider)

Example 5 with TransactionStateMachineSPIProvider

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);
}
Also used : StatementProcessorReleaseManager(org.neo4j.bolt.runtime.statemachine.StatementProcessorReleaseManager) TransactionStateMachineSPI(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPI) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) TransactionStateMachineSPIProvider(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionStateMachineSPIProvider (org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider)7 Test (org.junit.jupiter.api.Test)5 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)5 StatementProcessorReleaseManager (org.neo4j.bolt.runtime.statemachine.StatementProcessorReleaseManager)4 TransactionStateMachineSPI (org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPI)3 BoltChannel (org.neo4j.bolt.BoltChannel)1 BoltIOException (org.neo4j.bolt.messaging.BoltIOException)1 BoltProtocolBreachFatality (org.neo4j.bolt.runtime.BoltProtocolBreachFatality)1 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)1 BoltStateMachineSPI (org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI)1 BoltStateMachineV4 (org.neo4j.bolt.v4.BoltStateMachineV4)1 DatabaseNotFoundException (org.neo4j.dbms.api.DatabaseNotFoundException)1 DefaultDatabaseResolver (org.neo4j.kernel.database.DefaultDatabaseResolver)1