Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCreatesStoreLockFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestCreatesStoreLockFile()
        {
            // Given
            DatabaseLayout databaseLayout = _testDirectory.databaseLayout();

            // When
            BatchInserter inserter = BatchInserters.inserter(databaseLayout.DatabaseDirectory(), _fileSystemRule.get());

            // Then
            assertThat(databaseLayout.StoreLayout.storeLockFile().exists(), equalTo(true));
            inserter.Shutdown();
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void canRunOnBackup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void CanRunOnBackup()
        {
            ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService));

            DatabaseLayout          backupLayout            = _testDir.databaseLayout("backup");
            Path                    homeDir                 = _testDir.directory("home").toPath();
            CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService);

            when(consistencyCheckService.runFullConsistencyCheck(eq(backupLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(false), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null));

            checkConsistencyCommand.Execute(new string[] { "--backup=" + backupLayout.DatabaseDirectory() });

            verify(consistencyCheckService).runFullConsistencyCheck(eq(backupLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(false), any(), any(typeof(ConsistencyFlags)));
        }
Example #3
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 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void migrateHighLimit3_0StoreFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MigrateHighLimit3_0StoreFiles()
        {
            FileSystemAbstraction fileSystem = _fileSystemRule.get();
            PageCache             pageCache  = _pageCacheRule.getPageCache(fileSystem);

            using (JobScheduler jobScheduler = new ThreadPoolJobScheduler())
            {
                StoreMigrator migrator = new StoreMigrator(fileSystem, pageCache, Config.defaults(), NullLogService.Instance, jobScheduler);

                DatabaseLayout databaseLayout  = _testDirectory.databaseLayout();
                DatabaseLayout migrationLayout = _testDirectory.databaseLayout("migration");

                PrepareNeoStoreFile(fileSystem, databaseLayout, HighLimitV3_0_0.STORE_VERSION, pageCache);

                ProgressReporter progressMonitor = mock(typeof(ProgressReporter));

                migrator.Migrate(databaseLayout, migrationLayout, progressMonitor, HighLimitV3_0_0.STORE_VERSION, HighLimit.StoreVersion);

                int newStoreFilesCount = fileSystem.ListFiles(migrationLayout.DatabaseDirectory()).Length;
                assertThat("Store should be migrated and new store files should be created.", newStoreFilesCount, Matchers.greaterThanOrEqualTo(StoreType.values().length));
            }
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCreateIndexesForReadOnlyDb()
        public virtual void ShouldNotCreateIndexesForReadOnlyDb()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.io.layout.DatabaseLayout databaseLayout = db.databaseLayout();
            DatabaseLayout databaseLayout = Db.databaseLayout();

            // Make sure we have database to start on
            Db.shutdown();
            GraphDatabaseService db = (new GraphDatabaseFactory()).newEmbeddedDatabaseBuilder(databaseLayout.DatabaseDirectory()).setConfig(GraphDatabaseSettings.read_only, TRUE.ToString()).newGraphDatabase();

            try
            {
                // when
                try
                {
                    using (Transaction tx = Db.beginTx())
                    {
                        Db.index().forNodes("NODE");
                        fail("Should've failed");
                    }
                }
                catch (WriteOperationsNotAllowedException)
                {
                    // then good
                }
                try
                {
                    using (Transaction tx = Db.beginTx())
                    {
                        Db.index().forRelationships("RELATIONSHIP");
                        fail("Should've failed");
                    }
                }
                catch (WriteOperationsNotAllowedException)
                {
                    // then good
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
Example #6
0
 internal CountsComputer(NeoStores stores, PageCache pageCache, DatabaseLayout databaseLayout) : this(stores.MetaDataStore.LastCommittedTransactionId, stores.NodeStore, stores.RelationshipStore, ( int )stores.LabelTokenStore.HighId, ( int )stores.RelationshipTypeTokenStore.HighId, NumberArrayFactory.auto(pageCache, databaseLayout.DatabaseDirectory(), true, [email protected]_Fields.NoMonitor))
 {
 }
 private static File GetLuceneStoreDirectory(DatabaseLayout directoryStructure)
 {
     return(new File(new File(new File(directoryStructure.DatabaseDirectory(), "schema"), "label"), "lucene"));
 }