コード例 #1
0
ファイル: UnbindHandlerTest.java プロジェクト: MZDN/k3po
  @Test
  public void shouldPropagateDownstreamUnbindOnPipelineFutureSuccess() 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)));
            oneOf(downstream)
                .handleDownstream(
                    with(any(ChannelHandlerContext.class)), with(channelState(BOUND, null)));
            oneOf(upstream)
                .handleUpstream(
                    with(any(ChannelHandlerContext.class)), with(channelState(OPEN, FALSE)));
          }
        });

    channelFactory.newChannel(pipeline);
    ChannelFuture executionFuture = execution.getHandlerFuture();
    executionFuture.setSuccess();

    ChannelFuture handlerFuture = handler.getHandlerFuture();
    assertTrue(handlerFuture.isSuccess());

    context.assertIsSatisfied();
  }
コード例 #2
0
ファイル: UnbindHandlerTest.java プロジェクト: MZDN/k3po
  @Test
  public void shouldNotPropagateDownstreamUnbindOnPipelineFutureFailure() 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 executionFuture = execution.getHandlerFuture();
    executionFuture.setFailure(new ChannelException("pipeline already failed"));

    ChannelFuture handlerFuture = handler.getHandlerFuture();
    assertFalse(handlerFuture.isDone());

    context.assertIsSatisfied();
  }