コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void retrieveCustomTransactionTimeout()
        public virtual void RetrieveCustomTransactionTimeout()
        {
            when(_request.getHeader(MAX_EXECUTION_TIME_HEADER)).thenReturn("100");
            Log  log = LogProvider.getLog(typeof(HttpServletRequest));
            long transactionTimeout = getTransactionTimeout(_request, log);

            assertEquals("Transaction timeout should be retrieved.", 100, transactionTimeout);
            LogProvider.assertNoLoggingOccurred();
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void applyTo()
        public virtual void ApplyTo()
        {
            //Test that truncate commands correctly remove entries from the cache.

            //given
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log  log       = logProvider.getLog(this.GetType());
            long fromIndex = 2L;
            TruncateLogCommand truncateLogCommand = new TruncateLogCommand(fromIndex);
            InFlightCache      inFlightCache      = new ConsecutiveInFlightCache();

            inFlightCache.Put(0L, new RaftLogEntry(0L, valueOf(0)));
            inFlightCache.Put(1L, new RaftLogEntry(1L, valueOf(1)));
            inFlightCache.Put(2L, new RaftLogEntry(2L, valueOf(2)));
            inFlightCache.Put(3L, new RaftLogEntry(3L, valueOf(3)));

            //when
            truncateLogCommand.ApplyTo(inFlightCache, log);

            //then
            assertNotNull(inFlightCache.Get(0L));
            assertNotNull(inFlightCache.Get(1L));
            assertNull(inFlightCache.Get(2L));
            assertNull(inFlightCache.Get(3L));

            logProvider.AssertAtLeastOnce(inLog(this.GetType()).debug("Start truncating in-flight-map from index %d. Current map:%n%s", fromIndex, inFlightCache));
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void progressNeverReportMoreThenHundredPercent()
        public virtual void ProgressNeverReportMoreThenHundredPercent()
        {
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log log = logProvider.getLog(this.GetType());
            VisibleMigrationProgressMonitor monitor = new VisibleMigrationProgressMonitor(log);

            monitor.Started(1);
            MonitorSection(monitor, "First", 100, 1, 10, 99, 170);
            monitor.Completed();

            VerifySectionReportedCorrectly(logProvider);
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludeDurationInCompletionMessage()
        public virtual void ShouldIncludeDurationInCompletionMessage()
        {
            // given
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log       log   = logProvider.getLog(this.GetType());
            FakeClock clock = new FakeClock();
            VisibleMigrationProgressMonitor monitor = new VisibleMigrationProgressMonitor(log, clock);

            // when
            monitor.Started(1);
            clock.Forward(1500, TimeUnit.MILLISECONDS);
            monitor.Completed();

            // then
            logProvider.FormattedMessageMatcher().assertContains("took 1s 500ms");
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportAllPercentageSteps()
        public virtual void ShouldReportAllPercentageSteps()
        {
            // GIVEN
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log log = logProvider.getLog(this.GetType());
            VisibleMigrationProgressMonitor monitor = new VisibleMigrationProgressMonitor(log);

            monitor.Started(1);

            // WHEN
            MonitorSection(monitor, "First", 100, 40, 25, 23, 10, 50);
            monitor.Completed();

            // THEN
            VerifySectionReportedCorrectly(logProvider);
        }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCountFileSizeRecursively() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCountFileSizeRecursively()
        {
            // file structure:
            //   storeDir/indexDir/indexFile (1 kB)
            //   storeDir/neostore (3 kB)
            File           storeDir = DirectoryConflict.directory("storeDir");
            DatabaseLayout layout   = DatabaseLayout.of(storeDir);
            File           indexDir = Directory(storeDir, "indexDir");

            File(indexDir, "indexFile", ( int )kibiBytes(1));
            File(storeDir, layout.MetadataStore().Name, (int)kibiBytes(3));

            AssertableLogProvider logProvider = new AssertableLogProvider();

            KernelDiagnostics.StoreFiles storeFiles = new KernelDiagnostics.StoreFiles(layout);
            storeFiles.Dump(logProvider.getLog(this.GetType()).debugLogger());

            logProvider.RawMessageMatcher().assertContains("Total size of store: 4.00 kB");
            logProvider.RawMessageMatcher().assertContains("Total size of mapped files: 3.00 kB");
        }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPrintDiskUsage()
        public virtual void ShouldPrintDiskUsage()
        {
            // Not sure how to get around this w/o spying. The method that we're unit testing will construct
            // other File instances with this guy as parent and internally the File constructor uses the field 'path'
            // which, if purely mocked, won't be assigned. At the same time we want to control the total/free space methods
            // and what they return... a tough one.
            File           storeDir = Mockito.spy(new File("storeDir"));
            DatabaseLayout layout   = mock(typeof(DatabaseLayout));

            when(layout.DatabaseDirectory()).thenReturn(storeDir);
            when(storeDir.TotalSpace).thenReturn(100L);
            when(storeDir.FreeSpace).thenReturn(40L);

            AssertableLogProvider logProvider = new AssertableLogProvider();

            KernelDiagnostics.StoreFiles storeFiles = new KernelDiagnostics.StoreFiles(layout);
            storeFiles.Dump(logProvider.getLog(this.GetType()).debugLogger());

            logProvider.RawMessageMatcher().assertContains("100 / 40 / 40");
        }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            _log = _logProvider.getLog(this.GetType());
            System.setProperty("org.neo4j.helpers.Service.printServiceLoaderStackTraces", "true");
        }