@Test public void shouldPropagateDownstreamFlushOnPipelineFutureSuccess() 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(any(FlushEvent.class))); } }); channelFactory.newChannel(pipeline); ChannelFuture executionFuture = execution.getHandlerFuture(); executionFuture.setSuccess(); ChannelFuture handlerFuture = handler.getHandlerFuture(); handlerFuture.sync(); context.assertIsSatisfied(); }
@Test public void shouldPropagateDownstreamMessageOnPipelineFutureSuccess() throws Exception { final ChannelBuffer[] expectedArr = new ChannelBuffer[3]; expectedArr[0] = wrappedBuffer(new byte[] {0x01, 0x02, 0x03}); expectedArr[1] = copiedBuffer("Hello, world", UTF_8); expectedArr[2] = wrappedBuffer(new byte[] {0x01, 0x02, 0x03}); final ChannelBuffer expected = masker.applyMask(wrappedBuffer(expectedArr)); 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(message(expected))); oneOf(upstream) .handleUpstream( with(any(ChannelHandlerContext.class)), with(any(WriteCompletionEvent.class))); } }); expression.setValue(environment, new byte[] {0x01, 0x02, 0x03}); channelFactory.newChannel(pipeline); ChannelFuture executionFuture = execution.getHandlerFuture(); executionFuture.setSuccess(); ChannelFuture handlerFuture = handler.getHandlerFuture(); handlerFuture.sync(); context.assertIsSatisfied(); }