@@ -550,17 +550,12 @@ public void testFormatThrowsNullPointerException() {
550550
551551 final CSVFormat csvFormat = CSVFormat .MYSQL ;
552552
553- try {
554- csvFormat .format ((Object []) null );
555- fail ("Expecting exception: NullPointerException" );
556- } catch (final NullPointerException e ) {
557- assertEquals (CSVFormat .class .getName (), e .getStackTrace ()[0 ].getClassName ());
558- }
559-
553+ NullPointerException e = assertThrows (NullPointerException .class , () -> csvFormat .format ((Object []) null ));
554+ assertEquals (CSVFormat .class .getName (), e .getStackTrace ()[0 ].getClassName ());
560555 }
561556
562557 @ Test
563- public void testGetHeader () throws Exception {
558+ public void testGetHeader () {
564559 final String [] header = new String []{"one" , "two" , "three" };
565560 final CSVFormat formatWithHeader = CSVFormat .DEFAULT .withHeader (header );
566561 // getHeader() makes a copy of the header array.
@@ -893,7 +888,7 @@ public void testToStringAndWithCommentMarkerTakingCharacter() {
893888 }
894889
895890 @ Test
896- public void testWithCommentStart () throws Exception {
891+ public void testWithCommentStart () {
897892 final CSVFormat formatWithCommentStart = CSVFormat .DEFAULT .withCommentMarker ('#' );
898893 assertEquals ( Character .valueOf ('#' ), formatWithCommentStart .getCommentMarker ());
899894 }
@@ -904,7 +899,7 @@ public void testWithCommentStartCRThrowsException() {
904899 }
905900
906901 @ Test
907- public void testWithDelimiter () throws Exception {
902+ public void testWithDelimiter () {
908903 final CSVFormat formatWithDelimiter = CSVFormat .DEFAULT .withDelimiter ('!' );
909904 assertEquals ('!' , formatWithDelimiter .getDelimiter ());
910905 }
@@ -915,13 +910,13 @@ public void testWithDelimiterLFThrowsException() {
915910 }
916911
917912 @ Test
918- public void testWithEmptyEnum () throws Exception {
913+ public void testWithEmptyEnum () {
919914 final CSVFormat formatWithHeader = CSVFormat .DEFAULT .withHeader (EmptyEnum .class );
920915 assertTrue (formatWithHeader .getHeader ().length == 0 );
921916 }
922917
923918 @ Test
924- public void testWithEscape () throws Exception {
919+ public void testWithEscape () {
925920 final CSVFormat formatWithEscape = CSVFormat .DEFAULT .withEscape ('&' );
926921 assertEquals (Character .valueOf ('&' ), formatWithEscape .getEscapeCharacter ());
927922 }
@@ -932,14 +927,14 @@ public void testWithEscapeCRThrowsExceptions() {
932927 }
933928
934929 @ Test
935- public void testWithFirstRecordAsHeader () throws Exception {
930+ public void testWithFirstRecordAsHeader () {
936931 final CSVFormat formatWithFirstRecordAsHeader = CSVFormat .DEFAULT .withFirstRecordAsHeader ();
937932 assertTrue (formatWithFirstRecordAsHeader .getSkipHeaderRecord ());
938933 assertTrue (formatWithFirstRecordAsHeader .getHeader ().length == 0 );
939934 }
940935
941936 @ Test
942- public void testWithHeader () throws Exception {
937+ public void testWithHeader () {
943938 final String [] header = new String []{"one" , "two" , "three" };
944939 // withHeader() makes a copy of the header array.
945940 final CSVFormat formatWithHeader = CSVFormat .DEFAULT .withHeader (header );
@@ -1111,35 +1106,35 @@ public void testWithHeaderComments() {
11111106
11121107
11131108 @ Test
1114- public void testWithHeaderEnum () throws Exception {
1109+ public void testWithHeaderEnum () {
11151110 final CSVFormat formatWithHeader = CSVFormat .DEFAULT .withHeader (Header .class );
11161111 assertArrayEquals (new String []{ "Name" , "Email" , "Phone" }, formatWithHeader .getHeader ());
11171112 }
11181113
11191114
11201115 @ Test
1121- public void testWithIgnoreEmptyLines () throws Exception {
1116+ public void testWithIgnoreEmptyLines () {
11221117 assertFalse (CSVFormat .DEFAULT .withIgnoreEmptyLines (false ).getIgnoreEmptyLines ());
11231118 assertTrue (CSVFormat .DEFAULT .withIgnoreEmptyLines ().getIgnoreEmptyLines ());
11241119 }
11251120
11261121
11271122 @ Test
1128- public void testWithIgnoreSurround () throws Exception {
1123+ public void testWithIgnoreSurround () {
11291124 assertFalse (CSVFormat .DEFAULT .withIgnoreSurroundingSpaces (false ).getIgnoreSurroundingSpaces ());
11301125 assertTrue (CSVFormat .DEFAULT .withIgnoreSurroundingSpaces ().getIgnoreSurroundingSpaces ());
11311126 }
11321127
11331128
11341129 @ Test
1135- public void testWithNullString () throws Exception {
1130+ public void testWithNullString () {
11361131 final CSVFormat formatWithNullString = CSVFormat .DEFAULT .withNullString ("null" );
11371132 assertEquals ("null" , formatWithNullString .getNullString ());
11381133 }
11391134
11401135
11411136 @ Test
1142- public void testWithQuoteChar () throws Exception {
1137+ public void testWithQuoteChar () {
11431138 final CSVFormat formatWithQuoteChar = CSVFormat .DEFAULT .withQuote ('"' );
11441139 assertEquals (Character .valueOf ('"' ), formatWithQuoteChar .getQuoteCharacter ());
11451140 }
@@ -1151,31 +1146,31 @@ public void testWithQuoteLFThrowsException() {
11511146 }
11521147
11531148 @ Test
1154- public void testWithQuotePolicy () throws Exception {
1149+ public void testWithQuotePolicy () {
11551150 final CSVFormat formatWithQuotePolicy = CSVFormat .DEFAULT .withQuoteMode (QuoteMode .ALL );
11561151 assertEquals (QuoteMode .ALL , formatWithQuotePolicy .getQuoteMode ());
11571152 }
11581153
11591154 @ Test
1160- public void testWithRecordSeparatorCR () throws Exception {
1155+ public void testWithRecordSeparatorCR () {
11611156 final CSVFormat formatWithRecordSeparator = CSVFormat .DEFAULT .withRecordSeparator (CR );
11621157 assertEquals (String .valueOf (CR ), formatWithRecordSeparator .getRecordSeparator ());
11631158 }
11641159
11651160 @ Test
1166- public void testWithRecordSeparatorCRLF () throws Exception {
1161+ public void testWithRecordSeparatorCRLF () {
11671162 final CSVFormat formatWithRecordSeparator = CSVFormat .DEFAULT .withRecordSeparator (CRLF );
11681163 assertEquals (CRLF , formatWithRecordSeparator .getRecordSeparator ());
11691164 }
11701165
11711166 @ Test
1172- public void testWithRecordSeparatorLF () throws Exception {
1167+ public void testWithRecordSeparatorLF () {
11731168 final CSVFormat formatWithRecordSeparator = CSVFormat .DEFAULT .withRecordSeparator (LF );
11741169 assertEquals (String .valueOf (LF ), formatWithRecordSeparator .getRecordSeparator ());
11751170 }
11761171
11771172 @ Test
1178- public void testWithSystemRecordSeparator () throws Exception {
1173+ public void testWithSystemRecordSeparator () {
11791174 final CSVFormat formatWithRecordSeparator = CSVFormat .DEFAULT .withSystemRecordSeparator ();
11801175 assertEquals (System .getProperty ("line.separator" ), formatWithRecordSeparator .getRecordSeparator ());
11811176 }
0 commit comments