@Test public void testBigBadFile2() throws IOException { // the problem with this file is that it contains unbalanced quotes, // but now we've set the buffer size bigger than the file size. that // should lead to a different error message ClassLoader cloader = Thread.currentThread().getContextClassLoader(); InputStream istream = cloader.getResourceAsStream("big-bad.csv"); CSVReader reader = new CSVReader(new InputStreamReader(istream), 90000, "big-bad.csv"); try { String[] row = reader.next(); while (reader.next() != null) ; fail("Shouldn't accept malformed file"); } catch (DukeException e) { // error message must contain name of file assertTrue(e.getMessage().indexOf("big-bad.csv") != -1); } }
@Test public void testBigBadFile() throws IOException { // the problem with this file is that it contains unbalanced quotes, // leading to a row that's longer than the buffer. that used to cause // a stack overflow crash. we verify that instead we get an error message ClassLoader cloader = Thread.currentThread().getContextClassLoader(); InputStream istream = cloader.getResourceAsStream("big-bad.csv"); CSVReader reader = new CSVReader(new InputStreamReader(istream), 65536, "big-bad.csv"); try { String[] row = reader.next(); while (reader.next() != null) ; fail("Shouldn't accept malformed file"); } catch (DukeException e) { // error message must contain name of file assertTrue(e.getMessage().indexOf("big-bad.csv") != -1); } }