### Question:
Log4jFileAppender implements Appender { public void doAppend( LoggingEvent event ) { String line = layout.format( event ) + Const.CR; try { fileOutputStream.write( line.getBytes( Const.XML_ENCODING ) ); } catch ( IOException e ) { System.out.println( "Unable to close Logging file [" + file.getName() + "] : " + e.getMessage() ); } } Log4jFileAppender( FileObject file );  Log4jFileAppender( FileObject file, boolean append ); void addFilter( Filter filter ); Filter getFilter(); void clearFilters(); void close(); void doAppend( LoggingEvent event ); void setName( String name ); String getName(); void setErrorHandler( ErrorHandler arg0 ); ErrorHandler getErrorHandler(); void setLayout( Layout layout ); Layout getLayout(); boolean requiresLayout(); FileObject getFile(); void setFilename( FileObject file ); OutputStream getFileOutputStream(); void setFileOutputStream( OutputStream fileOutputStream ); void setFilter( Filter filter );  }### Answer:
@Test public void doAppend() throws IOException { LoggingEvent loggingEvent = mock( LoggingEvent.class ); Layout testLayout = mock( Layout.class ); when( testLayout.format( loggingEvent ) ).thenReturn( "LOG_TEST_LINE" ); log4jFileAppender.setLayout( testLayout ); log4jFileAppender.doAppend( loggingEvent ); verify( outputStream ).write( ( "LOG_TEST_LINE" + Const.CR ).getBytes() ); }