use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldTerminateOnAuthExpiryDuringREADYRun.
@SuppressWarnings("unchecked")
@Test
void shouldTerminateOnAuthExpiryDuringREADYRun() throws Throwable {
// Given
TransactionStateMachineSPI transactionSPI = mock(TransactionStateMachineSPI.class);
doThrow(new AuthorizationExpiredException("Auth expired!")).when(transactionSPI).beginTransaction(any(), any(), any(), any(), any(), any());
BoltStateMachine machine = newMachineWithTransactionSPI(transactionSPI);
// When & Then
try {
machine.process(BoltV4Messages.run("THIS WILL BE IGNORED"), nullResponseHandler());
fail("Exception expected");
} catch (BoltConnectionAuthFatality e) {
assertEquals("Auth expired!", e.getCause().getMessage());
}
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldSucceedOnResetOnFailedState.
@Test
void shouldSucceedOnResetOnFailedState() throws Exception {
// Given
BoltResponseRecorder recorder = new BoltResponseRecorder();
// Given a FAILED machine
BoltStateMachine machine = init(newMachine());
machine.markFailed(Neo4jError.from(Status.Request.NoThreadsAvailable, "No Threads Available"));
machine.process(BoltV4Messages.pullAll(), recorder);
// When I RESET...
machine.interrupt();
machine.markFailed(Neo4jError.from(Status.Request.NoThreadsAvailable, "No Threads Available"));
machine.process(BoltV4Messages.reset(), recorder);
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Request.NoThreadsAvailable));
// ...successfully
assertThat(recorder.nextResponse()).satisfies(succeeded());
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldRollbackOpenTransactionOnClose.
@Test
void shouldRollbackOpenTransactionOnClose() throws Throwable {
// Given a ready machine with an open transaction
final BoltStateMachine machine = newMachineWithTransaction();
// When the machine is shut down
machine.close();
// Then the transaction should have been rolled back
assertThat(machine).satisfies(hasNoTransaction());
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldBeAbleToKillMessagesAheadInLineWithAnInterrupt.
@Test
void shouldBeAbleToKillMessagesAheadInLineWithAnInterrupt() throws Throwable {
// Given
final BoltStateMachine machine = init(newMachine());
// When
machine.interrupt();
// ...and
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(BoltV4Messages.run(), recorder);
machine.process(BoltV4Messages.reset(), recorder);
machine.process(BoltV4Messages.run(), recorder);
// Then
assertThat(recorder.nextResponse()).satisfies(wasIgnored());
assertThat(recorder.nextResponse()).satisfies(succeeded());
assertThat(recorder.nextResponse()).satisfies(succeeded());
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method testUsingResetToAcknowledgeError.
@Test
void testUsingResetToAcknowledgeError() throws Throwable {
// Given
BoltResponseRecorder recorder = new BoltResponseRecorder();
// Given a FAILED machine
BoltStateMachine machine = init(newMachine());
machine.markFailed(Neo4jError.from(new RuntimeException()));
// When I RESET...
reset(machine, recorder);
// ...successfully
assertThat(recorder.nextResponse()).satisfies(succeeded());
// Then if I RUN a statement...
machine.process(BoltV4Messages.run(), recorder);
// ...everything should be fine again
assertThat(recorder.nextResponse()).satisfies(succeeded());
}
Aggregations