You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2014/03/17 02:05:57 UTC
svn commit: r1578196 -
/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
Author: ggregory
Date: Mon Mar 17 01:05:57 2014
New Revision: 1578196
URL: http://svn.apache.org/r1578196
Log:
Testing [CSV-107] CSVFormat.EXCEL.parse should handle byte order marks
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=1578196&r1=1578195&r2=1578196&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 Mar 17 01:05:57 2014
@@ -30,6 +30,7 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
@@ -41,6 +42,7 @@ import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
+import org.apache.commons.io.input.BOMInputStream;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -177,6 +179,34 @@ public class CSVParserTest {
}
@Test
+ @Ignore("CSV-107")
+ public void testBOM() throws IOException {
+ URL url = ClassLoader.getSystemClassLoader().getResource("CSVFileParser/bom.csv");
+ final CSVParser parser = CSVParser.parse(url, null, CSVFormat.EXCEL.withHeader());
+ try {
+ for (CSVRecord record : parser) {
+ System.out.println("date: " + record.get("Date"));
+ }
+ } finally {
+ parser.close();
+ }
+ }
+
+ @Test
+ public void testBOMInputStream() throws IOException {
+ URL url = ClassLoader.getSystemClassLoader().getResource("CSVFileParser/bom.csv");
+ Reader reader = new InputStreamReader(new BOMInputStream(url.openStream()), "UTF-8");
+ final CSVParser parser = new CSVParser(reader, CSVFormat.EXCEL.withHeader());
+ try {
+ for (CSVRecord record : parser) {
+ System.out.println("date: " + record.get("Date"));
+ }
+ } finally {
+ parser.close();
+ }
+ }
+
+ @Test
public void testCarriageReturnEndings() throws IOException {
final String code = "foo\rbaar,\rhello,world\r,kanu";
final CSVParser parser = CSVParser.parse(code, CSVFormat.DEFAULT);