use of org.neo4j.bolt.transport.SocketTransportHandler in project neo4j by neo4j.
the class SocketTransportHandlerTest method shouldInitializeProtocolOnFirstMessage.
@Test
public void shouldInitializeProtocolOnFirstMessage() throws Exception {
BoltStateMachine machine = mock(BoltStateMachine.class);
ProtocolChooser chooser = protocolChooser(machine);
ChannelHandlerContext context = channelHandlerContextMock();
SocketTransportHandler handler = new SocketTransportHandler(chooser, NullLogProvider.getInstance());
handler.channelRead(context, handshake());
BoltProtocol protocol1 = chooser.chosenProtocol();
handler.channelRead(context, handshake());
BoltProtocol protocol2 = chooser.chosenProtocol();
assertSame(protocol1, protocol2);
}
use of org.neo4j.bolt.transport.SocketTransportHandler in project neo4j by neo4j.
the class SocketTransportHandlerTest method shouldCloseContextWhenProtocolNotInitializedOnHandlerRemoved.
@Test
public void shouldCloseContextWhenProtocolNotInitializedOnHandlerRemoved() throws Throwable {
// Given
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
SocketTransportHandler handler = newSocketTransportHandler(mock(ProtocolChooser.class));
// When
handler.handlerRemoved(context);
// Then
verify(context).close();
}
use of org.neo4j.bolt.transport.SocketTransportHandler in project neo4j by neo4j.
the class SocketTransportHandlerTest method shouldCloseProtocolOnChannelInactive.
@Test
public void shouldCloseProtocolOnChannelInactive() throws Throwable {
// Given
BoltStateMachine machine = mock(BoltStateMachine.class);
ChannelHandlerContext ctx = channelHandlerContextMock();
SocketTransportHandler handler = newSocketTransportHandler(protocolChooser(machine));
// And Given a session has been established
handler.channelRead(ctx, handshake());
// When
handler.channelInactive(ctx);
// Then
verify(machine).close();
}
use of org.neo4j.bolt.transport.SocketTransportHandler in project neo4j by neo4j.
the class SocketTransportHandlerTest method shouldCloseProtocolOnHandlerRemoved.
@Test
public void shouldCloseProtocolOnHandlerRemoved() throws Throwable {
// Given
BoltStateMachine machine = mock(BoltStateMachine.class);
ChannelHandlerContext ctx = channelHandlerContextMock();
SocketTransportHandler handler = newSocketTransportHandler(protocolChooser(machine));
// And Given a session has been established
handler.channelRead(ctx, handshake());
// When
handler.handlerRemoved(ctx);
// Then
verify(machine).close();
}
use of org.neo4j.bolt.transport.SocketTransportHandler in project neo4j by neo4j.
the class SocketTransportHandlerTest method shouldCloseContextWhenProtocolNotInitializedOnChannelInactive.
@Test
public void shouldCloseContextWhenProtocolNotInitializedOnChannelInactive() throws Throwable {
// Given
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
SocketTransportHandler handler = newSocketTransportHandler(mock(ProtocolChooser.class));
// When
handler.channelInactive(context);
// Then
verify(context).close();
}
Aggregations