use of org.neo4j.bolt.messaging.BoltResponseMessageWriter in project neo4j by neo4j.
the class MessageProcessingHandlerTest method shouldCallHaltOnUnexpectedFailures.
@Test
void shouldCallHaltOnUnexpectedFailures() throws Exception {
// Given
BoltResponseMessageWriter msgWriter = newResponseHandlerMock();
doThrow(new RuntimeException("Something went horribly wrong")).when(msgWriter).write(any(SuccessMessage.class));
BoltConnection connection = mock(BoltConnection.class);
MessageProcessingHandler handler = new MessageProcessingHandler(msgWriter, connection, mock(Log.class));
// When
handler.onFinish();
// Then
verify(connection).stop();
}
use of org.neo4j.bolt.messaging.BoltResponseMessageWriter in project neo4j by neo4j.
the class MessageProcessingHandlerTest method emulateFailureWritingError.
private static AssertableLogProvider emulateFailureWritingError(Neo4jError error, Throwable errorDuringWrite) throws Exception {
AssertableLogProvider logProvider = new AssertableLogProvider();
BoltResponseMessageWriter responseHandler = newResponseHandlerMock(errorDuringWrite);
MessageProcessingHandler handler = new MessageProcessingHandler(responseHandler, mock(BoltConnection.class), logProvider.getLog(MessageProcessingHandlerTest.class));
handler.markFailed(error);
handler.onFinish();
return logProvider;
}
use of org.neo4j.bolt.messaging.BoltResponseMessageWriter in project neo4j by neo4j.
the class MessageDecoderTest method shouldLogContentOfTheMessageOnIOError.
@ParameterizedTest
@MethodSource("argumentsProvider")
public void shouldLogContentOfTheMessageOnIOError(Neo4jPack packerUnderTest) throws Exception {
this.packerUnderTest = packerUnderTest;
BoltConnection connection = mock(BoltConnection.class);
BoltResponseMessageWriter responseMessageHandler = mock(BoltResponseMessageWriter.class);
BoltRequestMessageReader requestMessageReader = new BoltRequestMessageReaderV3(connection, responseMessageHandler, mock(ChannelProtector.class), NullLogService.getInstance());
LogService logService = mock(LogService.class);
Log log = mock(Log.class);
when(logService.getInternalLog(MessageDecoder.class)).thenReturn(log);
channel = new EmbeddedChannel(new MessageDecoder(packerUnderTest::newUnpacker, requestMessageReader, logService));
byte invalidMessageSignature = Byte.MAX_VALUE;
byte[] messageBytes = packMessageWithSignature(invalidMessageSignature);
assertThrows(BoltIOException.class, () -> channel.writeInbound(Unpooled.wrappedBuffer(messageBytes)));
assertMessageHexDumpLogged(log, messageBytes);
}
use of org.neo4j.bolt.messaging.BoltResponseMessageWriter in project neo4j by neo4j.
the class MessageConditions method serialize.
public static byte[] serialize(Neo4jPack neo4jPack, ResponseMessage... messages) throws IOException {
RecordingByteChannel rawData = new RecordingByteChannel();
BufferedChannelOutput output = new BufferedChannelOutput(rawData);
BoltResponseMessageWriter writer = new BoltResponseMessageWriterV3(neo4jPack::newPacker, output, NullLogService.getInstance());
for (ResponseMessage message : messages) {
writer.write(message);
}
writer.flush();
return rawData.getBytes();
}
use of org.neo4j.bolt.messaging.BoltResponseMessageWriter in project neo4j by neo4j.
the class MessageProcessingHandlerTest method newResponseHandlerMock.
private static BoltResponseMessageWriter newResponseHandlerMock(Throwable error) throws Exception {
BoltResponseMessageWriter handler = newResponseHandlerMock();
doThrow(error).when(handler).write(any(FailureMessage.class));
return handler;
}
Aggregations