Author: britter
Date: Mon Aug 12 19:23:16 2013
New Revision: 1513228
URL: http://svn.apache.org/r1513228
Log:
Add test that documents behavior of multiple iterators over the same CSVParser.
Modified:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
Modified:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java?rev=1513228&r1=1513227&r2=1513228&view=diff
==============================================================================
---
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
(original)
+++
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
Mon Aug 12 19:23:16 2013
@@ -488,6 +488,24 @@ public class CSVParserTest {
}
}
+ @Test // TODO this may lead to strange behavior, throw an exception if
iterator() has already been called?
+ public void testMultipleIterators() throws Exception {
+ CSVParser parser = CSVParser.parse("a,b,c" + CR + "d,e,f",
CSVFormat.DEFAULT);
+
+ Iterator<CSVRecord> itr1 = parser.iterator();
+ Iterator<CSVRecord> itr2 = parser.iterator();
+
+ CSVRecord first = itr1.next();
+ assertEquals("a", first.get(0));
+ assertEquals("b", first.get(1));
+ assertEquals("c", first.get(2));
+
+ CSVRecord second = itr2.next();
+ assertEquals("d", second.get(0));
+ assertEquals("e", second.get(1));
+ assertEquals("f", second.get(2));
+ }
+
@Test
public void testHeader() throws Exception {
final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");