### Question:
TextFileOutput extends BaseStep implements StepInterface { public void writeRowToFile( RowMetaInterface rowMeta, Object[] r ) throws KettleStepException { try { if ( meta.getOutputFields() == null || meta.getOutputFields().length == 0 ) { for ( int i = 0; i < rowMeta.size(); i++ ) { if ( i > 0 && data.binarySeparator.length > 0 ) { data.writer.write( data.binarySeparator ); } ValueMetaInterface v = rowMeta.getValueMeta( i ); Object valueData = r[i]; writeField( v, valueData, null ); } data.writer.write( data.binaryNewline ); } else { for ( int i = 0; i < meta.getOutputFields().length; i++ ) { if ( i > 0 && data.binarySeparator.length > 0 ) { data.writer.write( data.binarySeparator ); } ValueMetaInterface v = rowMeta.getValueMeta( data.fieldnrs[i] ); Object valueData = r[data.fieldnrs[i]]; writeField( v, valueData, data.binaryNullValue[i] ); } data.writer.write( data.binaryNewline ); } incrementLinesOutput(); } catch ( Exception e ) { throw new KettleStepException( "Error writing line", e ); } } TextFileOutput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
      Trans trans ); synchronized boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void writeRowToFile( RowMetaInterface rowMeta, Object[] r ); String buildFilename( String filename, boolean ziparchive ); void openNewFile( String baseFilename ); boolean checkPreviouslyOpened( String filename ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); boolean containsSeparatorOrEnclosure( byte[] source, byte[] separator, byte[] enclosure ); public TextFileOutputMeta meta; public TextFileOutputData data; }### Answer:
@Test public void testFastDumpDisableStreamEncodeTest() throws Exception { textFileOutput = new TextFileOutputTestHandler( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); textFileOutput.meta = stepMockHelper.processRowsStepMetaInterface; String testString = "ÖÜä"; String inputEncode = "UTF-8"; String outputEncode = "Windows-1252"; Object[] rows = {testString.getBytes( inputEncode )}; ValueMetaBase valueMetaInterface = new ValueMetaBase( "test", ValueMetaInterface.TYPE_STRING ); valueMetaInterface.setStringEncoding( inputEncode ); valueMetaInterface.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING ); valueMetaInterface.setStorageMetadata( new ValueMetaString() ); TextFileOutputData data = new TextFileOutputData(); data.binarySeparator = " ".getBytes(); data.binaryEnclosure = "\"".getBytes(); data.binaryNewline = "\n".getBytes(); textFileOutput.data = data; RowMeta rowMeta = new RowMeta(); rowMeta.addValueMeta( valueMetaInterface ); Mockito.doReturn( outputEncode ).when( stepMockHelper.processRowsStepMetaInterface ).getEncoding(); textFileOutput.data.writer = Mockito.mock( BufferedOutputStream.class ); textFileOutput.writeRowToFile( rowMeta, rows ); Mockito.verify( textFileOutput.data.writer, Mockito.times( 1 ) ).write( testString.getBytes( outputEncode ) ); }