use of org.neo4j.bolt.v3.messaging.request.BeginMessage in project neo4j by neo4j.
the class TransactionStreamingStateIT method getBoltStateMachineInTxStreamingState.
private BoltStateMachineV3 getBoltStateMachineInTxStreamingState() throws BoltConnectionFatality {
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
machine.process(new BeginMessage(), nullResponseHandler());
assertThat(machine.state()).isInstanceOf(TransactionReadyState.class);
machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k"), nullResponseHandler());
// tx streaming state
assertThat(machine.state()).isInstanceOf(TransactionStreamingState.class);
return machine;
}
use of org.neo4j.bolt.v3.messaging.request.BeginMessage in project neo4j by neo4j.
the class TransactionStreamingStateIT method shouldThrowExceptionOnIllegalMessagesInTxStreamingState.
private void shouldThrowExceptionOnIllegalMessagesInTxStreamingState(RequestMessage message) throws Throwable {
// Given
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
machine.process(new BeginMessage(), nullResponseHandler());
machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k"), nullResponseHandler());
assertThat(machine.state()).isInstanceOf(TransactionStreamingState.class);
// when
BoltResponseRecorder recorder = new BoltResponseRecorder();
verifyKillsConnection(() -> machine.process(message, recorder));
// then
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Request.Invalid));
assertNull(machine.state());
}
use of org.neo4j.bolt.v3.messaging.request.BeginMessage in project neo4j by neo4j.
the class TransactionReadyStateIT method getBoltStateMachineInTxReadyState.
private BoltStateMachineV3 getBoltStateMachineInTxReadyState() throws BoltConnectionFatality {
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
machine.process(new BeginMessage(), nullResponseHandler());
return machine;
}
use of org.neo4j.bolt.v3.messaging.request.BeginMessage in project neo4j by neo4j.
the class BoltResponseMessageWriterV3Test method shouldNotNotifyOutputWhenOutputItselfFails.
@Test
void shouldNotNotifyOutputWhenOutputItselfFails() throws Exception {
PackOutput output = mock(PackOutput.class);
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
IOException error = new IOException("Unable to flush");
doThrow(error).when(output).messageSucceeded();
var writer = newWriter(output, packer);
var e = assertThrows(IOException.class, () -> writer.write(new RecordMessage(new AnyValue[] { longValue(1), longValue(2) })));
assertEquals(error, e);
InOrder inOrder = inOrder(output, packer);
inOrder.verify(output).beginMessage();
inOrder.verify(packer).pack(longValue(1));
inOrder.verify(packer).pack(longValue(2));
inOrder.verify(output).messageSucceeded();
verify(output, never()).messageFailed();
}
use of org.neo4j.bolt.v3.messaging.request.BeginMessage in project neo4j by neo4j.
the class BoltResponseMessageWriterV3Test method shouldWriteRecordMessage.
@Test
void shouldWriteRecordMessage() throws Exception {
PackOutput output = mock(PackOutput.class);
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
var writer = newWriter(output, packer);
writer.write(new RecordMessage(new AnyValue[] { longValue(42), stringValue("42") }));
InOrder inOrder = inOrder(output, packer);
inOrder.verify(output).beginMessage();
inOrder.verify(packer).pack(longValue(42));
inOrder.verify(packer).pack(stringValue("42"));
inOrder.verify(output).messageSucceeded();
}
Aggregations