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 2016/01/19 07:20:08 UTC
svn commit: r1725424 -
/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
Author: ggregory
Date: Tue Jan 19 06:20:08 2016
New Revision: 1725424
URL: http://svn.apache.org/viewvc?rev=1725424&view=rev
Log:
Update copyright for 2016 in NOTICE.txt
Modified:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java?rev=1725424&r1=1725423&r2=1725424&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java Tue Jan 19 06:20:08 2016
@@ -33,6 +33,7 @@ import java.sql.Statement;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Random;
@@ -232,6 +233,68 @@ public class CSVPrinterTest {
}
@Test
+ public void testJira135All() throws IOException {
+ CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
+ StringWriter sw = new StringWriter();
+ CSVPrinter printer = new CSVPrinter(sw, format);
+ List<String> list = new LinkedList<String>();
+ list.add("\"");
+ list.add("\n");
+ list.add("\\");
+ printer.printRecord(list);
+ printer.close();
+ final String expected = "\"\\\"\",\"\\n\",\"\\\"" + format.getRecordSeparator();
+ assertEquals(expected, sw.toString());
+ String[] record0 = toFirstRecordValues(expected, format);
+ assertArrayEquals(expectNulls(list.toArray(), format), record0);
+ }
+
+ @Test
+ public void testJira135_part3() throws IOException {
+ CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
+ StringWriter sw = new StringWriter();
+ CSVPrinter printer = new CSVPrinter(sw, format);
+ List<String> list = new LinkedList<String>();
+ list.add("\\");
+ printer.printRecord(list);
+ printer.close();
+ final String expected = "\"\\\\\"" + format.getRecordSeparator();
+ assertEquals(expected, sw.toString());
+ String[] record0 = toFirstRecordValues(expected, format);
+ assertArrayEquals(expectNulls(list.toArray(), format), record0);
+ }
+
+ @Test
+ public void testJira135_part2() throws IOException {
+ CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
+ StringWriter sw = new StringWriter();
+ CSVPrinter printer = new CSVPrinter(sw, format);
+ List<String> list = new LinkedList<String>();
+ list.add("\n");
+ printer.printRecord(list);
+ printer.close();
+ final String expected = "\"\\n\"" + format.getRecordSeparator();
+ assertEquals(expected, sw.toString());
+ String[] record0 = toFirstRecordValues(expected, format);
+ assertArrayEquals(expectNulls(list.toArray(), format), record0);
+ }
+
+ @Test
+ public void testJira135_part1() throws IOException {
+ CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
+ StringWriter sw = new StringWriter();
+ CSVPrinter printer = new CSVPrinter(sw, format);
+ List<String> list = new LinkedList<String>();
+ list.add("\"");
+ printer.printRecord(list);
+ printer.close();
+ final String expected = "\"\\\"\"" + format.getRecordSeparator();
+ assertEquals(expected, sw.toString());
+ String[] record0 = toFirstRecordValues(expected, format);
+ assertArrayEquals(expectNulls(list.toArray(), format), record0);
+ }
+
+ @Test
public void testJdbcPrinter() throws IOException, ClassNotFoundException, SQLException {
final StringWriter sw = new StringWriter();
final Connection connection = geH2Connection();