### Question:
BatchingTransactionAppender extends LifecycleAdapter implements TransactionAppender { @Override public void checkPoint( LogPosition logPosition, LogCheckPointEvent logCheckPointEvent ) throws IOException { synchronized ( logFile ) { try { transactionLogWriter.checkPoint( logPosition ); } catch ( Throwable cause ) { databaseHealth.panic( cause ); throw cause; } } forceAfterAppend( logCheckPointEvent ); } BatchingTransactionAppender( LogFiles logFiles, LogRotation logRotation,
            TransactionMetadataCache transactionMetadataCache, TransactionIdStore transactionIdStore,
            IdOrderingQueue explicitIndexTransactionOrdering, DatabaseHealth databaseHealth ); @Override void start(); @Override long append( TransactionToApply batch, LogAppendEvent logAppendEvent ); @Override void checkPoint( LogPosition logPosition, LogCheckPointEvent logCheckPointEvent );  }### Answer:
@Test public void shouldBeAbleToWriteACheckPoint() throws Throwable { FlushablePositionAwareChannel channel = mock( FlushablePositionAwareChannel.class, RETURNS_MOCKS ); Flushable flushable = mock( Flushable.class ); when( channel.prepareForFlush() ).thenReturn( flushable ); when( channel.putLong( anyLong() ) ).thenReturn( channel ); when( logFile.getWriter() ).thenReturn( channel ); BatchingTransactionAppender appender = life.add( createTransactionAppender() ); appender.checkPoint( new LogPosition( 1L, 2L ), LogCheckPointEvent.NULL ); 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() ); }
@Test public void shouldKernelPanicIfNotAbleToWriteACheckPoint() throws Throwable { IOException ioex = new IOException( "boom!" ); FlushablePositionAwareChannel channel = mock( FlushablePositionAwareChannel.class, RETURNS_MOCKS ); when( channel.put( anyByte() ) ).thenReturn( channel ); when( channel.putLong( anyLong() ) ).thenThrow( ioex ); when( channel.put( anyByte() ) ).thenThrow( ioex ); when( logFile.getWriter() ).thenReturn( channel ); BatchingTransactionAppender appender = life.add( createTransactionAppender() ); try { appender.checkPoint( new LogPosition( 0L, 0L ), LogCheckPointEvent.NULL ); fail( "should have thrown " ); } catch ( IOException ex ) { assertEquals( ioex, ex ); } verify( databaseHealth, times( 1 ) ).panic( ioex ); }