Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOpenTheNextChannelWhenItExists() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldOpenTheNextChannelWhenItExists()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.io.fs.StoreChannel newStoreChannel = mock(org.neo4j.io.fs.StoreChannel.class);
            StoreChannel newStoreChannel = mock(typeof(StoreChannel));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.ReaderLogVersionBridge bridge = new org.neo4j.kernel.impl.transaction.log.ReaderLogVersionBridge(logFiles);
            ReaderLogVersionBridge bridge = new ReaderLogVersionBridge(_logFiles);

            when(_channel.Version).thenReturn(_version);
            when(_channel.LogFormatVersion).thenReturn(CURRENT_LOG_VERSION);
            when(_fs.fileExists(any(typeof(File)))).thenReturn(true);
            when(_fs.open(any(typeof(File)), eq(OpenMode.READ))).thenReturn(newStoreChannel);
            when(newStoreChannel.read(ArgumentMatchers.any <ByteBuffer>())).then(invocationOnMock =>
            {
                ByteBuffer buffer = invocationOnMock.getArgument(0);
                buffer.putLong(encodeLogVersion(_version + 1));
                buffer.putLong(42);
                return(LOG_HEADER_SIZE);
            });

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel result = bridge.next(channel);
            LogVersionedStoreChannel result = bridge.Next(_channel);

            // then
            PhysicalLogVersionedStoreChannel expected = new PhysicalLogVersionedStoreChannel(newStoreChannel, _version + 1, CURRENT_LOG_VERSION);

            assertEquals(expected, result);
            verify(_channel, times(1)).close();
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnOldChannelWhenNextChannelHasntGottenCompleteHeaderYet() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnOldChannelWhenNextChannelHasntGottenCompleteHeaderYet()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.ReaderLogVersionBridge bridge = new org.neo4j.kernel.impl.transaction.log.ReaderLogVersionBridge(logFiles);
            ReaderLogVersionBridge bridge = new ReaderLogVersionBridge(_logFiles);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.io.fs.StoreChannel nextVersionWithIncompleteHeader = mock(org.neo4j.io.fs.StoreChannel.class);
            StoreChannel nextVersionWithIncompleteHeader = mock(typeof(StoreChannel));

            when(nextVersionWithIncompleteHeader.read(any(typeof(ByteBuffer)))).thenReturn(LOG_HEADER_SIZE / 2);

            when(_channel.Version).thenReturn(_version);
            when(_fs.fileExists(any(typeof(File)))).thenReturn(true);
            when(_fs.open(any(typeof(File)), eq(OpenMode.READ))).thenReturn(nextVersionWithIncompleteHeader);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel result = bridge.next(channel);
            LogVersionedStoreChannel result = bridge.Next(_channel);

            // then
            assertEquals(_channel, result);
            verify(_channel, never()).close();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Opens a <seealso cref="LogEntryCursor"/> for requested file
        /// </summary>
        /// <param name="fileSystem"> to find {@code file} in. </param>
        /// <param name="file"> file to open </param>
        /// <param name="readerLogVersionBridge"> log version bridge to use </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static org.neo4j.kernel.impl.transaction.log.LogEntryCursor openLogEntryCursor(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file, org.neo4j.kernel.impl.transaction.log.LogVersionBridge readerLogVersionBridge) throws java.io.IOException
        public static LogEntryCursor OpenLogEntryCursor(FileSystemAbstraction fileSystem, File file, LogVersionBridge readerLogVersionBridge)
        {
            LogVersionedStoreChannel channel    = OpenVersionedChannel(fileSystem, file);
            ReadableLogChannel       logChannel = new ReadAheadLogChannel(channel, readerLogVersionBridge);
            LogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();

            return(new LogEntryCursor(logEntryReader, logChannel));
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel next(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel channel) throws java.io.IOException
            public LogVersionedStoreChannel next(LogVersionedStoreChannel channel)
            {
                if (!returned)
                {
                    returned = true;
                    channel.close();
                    return(new PhysicalLogVersionedStoreChannel(_outerInstance.fileSystemRule.get().open(_outerInstance.file(1), OpenMode.READ), -1, (sbyte)-1));
                }
                return(channel);
            }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel next(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel channel) throws java.io.IOException
            public override LogVersionedStoreChannel next(LogVersionedStoreChannel channel)
            {
                LogVersionedStoreChannel next = base.next(channel);

                if (next != channel)
                {
                    _monitor.logFile(_logFiles.getLogFileForVersion(next.Version), next.Version);
                }
                return(next);
            }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnOldChannelWhenThereIsNoNextChannel() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnOldChannelWhenThereIsNoNextChannel()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.ReaderLogVersionBridge bridge = new org.neo4j.kernel.impl.transaction.log.ReaderLogVersionBridge(logFiles);
            ReaderLogVersionBridge bridge = new ReaderLogVersionBridge(_logFiles);

            when(_channel.Version).thenReturn(_version);
            when(_fs.open(any(typeof(File)), eq(OpenMode.READ))).thenThrow(new FileNotFoundException());

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel result = bridge.next(channel);
            LogVersionedStoreChannel result = bridge.Next(_channel);

            // then
            assertEquals(_channel, result);
            verify(_channel, never()).close();
        }