private void doTest( final String fileEncoding, final String stepEncoding, final String testData,
final String delimiter, final boolean useHeader ) throws Exception {
String testFilePath = createTestFile( fileEncoding, testData ).getAbsolutePath();
CsvInputMeta meta = createStepMeta( testFilePath, stepEncoding, delimiter, useHeader );
CsvInputData data = new CsvInputData();
CsvInput csvInput =
new CsvInput(
stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta,
stepMockHelper.trans );
csvInput.init( meta, data );
csvInput.addRowListener( new RowAdapter() {
@Override
public void rowWrittenEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException {
for ( int i = 0; i < rowMeta.size(); i++ ) {
Assert.assertEquals( "Value", row[ i ] );
}
}
} );
boolean haveRowsToRead;
do {
haveRowsToRead = !csvInput.processRow( meta, data );
} while ( !haveRowsToRead );
csvInput.dispose( meta, data );
Assert.assertEquals( 2, csvInput.getLinesWritten() );
}