예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.impl.transaction.log.ReadableLogChannel openLogFile(org.neo4j.io.fs.FileSystemAbstraction fs, int version) throws java.io.IOException
            internal virtual ReadableLogChannel OpenLogFile(FileSystemAbstraction fs, int version)
            {
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(WorkingDirectory, fs).build();
                PhysicalLogVersionedStoreChannel channel = logFiles.OpenForVersion(version);

                return(new ReadAheadLogChannel(channel, new ReaderLogVersionBridge(logFiles)));
            }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSuppressFailureToCloseChannelInFailedAttemptToReadHeaderAfterOpen() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSuppressFailureToCloseChannelInFailedAttemptToReadHeaderAfterOpen()
        {
            // GIVEN a file which returns 1/2 log header size worth of bytes
            FileSystemAbstraction fs = mock(typeof(FileSystemAbstraction));
            LogFiles     logFiles    = LogFilesBuilder.builder(_directory.databaseLayout(), fs).withTransactionIdStore(_transactionIdStore).withLogVersionRepository(_logVersionRepository).build();
            int          logVersion  = 0;
            File         logFile     = logFiles.GetLogFileForVersion(logVersion);
            StoreChannel channel     = mock(typeof(StoreChannel));

            when(channel.read(any(typeof(ByteBuffer)))).thenReturn(LogHeader.LOG_HEADER_SIZE / 2);
            when(fs.FileExists(logFile)).thenReturn(true);
            when(fs.Open(eq(logFile), any(typeof(OpenMode)))).thenReturn(channel);
            doThrow(typeof(IOException)).when(channel).close();

            // WHEN
            try
            {
                logFiles.OpenForVersion(logVersion);
                fail("Should have failed");
            }
            catch (IncompleteLogHeaderException e)
            {
                // THEN good
                verify(channel).close();
                assertEquals(1, e.Suppressed.length);
                assertTrue(e.Suppressed[0] is IOException);
            }
        }