commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1584903 - /commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
Date Fri, 04 Apr 2014 20:44:46 GMT
Author: ggregory
Date: Fri Apr  4 20:44:46 2014
New Revision: 1584903

URL: http://svn.apache.org/r1584903
Log:
Add API org.apache.commons.csv.CSVParser.getRecords(T).

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=1584903&r1=1584902&r2=1584903&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 Fri Apr
 4 20:44:46 2014
@@ -38,6 +38,7 @@ import java.net.URL;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
@@ -66,6 +67,8 @@ public class CSVParserTest {
                     // + "   \"foo\n,,\n\"\",,\n\\\"\",d,e\n";
                     + "   \"foo\n,,\n\"\",,\n\"\"\",d,e\n";   // changed to use standard
CSV escaping
 
+    private static final String CSV_INPUT_1 = "a,b,c,d";
+
     private static final String[][] RESULT = {
             {"a", "b", "c", "d"},
             {"a", "b", "1 2"},
@@ -512,6 +515,22 @@ public class CSVParserTest {
     }
 
     @Test
+    public void testGetOneLine() throws IOException {
+        final CSVParser parser = CSVParser.parse(CSV_INPUT_1, CSVFormat.DEFAULT);
+        final CSVRecord record = parser.getRecords().get(0);
+        assertArrayEquals(RESULT[0], record.values());
+        parser.close();
+    }
+
+    @Test
+    public void testGetOneLineCustomCollection() throws IOException {
+        final CSVParser parser = CSVParser.parse(CSV_INPUT_1, CSVFormat.DEFAULT);
+        final CSVRecord record = parser.getRecords(new LinkedList<CSVRecord>()).getFirst();
+        assertArrayEquals(RESULT[0], record.values());
+        parser.close();
+    }
+
+    @Test
     public void testGetRecordNumberWithCR() throws Exception {
         this.validateRecordNumbers(String.valueOf(CR));
     }



Mime
View raw message