File tree Expand file tree Collapse file tree
src/test/java/org/apache/commons/csv Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030
3131import java .io .ByteArrayInputStream ;
3232import java .io .ByteArrayOutputStream ;
33+ import java .io .IOException ;
3334import java .io .ObjectInputStream ;
3435import java .io .ObjectOutputStream ;
3536import java .util .Arrays ;
3637
38+ import org .junit .Assert ;
3739import org .junit .Test ;
3840
3941/**
@@ -374,6 +376,20 @@ public void testWithHeader() throws Exception {
374376 assertFalse (Arrays .equals (formatWithHeader .getHeader (), header ));
375377 }
376378
379+ @ Test
380+ public void testJIraCsv154 () throws IOException {
381+ final String comment = "This is a header comment" ;
382+ CSVFormat format = CSVFormat .EXCEL .withHeader ("H1" , "H2" ).withCommentMarker ('#' )
383+ .withHeaderComments (comment );
384+ StringBuilder out = new StringBuilder ();
385+ final CSVPrinter printer = format .print (out );
386+ printer .print ("A" );
387+ printer .print ("B" );
388+ printer .close ();
389+ String s = out .toString ();
390+ Assert .assertTrue (s , s .contains (comment ));
391+ }
392+
377393 @ Test
378394 public void testWithIgnoreEmptyLines () throws Exception {
379395 assertFalse (CSVFormat .DEFAULT .withIgnoreEmptyLines (false ).getIgnoreEmptyLines ());
You can’t perform that action at this time.
0 commit comments