Example #1
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");
        }
Example #2
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");
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludeNativeIndexFilesInTotalMappedSize()
        public virtual void ShouldIncludeNativeIndexFilesInTotalMappedSize()
        {
            int i = 0;

            foreach (GraphDatabaseSettings.SchemaIndex schemaIndex in GraphDatabaseSettings.SchemaIndex.values())
            {
                // given
                File dbDir = new File(Directory.databaseDir(), (i++).ToString());
                CreateIndexInIsolatedDbInstance(dbDir, schemaIndex);

                // when
                KernelDiagnostics.StoreFiles files = new KernelDiagnostics.StoreFiles(DatabaseLayout.of(dbDir));
                SizeCapture capture = new SizeCapture(this);
                Files.dump(capture);
                assertNotNull(capture.Size);

                // then
                long expected = ManuallyCountTotalMappedFileSize(dbDir);
                assertEquals(Format.bytes(expected), capture.Size);
            }
        }