Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 5_000) public void shouldGiveUpAddingMessagesInTheQueueIfTheHandlerHasBeenStopped() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldGiveUpAddingMessagesInTheQueueIfTheHandlerHasBeenStopped()
        {
            // given
            BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, new BoundedPriorityQueue.Config(1, 1, 1024), _batchConfig, _jobSchedulerFactory, NullLogProvider.Instance);

            NewEntry.Request message = new NewEntry.Request(null, new ReplicatedString("dummy"));
            batchHandler.Handle(Wrap(message));                   // fill the queue

            System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1);

            // when
            Thread thread = new Thread(() =>
            {
                latch.Signal();
                batchHandler.Handle(Wrap(message));
            });

            thread.Start();

            latch.await();

            batchHandler.Stop();

            thread.Join();

            // then we are not stuck and we terminate
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStopJob() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldStopJob()
        {
            // given
            BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, NullLogProvider.Instance);

            // when
            batchHandler.Stop();

            // then
            Mockito.verify(_mockJob).stop();
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDropMessagesAfterBeingStopped() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDropMessagesAfterBeingStopped()
        {
            // given
            AssertableLogProvider  logProvider  = new AssertableLogProvider();
            BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, logProvider);

            NewEntry.Request message = new NewEntry.Request(null, null);
            batchHandler.Stop();

            // when
            batchHandler.Handle(Wrap(message));
            batchHandler.Run();

            // then
            verify(_downstreamHandler, never()).handle(ArgumentMatchers.any(typeof(RaftMessages_ReceivedInstantClusterIdAwareMessage)));
            logProvider.AssertAtLeastOnce(AssertableLogProvider.inLog(typeof(BatchingMessageHandler)).debug("This handler has been stopped, dropping the message: %s", Wrap(message)));
        }