@AdviseWith(adviceClasses = NettyUtilAdvice.class) @Test public void testGetFileChannelCancellation() { _channelPipeline.addFirst( new ChannelOutboundHandlerAdapter() { @Override public void write( ChannelHandlerContext channelHandlerContext, Object object, ChannelPromise channelPromise) { channelPromise.cancel(true); } }); try { NoticeableFuture<Path> noticeableFuture = _nettyRepository.getFile( _embeddedChannel, Paths.get("remoteFile"), Paths.get("localFile"), false, false); Assert.assertTrue(noticeableFuture.isDone()); Assert.assertTrue(noticeableFuture.isCancelled()); } finally { _channelPipeline.removeFirst(); } }
@AdviseWith(adviceClasses = NettyUtilAdvice.class) @Test public void testGetFileTimeoutCancellation() { NettyRepository nettyRepository = new NettyRepository(_repositoryPath, 0); _channelPipeline.addLast( new FileResponseChannelHandler( nettyRepository.getAsyncBroker(), _embeddedChannel.eventLoop())); NoticeableFuture<Path> noticeableFuture = nettyRepository.getFile( _embeddedChannel, Paths.get("remoteFile"), Paths.get("localFile"), false, false); Assert.assertTrue(noticeableFuture.isDone()); Assert.assertTrue(noticeableFuture.isCancelled()); }