Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCloseAnyRecentlyActiveChannels()
        public virtual void ShouldNotCloseAnyRecentlyActiveChannels()
        {
            // given
            FakeClock         clock             = Clocks.fakeClock();
            ChannelCloser     channelCloser     = mock(typeof(ChannelCloser));
            IdleChannelReaper idleChannelReaper = new IdleChannelReaper(channelCloser, _noLogging, clock, THRESHOLD);

            Channel channel = mock(typeof(Channel));

            idleChannelReaper.Add(channel, DummyRequestContext());

            // when
            idleChannelReaper.Run();

            // then
            verifyNoMoreInteractions(channelCloser);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseAnyChannelsThatHaveBeenIdleForLongerThanThreshold()
        public virtual void ShouldCloseAnyChannelsThatHaveBeenIdleForLongerThanThreshold()
        {
            // given
            FakeClock         clock             = Clocks.fakeClock();
            ChannelCloser     channelCloser     = mock(typeof(ChannelCloser));
            IdleChannelReaper idleChannelReaper = new IdleChannelReaper(channelCloser, _noLogging, clock, THRESHOLD);

            Channel channel = mock(typeof(Channel));

            idleChannelReaper.Add(channel, DummyRequestContext());

            // when
            clock.Forward(THRESHOLD + 1, TimeUnit.MILLISECONDS);
            idleChannelReaper.Run();

            // then
            verify(channelCloser).tryToCloseChannel(channel);
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotTryToCloseAChannelThatWasRecentlyActive()
        public virtual void ShouldNotTryToCloseAChannelThatWasRecentlyActive()
        {
            // given
            FakeClock         clock             = Clocks.fakeClock();
            ChannelCloser     channelCloser     = mock(typeof(ChannelCloser));
            IdleChannelReaper idleChannelReaper = new IdleChannelReaper(channelCloser, _noLogging, clock, THRESHOLD);

            Channel        channel = mock(typeof(Channel));
            RequestContext request = DummyRequestContext();

            idleChannelReaper.Add(channel, request);

            // when
            clock.Forward(THRESHOLD + 100, TimeUnit.MILLISECONDS);
            idleChannelReaper.Update(channel);
            idleChannelReaper.Run();

            // then
            verifyNoMoreInteractions(channelCloser);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCloseAChannelThatHasBeenIdleForMoreThanHalfThresholdButIsStillOpenConnectedAndBound()
        public virtual void ShouldNotCloseAChannelThatHasBeenIdleForMoreThanHalfThresholdButIsStillOpenConnectedAndBound()
        {
            // given
            FakeClock         clock             = Clocks.fakeClock();
            ChannelCloser     channelCloser     = mock(typeof(ChannelCloser));
            IdleChannelReaper idleChannelReaper = new IdleChannelReaper(channelCloser, _noLogging, clock, THRESHOLD);

            Channel channel = mock(typeof(Channel));

            idleChannelReaper.Add(channel, DummyRequestContext());
            when(channel.Open).thenReturn(true);
            when(channel.Connected).thenReturn(true);
            when(channel.Bound).thenReturn(true);

            // when
            clock.Forward(THRESHOLD / 2 + 10, TimeUnit.MILLISECONDS);
            idleChannelReaper.Run();

            // then
            verifyNoMoreInteractions(channelCloser);
        }