public PipelineTester(ChannelPipeline pipeline) {
LocalAddress address = new LocalAddress(LocalAddress.EPHEMERAL);
ServerBootstrap sb = new ServerBootstrap(new DefaultLocalServerChannelFactory());
pipeline.addLast("pipelineTesterEndpoint", new SimpleChannelHandler() {
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
emittedInside.put(e.getMessage());
}
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
super.channelConnected(ctx, e);
innerChannel = e.getChannel();
}
});
sb.setPipeline(pipeline);
sb.bind(address);
ClientBootstrap cb = new ClientBootstrap(new DefaultLocalClientChannelFactory());
cb.getPipeline().addLast("1", new SimpleChannelHandler() {
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
super.channelConnected(ctx, e);
outerChannel = e.getChannel();