//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldKernelPanicIfNotAbleToWriteACheckPoint() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldKernelPanicIfNotAbleToWriteACheckPoint() { // Given IOException ioex = new IOException("boom!"); FlushablePositionAwareChannel channel = mock(typeof(FlushablePositionAwareChannel), RETURNS_MOCKS); when(channel.Put(anyByte())).thenReturn(channel); when(channel.PutLong(anyLong())).thenThrow(ioex); when(channel.Put(anyByte())).thenThrow(ioex); when(_logFile.Writer).thenReturn(channel); BatchingTransactionAppender appender = Life.add(CreateTransactionAppender()); // When try { appender.CheckPoint(new LogPosition(0L, 0L), LogCheckPointEvent.NULL); fail("should have thrown "); } catch (IOException ex) { assertEquals(ioex, ex); } // Then verify(_databaseHealth, times(1)).panic(ioex); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWriteSomeDataIntoTheLog() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldWriteSomeDataIntoTheLog() { // GIVEN string name = "log"; FileSystemAbstraction fs = _fileSystemRule.get(); LogFiles logFiles = LogFilesBuilder.builder(_directory.databaseLayout(), fs).withTransactionIdStore(_transactionIdStore).withLogVersionRepository(_logVersionRepository).build(); _life.start(); _life.add(logFiles); // WHEN FlushablePositionAwareChannel writer = logFiles.LogFile.Writer; LogPositionMarker positionMarker = new LogPositionMarker(); writer.GetCurrentPosition(positionMarker); int intValue = 45; long longValue = 4854587; writer.PutInt(intValue); writer.PutLong(longValue); writer.PrepareForFlush().flush(); // THEN using (ReadableClosableChannel reader = logFiles.LogFile.getReader(positionMarker.NewPosition())) { assertEquals(intValue, reader.Int); assertEquals(longValue, reader.Long); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReadOlderLogs() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReadOlderLogs() { // GIVEN FileSystemAbstraction fs = _fileSystemRule.get(); LogFiles logFiles = LogFilesBuilder.builder(_directory.databaseLayout(), fs).withTransactionIdStore(_transactionIdStore).withLogVersionRepository(_logVersionRepository).build(); _life.start(); _life.add(logFiles); // WHEN LogFile logFile = logFiles.LogFile; FlushablePositionAwareChannel writer = logFile.Writer; LogPositionMarker positionMarker = new LogPositionMarker(); writer.GetCurrentPosition(positionMarker); LogPosition position1 = positionMarker.NewPosition(); int intValue = 45; long longValue = 4854587; sbyte[] someBytes = someBytes(40); writer.PutInt(intValue); writer.PutLong(longValue); writer.Put(someBytes, someBytes.Length); writer.PrepareForFlush().flush(); writer.GetCurrentPosition(positionMarker); LogPosition position2 = positionMarker.NewPosition(); long longValue2 = 123456789L; writer.PutLong(longValue2); writer.Put(someBytes, someBytes.Length); writer.PrepareForFlush().flush(); // THEN using (ReadableClosableChannel reader = logFile.GetReader(position1)) { assertEquals(intValue, reader.Int); assertEquals(longValue, reader.Long); assertArrayEquals(someBytes, ReadBytes(reader, 40)); } using (ReadableClosableChannel reader = logFile.GetReader(position2)) { assertEquals(longValue2, reader.Long); assertArrayEquals(someBytes, ReadBytes(reader, 40)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToWriteACheckPoint() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToWriteACheckPoint() { // Given FlushablePositionAwareChannel channel = mock(typeof(FlushablePositionAwareChannel), RETURNS_MOCKS); Flushable flushable = mock(typeof(Flushable)); when(channel.PrepareForFlush()).thenReturn(flushable); when(channel.PutLong(anyLong())).thenReturn(channel); when(_logFile.Writer).thenReturn(channel); BatchingTransactionAppender appender = Life.add(CreateTransactionAppender()); // When appender.CheckPoint(new LogPosition(1L, 2L), LogCheckPointEvent.NULL); // Then verify(channel, times(1)).putLong(1L); verify(channel, times(1)).putLong(2L); verify(channel, times(1)).prepareForFlush(); verify(flushable, times(1)).flush(); verify(_databaseHealth, never()).panic(any()); }