//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDeleteIdGeneratorsWhenOpeningExistingStore() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDeleteIdGeneratorsWhenOpeningExistingStore()
        {
            // given
            long expectedHighId;

            using (BatchingNeoStores stores = BatchingNeoStores.BatchingNeoStoresWithExternalPageCache(Storage.fileSystem(), Storage.pageCache(), PageCacheTracer.NULL, Storage.directory().absolutePath(), LATEST_RECORD_FORMATS, DEFAULT, NullLogService.Instance, EMPTY, Config.defaults()))
            {
                stores.CreateNew();
                RelationshipStore  relationshipStore = stores.RelationshipStore;
                RelationshipRecord record            = relationshipStore.NewRecord();
                long no = NULL_REFERENCE.longValue();
                record.Initialize(true, no, 1, 2, 0, no, no, no, no, true, true);
                record.Id      = relationshipStore.NextId();
                expectedHighId = relationshipStore.HighId;
                relationshipStore.UpdateRecord(record);
                // fiddle with the highId
                relationshipStore.HighId = record.Id + 999;
            }

            // when
            using (BatchingNeoStores stores = BatchingNeoStores.BatchingNeoStoresWithExternalPageCache(Storage.fileSystem(), Storage.pageCache(), PageCacheTracer.NULL, Storage.directory().absolutePath(), LATEST_RECORD_FORMATS, DEFAULT, NullLogService.Instance, EMPTY, Config.defaults()))
            {
                stores.PruneAndOpenExistingStore(Predicates.alwaysTrue(), Predicates.alwaysTrue());

                // then
                assertEquals(expectedHighId, stores.RelationshipStore.HighId);
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPruneAndOpenExistingDatabase() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPruneAndOpenExistingDatabase()
        {
            // given
            foreach (StoreType typeToTest in RelevantRecordStores())
            {
                // given all the stores with some records in them
                using (PageCache pageCache = Storage.pageCache())
                {
                    Storage.directory().cleanup();
                    using (BatchingNeoStores stores = BatchingNeoStores.BatchingNeoStoresWithExternalPageCache(Storage.fileSystem(), pageCache, PageCacheTracer.NULL, Storage.directory().absolutePath(), LATEST_RECORD_FORMATS, DEFAULT, NullLogService.Instance, EMPTY, Config.defaults()))
                    {
                        stores.CreateNew();
                        foreach (StoreType type in RelevantRecordStores())
                        {
                            CreateRecordIn(stores.NeoStores.getRecordStore(type));
                        }
                    }

                    // when opening and pruning all except the one we test
                    using (BatchingNeoStores stores = BatchingNeoStores.BatchingNeoStoresWithExternalPageCache(Storage.fileSystem(), pageCache, PageCacheTracer.NULL, Storage.directory().absolutePath(), LATEST_RECORD_FORMATS, DEFAULT, NullLogService.Instance, EMPTY, Config.defaults()))
                    {
                        stores.PruneAndOpenExistingStore(type => type == typeToTest, Predicates.alwaysFalse());

                        // then only the one we kept should have data in it
                        foreach (StoreType type in RelevantRecordStores())
                        {
                            RecordStore <AbstractBaseRecord> store = stores.NeoStores.getRecordStore(type);
                            if (type == typeToTest)
                            {
                                assertThat(store.ToString(), (int)store.HighId, greaterThan(store.NumberOfReservedLowIds));
                            }
                            else
                            {
                                assertEquals(store.ToString(), store.NumberOfReservedLowIds, store.HighId);
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
 internal static System.Predicate <string> CommunityFileWatcherFileNameFilter()
 {
     return(Predicates.any(fileName => fileName.StartsWith(TransactionLogFiles.DEFAULT_NAME), fileName => fileName.StartsWith(IndexConfigStore.INDEX_DB_FILE_NAME)));
 }
Beispiel #4
0
 internal static System.Predicate <string> EnterpriseNonClusterFileWatcherFileNameFilter()
 {
     return(Predicates.any(fileName => fileName.StartsWith(TransactionLogFiles.DEFAULT_NAME), fileName => fileName.StartsWith(IndexConfigStore.INDEX_DB_FILE_NAME), filename => filename.EndsWith(PageCacheWarmer.SUFFIX_CACHEPROF)));
 }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private boolean isNativeLabelScanStoreMigrationRequired(org.neo4j.io.layout.DatabaseLayout directoryStructure) throws java.io.IOException
        private bool IsNativeLabelScanStoreMigrationRequired(DatabaseLayout directoryStructure)
        {
            return(_fileSystem.streamFilesRecursive(directoryStructure.LabelScanStore()).noneMatch(Predicates.alwaysTrue()));
        }
Beispiel #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsAFile() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsAFile()
        {
            Path directory = _testDirectory.directory("a-directory").toPath();
            Path archive   = _testDirectory.file("subdir/the-archive.dump").toPath();

            Files.write(archive.Parent, new sbyte[0]);
            FileSystemException exception = assertThrows(typeof(FileSystemException), () => (new Dumper()).dump(directory, directory, archive, GZIP, Predicates.alwaysFalse()));

            assertEquals(archive.Parent.ToString() + ": Not a directory", exception.Message);
        }
Beispiel #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldGiveAClearErrorMessageIfTheArchivesParentDirectoryDoesntExist()
        internal virtual void ShouldGiveAClearErrorMessageIfTheArchivesParentDirectoryDoesntExist()
        {
            Path directory = _testDirectory.directory("a-directory").toPath();
            Path archive   = _testDirectory.file("subdir/the-archive.dump").toPath();
            NoSuchFileException exception = assertThrows(typeof(NoSuchFileException), () => (new Dumper()).dump(directory, directory, archive, GZIP, Predicates.alwaysFalse()));

            assertEquals(archive.Parent.ToString(), exception.Message);
        }
Beispiel #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldGiveAClearErrorIfTheArchiveAlreadyExists() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldGiveAClearErrorIfTheArchiveAlreadyExists()
        {
            Path directory = _testDirectory.directory("a-directory").toPath();
            Path archive   = _testDirectory.file("the-archive.dump").toPath();

            Files.write(archive, new sbyte[0]);
            FileAlreadyExistsException exception = assertThrows(typeof(FileAlreadyExistsException), () => (new Dumper()).dump(directory, directory, archive, GZIP, Predicates.alwaysFalse()));

            assertEquals(archive.ToString(), exception.Message);
        }
Beispiel #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) void shouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsNotWritable() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsNotWritable()
        {
            Path directory = _testDirectory.directory("a-directory").toPath();
            Path archive   = _testDirectory.file("subdir/the-archive.dump").toPath();

            Files.createDirectories(archive.Parent);
            using (System.IDisposable ignored = TestUtils.WithPermissions(archive.Parent, emptySet()))
            {
                AccessDeniedException exception = assertThrows(typeof(AccessDeniedException), () => (new Dumper()).dump(directory, directory, archive, GZIP, Predicates.alwaysFalse()));
                assertEquals(archive.Parent.ToString(), exception.Message);
            }
        }