@Test public void testApacheCommonCsvQualifier() throws Exception { StringReader stringReader = new StringReader("'foo,s','bar,n'"); CSVFormat csvFormat = CSVFormat.DEFAULT.withQuote('\'').withHeader("firstName", "lastName", "age", "married"); ApacheCommonCsvRecord record = getApacheCommonCsvRecord(stringReader, csvFormat); Foo foo = mapper.mapRecord(record); assertThat(foo).isNotNull(); assertThat(foo.getFirstName()).isEqualTo("foo,s"); assertThat(foo.getLastName()).isEqualTo("bar,n"); assertThat(foo.getAge()).isEqualTo(0); assertThat(foo.isMarried()).isFalse(); }
@Test(expected = IllegalArgumentException.class) public void testWithQuoteLFThrowsException() { CSVFormat.DEFAULT.withQuote(LF); }
@Test public void testWithQuoteChar() throws Exception { final CSVFormat formatWithQuoteChar = CSVFormat.DEFAULT.withQuote('"'); assertEquals(Character.valueOf('"'), formatWithQuoteChar.getQuoteCharacter()); }
@Test(expected = IllegalArgumentException.class) public void testQuoteCharSameAsDelimiterThrowsException() { CSVFormat.DEFAULT.withQuote('!').withDelimiter('!'); }
@Test(expected = IllegalArgumentException.class) public void testQuoteCharSameAsCommentStartThrowsExceptionForWrapperType() { // Cannot assume that callers won't use different Character objects CSVFormat.DEFAULT.withQuote(new Character('!')).withCommentMarker('!'); }
@Test(expected = IllegalArgumentException.class) public void testQuoteCharSameAsCommentStartThrowsException() { CSVFormat.DEFAULT.withQuote('!').withCommentMarker('!'); }