diff --git a/src/test/java/org/apache/commons/csv/CSVFormatTest.java b/src/test/java/org/apache/commons/csv/CSVFormatTest.java index f7c32bd6..90417926 100644 --- a/src/test/java/org/apache/commons/csv/CSVFormatTest.java +++ b/src/test/java/org/apache/commons/csv/CSVFormatTest.java @@ -261,8 +261,8 @@ public class CSVFormatTest { final Object b = method.invoke(CSVFormat.DEFAULT, QuoteMode.ALL); assertNotEquals(name, type, a, b); } else if ("org.apache.commons.csv.DuplicateHeaderMode".equals(type)) { - final Object a = method.invoke(CSVFormat.DEFAULT, new Object[] {DuplicateHeaderMode.ALLOW_ALL}); - final Object b = method.invoke(CSVFormat.DEFAULT, new Object[] {DuplicateHeaderMode.DISALLOW}); + final Object a = method.invoke(CSVFormat.DEFAULT, DuplicateHeaderMode.ALLOW_ALL); + final Object b = method.invoke(CSVFormat.DEFAULT, DuplicateHeaderMode.DISALLOW); assertNotEquals(name, type, a, b); } else if ("java.lang.Object[]".equals(type)){ final Object a = method.invoke(CSVFormat.DEFAULT, new Object[] {new Object[] {null, null}}); diff --git a/src/test/java/org/apache/commons/csv/issues/JiraCsv288Test.java b/src/test/java/org/apache/commons/csv/issues/JiraCsv288Test.java index 354f3051..81dff119 100644 --- a/src/test/java/org/apache/commons/csv/issues/JiraCsv288Test.java +++ b/src/test/java/org/apache/commons/csv/issues/JiraCsv288Test.java @@ -34,10 +34,10 @@ public class JiraCsv288Test { // expected: but was: public void testParseWithDoublePipeDelimiter() throws Exception { final Reader in = new StringReader("a||b||c||d||||f"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("||").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); } @@ -51,10 +51,10 @@ public class JiraCsv288Test { // expected: but was: public void testParseWithTriplePipeDelimiter() throws Exception { final Reader in = new StringReader("a|||b|||c|||d||||||f"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("|||").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); } @@ -68,10 +68,10 @@ public class JiraCsv288Test { // expected: but was: public void testParseWithABADelimiter() throws Exception { final Reader in = new StringReader("a|~|b|~|c|~|d|~||~|f"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("|~|").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); } @@ -85,10 +85,10 @@ public class JiraCsv288Test { // expected: but was: public void testParseWithDoublePipeDelimiterQuoted() throws Exception { final Reader in = new StringReader("a||\"b||c\"||d||||f"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("||").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); } @@ -102,10 +102,10 @@ public class JiraCsv288Test { // expected: but was: public void testParseWithDoublePipeDelimiterEndsWithDelimiter() throws Exception { final Reader in = new StringReader("a||b||c||d||||f||"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("||").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); } @@ -119,10 +119,10 @@ public class JiraCsv288Test { // expected: but was: public void testParseWithTwoCharDelimiterEndsWithDelimiter() throws Exception { final Reader in = new StringReader("a~|b~|c~|d~|~|f~|"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("~|").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); } @@ -136,10 +136,10 @@ public class JiraCsv288Test { public void testParseWithDoublePipeDelimiterDoubleCharValue() throws Exception { final Reader in = new StringReader("a||bb||cc||dd||f"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("||").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); } @@ -152,10 +152,10 @@ public class JiraCsv288Test { // Regression, already passed before fix public void testParseWithTwoCharDelimiter1() throws Exception { final Reader in = new StringReader("a~|b~|c~|d~|~|f"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("~|").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); } @@ -168,10 +168,10 @@ public class JiraCsv288Test { // Regression, already passed before fix public void testParseWithTwoCharDelimiter2() throws Exception { final Reader in = new StringReader("a~|b~|c~|d~|~|f~"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("~|").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); } @@ -184,10 +184,10 @@ public class JiraCsv288Test { // Regression, already passed before fix public void testParseWithTwoCharDelimiter3() throws Exception { final Reader in = new StringReader("a~|b~|c~|d~|~|f|"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("~|").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); } @@ -200,10 +200,10 @@ public class JiraCsv288Test { // Regression, already passed before fix public void testParseWithTwoCharDelimiter4() throws Exception { final Reader in = new StringReader("a~|b~|c~|d~|~|f~~||g"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("~|").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); } @@ -216,10 +216,10 @@ public class JiraCsv288Test { // Regression, already passed before fix public void testParseWithSinglePipeDelimiterEndsWithDelimiter() throws Exception { final Reader in = new StringReader("a|b|c|d||f|"); - StringBuilder stringBuilder = new StringBuilder(); + final StringBuilder stringBuilder = new StringBuilder(); try (CSVPrinter csvPrinter = new CSVPrinter(stringBuilder, CSVFormat.EXCEL); CSVParser csvParser = CSVParser.parse(in, CSVFormat.Builder.create().setDelimiter("|").build())) { - for (CSVRecord csvRecord : csvParser) { + for (final CSVRecord csvRecord : csvParser) { for (int i = 0; i < csvRecord.size(); i++) { csvPrinter.print(csvRecord.get(i)); }