@Test
public void shouldThrowExceptionIfBadHandshakeIsReceived() throws Exception {
final InetSocketAddress remoteAddress = new InetSocketAddress(0);
// start off by simulating a 'channelConnected' event
// this should set the internal state properly
handler.channelConnected(ctx, new UpstreamChannelStateEvent(channel, ChannelState.CONNECTED, remoteAddress));
// we shouldn't forward the event on
Mockito.verifyNoMoreInteractions(ctx);
// now simulate an incoming message
// the handler is expecting a handshake message
// but we're going to feed it something else, and we expect an exception as a result
ChannelBuffer badHandshakeBuffer = ChannelBuffers.wrappedBuffer(new byte[]{0, 1, 3, 4});
expectedException.expect(IOException.class);
handler.messageReceived(ctx, new UpstreamMessageEvent(channel, badHandshakeBuffer, remoteAddress));
}
IncomingHandshakeHandlerTest.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:libraft
作者:
评论列表
文章目录