Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6D256200B42 for ; Sun, 10 Jul 2016 21:39:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6B5B4160A58; Sun, 10 Jul 2016 19:39:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 205B9160A66 for ; Sun, 10 Jul 2016 21:38:57 +0200 (CEST) Received: (qmail 37094 invoked by uid 500); 10 Jul 2016 19:38:57 -0000 Mailing-List: contact notifications-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list notifications@commons.apache.org Received: (qmail 37081 invoked by uid 99); 10 Jul 2016 19:38:57 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Jul 2016 19:38:57 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id BFA35183A2C for ; Sun, 10 Jul 2016 19:38:56 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.426 X-Spam-Level: X-Spam-Status: No, score=-0.426 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id GfR4cRp32pr6 for ; Sun, 10 Jul 2016 19:38:35 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTP id 29AC461201 for ; Sun, 10 Jul 2016 19:38:28 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 8F6F7E7376 for ; Sun, 10 Jul 2016 19:38:24 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 59C6B3A2A2F for ; Sun, 10 Jul 2016 19:38:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r992480 [38/46] - in /websites/production/commons/content/proper/commons-csv: ./ apidocs/ apidocs/org/apache/commons/csv/ apidocs/org/apache/commons/csv/class-use/ apidocs/resources/ apidocs/src-html/org/apache/commons/csv/ css/ jacoco/ jac... Date: Sun, 10 Jul 2016 19:38:21 -0000 To: notifications@commons.apache.org From: britter@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160710193824.59C6B3A2A2F@svn01-us-west.apache.org> archived-at: Sun, 10 Jul 2016 19:39:00 -0000 Modified: websites/production/commons/content/proper/commons-csv/xref-test/org/apache/commons/csv/CSVPrinterTest.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/xref-test/org/apache/commons/csv/CSVPrinterTest.html (original) +++ websites/production/commons/content/proper/commons-csv/xref-test/org/apache/commons/csv/CSVPrinterTest.html Sun Jul 10 19:38:20 2016 @@ -1,963 +1,981 @@ - - - -CSVPrinterTest xref - - - -
-1   /*
-2    * Licensed to the Apache Software Foundation (ASF) under one or more
-3    * contributor license agreements.  See the NOTICE file distributed with
-4    * this work for additional information regarding copyright ownership.
-5    * The ASF licenses this file to You under the Apache License, Version 2.0
-6    * (the "License"); you may not use this file except in compliance with
-7    * the License.  You may obtain a copy of the License at
-8    *
-9    *      http://www.apache.org/licenses/LICENSE-2.0
-10   *
-11   * Unless required by applicable law or agreed to in writing, software
-12   * distributed under the License is distributed on an "AS IS" BASIS,
-13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-14   * See the License for the specific language governing permissions and
-15   * limitations under the License.
-16   */
-17  
-18  package org.apache.commons.csv;
-19  
-20  import static org.apache.commons.csv.Constants.CR;
-21  import static org.junit.Assert.assertArrayEquals;
-22  import static org.junit.Assert.assertEquals;
-23  import static org.junit.Assert.assertFalse;
-24  
-25  import java.io.IOException;
-26  import java.io.StringReader;
-27  import java.io.StringWriter;
-28  import java.sql.Connection;
-29  import java.sql.DriverManager;
-30  import java.sql.ResultSet;
-31  import java.sql.SQLException;
-32  import java.sql.Statement;
-33  import java.util.Arrays;
-34  import java.util.Date;
-35  import java.util.Iterator;
-36  import java.util.LinkedList;
-37  import java.util.List;
-38  import java.util.Random;
-39  
-40  import org.apache.commons.lang3.ObjectUtils;
-41  import org.junit.Ignore;
-42  import org.junit.Test;
-43  
-44  /**
-45   *
-46   *
-47   * @version $Id: CSVPrinterTest.java 1743528 2016-05-12 16:59:59Z ggregory $
-48   */
-49  public class CSVPrinterTest {
-50  
-51      private static final int ITERATIONS_FOR_RANDOM_TEST = 50000;
-52      
-53      private static String printable(final String s) {
-54          final StringBuilder sb = new StringBuilder();
-55          for (int i = 0; i < s.length(); i++) {
-56              final char ch = s.charAt(i);
-57              if (ch <= ' ' || ch >= 128) {
-58                  sb.append("(").append((int) ch).append(")");
-59              } else {
-60                  sb.append(ch);
-61              }
-62          }
-63          return sb.toString();
-64      }
-65  
-66      private final String recordSeparator = CSVFormat.DEFAULT.getRecordSeparator();
-67  
-68      private void doOneRandom(final CSVFormat format) throws Exception {
-69          final Random r = new Random();
-70  
-71          final int nLines = r.nextInt(4) + 1;
-72          final int nCol = r.nextInt(3) + 1;
-73          // nLines=1;nCol=2;
-74          final String[][] lines = generateLines(nLines, nCol);
-75  
-76          final StringWriter sw = new StringWriter();
-77          final CSVPrinter printer = new CSVPrinter(sw, format);
-78  
-79          for (int i = 0; i < nLines; i++) {
-80              // for (int j=0; j<lines[i].length; j++) System.out.println("### VALUE=:" + printable(lines[i][j]));
-81              printer.printRecord((Object[]) lines[i]);
-82          }
-83  
-84          printer.flush();
-85          printer.close();
-86          final String result = sw.toString();
-87          // System.out.println("### :" + printable(result));
-88  
-89          final CSVParser parser = CSVParser.parse(result, format);
-90          final List<CSVRecord> parseResult = parser.getRecords();
-91  
-92          final String[][] expected = lines.clone();
-93          for (int i = 0; i < expected.length; i++) {
-94              expected[i] = expectNulls(expected[i], format);
-95          }
-96          Utils.compare("Printer output :" + printable(result), expected, parseResult);
-97          parser.close();
-98      }
-99  
-100     private void doRandom(final CSVFormat format, final int iter) throws Exception {
-101         for (int i = 0; i < iter; i++) {
-102             doOneRandom(format);
-103         }
-104     }
-105 
-106     /**
-107      * Converts an input CSV array into expected output values WRT NULLs. NULL strings are converted to null values
-108      * because the parser will convert these strings to null.
-109      */
-110     private <T> T[] expectNulls(final T[] original, final CSVFormat csvFormat) {
-111         final T[] fixed = original.clone();
-112         for (int i = 0; i < fixed.length; i++) {
-113             if (ObjectUtils.equals(csvFormat.getNullString(), fixed[i])) {
-114                 fixed[i] = null;
-115             }
-116         }
-117         return fixed;
-118     }
-119 
-120     private Connection geH2Connection() throws SQLException, ClassNotFoundException {
-121         Class.forName("org.h2.Driver");
-122         return DriverManager.getConnection("jdbc:h2:mem:my_test;", "sa", "");
-123     }
-124 
-125     private String[][] generateLines(final int nLines, final int nCol) {
-126         final String[][] lines = new String[nLines][];
-127         for (int i = 0; i < nLines; i++) {
-128             final String[] line = new String[nCol];
-129             lines[i] = line;
-130             for (int j = 0; j < nCol; j++) {
-131                 line[j] = randStr();
-132             }
-133         }
-134         return lines;
-135     }
-136 
-137     private CSVPrinter printWithHeaderComments(final StringWriter sw, final Date now, final CSVFormat baseFormat)
-138             throws IOException {
-139         CSVFormat format = baseFormat;
-140         // Use withHeaderComments first to test CSV-145
-141         format = format.withHeaderComments("Generated by Apache Commons CSV 1.1", now);
-142         format = format.withCommentMarker('#');
-143         format = format.withHeader("Col1", "Col2");
-144         final CSVPrinter csvPrinter = format.print(sw);
-145         csvPrinter.printRecord("A", "B");
-146         csvPrinter.printRecord("C", "D");
-147         csvPrinter.close();
-148         return csvPrinter;
-149     }
-150 
-151     private String randStr() {
-152         final Random r = new Random();
-153 
-154         final int sz = r.nextInt(20);
-155         // sz = r.nextInt(3);
-156         final char[] buf = new char[sz];
-157         for (int i = 0; i < sz; i++) {
-158             // stick in special chars with greater frequency
-159             char ch;
-160             final int what = r.nextInt(20);
-161             switch (what) {
-162             case 0:
-163                 ch = '\r';
-164                 break;
-165             case 1:
-166                 ch = '\n';
-167                 break;
-168             case 2:
-169                 ch = '\t';
-170                 break;
-171             case 3:
-172                 ch = '\f';
-173                 break;
-174             case 4:
-175                 ch = ' ';
-176                 break;
-177             case 5:
-178                 ch = ',';
-179                 break;
-180             case 6:
-181                 ch = '"';
-182                 break;
-183             case 7:
-184                 ch = '\'';
-185                 break;
-186             case 8:
-187                 ch = '\\';
-188                 break;
-189             default:
-190                 ch = (char) r.nextInt(300);
-191                 break;
-192             // default: ch = 'a'; break;
-193             }
-194             buf[i] = ch;
-195         }
-196         return new String(buf);
-197     }
-198 
-199     private void setUpTable(final Connection connection) throws SQLException {
-200         final Statement statement = connection.createStatement();
-201         try {
-202             statement.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
-203             statement.execute("insert into TEST values(1, 'r1')");
-204             statement.execute("insert into TEST values(2, 'r2')");
-205         } finally {
-206             statement.close();
-207         }
-208     }
-209 
-210     @Test
-211     public void testDelimeterQuoted() throws IOException {
-212         final StringWriter sw = new StringWriter();
-213         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote('\''));
-214         printer.print("a,b,c");
-215         printer.print("xyz");
-216         assertEquals("'a,b,c',xyz", sw.toString());
-217         printer.close();
-218     }
-219 
-220     @Test
-221     public void testDelimeterQuoteNONE() throws IOException {
-222         final StringWriter sw = new StringWriter();
-223         final CSVFormat format = CSVFormat.DEFAULT.withEscape('!').withQuoteMode(QuoteMode.NONE);
-224         final CSVPrinter printer = new CSVPrinter(sw, format);
-225         printer.print("a,b,c");
-226         printer.print("xyz");
-227         assertEquals("a!,b!,c,xyz", sw.toString());
-228         printer.close();
-229     }
-230 
-231     @Test
-232     public void testDelimiterEscaped() throws IOException {
-233         final StringWriter sw = new StringWriter();
-234         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withEscape('!').withQuote(null));
-235         printer.print("a,b,c");
-236         printer.print("xyz");
-237         assertEquals("a!,b!,c,xyz", sw.toString());
-238         printer.close();
-239     }
-240 
-241     @Test
-242     public void testDelimiterPlain() throws IOException {
-243         final StringWriter sw = new StringWriter();
-244         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null));
-245         printer.print("a,b,c");
-246         printer.print("xyz");
-247         assertEquals("a,b,c,xyz", sw.toString());
-248         printer.close();
-249     }
-250 
-251     @Test
-252     public void testDisabledComment() throws IOException {
-253         final StringWriter sw = new StringWriter();
-254         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
-255         printer.printComment("This is a comment");
-256 
-257         assertEquals("", sw.toString());
-258         printer.close();
-259     }
-260     
-261     @Test
-262     public void testEOLEscaped() throws IOException {
-263         final StringWriter sw = new StringWriter();
-264         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null).withEscape('!'));
-265         printer.print("a\rb\nc");
-266         printer.print("x\fy\bz");
-267         assertEquals("a!rb!nc,x\fy\bz", sw.toString());
-268         printer.close();
-269     }
-270     
-271     @Test
-272     public void testEOLPlain() throws IOException {
-273         final StringWriter sw = new StringWriter();
-274         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null));
-275         printer.print("a\rb\nc");
-276         printer.print("x\fy\bz");
-277         assertEquals("a\rb\nc,x\fy\bz", sw.toString());
-278         printer.close();
-279     }
-280     
-281     @Test
-282     public void testEOLQuoted() throws IOException {
-283         final StringWriter sw = new StringWriter();
-284         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote('\''));
-285         printer.print("a\rb\nc");
-286         printer.print("x\by\fz");
-287         assertEquals("'a\rb\nc',x\by\fz", sw.toString());
-288         printer.close();
-289     }
-290     
-291     @Test
-292     public void testEscapeBackslash() throws IOException {
-293         StringWriter sw = new StringWriter();
-294         final char quoteChar = '\'';
-295         final String eol = "\r\n";
-296         CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(quoteChar));
-297         printer.print("\\");
-298         printer.close();
-299         assertEquals("'\\'", sw.toString());
-300 
-301         sw = new StringWriter();
-302         printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(quoteChar));
-303         printer.print("\\\r");
-304         printer.close();
-305         assertEquals("'\\\r'", sw.toString());
-306 
-307         sw = new StringWriter();
-308         printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(quoteChar));
-309         printer.print("X\\\r");
-310         printer.close();
-311         assertEquals("'X\\\r'", sw.toString());
-312 
-313         sw = new StringWriter();
-314         printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(quoteChar));
-315         printer.printRecord(new Object[] { "\\\r" });
-316         printer.close();
-317         assertEquals("'\\\r'" + eol, sw.toString());
-318 
-319         sw = new StringWriter();
-320         printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(quoteChar));
-321         printer.print("\\\\");
-322         printer.close();
-323         assertEquals("'\\\\'", sw.toString());
-324 
-325     }
-326 
-327     @Test
-328     public void testExcelPrintAllArrayOfArrays() throws IOException {
-329         final StringWriter sw = new StringWriter();
-330         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
-331         printer.printRecords((Object[]) new String[][] { { "r1c1", "r1c2" }, { "r2c1", "r2c2" } });
-332         assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" + recordSeparator, sw.toString());
-333         printer.close();
-334     }
-335 
-336     @Test
-337     public void testExcelPrintAllArrayOfLists() throws IOException {
-338         final StringWriter sw = new StringWriter();
-339         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
-340         printer.printRecords((Object[]) new List[] { Arrays.asList("r1c1", "r1c2"), Arrays.asList("r2c1", "r2c2") });
-341         assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" + recordSeparator, sw.toString());
-342         printer.close();
-343     }
-344 
-345     @Test
-346     public void testExcelPrintAllIterableOfArrays() throws IOException {
-347         final StringWriter sw = new StringWriter();
-348         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
-349         printer.printRecords(Arrays.asList(new String[][] { { "r1c1", "r1c2" }, { "r2c1", "r2c2" } }));
-350         assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" + recordSeparator, sw.toString());
-351         printer.close();
-352     }
-353 
-354     @Test
-355     public void testExcelPrintAllIterableOfLists() throws IOException {
-356         final StringWriter sw = new StringWriter();
-357         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
-358         printer.printRecords(
-359                 Arrays.asList(new List[] { Arrays.asList("r1c1", "r1c2"), Arrays.asList("r2c1", "r2c2") }));
-360         assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" + recordSeparator, sw.toString());
-361         printer.close();
-362     }
-363 
-364     @Test
-365     public void testExcelPrinter1() throws IOException {
-366         final StringWriter sw = new StringWriter();
-367         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
-368         printer.printRecord("a", "b");
-369         assertEquals("a,b" + recordSeparator, sw.toString());
-370         printer.close();
-371     }
-372 
-373     @Test
-374     public void testExcelPrinter2() throws IOException {
-375         final StringWriter sw = new StringWriter();
-376         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
-377         printer.printRecord("a,b", "b");
-378         assertEquals("\"a,b\",b" + recordSeparator, sw.toString());
-379         printer.close();
-380     }
-381 
-382     @Test
-383     public void testHeader() throws IOException {
-384         final StringWriter sw = new StringWriter();
-385         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null).withHeader("C1", "C2", "C3"));
-386         printer.printRecord("a", "b", "c");
-387         printer.printRecord("x", "y", "z");
-388         assertEquals("C1,C2,C3\r\na,b,c\r\nx,y,z\r\n", sw.toString());
-389         printer.close();
-390     }
-391 
-392     @Test
-393     public void testHeaderCommentExcel() throws IOException {
-394         final StringWriter sw = new StringWriter();
-395         final Date now = new Date();
-396         final CSVFormat format = CSVFormat.EXCEL;
-397         final CSVPrinter csvPrinter = printWithHeaderComments(sw, now, format);
-398         assertEquals("# Generated by Apache Commons CSV 1.1\r\n# " + now + "\r\nCol1,Col2\r\nA,B\r\nC,D\r\n",
-399                 sw.toString());
-400         csvPrinter.close();
-401     }
-402 
-403     @Test
-404     public void testHeaderCommentTdf() throws IOException {
-405         final StringWriter sw = new StringWriter();
-406         final Date now = new Date();
-407         final CSVFormat format = CSVFormat.TDF;
-408         final CSVPrinter csvPrinter = printWithHeaderComments(sw, now, format);
-409         assertEquals("# Generated by Apache Commons CSV 1.1\r\n# " + now + "\r\nCol1\tCol2\r\nA\tB\r\nC\tD\r\n",
-410                 sw.toString());
-411         csvPrinter.close();
-412     }
-413 
-414     @Test
-415     public void testHeaderNotSet() throws IOException {
-416         final StringWriter sw = new StringWriter();
-417         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null));
-418         printer.printRecord("a", "b", "c");
-419         printer.printRecord("x", "y", "z");
-420         assertEquals("a,b,c\r\nx,y,z\r\n", sw.toString());
-421         printer.close();
-422     }
-423 
-424     @Test(expected = IllegalArgumentException.class)
-425     public void testInvalidFormat() throws Exception {
-426         final CSVFormat invalidFormat = CSVFormat.DEFAULT.withDelimiter(CR);
-427         new CSVPrinter(new StringWriter(), invalidFormat).close();
-428     }
-429 
-430     @Test
-431     public void testJdbcPrinter() throws IOException, ClassNotFoundException, SQLException {
-432         final StringWriter sw = new StringWriter();
-433         final Connection connection = geH2Connection();
-434         try {
-435             setUpTable(connection);
-436             final Statement stmt = connection.createStatement();
-437             final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
-438             printer.printRecords(stmt.executeQuery("select ID, NAME from TEST"));
-439             assertEquals("1,r1" + recordSeparator + "2,r2" + recordSeparator, sw.toString());
-440             printer.close();
-441         } finally {
-442             connection.close();
-443         }
-444     }
-445 
-446     @Test
-447     public void testJdbcPrinterWithResultSet() throws IOException, ClassNotFoundException, SQLException {
-448         final StringWriter sw = new StringWriter();
-449         Class.forName("org.h2.Driver");
-450         final Connection connection = geH2Connection();
-451         try {
-452             setUpTable(connection);
-453             @SuppressWarnings("resource")
-454             // Closed when the connection is closed.
-455             final Statement stmt = connection.createStatement();
-456             @SuppressWarnings("resource")
-457             // Closed when the connection is closed.
-458             final ResultSet resultSet = stmt.executeQuery("select ID, NAME from TEST");
-459             final CSVPrinter printer = CSVFormat.DEFAULT.withHeader(resultSet).print(sw);
-460             printer.printRecords(resultSet);
-461             assertEquals("ID,NAME" + recordSeparator + "1,r1" + recordSeparator + "2,r2" + recordSeparator,
-462                     sw.toString());
-463             printer.close();
-464         } finally {
-465             connection.close();
-466         }
-467     }
-468 
-469     @Test
-470     public void testJdbcPrinterWithResultSetMetaData() throws IOException, ClassNotFoundException, SQLException {
-471         final StringWriter sw = new StringWriter();
-472         Class.forName("org.h2.Driver");
-473         final Connection connection = geH2Connection();
-474         try {
-475             setUpTable(connection);
-476             @SuppressWarnings("resource")
-477             // Closed when the connection is closed.
-478             final Statement stmt = connection.createStatement();
-479             @SuppressWarnings("resource")
-480             // Closed when the connection is closed.
-481             final ResultSet resultSet = stmt.executeQuery("select ID, NAME from TEST");
-482             final CSVPrinter printer = CSVFormat.DEFAULT.withHeader(resultSet.getMetaData()).print(sw);
-483             printer.printRecords(resultSet);
-484             assertEquals("ID,NAME" + recordSeparator + "1,r1" + recordSeparator + "2,r2" + recordSeparator,
-485                     sw.toString());
-486             printer.close();
-487         } finally {
-488             connection.close();
-489         }
-490     }
-491 
-492     @Test
-493     @Ignore
-494     public void testJira135_part1() throws IOException {
-495         final CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
-496         final StringWriter sw = new StringWriter();
-497         final CSVPrinter printer = new CSVPrinter(sw, format);
-498         final List<String> list = new LinkedList<String>();
-499         list.add("\"");
-500         printer.printRecord(list);
-501         printer.close();
-502         final String expected = "\"\\\"\"" + format.getRecordSeparator();
-503         assertEquals(expected, sw.toString());
-504         final String[] record0 = toFirstRecordValues(expected, format);
-505         assertArrayEquals(expectNulls(list.toArray(), format), record0);
-506     }
-507 
-508     @Test
-509     @Ignore
-510     public void testJira135_part2() throws IOException {
-511         final CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
-512         final StringWriter sw = new StringWriter();
-513         final CSVPrinter printer = new CSVPrinter(sw, format);
-514         final List<String> list = new LinkedList<String>();
-515         list.add("\n");
-516         printer.printRecord(list);
-517         printer.close();
-518         final String expected = "\"\\n\"" + format.getRecordSeparator();
-519         assertEquals(expected, sw.toString());
-520         final String[] record0 = toFirstRecordValues(expected, format);
-521         assertArrayEquals(expectNulls(list.toArray(), format), record0);
-522     }
-523 
-524     @Test
-525     @Ignore
-526     public void testJira135_part3() throws IOException {
-527         final CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
-528         final StringWriter sw = new StringWriter();
-529         final CSVPrinter printer = new CSVPrinter(sw, format);
-530         final List<String> list = new LinkedList<String>();
-531         list.add("\\");
-532         printer.printRecord(list);
-533         printer.close();
-534         final String expected = "\"\\\\\"" + format.getRecordSeparator();
-535         assertEquals(expected, sw.toString());
-536         final String[] record0 = toFirstRecordValues(expected, format);
-537         assertArrayEquals(expectNulls(list.toArray(), format), record0);
-538     }
-539 
-540     @Test
-541     @Ignore
-542     public void testJira135All() throws IOException {
-543         final CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
-544         final StringWriter sw = new StringWriter();
-545         final CSVPrinter printer = new CSVPrinter(sw, format);
-546         final List<String> list = new LinkedList<String>();
-547         list.add("\"");
-548         list.add("\n");
-549         list.add("\\");
-550         printer.printRecord(list);
-551         printer.close();
-552         final String expected = "\"\\\"\",\"\\n\",\"\\\"" + format.getRecordSeparator();
-553         assertEquals(expected, sw.toString());
-554         final String[] record0 = toFirstRecordValues(expected, format);
-555         assertArrayEquals(expectNulls(list.toArray(), format), record0);
-556     }
-557 
-558     @Test
-559     public void testMultiLineComment() throws IOException {
-560         final StringWriter sw = new StringWriter();
-561         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withCommentMarker('#'));
-562         printer.printComment("This is a comment\non multiple lines");
-563 
-564         assertEquals("# This is a comment" + recordSeparator + "# on multiple lines" + recordSeparator, sw.toString());
-565         printer.close();
-566     }
-567 
-568     @Test
-569     public void testMySqlNullOutput() throws IOException {
-570         Object[] s = new String[] { "NULL", null };
-571         CSVFormat format = CSVFormat.MYSQL.withQuote('"').withNullString("NULL").withQuoteMode(QuoteMode.NON_NUMERIC);
-572         StringWriter writer = new StringWriter();
-573         CSVPrinter printer = new CSVPrinter(writer, format);
-574         printer.printRecord(s);
-575         printer.close();
-576         String expected = "\"NULL\"\tNULL\n";
-577         assertEquals(expected, writer.toString());
-578         String[] record0 = toFirstRecordValues(expected, format);
-579         assertArrayEquals(new Object[2], record0);
-580 
-581         s = new String[] { "\\N", null };
-582         format = CSVFormat.MYSQL.withNullString("\\N");
-583         writer = new StringWriter();
-584         printer = new CSVPrinter(writer, format);
-585         printer.printRecord(s);
-586         printer.close();
-587         expected = "\\\\N\t\\N\n";
-588         assertEquals(expected, writer.toString());
-589         record0 = toFirstRecordValues(expected, format);
-590         assertArrayEquals(expectNulls(s, format), record0);
-591 
-592         s = new String[] { "\\N", "A" };
-593         format = CSVFormat.MYSQL.withNullString("\\N");
-594         writer = new StringWriter();
-595         printer = new CSVPrinter(writer, format);
-596         printer.printRecord(s);
-597         printer.close();
-598         expected = "\\\\N\tA\n";
-599         assertEquals(expected, writer.toString());
-600         record0 = toFirstRecordValues(expected, format);
-601         assertArrayEquals(expectNulls(s, format), record0);
-602 
-603         s = new String[] { "\n", "A" };
-604         format = CSVFormat.MYSQL.withNullString("\\N");
-605         writer = new StringWriter();
-606         printer = new CSVPrinter(writer, format);
-607         printer.printRecord(s);
-608         printer.close();
-609         expected = "\\n\tA\n";
-610         assertEquals(expected, writer.toString());
-611         record0 = toFirstRecordValues(expected, format);
-612         assertArrayEquals(expectNulls(s, format), record0);
-613 
-614         s = new String[] { "", null };
-615         format = CSVFormat.MYSQL.withNullString("NULL");
-616         writer = new StringWriter();
-617         printer = new CSVPrinter(writer, format);
-618         printer.printRecord(s);
-619         printer.close();
-620         expected = "\tNULL\n";
-621         assertEquals(expected, writer.toString());
-622         record0 = toFirstRecordValues(expected, format);
-623         assertArrayEquals(expectNulls(s, format), record0);
-624 
-625         s = new String[] { "", null };
-626         format = CSVFormat.MYSQL;
-627         writer = new StringWriter();
-628         printer = new CSVPrinter(writer, format);
-629         printer.printRecord(s);
-630         printer.close();
-631         expected = "\t\\N\n";
-632         assertEquals(expected, writer.toString());
-633         record0 = toFirstRecordValues(expected, format);
-634         assertArrayEquals(expectNulls(s, format), record0);
-635 
-636         s = new String[] { "\\N", "", "\u000e,\\\r" };
-637         format = CSVFormat.MYSQL;
-638         writer = new StringWriter();
-639         printer = new CSVPrinter(writer, format);
-640         printer.printRecord(s);
-641         printer.close();
-642         expected = "\\\\N\t\t\u000e,\\\\\\r\n";
-643         assertEquals(expected, writer.toString());
-644         record0 = toFirstRecordValues(expected, format);
-645         assertArrayEquals(expectNulls(s, format), record0);
-646 
-647         s = new String[] { "NULL", "\\\r" };
-648         format = CSVFormat.MYSQL;
-649         writer = new StringWriter();
-650         printer = new CSVPrinter(writer, format);
-651         printer.printRecord(s);
-652         printer.close();
-653         expected = "NULL\t\\\\\\r\n";
-654         assertEquals(expected, writer.toString());
-655         record0 = toFirstRecordValues(expected, format);
-656         assertArrayEquals(expectNulls(s, format), record0);
-657 
-658         s = new String[] { "\\\r" };
-659         format = CSVFormat.MYSQL;

[... 1278 lines stripped ...]