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 D7423200CF9 for ; Sun, 3 Sep 2017 07:34:26 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D5DE416468E; Sun, 3 Sep 2017 05:34:26 +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 81C991646C3 for ; Sun, 3 Sep 2017 07:34:24 +0200 (CEST) Received: (qmail 99654 invoked by uid 500); 3 Sep 2017 05:34:23 -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 98961 invoked by uid 99); 3 Sep 2017 05:34:20 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Sep 2017 05:34:20 +0000 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 3B4913A0D24 for ; Sun, 3 Sep 2017 05:34:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1017635 [26/40] - in /websites/production/commons/content/proper/commons-csv: ./ apidocs/ apidocs/org/apache/commons/csv/ apidocs/org/apache/commons/csv/class-use/ apidocs/src-html/org/apache/commons/csv/ images/ jacoco-aggregate/ jacoco-a... Date: Sun, 03 Sep 2017 05:34:10 -0000 To: notifications@commons.apache.org From: kinow@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170903053415.3B4913A0D24@svn01-us-west.apache.org> archived-at: Sun, 03 Sep 2017 05:34:27 -0000 Modified: websites/production/commons/content/proper/commons-csv/xref-test/org/apache/commons/csv/CSVFormatTest.html ============================================================================== --- websites/production/commons/content/proper/commons-csv/xref-test/org/apache/commons/csv/CSVFormatTest.html (original) +++ websites/production/commons/content/proper/commons-csv/xref-test/org/apache/commons/csv/CSVFormatTest.html Sun Sep 3 05:34:03 2017 @@ -25,30 +25,30 @@ 17 18 package org.apache.commons.csv; 19 -20 import static org.apache.commons.csv.CSVFormat.RFC4180; -21 import static org.apache.commons.csv.Constants.CR; -22 import static org.apache.commons.csv.Constants.CRLF; -23 import static org.apache.commons.csv.Constants.LF; -24 import static org.junit.Assert.assertArrayEquals; -25 import static org.junit.Assert.assertEquals; -26 import static org.junit.Assert.assertFalse; -27 import static org.junit.Assert.assertNotNull; -28 import static org.junit.Assert.assertNotSame; -29 import static org.junit.Assert.assertTrue; -30 -31 import java.io.ByteArrayInputStream; -32 import java.io.ByteArrayOutputStream; -33 import java.io.ObjectInputStream; -34 import java.io.ObjectOutputStream; -35 import java.util.Arrays; -36 -37 import org.junit.Assert; -38 import org.junit.Test; -39 -40 /** -41 * -42 * -43 * @version $Id$ +20 import static junit.framework.TestCase.assertNull; +21 import static org.apache.commons.csv.CSVFormat.RFC4180; +22 import static org.apache.commons.csv.Constants.CR; +23 import static org.apache.commons.csv.Constants.CRLF; +24 import static org.apache.commons.csv.Constants.LF; +25 import static org.junit.Assert.assertArrayEquals; +26 import static org.junit.Assert.assertEquals; +27 import static org.junit.Assert.assertFalse; +28 import static org.junit.Assert.assertNotNull; +29 import static org.junit.Assert.assertNotSame; +30 import static org.junit.Assert.assertTrue; +31 import static org.junit.Assert.fail; +32 +33 import java.io.ByteArrayInputStream; +34 import java.io.ByteArrayOutputStream; +35 import java.io.ObjectInputStream; +36 import java.io.ObjectOutputStream; +37 import java.util.Arrays; +38 +39 import org.junit.Assert; +40 import org.junit.Test; +41 +42 /** +43 * 44 */ 45 public class CSVFormatTest { 46 @@ -183,7 +183,7 @@ 175 public void testEqualsLeftNoQuoteRightQuote() { 176 final CSVFormat left = CSVFormat.newFormat(',').withQuote(null); 177 final CSVFormat right = left.withQuote('#'); -178 +178 179 assertNotEquals(left, right); 180 } 181 @@ -467,15 +467,640 @@ 459 assertTrue(formatWithFirstRecordAsHeader.getHeader().length == 0); 460 } 461 -462 public enum Header { -463 Name, Email, Phone -464 } -465 -466 public enum EmptyEnum { -467 } -468 } +462 @Test +463 public void testToStringAndWithCommentMarkerTakingCharacter() { +464 +465 CSVFormat.Predefined cSVFormat_Predefined = CSVFormat.Predefined.Default; +466 CSVFormat cSVFormat = cSVFormat_Predefined.getFormat(); +467 +468 assertNull(cSVFormat.getEscapeCharacter()); +469 assertTrue(cSVFormat.isQuoteCharacterSet()); +470 +471 assertFalse(cSVFormat.getTrim()); +472 assertFalse(cSVFormat.getIgnoreSurroundingSpaces()); +473 +474 assertFalse(cSVFormat.getTrailingDelimiter()); +475 assertEquals(',', cSVFormat.getDelimiter()); +476 +477 assertFalse(cSVFormat.getIgnoreHeaderCase()); +478 assertEquals("\r\n", cSVFormat.getRecordSeparator()); +479 +480 assertFalse(cSVFormat.isCommentMarkerSet()); +481 assertNull(cSVFormat.getCommentMarker()); +482 +483 assertFalse(cSVFormat.isNullStringSet()); +484 assertFalse(cSVFormat.getAllowMissingColumnNames()); +485 +486 assertFalse(cSVFormat.isEscapeCharacterSet()); +487 assertFalse(cSVFormat.getSkipHeaderRecord()); +488 +489 assertNull(cSVFormat.getNullString()); +490 assertNull(cSVFormat.getQuoteMode()); +491 +492 assertTrue(cSVFormat.getIgnoreEmptyLines()); +493 assertEquals('\"', (char)cSVFormat.getQuoteCharacter()); +494 +495 Character character = Character.valueOf('n'); +496 +497 CSVFormat cSVFormatTwo = cSVFormat.withCommentMarker(character); +498 +499 assertNull(cSVFormat.getEscapeCharacter()); +500 assertTrue(cSVFormat.isQuoteCharacterSet()); +501 +502 assertFalse(cSVFormat.getTrim()); +503 assertFalse(cSVFormat.getIgnoreSurroundingSpaces()); +504 +505 assertFalse(cSVFormat.getTrailingDelimiter()); +506 assertEquals(',', cSVFormat.getDelimiter()); +507 +508 assertFalse(cSVFormat.getIgnoreHeaderCase()); +509 assertEquals("\r\n", cSVFormat.getRecordSeparator()); +510 +511 assertFalse(cSVFormat.isCommentMarkerSet()); +512 assertNull(cSVFormat.getCommentMarker()); +513 +514 assertFalse(cSVFormat.isNullStringSet()); +515 assertFalse(cSVFormat.getAllowMissingColumnNames()); +516 +517 assertFalse(cSVFormat.isEscapeCharacterSet()); +518 assertFalse(cSVFormat.getSkipHeaderRecord()); +519 +520 assertNull(cSVFormat.getNullString()); +521 assertNull(cSVFormat.getQuoteMode()); +522 +523 assertTrue(cSVFormat.getIgnoreEmptyLines()); +524 assertEquals('\"', (char)cSVFormat.getQuoteCharacter()); +525 +526 assertFalse(cSVFormatTwo.isNullStringSet()); +527 assertFalse(cSVFormatTwo.getAllowMissingColumnNames()); +528 +529 assertEquals('\"', (char)cSVFormatTwo.getQuoteCharacter()); +530 assertNull(cSVFormatTwo.getNullString()); +531 +532 assertEquals(',', cSVFormatTwo.getDelimiter()); +533 assertFalse(cSVFormatTwo.getTrailingDelimiter()); +534 +535 assertTrue(cSVFormatTwo.isCommentMarkerSet()); +536 assertFalse(cSVFormatTwo.getIgnoreHeaderCase()); +537 +538 assertFalse(cSVFormatTwo.getTrim()); +539 assertNull(cSVFormatTwo.getEscapeCharacter()); +540 +541 assertTrue(cSVFormatTwo.isQuoteCharacterSet()); +542 assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces()); +543 +544 assertEquals("\r\n", cSVFormatTwo.getRecordSeparator()); +545 assertNull(cSVFormatTwo.getQuoteMode()); +546 +547 assertEquals('n', (char)cSVFormatTwo.getCommentMarker()); +548 assertFalse(cSVFormatTwo.getSkipHeaderRecord()); +549 +550 assertFalse(cSVFormatTwo.isEscapeCharacterSet()); +551 assertTrue(cSVFormatTwo.getIgnoreEmptyLines()); +552 +553 assertNotSame(cSVFormat, cSVFormatTwo); +554 assertNotSame(cSVFormatTwo, cSVFormat); +555 +556 assertFalse(cSVFormatTwo.equals(cSVFormat)); +557 +558 assertNull(cSVFormat.getEscapeCharacter()); +559 assertTrue(cSVFormat.isQuoteCharacterSet()); +560 +561 assertFalse(cSVFormat.getTrim()); +562 assertFalse(cSVFormat.getIgnoreSurroundingSpaces()); +563 +564 assertFalse(cSVFormat.getTrailingDelimiter()); +565 assertEquals(',', cSVFormat.getDelimiter()); +566 +567 assertFalse(cSVFormat.getIgnoreHeaderCase()); +568 assertEquals("\r\n", cSVFormat.getRecordSeparator()); +569 +570 assertFalse(cSVFormat.isCommentMarkerSet()); +571 assertNull(cSVFormat.getCommentMarker()); +572 +573 assertFalse(cSVFormat.isNullStringSet()); +574 assertFalse(cSVFormat.getAllowMissingColumnNames()); +575 +576 assertFalse(cSVFormat.isEscapeCharacterSet()); +577 assertFalse(cSVFormat.getSkipHeaderRecord()); +578 +579 assertNull(cSVFormat.getNullString()); +580 assertNull(cSVFormat.getQuoteMode()); +581 +582 assertTrue(cSVFormat.getIgnoreEmptyLines()); +583 assertEquals('\"', (char)cSVFormat.getQuoteCharacter()); +584 +585 assertFalse(cSVFormatTwo.isNullStringSet()); +586 assertFalse(cSVFormatTwo.getAllowMissingColumnNames()); +587 +588 assertEquals('\"', (char)cSVFormatTwo.getQuoteCharacter()); +589 assertNull(cSVFormatTwo.getNullString()); +590 +591 assertEquals(',', cSVFormatTwo.getDelimiter()); +592 assertFalse(cSVFormatTwo.getTrailingDelimiter()); +593 +594 assertTrue(cSVFormatTwo.isCommentMarkerSet()); +595 assertFalse(cSVFormatTwo.getIgnoreHeaderCase()); +596 +597 assertFalse(cSVFormatTwo.getTrim()); +598 assertNull(cSVFormatTwo.getEscapeCharacter()); +599 +600 assertTrue(cSVFormatTwo.isQuoteCharacterSet()); +601 assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces()); +602 +603 assertEquals("\r\n", cSVFormatTwo.getRecordSeparator()); +604 assertNull(cSVFormatTwo.getQuoteMode()); +605 +606 assertEquals('n', (char)cSVFormatTwo.getCommentMarker()); +607 assertFalse(cSVFormatTwo.getSkipHeaderRecord()); +608 +609 assertFalse(cSVFormatTwo.isEscapeCharacterSet()); +610 assertTrue(cSVFormatTwo.getIgnoreEmptyLines()); +611 +612 assertNotSame(cSVFormat, cSVFormatTwo); +613 assertNotSame(cSVFormatTwo, cSVFormat); +614 +615 assertFalse(cSVFormat.equals(cSVFormatTwo)); +616 +617 assertFalse(cSVFormatTwo.equals(cSVFormat)); +618 assertEquals("Delimiter=<,> QuoteChar=<\"> CommentStart=<n> " + +619 "RecordSeparator=<\r\n> EmptyLines:ignored SkipHeaderRecord:false" +620 , cSVFormatTwo.toString()); +621 +622 } +623 +624 +625 @Test +626 public void testNewFormat() { +627 +628 CSVFormat cSVFormat = CSVFormat.newFormat('X'); +629 +630 assertFalse(cSVFormat.getSkipHeaderRecord()); +631 assertFalse(cSVFormat.isEscapeCharacterSet()); +632 +633 assertNull(cSVFormat.getRecordSeparator()); +634 assertNull(cSVFormat.getQuoteMode()); +635 +636 assertNull(cSVFormat.getCommentMarker()); +637 assertFalse(cSVFormat.getIgnoreHeaderCase()); +638 +639 assertFalse(cSVFormat.getAllowMissingColumnNames()); +640 assertFalse(cSVFormat.getTrim()); +641 +642 assertFalse(cSVFormat.isNullStringSet()); +643 assertNull(cSVFormat.getEscapeCharacter()); +644 +645 assertFalse(cSVFormat.getIgnoreSurroundingSpaces()); +646 assertFalse(cSVFormat.getTrailingDelimiter()); +647 +648 assertEquals('X', cSVFormat.getDelimiter()); +649 assertNull(cSVFormat.getNullString()); +650 +651 assertFalse(cSVFormat.isQuoteCharacterSet()); +652 assertFalse(cSVFormat.isCommentMarkerSet()); +653 +654 assertNull(cSVFormat.getQuoteCharacter()); +655 assertFalse(cSVFormat.getIgnoreEmptyLines()); +656 +657 assertFalse(cSVFormat.getSkipHeaderRecord()); +658 assertFalse(cSVFormat.isEscapeCharacterSet()); +659 +660 assertNull(cSVFormat.getRecordSeparator()); +661 assertNull(cSVFormat.getQuoteMode()); +662 +663 assertNull(cSVFormat.getCommentMarker()); +664 assertFalse(cSVFormat.getIgnoreHeaderCase()); +665 +666 assertFalse(cSVFormat.getAllowMissingColumnNames()); +667 assertFalse(cSVFormat.getTrim()); +668 +669 assertFalse(cSVFormat.isNullStringSet()); +670 assertNull(cSVFormat.getEscapeCharacter()); +671 +672 assertFalse(cSVFormat.getIgnoreSurroundingSpaces()); +673 assertFalse(cSVFormat.getTrailingDelimiter()); +674 +675 assertEquals('X', cSVFormat.getDelimiter()); +676 assertNull(cSVFormat.getNullString()); +677 +678 assertFalse(cSVFormat.isQuoteCharacterSet()); +679 assertFalse(cSVFormat.isCommentMarkerSet()); +680 +681 assertNull(cSVFormat.getQuoteCharacter()); +682 assertFalse(cSVFormat.getIgnoreEmptyLines()); +683 +684 } +685 +686 +687 @Test +688 public void testWithHeaderComments() { +689 +690 CSVFormat cSVFormat = CSVFormat.DEFAULT; +691 +692 assertEquals('\"', (char)cSVFormat.getQuoteCharacter()); +693 assertFalse(cSVFormat.isCommentMarkerSet()); +694 +695 assertFalse(cSVFormat.isEscapeCharacterSet()); +696 assertTrue(cSVFormat.isQuoteCharacterSet()); +697 +698 assertFalse(cSVFormat.getSkipHeaderRecord()); +699 assertNull(cSVFormat.getQuoteMode()); +700 +701 assertEquals(',', cSVFormat.getDelimiter()); +702 assertTrue(cSVFormat.getIgnoreEmptyLines()); +703 +704 assertFalse(cSVFormat.getIgnoreHeaderCase()); +705 assertNull(cSVFormat.getCommentMarker()); +706 +707 assertEquals("\r\n", cSVFormat.getRecordSeparator()); +708 assertFalse(cSVFormat.getTrailingDelimiter()); +709 +710 assertFalse(cSVFormat.getAllowMissingColumnNames()); +711 assertFalse(cSVFormat.getTrim()); +712 +713 assertFalse(cSVFormat.isNullStringSet()); +714 assertNull(cSVFormat.getNullString()); +715 +716 assertFalse(cSVFormat.getIgnoreSurroundingSpaces()); +717 assertNull(cSVFormat.getEscapeCharacter()); +718 +719 Object[] objectArray = new Object[8]; +720 CSVFormat cSVFormatTwo = cSVFormat.withHeaderComments(objectArray); +721 +722 assertEquals('\"', (char)cSVFormat.getQuoteCharacter()); +723 assertFalse(cSVFormat.isCommentMarkerSet()); +724 +725 assertFalse(cSVFormat.isEscapeCharacterSet()); +726 assertTrue(cSVFormat.isQuoteCharacterSet()); +727 +728 assertFalse(cSVFormat.getSkipHeaderRecord()); +729 assertNull(cSVFormat.getQuoteMode()); +730 +731 assertEquals(',', cSVFormat.getDelimiter()); +732 assertTrue(cSVFormat.getIgnoreEmptyLines()); +733 +734 assertFalse(cSVFormat.getIgnoreHeaderCase()); +735 assertNull(cSVFormat.getCommentMarker()); +736 +737 assertEquals("\r\n", cSVFormat.getRecordSeparator()); +738 assertFalse(cSVFormat.getTrailingDelimiter()); +739 +740 assertFalse(cSVFormat.getAllowMissingColumnNames()); +741 assertFalse(cSVFormat.getTrim()); +742 +743 assertFalse(cSVFormat.isNullStringSet()); +744 assertNull(cSVFormat.getNullString()); +745 +746 assertFalse(cSVFormat.getIgnoreSurroundingSpaces()); +747 assertNull(cSVFormat.getEscapeCharacter()); +748 +749 assertFalse(cSVFormatTwo.getIgnoreHeaderCase()); +750 assertNull(cSVFormatTwo.getQuoteMode()); +751 +752 assertTrue(cSVFormatTwo.getIgnoreEmptyLines()); +753 assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces()); +754 +755 assertNull(cSVFormatTwo.getEscapeCharacter()); +756 assertFalse(cSVFormatTwo.getTrim()); +757 +758 assertFalse(cSVFormatTwo.isEscapeCharacterSet()); +759 assertTrue(cSVFormatTwo.isQuoteCharacterSet()); +760 +761 assertFalse(cSVFormatTwo.getSkipHeaderRecord()); +762 assertEquals('\"', (char)cSVFormatTwo.getQuoteCharacter()); +763 +764 assertFalse(cSVFormatTwo.getAllowMissingColumnNames()); +765 assertNull(cSVFormatTwo.getNullString()); +766 +767 assertFalse(cSVFormatTwo.isNullStringSet()); +768 assertFalse(cSVFormatTwo.getTrailingDelimiter()); +769 +770 assertEquals("\r\n", cSVFormatTwo.getRecordSeparator()); +771 assertEquals(',', cSVFormatTwo.getDelimiter()); +772 +773 assertNull(cSVFormatTwo.getCommentMarker()); +774 assertFalse(cSVFormatTwo.isCommentMarkerSet()); +775 +776 assertNotSame(cSVFormat, cSVFormatTwo); +777 assertNotSame(cSVFormatTwo, cSVFormat); +778 +779 assertTrue(cSVFormatTwo.equals(cSVFormat)); +780 +781 String string = cSVFormatTwo.format(objectArray); +782 +783 assertEquals('\"', (char)cSVFormat.getQuoteCharacter()); +784 assertFalse(cSVFormat.isCommentMarkerSet()); +785 +786 assertFalse(cSVFormat.isEscapeCharacterSet()); +787 assertTrue(cSVFormat.isQuoteCharacterSet()); +788 +789 assertFalse(cSVFormat.getSkipHeaderRecord()); +790 assertNull(cSVFormat.getQuoteMode()); +791 +792 assertEquals(',', cSVFormat.getDelimiter()); +793 assertTrue(cSVFormat.getIgnoreEmptyLines()); +794 +795 assertFalse(cSVFormat.getIgnoreHeaderCase()); +796 assertNull(cSVFormat.getCommentMarker()); +797 +798 assertEquals("\r\n", cSVFormat.getRecordSeparator()); +799 assertFalse(cSVFormat.getTrailingDelimiter()); +800 +801 assertFalse(cSVFormat.getAllowMissingColumnNames()); +802 assertFalse(cSVFormat.getTrim()); +803 +804 assertFalse(cSVFormat.isNullStringSet()); +805 assertNull(cSVFormat.getNullString()); +806 +807 assertFalse(cSVFormat.getIgnoreSurroundingSpaces()); +808 assertNull(cSVFormat.getEscapeCharacter()); +809 +810 assertFalse(cSVFormatTwo.getIgnoreHeaderCase()); +811 assertNull(cSVFormatTwo.getQuoteMode()); +812 +813 assertTrue(cSVFormatTwo.getIgnoreEmptyLines()); +814 assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces()); +815 +816 assertNull(cSVFormatTwo.getEscapeCharacter()); +817 assertFalse(cSVFormatTwo.getTrim()); +818 +819 assertFalse(cSVFormatTwo.isEscapeCharacterSet()); +820 assertTrue(cSVFormatTwo.isQuoteCharacterSet()); +821 +822 assertFalse(cSVFormatTwo.getSkipHeaderRecord()); +823 assertEquals('\"', (char)cSVFormatTwo.getQuoteCharacter()); +824 +825 assertFalse(cSVFormatTwo.getAllowMissingColumnNames()); +826 assertNull(cSVFormatTwo.getNullString()); +827 +828 assertFalse(cSVFormatTwo.isNullStringSet()); +829 assertFalse(cSVFormatTwo.getTrailingDelimiter()); +830 +831 assertEquals("\r\n", cSVFormatTwo.getRecordSeparator()); +832 assertEquals(',', cSVFormatTwo.getDelimiter()); +833 +834 assertNull(cSVFormatTwo.getCommentMarker()); +835 assertFalse(cSVFormatTwo.isCommentMarkerSet()); +836 +837 assertNotSame(cSVFormat, cSVFormatTwo); +838 assertNotSame(cSVFormatTwo, cSVFormat); +839 +840 assertNotNull(string); +841 assertTrue(cSVFormat.equals(cSVFormatTwo)); +842 +843 assertTrue(cSVFormatTwo.equals(cSVFormat)); +844 assertEquals(",,,,,,,", string); +845 +846 } +847 +848 +849 @Test //I assume this to be a defect. +850 public void testFormatThrowsNullPointerException() { +851 +852 CSVFormat cSVFormat = CSVFormat.MYSQL; +853 +854 try { +855 cSVFormat.format(null); +856 fail("Expecting exception: NullPointerException"); +857 } catch(NullPointerException e) { +858 assertEquals(CSVFormat.class.getName(), e.getStackTrace()[0].getClassName()); +859 } +860 +861 } +862 +863 +864 @Test +865 public void testEqualsOne() { +866 +867 CSVFormat cSVFormatOne = CSVFormat.INFORMIX_UNLOAD; +868 CSVFormat cSVFormatTwo = CSVFormat.MYSQL; +869 +870 +871 assertEquals('\\', (char)cSVFormatOne.getEscapeCharacter()); +872 assertNull(cSVFormatOne.getQuoteMode()); +873 +874 assertTrue(cSVFormatOne.getIgnoreEmptyLines()); +875 assertFalse(cSVFormatOne.getSkipHeaderRecord()); +876 +877 assertFalse(cSVFormatOne.getIgnoreHeaderCase()); +878 assertNull(cSVFormatOne.getCommentMarker()); +879 +880 assertFalse(cSVFormatOne.isCommentMarkerSet()); +881 assertTrue(cSVFormatOne.isQuoteCharacterSet()); +882 +883 assertEquals('|', cSVFormatOne.getDelimiter()); +884 assertFalse(cSVFormatOne.getAllowMissingColumnNames()); +885 +886 assertTrue(cSVFormatOne.isEscapeCharacterSet()); +887 assertEquals("\n", cSVFormatOne.getRecordSeparator()); +888 +889 assertEquals('\"', (char)cSVFormatOne.getQuoteCharacter()); +890 assertFalse(cSVFormatOne.getTrailingDelimiter()); +891 +892 assertFalse(cSVFormatOne.getTrim()); +893 assertFalse(cSVFormatOne.isNullStringSet()); +894 +895 assertNull(cSVFormatOne.getNullString()); +896 assertFalse(cSVFormatOne.getIgnoreSurroundingSpaces()); +897 +898 +899 assertTrue(cSVFormatTwo.isEscapeCharacterSet()); +900 assertNull(cSVFormatTwo.getQuoteCharacter()); +901 +902 assertFalse(cSVFormatTwo.getAllowMissingColumnNames()); +903 assertEquals(QuoteMode.ALL_NON_NULL, cSVFormatTwo.getQuoteMode()); +904 +905 assertEquals('\t', cSVFormatTwo.getDelimiter()); +906 assertEquals("\n", cSVFormatTwo.getRecordSeparator()); +907 +908 assertFalse(cSVFormatTwo.isQuoteCharacterSet()); +909 assertTrue(cSVFormatTwo.isNullStringSet()); +910 +911 assertEquals('\\', (char)cSVFormatTwo.getEscapeCharacter()); +912 assertFalse(cSVFormatTwo.getIgnoreHeaderCase()); +913 +914 assertFalse(cSVFormatTwo.getTrim()); +915 assertFalse(cSVFormatTwo.getIgnoreEmptyLines()); +916 +917 assertEquals("\\N", cSVFormatTwo.getNullString()); +918 assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces()); +919 +920 assertFalse(cSVFormatTwo.getTrailingDelimiter()); +921 assertFalse(cSVFormatTwo.getSkipHeaderRecord()); +922 +923 assertNull(cSVFormatTwo.getCommentMarker()); +924 assertFalse(cSVFormatTwo.isCommentMarkerSet()); +925 +926 assertNotSame(cSVFormatTwo, cSVFormatOne); +927 assertFalse(cSVFormatTwo.equals(cSVFormatOne)); +928 +929 assertEquals('\\', (char)cSVFormatOne.getEscapeCharacter()); +930 assertNull(cSVFormatOne.getQuoteMode()); +931 +932 assertTrue(cSVFormatOne.getIgnoreEmptyLines()); +933 assertFalse(cSVFormatOne.getSkipHeaderRecord()); +934 +935 assertFalse(cSVFormatOne.getIgnoreHeaderCase()); +936 assertNull(cSVFormatOne.getCommentMarker()); +937 +938 assertFalse(cSVFormatOne.isCommentMarkerSet()); +939 assertTrue(cSVFormatOne.isQuoteCharacterSet()); +940 +941 assertEquals('|', cSVFormatOne.getDelimiter()); +942 assertFalse(cSVFormatOne.getAllowMissingColumnNames()); +943 +944 assertTrue(cSVFormatOne.isEscapeCharacterSet()); +945 assertEquals("\n", cSVFormatOne.getRecordSeparator()); +946 +947 assertEquals('\"', (char)cSVFormatOne.getQuoteCharacter()); +948 assertFalse(cSVFormatOne.getTrailingDelimiter()); +949 +950 assertFalse(cSVFormatOne.getTrim()); +951 assertFalse(cSVFormatOne.isNullStringSet()); +952 +953 assertNull(cSVFormatOne.getNullString()); +954 assertFalse(cSVFormatOne.getIgnoreSurroundingSpaces()); +955 +956 assertTrue(cSVFormatTwo.isEscapeCharacterSet()); +957 assertNull(cSVFormatTwo.getQuoteCharacter()); +958 +959 assertFalse(cSVFormatTwo.getAllowMissingColumnNames()); +960 assertEquals(QuoteMode.ALL_NON_NULL, cSVFormatTwo.getQuoteMode()); +961 +962 assertEquals('\t', cSVFormatTwo.getDelimiter()); +963 assertEquals("\n", cSVFormatTwo.getRecordSeparator()); +964 +965 assertFalse(cSVFormatTwo.isQuoteCharacterSet()); +966 assertTrue(cSVFormatTwo.isNullStringSet()); +967 +968 assertEquals('\\', (char)cSVFormatTwo.getEscapeCharacter()); +969 assertFalse(cSVFormatTwo.getIgnoreHeaderCase()); +970 +971 assertFalse(cSVFormatTwo.getTrim()); +972 assertFalse(cSVFormatTwo.getIgnoreEmptyLines()); +973 +974 assertEquals("\\N", cSVFormatTwo.getNullString()); +975 assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces()); +976 +977 assertFalse(cSVFormatTwo.getTrailingDelimiter()); +978 assertFalse(cSVFormatTwo.getSkipHeaderRecord()); +979 +980 assertNull(cSVFormatTwo.getCommentMarker()); +981 assertFalse(cSVFormatTwo.isCommentMarkerSet()); +982 +983 assertNotSame(cSVFormatOne, cSVFormatTwo); +984 assertNotSame(cSVFormatTwo, cSVFormatOne); +985 +986 assertFalse(cSVFormatOne.equals(cSVFormatTwo)); +987 assertFalse(cSVFormatTwo.equals(cSVFormatOne)); +988 +989 assertFalse(cSVFormatTwo.equals(cSVFormatOne)); +990 +991 } +992 +993 +994 @Test +995 public void testEqualsWithNull() { +996 +997 CSVFormat cSVFormat = CSVFormat.POSTGRESQL_TEXT; +998 +999 assertEquals('\"', (char)cSVFormat.getEscapeCharacter()); +1000 assertFalse(cSVFormat.getIgnoreSurroundingSpaces()); +1001 +1002 assertFalse(cSVFormat.getTrailingDelimiter()); +1003 assertFalse(cSVFormat.getTrim()); +1004 +1005 assertTrue(cSVFormat.isQuoteCharacterSet()); +1006 assertEquals("\\N", cSVFormat.getNullString()); +1007 +1008 assertFalse(cSVFormat.getIgnoreHeaderCase()); +1009 assertTrue(cSVFormat.isEscapeCharacterSet()); +1010 +1011 assertFalse(cSVFormat.isCommentMarkerSet()); +1012 assertNull(cSVFormat.getCommentMarker()); +1013 +1014 assertFalse(cSVFormat.getAllowMissingColumnNames()); +1015 assertEquals(QuoteMode.ALL_NON_NULL, cSVFormat.getQuoteMode()); +1016 +1017 assertEquals('\t', cSVFormat.getDelimiter()); +1018 assertFalse(cSVFormat.getSkipHeaderRecord()); +1019 +1020 assertEquals("\n", cSVFormat.getRecordSeparator()); +1021 assertFalse(cSVFormat.getIgnoreEmptyLines()); +1022 +1023 assertEquals('\"', (char)cSVFormat.getQuoteCharacter()); +1024 assertTrue(cSVFormat.isNullStringSet()); +1025 +1026 assertEquals('\"', (char)cSVFormat.getEscapeCharacter()); +1027 assertFalse(cSVFormat.getIgnoreSurroundingSpaces()); +1028 +1029 assertFalse(cSVFormat.getTrailingDelimiter()); +1030 assertFalse(cSVFormat.getTrim()); +1031 +1032 assertTrue(cSVFormat.isQuoteCharacterSet()); +1033 assertEquals("\\N", cSVFormat.getNullString()); +1034 +1035 assertFalse(cSVFormat.getIgnoreHeaderCase()); +1036 assertTrue(cSVFormat.isEscapeCharacterSet()); +1037 +1038 assertFalse(cSVFormat.isCommentMarkerSet()); +1039 assertNull(cSVFormat.getCommentMarker()); +1040 +1041 assertFalse(cSVFormat.getAllowMissingColumnNames()); +1042 assertEquals(QuoteMode.ALL_NON_NULL, cSVFormat.getQuoteMode()); +1043 +1044 assertEquals('\t', cSVFormat.getDelimiter()); +1045 assertFalse(cSVFormat.getSkipHeaderRecord()); +1046 +1047 assertEquals("\n", cSVFormat.getRecordSeparator()); +1048 assertFalse(cSVFormat.getIgnoreEmptyLines()); +1049 +1050 assertEquals('\"', (char)cSVFormat.getQuoteCharacter()); +1051 assertTrue(cSVFormat.isNullStringSet()); +1052 +1053 assertFalse(cSVFormat.equals( null)); +1054 +1055 } +1056 +1057 +1058 @Test +1059 public void testToString() { +1060 +1061 CSVFormat cSVFormat = CSVFormat.POSTGRESQL_TEXT; +1062 String string = cSVFormat.INFORMIX_UNLOAD.toString(); +1063 +1064 assertEquals("Delimiter=<|> Escape=<\\> QuoteChar=<\"> RecordSeparator=<\n> EmptyLines:ignored SkipHeaderRecord:false", string); +1065 +1066 } +1067 +1068 +1069 @Test +1070 public void testHashCodeAndWithIgnoreHeaderCase() { +1071 +1072 CSVFormat cSVFormat = CSVFormat.INFORMIX_UNLOAD_CSV; +1073 CSVFormat cSVFormatTwo = cSVFormat.withIgnoreHeaderCase(); +1074 cSVFormatTwo.hashCode(); +1075 +1076 assertTrue(cSVFormatTwo.getIgnoreHeaderCase()); +1077 assertFalse(cSVFormatTwo.getTrailingDelimiter()); +1078 +1079 assertTrue(cSVFormatTwo.equals(cSVFormat)); +1080 assertFalse(cSVFormatTwo.getAllowMissingColumnNames()); +1081 +1082 assertFalse(cSVFormatTwo.getTrim()); +1083 +1084 } +1085 +1086 public enum Header { +1087 Name, Email, Phone +1088 } +1089 +1090 public enum EmptyEnum { +1091 } +1092 +1093 }
- + \ No newline at end of file