コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnMinusOneIfNoDataIsAvailableForLogRotation()
        public virtual void ShouldReturnMinusOneIfNoDataIsAvailableForLogRotation()
        {
            DefaultTransactionTracer tracer = new DefaultTransactionTracer(_clock, _monitor, _jobScheduler);

            _jobScheduler.runJob();

            assertEquals(0, tracer.NumberOfLogRotationEvents());
            assertEquals(0, tracer.LogRotationAccumulatedTotalTimeMillis());
            verifyZeroInteractions(_monitor);
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldComputeStartEndAndTotalTimeForLogRotation()
        public virtual void ShouldComputeStartEndAndTotalTimeForLogRotation()
        {
            DefaultTransactionTracer tracer = new DefaultTransactionTracer(_clock, _monitor, _jobScheduler);

            TriggerEvent(tracer, 20);

            assertEquals(1, tracer.NumberOfLogRotationEvents());
            assertEquals(20, tracer.LogRotationAccumulatedTotalTimeMillis());
            verify(_monitor, times(1)).lastLogRotationEventDuration(20L);

            TriggerEvent(tracer, 30);

            // should reset the total time value whenever read
            assertEquals(2, tracer.NumberOfLogRotationEvents());
            assertEquals(50, tracer.LogRotationAccumulatedTotalTimeMillis());
            verify(_monitor, times(1)).lastLogRotationEventDuration(30L);
        }
コード例 #3
0
        private void TriggerEvent(DefaultTransactionTracer tracer, int eventDuration)
        {
            using (TransactionEvent txEvent = tracer.BeginTransaction())
            {
                using (CommitEvent commitEvent = txEvent.BeginCommitEvent())
                {
                    using (LogAppendEvent logAppendEvent = commitEvent.BeginLogAppend())
                    {
                        _clock.forward(ThreadLocalRandom.current().nextLong(200), TimeUnit.MILLISECONDS);
                        using (LogRotateEvent @event = logAppendEvent.BeginLogRotate())
                        {
                            _clock.forward(eventDuration, TimeUnit.MILLISECONDS);
                        }
                    }
                }
            }

            _jobScheduler.runJob();
        }