//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotReturnReaderExperiencingErrorToPool() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotReturnReaderExperiencingErrorToPool() { // given StoreChannel channel = mock(typeof(StoreChannel)); Reader reader = mock(typeof(Reader)); ReaderPool readerPool = mock(typeof(ReaderPool)); when(channel.read(any(typeof(ByteBuffer)))).thenThrow(new IOException()); when(reader.Channel()).thenReturn(channel); when(readerPool.Acquire(anyLong(), anyLong())).thenReturn(reader); using (SegmentFile segment = create(FsRule.get(), _fileNames.getForVersion(0), readerPool, 0, _contentMarshal, _logProvider, _segmentHeader)) { // given IOCursor <EntryRecord> cursor = segment.GetCursor(0); try { cursor.next(); fail(); } catch (IOException) { // expected from mocking } // when cursor.close(); // then verify(readerPool, never()).release(reader); verify(reader).close(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void attemptsPruningUntilOpenFileIsFound() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void AttemptsPruningUntilOpenFileIsFound() { /// <summary> /// prune stops attempting to prune files after finding one that is open. /// </summary> // Given Segments segments = new Segments(_fsa, _fileNames, _readerPool, Collections.emptyList(), _contentMarshal, _logProvider, -1); /* * create 0 * create 1 * create 2 * create 3 * * closeWriter on all * create reader on 1 * prune on 3 * * only 0 should be deleted */ segments.Rotate(-1, -1, -1); segments.Last().closeWriter(); // need to close writer otherwise dispose will not be called segments.Rotate(10, 10, 2); // we will truncate this whole file away segments.Last().closeWriter(); // need to close writer otherwise dispose will not be called IOCursor <EntryRecord> reader = segments.Last().getCursor(11); segments.Rotate(20, 20, 3); // we will truncate this whole file away segments.Last().closeWriter(); segments.Rotate(30, 30, 4); // we will truncate this whole file away segments.Last().closeWriter(); segments.Prune(31); //when OpenEndRangeMap.ValueRange <long, SegmentFile> shouldBePruned = segments.GetForIndex(5); OpenEndRangeMap.ValueRange <long, SegmentFile> shouldNotBePruned = segments.GetForIndex(15); OpenEndRangeMap.ValueRange <long, SegmentFile> shouldAlsoNotBePruned = segments.GetForIndex(25); //then assertFalse(shouldBePruned.Value().Present); assertTrue(shouldNotBePruned.Value().Present); assertTrue(shouldAlsoNotBePruned.Value().Present); //when reader.close(); segments.Prune(31); shouldBePruned = segments.GetForIndex(5); shouldNotBePruned = segments.GetForIndex(15); shouldAlsoNotBePruned = segments.GetForIndex(25); //then assertFalse(shouldBePruned.Value().Present); assertFalse(shouldNotBePruned.Value().Present); assertFalse(shouldAlsoNotBePruned.Value().Present); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToRepeatedlyReadWrittenValues() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToRepeatedlyReadWrittenValues() { using (SegmentFile segment = create(FsRule.get(), _fileNames.getForVersion(0), _readerPool, 0, _contentMarshal, _logProvider, _segmentHeader)) { // given segment.Write(0, _entry1); segment.Write(1, _entry2); segment.Write(2, _entry3); segment.Flush(); for (int i = 0; i < 3; i++) { // when IOCursor <EntryRecord> cursor = segment.GetCursor(0); // then assertTrue(cursor.next()); assertEquals(_entry1, cursor.get().logEntry()); assertTrue(cursor.next()); assertEquals(_entry2, cursor.get().logEntry()); assertTrue(cursor.next()); assertEquals(_entry3, cursor.get().logEntry()); assertFalse(cursor.next()); cursor.close(); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private boolean nextSegment() throws java.io.IOException private bool NextSegment() { _segmentRange = _segments.getForIndex(_currentIndex); Optional <SegmentFile> optionalFile = _segmentRange.value(); if (!optionalFile.Present) { _currentRecord.invalidate(); return(false); } SegmentFile file = optionalFile.get(); /* Open new reader before closing old, so that pruner cannot overtake us. */ IOCursor <EntryRecord> oldCursor = _cursor; try { _cursor = file.GetCursor(_currentIndex); } catch (DisposedException) { _currentRecord.invalidate(); return(false); } if (oldCursor != null) { oldCursor.close(); } _limit = _segmentRange.limit().GetValueOrDefault(long.MaxValue); return(true); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void close() throws java.io.IOException public override void Close() { if (_cursor != null) { _cursor.close(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCatchDoubleCloseReaderErrors() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCatchDoubleCloseReaderErrors() { try { using (SegmentFile segment = create(FsRule.get(), _fileNames.getForVersion(0), _readerPool, 0, _contentMarshal, _logProvider, _segmentHeader)) { // given IOCursor <EntryRecord> cursor = segment.GetCursor(0); cursor.close(); cursor.close(); fail("Should have caught double close error"); } } catch (System.InvalidOperationException) { // expected } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportCorrectInitialValues() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReportCorrectInitialValues() { using (SegmentFile segment = create(FsRule.get(), _fileNames.getForVersion(0), _readerPool, _version, _contentMarshal, _logProvider, _segmentHeader)) { assertEquals(0, segment.Header().version()); IOCursor <EntryRecord> cursor = segment.GetCursor(0); assertFalse(cursor.next()); cursor.close(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPruneReaderPoolOnClose() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPruneReaderPoolOnClose() { using (SegmentFile segment = create(FsRule.get(), _fileNames.getForVersion(0), _readerPool, 0, _contentMarshal, _logProvider, _segmentHeader)) { segment.Write(0, _entry1); segment.Flush(); segment.CloseWriter(); IOCursor <EntryRecord> cursor = segment.GetCursor(0); cursor.next(); cursor.close(); } verify(_readerPool).prune(0); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHaveIdempotentCloseMethods() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHaveIdempotentCloseMethods() { // given SegmentFile segment = create(FsRule.get(), _fileNames.getForVersion(0), _readerPool, 0, _contentMarshal, _logProvider, _segmentHeader); IOCursor <EntryRecord> cursor = segment.GetCursor(0); // when segment.CloseWriter(); cursor.close(); // then assertTrue(segment.TryClose()); segment.Close(); assertTrue(segment.TryClose()); segment.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToWriteAndRead() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToWriteAndRead() { using (SegmentFile segment = create(FsRule.get(), _fileNames.getForVersion(0), _readerPool, 0, _contentMarshal, _logProvider, _segmentHeader)) { // given segment.Write(0, _entry1); segment.Flush(); // when IOCursor <EntryRecord> cursor = segment.GetCursor(0); // then assertTrue(cursor.next()); assertEquals(_entry1, cursor.get().logEntry()); cursor.close(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleReaderPastEndCorrectly() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleReaderPastEndCorrectly() { using (SegmentFile segment = create(FsRule.get(), _fileNames.getForVersion(0), _readerPool, 0, _contentMarshal, _logProvider, _segmentHeader)) { // given segment.Write(0, _entry1); segment.Write(1, _entry2); segment.Flush(); segment.CloseWriter(); IOCursor <EntryRecord> cursor = segment.GetCursor(3); // then assertFalse(cursor.next()); // when cursor.close(); // then assertTrue(segment.TryClose()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCallDisposeHandlerAfterLastReaderIsClosed() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCallDisposeHandlerAfterLastReaderIsClosed() { using (SegmentFile segment = create(FsRule.get(), _fileNames.getForVersion(0), _readerPool, 0, _contentMarshal, _logProvider, _segmentHeader)) { // given IOCursor <EntryRecord> cursor0 = segment.GetCursor(0); IOCursor <EntryRecord> cursor1 = segment.GetCursor(0); // when segment.CloseWriter(); cursor0.close(); // then assertFalse(segment.TryClose()); // when cursor1.close(); // then assertTrue(segment.TryClose()); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void read(org.neo4j.io.fs.FileSystemAbstraction fileSystem, String cmd, org.neo4j.kernel.impl.store.NeoStores neoStores, org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException private static void Read(FileSystemAbstraction fileSystem, string cmd, NeoStores neoStores, DatabaseLayout databaseLayout) { Matcher matcher = _readCommandPattern.matcher(cmd); if (matcher.find()) { string lower = matcher.group("lower"); string upper = matcher.group("upper"); string fname = matcher.group("fname"); string regex = matcher.group("regex"); Pattern pattern = !string.ReferenceEquals(regex, null) ? Pattern.compile(regex) : null; long fromId = !string.ReferenceEquals(lower, null) ? long.Parse(lower) : 0L; long toId = !string.ReferenceEquals(upper, null) ? long.Parse(upper) : long.MaxValue; RecordStore store = GetStore(fname, neoStores); if (store != null) { ReadStore(fileSystem, store, fromId, toId, pattern); return; } IOCursor <LogEntry> cursor = GetLogCursor(fileSystem, fname, databaseLayout); if (cursor != null) { ReadLog(cursor, fromId, toId, pattern); cursor.close(); return; } _console.printf("don't know how to read '%s'%n", fname); } else { _console.printf("bad read command format%n"); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void close() throws Exception public override void Close() { _txCursor.close(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void close() throws java.io.IOException public override void Close() { @delegate.close(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void close() throws java.io.IOException public override void Close() { _inner.close(); }