use of org.neo4j.bolt.transport.SocketTransportHandler in project neo4j by neo4j.
the class SocketTransportHandlerTest method logsAndClosesContextWhenProtocolNotInitializedOnUnexpectedExceptions.
@Test
public void logsAndClosesContextWhenProtocolNotInitializedOnUnexpectedExceptions() throws Throwable {
// Given
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
AssertableLogProvider logging = new AssertableLogProvider();
SocketTransportHandler handler = new SocketTransportHandler(mock(ProtocolChooser.class), logging);
// When
Throwable cause = new Throwable("Oh no!");
handler.exceptionCaught(context, cause);
// Then
verify(context).close();
logging.assertExactly(inLog(SocketTransportHandler.class).error(equalTo("Fatal error occurred when handling a client connection: Oh no!"), is(cause)));
}
use of org.neo4j.bolt.transport.SocketTransportHandler in project neo4j by neo4j.
the class SocketTransportHandlerTest method logsAndClosesProtocolOnUnexpectedExceptions.
@Test
public void logsAndClosesProtocolOnUnexpectedExceptions() throws Throwable {
// Given
BoltStateMachine machine = mock(BoltStateMachine.class);
ChannelHandlerContext ctx = channelHandlerContextMock();
AssertableLogProvider logging = new AssertableLogProvider();
SocketTransportHandler handler = new SocketTransportHandler(protocolChooser(machine), logging);
// And Given a session has been established
handler.channelRead(ctx, handshake());
// When
Throwable cause = new Throwable("Oh no!");
handler.exceptionCaught(ctx, cause);
// Then
verify(machine).close();
logging.assertExactly(inLog(SocketTransportHandler.class).error(equalTo("Fatal error occurred when handling a client connection: Oh no!"), is(cause)));
}
Aggregations