@Test public void test() throws Exception { String id = "1"; String logMessage = "Log message"; FileObject fileObject = mock( FileObject.class ); FileContent fileContent = mock( FileContent.class ); OutputStream outputStream = mock( OutputStream.class ); when( fileObject.getContent() ).thenReturn( fileContent ); when( fileContent.getOutputStream( anyBoolean() ) ).thenReturn( outputStream ); LogChannelFileWriter writer = new LogChannelFileWriter( id, fileObject, false ); LoggingRegistry.getInstance().getLogChannelFileWriterBuffer( id ).addEvent( new KettleLoggingEvent( logMessage, System.currentTimeMillis(), LogLevel.BASIC ) ); writer.flush(); ArgumentCaptor<byte[]> captor = ArgumentCaptor.forClass( byte[].class ); verify( outputStream ).write( captor.capture() ); String arguments = new String( captor.getValue() ); assertTrue( arguments.contains( logMessage ) ); }
public synchronized void flush() { try { StringBuffer buffer = this.buffer.getBuffer(); logFileOutputStream.write( buffer.toString().getBytes() ); logFileOutputStream.flush(); } catch ( Exception e ) { exception = new KettleException( "There was an error logging to file '" + logFile + "'", e ); } }
LogChannelFileWriter { public synchronized void flush() { try { StringBuffer buffer = this.buffer.getBuffer(); logFileOutputStream.write( buffer.toString().getBytes() ); logFileOutputStream.flush(); } catch ( Exception e ) { exception = new KettleException( "There was an error logging to file '" + logFile + "'", e ); } } }
LogChannelFileWriter { public synchronized void flush() { try { StringBuffer buffer = this.buffer.getBuffer(); logFileOutputStream.write( buffer.toString().getBytes() ); logFileOutputStream.flush(); } catch ( Exception e ) { exception = new KettleException( "There was an error logging to file '" + logFile + "'", e ); } } LogChannelFileWriter( String logChannelId, FileObject logFile, boolean appending, int pollingInterval );  LogChannelFileWriter( String logChannelId, FileObject logFile, boolean appending ); }
LogChannelFileWriter { public synchronized void flush() { try { StringBuffer buffer = this.buffer.getBuffer(); logFileOutputStream.write( buffer.toString().getBytes() ); logFileOutputStream.flush(); } catch ( Exception e ) { exception = new KettleException( "There was an error logging to file '" + logFile + "'", e ); } } LogChannelFileWriter( String logChannelId, FileObject logFile, boolean appending, int pollingInterval );  LogChannelFileWriter( String logChannelId, FileObject logFile, boolean appending ); void startLogging(); synchronized void flush(); void stopLogging(); KettleException getException(); String getLogChannelId(); void setLogChannelId( String logChannelId ); FileObject getLogFile(); void setLogFile( FileObject logFile ); boolean isAppending(); void setAppending( boolean appending ); int getPollingInterval(); void setPollingInterval( int pollingInterval ); }
LogChannelFileWriter { public synchronized void flush() { try { StringBuffer buffer = this.buffer.getBuffer(); logFileOutputStream.write( buffer.toString().getBytes() ); logFileOutputStream.flush(); } catch ( Exception e ) { exception = new KettleException( "There was an error logging to file '" + logFile + "'", e ); } } LogChannelFileWriter( String logChannelId, FileObject logFile, boolean appending, int pollingInterval );  LogChannelFileWriter( String logChannelId, FileObject logFile, boolean appending ); void startLogging(); synchronized void flush(); void stopLogging(); KettleException getException(); String getLogChannelId(); void setLogChannelId( String logChannelId ); FileObject getLogFile(); void setLogFile( FileObject logFile ); boolean isAppending(); void setAppending( boolean appending ); int getPollingInterval(); void setPollingInterval( int pollingInterval );  }