HtmlDataSource implements IDataSource { @Override public void loadFromStream(InputStream is) throws DataSourceException { Parser parser = new HTMLParse().getParserPublic(); data = new ArrayList<List<String>>(); ParserCallback callback = new DataSourceHtmlParser(); try { parser.parse(new InputStreamReader(is), callback, true); is.close(); } catch (IOException e) { throw new DataSourceException("Error while reading HTML: " + e.getMessage(), e); } if (hadRowOrColSpan) { throw new DataSourceException( "The input table in the HTML file had rowspan or colspan attributes. These are not allowed for a data source!"); } if (data.size() == 0) { throw new DataSourceException("No table data found in HTML file!"); } this.headings = data.remove(0); }  @Override void close(); @Override String[] getFieldNames(); @Override int getNumberOfRows(); @Override Object getValueFor(String fieldName); @Override void loadFromStream(InputStream is); @Override void setRow(int index); @ConfigurationOption(defaultValue = "1", description = "The index of the table in the HTML file in which the data is contained") void setTable(String value);  }
@Test(expected = DataSourceException.class) public void testTableNotFound() throws Exception { this.ds.loadFromStream(getStream("no-table")); }
@Test(expected = DataSourceException.class) public void testTableWithNoRows() throws Exception { this.ds.loadFromStream(getStream("table-with-no-rows")); }
@Test(expected = DataSourceException.class) public void testTableWithColSpan() throws Exception { this.ds.loadFromStream(getStream("table-with-colspan")); }
@Test(expected = DataSourceException.class) public void testTableWithRowSpan() throws Exception { this.ds.loadFromStream(getStream("table-with-rowspan")); }