### Question:
AwaitBarrierUpstreamHandler extends AbstractBarrierHandler implements ChannelUpstreamHandler { boolean hasQueuedChannelEvents() { return queue != null && !queue.isEmpty(); } AwaitBarrierUpstreamHandler(Barrier barrier); @Override void prepareRequested(final ChannelHandlerContext ctx, PreparationEvent evt);  }### Answer:
@Test public void shouldPropagateUpstreamOpenOnBarrierFutureSuccess() throws Exception { context.checking(new Expectations() { { oneOf(upstream).handleUpstream(with(any(ChannelHandlerContext.class)), with(any(PreparationEvent.class))); oneOf(upstream).handleUpstream(with(any(ChannelHandlerContext.class)), with(channelState(OPEN, TRUE))); } }); channelFactory.newChannel(pipeline); ChannelFuture barrierFuture = barrier.getFuture(); barrierFuture.setSuccess(); ChannelFuture handlerFuture = handler.getHandlerFuture(); assertTrue(handlerFuture.isSuccess()); assertFalse(handler.hasQueuedChannelEvents()); context.assertIsSatisfied(); }
@Test public void shouldNotPropagateUpstreamOpenWhileBarrierFutureNotDone() throws Exception { context.checking(new Expectations() { { oneOf(upstream).handleUpstream(with(any(ChannelHandlerContext.class)), with(any(PreparationEvent.class))); } }); channelFactory.newChannel(pipeline); ChannelFuture handlerFuture = handler.getHandlerFuture(); assertFalse(handlerFuture.isDone()); assertTrue(handler.hasQueuedChannelEvents()); context.assertIsSatisfied(); }