//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowNoSuchTransactionExceptionIfMetadataNotFound() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldThrowNoSuchTransactionExceptionIfMetadataNotFound() { // GIVEN LogFiles logFiles = mock(typeof(LogFiles)); TransactionMetadataCache cache = new TransactionMetadataCache(); LifeSupport life = new LifeSupport(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final LogicalTransactionStore txStore = new PhysicalLogicalTransactionStore(logFiles, cache, new org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader<>(), monitors, true); LogicalTransactionStore txStore = new PhysicalLogicalTransactionStore(logFiles, cache, new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(), _monitors, true); try { life.Start(); // WHEN try { txStore.GetMetadataFor(10); fail("Should have thrown"); } catch (NoSuchTransactionException) { // THEN Good } } finally { life.Shutdown(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldOpenAndRecoverExistingData() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldOpenAndRecoverExistingData() { // GIVEN TransactionIdStore transactionIdStore = new SimpleTransactionIdStore(); TransactionMetadataCache positionCache = new TransactionMetadataCache(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final byte[] additionalHeader = new byte[]{1, 2, 5}; sbyte[] additionalHeader = new sbyte[] { 1, 2, 5 }; const int masterId = 2; int authorId = 1; const long timeStarted = 12345; long latestCommittedTxWhenStarted = 4545; long timeCommitted = timeStarted + 10; LifeSupport life = new LifeSupport(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles = org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.builder(dir.databaseLayout(), fileSystemRule.get()).withTransactionIdStore(transactionIdStore).withLogVersionRepository(mock(LogVersionRepository.class)).build(); LogFiles logFiles = LogFilesBuilder.builder(Dir.databaseLayout(), FileSystemRule.get()).withTransactionIdStore(transactionIdStore).withLogVersionRepository(mock(typeof(LogVersionRepository))).build(); life.Start(); life.Add(logFiles); try { AddATransactionAndRewind(life, logFiles, positionCache, transactionIdStore, additionalHeader, masterId, authorId, timeStarted, latestCommittedTxWhenStarted, timeCommitted); } finally { life.Shutdown(); } life = new LifeSupport(); life.Add(logFiles); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean recoveryRequired = new java.util.concurrent.atomic.AtomicBoolean(); AtomicBoolean recoveryRequired = new AtomicBoolean(); FakeRecoveryVisitor visitor = new FakeRecoveryVisitor(additionalHeader, masterId, authorId, timeStarted, timeCommitted, latestCommittedTxWhenStarted); LogicalTransactionStore txStore = new PhysicalLogicalTransactionStore(logFiles, positionCache, new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(), _monitors, true); life.Add(new BatchingTransactionAppender(logFiles, NO_ROTATION, positionCache, transactionIdStore, BYPASS, _databaseHealth)); CorruptedLogsTruncator logPruner = new CorruptedLogsTruncator(_databaseDirectory, logFiles, FileSystemRule.get()); life.add(new Recovery(new RecoveryServiceAnonymousInnerClass(this, recoveryRequired, visitor, txStore) , logPruner, new LifecycleAdapter(), mock(typeof(RecoveryMonitor)), SilentProgressReporter.INSTANCE, false)); // WHEN try { life.Start(); } finally { life.Shutdown(); } // THEN assertEquals(1, visitor.VisitedTransactions); assertTrue(recoveryRequired.get()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExtractMetadataFromExistingTransaction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldExtractMetadataFromExistingTransaction() { // GIVEN TransactionIdStore transactionIdStore = new SimpleTransactionIdStore(); TransactionMetadataCache positionCache = new TransactionMetadataCache(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final byte[] additionalHeader = new byte[]{1, 2, 5}; sbyte[] additionalHeader = new sbyte[] { 1, 2, 5 }; const int masterId = 2; int authorId = 1; const long timeStarted = 12345; long latestCommittedTxWhenStarted = 4545; long timeCommitted = timeStarted + 10; LifeSupport life = new LifeSupport(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles = org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.builder(dir.databaseLayout(), fileSystemRule.get()).withTransactionIdStore(transactionIdStore).withLogVersionRepository(mock(LogVersionRepository.class)).build(); LogFiles logFiles = LogFilesBuilder.builder(Dir.databaseLayout(), FileSystemRule.get()).withTransactionIdStore(transactionIdStore).withLogVersionRepository(mock(typeof(LogVersionRepository))).build(); life.Start(); life.Add(logFiles); try { AddATransactionAndRewind(life, logFiles, positionCache, transactionIdStore, additionalHeader, masterId, authorId, timeStarted, latestCommittedTxWhenStarted, timeCommitted); } finally { life.Shutdown(); } life = new LifeSupport(); life.Add(logFiles); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final LogicalTransactionStore store = new PhysicalLogicalTransactionStore(logFiles, positionCache, new org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader<>(), monitors, true); LogicalTransactionStore store = new PhysicalLogicalTransactionStore(logFiles, positionCache, new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(), _monitors, true); // WHEN life.Start(); try { VerifyTransaction(transactionIdStore, positionCache, additionalHeader, masterId, authorId, timeStarted, latestCommittedTxWhenStarted, timeCommitted, store); } finally { life.Shutdown(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowNoSuchTransactionExceptionIfLogFileIsMissing() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldThrowNoSuchTransactionExceptionIfLogFileIsMissing() { // GIVEN LogFile logFile = mock(typeof(LogFile)); LogFiles logFiles = mock(typeof(LogFiles)); // a missing file when(logFiles.LogFile).thenReturn(logFile); when(logFile.GetReader(any(typeof(LogPosition)))).thenThrow(new FileNotFoundException()); // Which is nevertheless in the metadata cache TransactionMetadataCache cache = new TransactionMetadataCache(); cache.CacheTransactionMetadata(10, new LogPosition(2, 130), 1, 1, 100, DateTimeHelper.CurrentUnixTimeMillis()); LifeSupport life = new LifeSupport(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final LogicalTransactionStore txStore = new PhysicalLogicalTransactionStore(logFiles, cache, new org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader<>(), monitors, true); LogicalTransactionStore txStore = new PhysicalLogicalTransactionStore(logFiles, cache, new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(), _monitors, true); try { life.Start(); // WHEN // we ask for that transaction and forward try { txStore.getTransactions(10); fail(); } catch (NoSuchTransactionException) { // THEN // We don't get a FileNotFoundException but a NoSuchTransactionException instead } } finally { life.Shutdown(); } }