public IdleChannelReaper(ChannelCloser channelCloser, LogProvider logProvider, Clock clock, long thresholdMillis) { this._channelCloser = channelCloser; this._clock = clock; this._thresholdMillis = thresholdMillis; _msgLog = logProvider.getLog(this.GetType()); }
/// <summary> /// This method disposes of the object. It is invoked by the parameterless Dispose() /// method of this object. /// </summary> /// <param name="disposing"> /// <para> /// This parameter indicates, when TRUE, this Dispose() method was called directly or indirectly by a user's /// code. When FALSE, this method was called by the runtime from inside the finalizer. /// </para> /// <para> /// When called by user code, references within the class should be valid and should be disposed of properly. /// When called by the finalizer, references within the class are not guaranteed to be valid and attempts to /// dispose of them should not be made. /// </para> /// </param> /// <returns> Returns TRUE to indicate that the object has been disposed. </returns> protected virtual void Dispose(bool disposing) { if (Disposed) { return; } if (disposing) { ChannelCloser.Close(Channel); _assignedXiLists.Clear(); } Disposed = true; }
//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); }
//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); }
//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); }
//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); }