//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public LogPosition getAndCacheFoundLogPosition(TransactionMetadataCache transactionMetadataCache) throws NoSuchTransactionException
            public virtual LogPosition GetAndCacheFoundLogPosition(TransactionMetadataCache transactionMetadataCache)
            {
                if (StartEntryForFoundTransaction == null)
                {
                    throw new NoSuchTransactionException(StartTransactionId);
                }
                transactionMetadataCache.CacheTransactionMetadata(StartTransactionId, StartEntryForFoundTransaction.StartPosition, StartEntryForFoundTransaction.MasterId, StartEntryForFoundTransaction.LocalId, LogEntryStart.checksum(StartEntryForFoundTransaction), CommitTimestamp);
                return(StartEntryForFoundTransaction.StartPosition);
            }
示例#2
0
//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();
            }
        }