@Override public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr, Trans trans ) { return new CsvInput( stepMeta, stepDataInterface, cnr, tr, trans ); }
private CsvInput createCsvInput() { return new CsvInput( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); }
@Before public void setUp() throws Exception { System.setProperty( Const.KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL, "Y" ); stepMockHelper = StepMockUtil .getStepMockHelper( CsvInputMeta.class, "Pdi15270Test" ); csvInput = new CsvInput( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); }
@Before public void setUp() throws Exception { stepMockHelper = StepMockUtil.getStepMockHelper( CsvInputMeta.class, "CsvInputRowNumberTest" ); csvInput = new CsvInput( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); }
@Before public void setUp() throws Exception { stepMockHelper = StepMockUtil.getStepMockHelper( CsvInputMeta.class, "CsvInputEnclosureTest" ); csvInput = new CsvInput( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); }
@Before public void setUp() throws Exception { stepMockHelper = StepMockUtil.getStepMockHelper( CsvInputMeta.class, "CsvInputEnclosureTest" ); csvInput = new CsvInput( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); }
/** * Initialize for processing specified file. */ protected void init( String file ) throws Exception { meta.setFilename( getFile( file ).getURL().getFile() ); step = new CsvInput( stepMeta, null, 1, transMeta, trans ); step.init( meta, data ); step.addRowListener( rowListener ); }
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() ); }
private void doTest( final String fileEncoding, final String stepEncoding, final String testData ) throws Exception { String testFilePath = createTestFile( fileEncoding, testData ).getAbsolutePath(); CsvInputMeta meta = createStepMeta( testFilePath, stepEncoding ); 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++ ) { assertEquals( "Value", row[ i ] ); } } } ); boolean haveRowsToRead; do { haveRowsToRead = !csvInput.processRow( meta, data ); } while ( !haveRowsToRead ); csvInput.dispose( meta, data ); assertEquals( 2, csvInput.getLinesWritten() ); }