use of org.neo4j.bolt.runtime.SynchronousBoltConnection in project neo4j by neo4j.
the class BoltRequestMessageReaderTest method shouldHandleErrorThatCausesFailureMessage.
@Test
void shouldHandleErrorThatCausesFailureMessage() throws Exception {
Unpacker unpacker = mock(Unpacker.class);
BoltIOException error = new BoltIOException(Status.General.UnknownError, "Hello");
when(unpacker.unpackStructHeader()).thenThrow(error);
BoltStateMachine stateMachine = mock(BoltStateMachine.class);
BoltConnection connection = new SynchronousBoltConnection(stateMachine);
BoltResponseHandler externalErrorResponseHandler = responseHandlerMock();
BoltRequestMessageReader reader = new TestBoltRequestMessageReader(connection, externalErrorResponseHandler, emptyList(), mock(ChannelProtector.class));
reader.read(unpacker);
verify(stateMachine).handleExternalFailure(Neo4jError.from(error), externalErrorResponseHandler);
}
use of org.neo4j.bolt.runtime.SynchronousBoltConnection in project neo4j by neo4j.
the class BoltRequestMessageReaderTest method shouldDecodeKnownMessage.
@Test
void shouldDecodeKnownMessage() throws Exception {
Unpacker unpacker = mock(Unpacker.class);
when(unpacker.unpackStructSignature()).thenReturn('a');
RequestMessage message = mock(RequestMessage.class);
BoltResponseHandler responseHandler = responseHandlerMock();
RequestMessageDecoder decoder = new TestRequestMessageDecoder('a', responseHandler, message);
BoltStateMachine stateMachine = mock(BoltStateMachine.class);
BoltConnection connection = new SynchronousBoltConnection(stateMachine);
BoltRequestMessageReader reader = new TestBoltRequestMessageReader(connection, responseHandlerMock(), singletonList(decoder), mock(ChannelProtector.class));
reader.read(unpacker);
verify(stateMachine).process(message, responseHandler);
}
Aggregations