use of org.neo4j.bolt.v1.runtime.BoltStateMachine in project neo4j by neo4j.
the class BoltProtocolV1Test method closesInputAndOutput.
@Test
public void closesInputAndOutput() {
Channel outputChannel = mock(Channel.class);
ByteBufAllocator allocator = mock(ByteBufAllocator.class);
ByteBuf buffer = mock(ByteBuf.class);
when(outputChannel.alloc()).thenReturn(allocator);
when(allocator.buffer(anyInt(), anyInt())).thenReturn(buffer);
BoltStateMachine machine = mock(BoltStateMachine.class);
BoltProtocolV1 protocol = new BoltProtocolV1(new SynchronousBoltWorker(machine), outputChannel, NullLogService.getInstance());
protocol.close();
verify(machine).close();
verify(buffer).release();
}
use of org.neo4j.bolt.v1.runtime.BoltStateMachine 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