VelocityDataSource implements IDataSource { @Override public void setRow(int index) throws DataSourceException { if (index < fRowCount) { fCurrentRow = index; } else { throw new DataSourceException( String.format("Index %d is out of bounds [0, %d]", index, fRowCount - 1)); } }  int getNumberOfRows(); @Override void setRow(int index); @Override String[] getFieldNames(); @Override Object getValueFor(String fieldName); @Override void close(); void loadFromStream(InputStream is); @ConfigurationOption(description = "The names of the variables that should be used as test data. The list is space separated.", defaultValue = "") void setIteratedVars(String value);  }
@Test public void invalidRowsAreReported() throws Exception { IDataSource ds = createDataSourceFromString("x", "#set($x=[1,2])"); try { ds.setRow(5); fail("Invalid row indexes should be reported"); } catch (DataSourceException ex) {} }