예제 #1
0
 public void GracefulShutdownIndefiniteTimeoutTest()
 {
     _handler = NewHandler();
     _handler.GracefulShutdownTimeout = TimeSpan.FromMilliseconds(-1);
     _handler.Close(_ctx.Object, _promise);
     _executor.Verify(
         x => x.Schedule(
             It.IsAny <Action <object, object> >(),
             It.IsAny <object>(),
             It.IsAny <object>(),
             It.IsAny <TimeSpan>()),
         Times.Never());
 }
예제 #2
0
        public void GracefulShutdownTimeoutTest()
        {
            _handler = NewHandler();
            long expectedMillis = 1234;

            _handler.GracefulShutdownTimeout = TimeSpan.FromMilliseconds(expectedMillis);
            _handler.Close(_ctx.Object, _promise);
            _executor.Verify(
                x => x.Schedule(
                    It.IsAny <Action <object> >(),
                    It.IsAny <object>(),
                    It.Is <TimeSpan>(v => v == TimeSpan.FromMilliseconds(expectedMillis))),
                Times.AtLeastOnce());
        }
예제 #3
0
 public void CloseListenerShouldBeNotifiedOnlyOneTime()
 {
     _handler = NewHandler();
     _future  = TaskUtil.Completed;
     //doAnswer(new Answer<ChannelFuture>() {
     //    @Override
     //    public ChannelFuture answer(InvocationOnMock invocation) throws Throwable {
     //        Object[] args = invocation.getArguments();
     //        GenericFutureListener<ChannelFuture> listener = (GenericFutureListener<ChannelFuture>) args[0];
     //        // Simulate that all streams have become inactive by the time the future completes.
     //        doAnswer(new Answer<Http2Stream>() {
     //            @Override
     //            public Http2Stream answer(InvocationOnMock in) throws Throwable {
     //                return null;
     //            }
     //        }).when(connection).forEachActiveStream(any(Http2StreamVisitor_class));
     //        when(connection.numActiveStreams()).thenReturn(0);
     //        // Simulate the future being completed.
     //        listener.operationComplete(future);
     //        return future;
     //    }
     //}).when(future).addListener(any(GenericFutureListener_class));
     _handler.Close(_ctx.Object, _promise);
     _connection
     .Setup(x => x.ForEachActiveStream(It.IsAny <IHttp2StreamVisitor>()))
     .Returns(default(IHttp2Stream));
     _connection
     .Setup(x => x.ForEachActiveStream(It.IsAny <Func <IHttp2Stream, bool> >()))
     .Returns(default(IHttp2Stream));
     if (_future.IsCompleted)
     {
         _connection.Setup(x => x.NumActiveStreams).Returns(0);
     }
     _handler.CloseStream(_stream.Object, _future);
     // Simulate another stream close call being made after the context should already be closed.
     _handler.CloseStream(_stream.Object, _future);
     _ctx.Verify(x => x.CloseAsync(It.IsAny <IPromise>()), Times.Once);
 }