//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportShortFileDoesNotHaveSpecifiedVersion() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReportShortFileDoesNotHaveSpecifiedVersion() { // given File shortFile = FileContaining(_fileSystemRule.get(), "nothing interesting"); StoreVersionCheck storeVersionCheck = new StoreVersionCheck(_pageCacheRule.getPageCache(_fileSystemRule.get())); // when StoreVersionCheck.Result result = storeVersionCheck.HasVersion(shortFile, "version"); // then assertFalse(result.Outcome.Successful); assertEquals(StoreVersionCheck.Result.Outcome.StoreVersionNotFound, result.Outcome); assertNull(result.ActualVersion); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailIfFileDoesNotExist() public virtual void ShouldFailIfFileDoesNotExist() { // given File missingFile = new File(_directory.directory(), "missing-file"); PageCache pageCache = _pageCacheRule.getPageCache(_fileSystemRule.get()); StoreVersionCheck storeVersionCheck = new StoreVersionCheck(pageCache); // when StoreVersionCheck.Result result = storeVersionCheck.HasVersion(missingFile, "version"); // then assertFalse(result.Outcome.Successful); assertEquals(StoreVersionCheck.Result.Outcome.MissingStoreFile, result.Outcome); assertNull(result.ActualVersion); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportFileWithCorrectVersion() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReportFileWithCorrectVersion() { // given File neoStore = EmptyFile(_fileSystemRule.get()); long v1 = MetaDataStore.versionStringToLong("V1"); PageCache pageCache = _pageCacheRule.getPageCache(_fileSystemRule.get()); MetaDataStore.setRecord(pageCache, neoStore, MetaDataStore.Position.STORE_VERSION, v1); StoreVersionCheck storeVersionCheck = new StoreVersionCheck(pageCache); // when StoreVersionCheck.Result result = storeVersionCheck.HasVersion(neoStore, "V1"); // then assertTrue(result.Outcome.Successful); assertEquals(StoreVersionCheck.Result.Outcome.Ok, result.Outcome); assertNull(result.ActualVersion); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Parameterized.Parameters(name = "Migrate: {0}->{1}") public static Iterable<Object[]> data() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public static IEnumerable <object[]> Data() { FileSystemAbstraction fs = _fileSystemRule.get(); PageCache pageCache = _pageCacheRule.getPageCache(fs); TestDirectory testDirectory = TestDirectory.testDirectory(); testDirectory.PrepareDirectory(typeof(StoreMigrationIT), "migration"); DatabaseLayout databaseLayout = testDirectory.DatabaseLayout(); StoreVersionCheck storeVersionCheck = new StoreVersionCheck(pageCache); VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(); LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseLayout.DatabaseDirectory(), fs).withLogEntryReader(logEntryReader).build(); LogTailScanner tailScanner = new LogTailScanner(logFiles, logEntryReader, new Monitors()); IList <object[]> data = new List <object[]>(); List <RecordFormats> recordFormats = new List <RecordFormats>(); RecordFormatSelector.allFormats().forEach(f => addIfNotThere(f, recordFormats)); foreach (RecordFormats toFormat in recordFormats) { UpgradableDatabase upgradableDatabase = new UpgradableDatabase(storeVersionCheck, toFormat, tailScanner); foreach (RecordFormats fromFormat in recordFormats) { try { CreateDb(fromFormat, databaseLayout.DatabaseDirectory()); if (!upgradableDatabase.HasCurrentVersion(databaseLayout)) { upgradableDatabase.CheckUpgradable(databaseLayout); data.Add(new object[] { fromFormat, toFormat }); } } catch (Exception) { //This means that the combination is not migratable. } fs.DeleteRecursively(databaseLayout.DatabaseDirectory()); } } return(data); }
public UpgradableDatabase(StoreVersionCheck storeVersionCheck, RecordFormats format, LogTailScanner tailScanner) { this._storeVersionCheck = storeVersionCheck; this._format = format; this._tailScanner = tailScanner; }
public static bool CheckNeoStoreHasDefaultFormatVersion(StoreVersionCheck check, DatabaseLayout databaseLayout) { File metadataStore = databaseLayout.MetadataStore(); return(check.HasVersion(metadataStore, RecordFormatSelector.defaultFormat().storeVersion()).Outcome.Successful); }