@@ -866,7 +866,7 @@ public void testSkipAutoHeader() throws Exception {
866866 assertEquals ("2" , record .get ("b" ));
867867 assertEquals ("3" , record .get ("c" ));
868868 }
869-
869+
870870 @ Test
871871 public void testSkipSetHeader () throws Exception {
872872 final Reader in = new StringReader ("a,b,c\n 1,2,3\n x,y,z" );
@@ -878,6 +878,28 @@ public void testSkipSetHeader() throws Exception {
878878 assertEquals ("3" , record .get ("c" ));
879879 }
880880
881+ @ Test
882+ public void testSkipSetAltHeaders () throws Exception {
883+ final Reader in = new StringReader ("a,b,c\n 1,2,3\n x,y,z" );
884+ final Iterator <CSVRecord > records = CSVFormat .DEFAULT .withHeader ("X" , "Y" , "Z" ).withSkipHeaderRecord ()
885+ .parse (in ).iterator ();
886+ final CSVRecord record = records .next ();
887+ assertEquals ("1" , record .get ("X" ));
888+ assertEquals ("2" , record .get ("Y" ));
889+ assertEquals ("3" , record .get ("Z" ));
890+ }
891+
892+ @ Test
893+ public void testSkipHeaderOverrideDuplicateHeaders () throws Exception {
894+ final Reader in = new StringReader ("a,a,a\n 1,2,3\n x,y,z" );
895+ final Iterator <CSVRecord > records = CSVFormat .DEFAULT .withHeader ("X" , "Y" , "Z" ).withSkipHeaderRecord ()
896+ .parse (in ).iterator ();
897+ final CSVRecord record = records .next ();
898+ assertEquals ("1" , record .get ("X" ));
899+ assertEquals ("2" , record .get ("Y" ));
900+ assertEquals ("3" , record .get ("Z" ));
901+ }
902+
881903 private void validateLineNumbers (final String lineSeparator ) throws IOException {
882904 final CSVParser parser = CSVParser .parse ("a" + lineSeparator + "b" + lineSeparator + "c" ,
883905 CSVFormat .DEFAULT .withRecordSeparator (lineSeparator ));
0 commit comments