@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();
  }
Esempio n. 2
0
 @Test(expected = IllegalArgumentException.class)
 public void testWithQuoteLFThrowsException() {
   CSVFormat.DEFAULT.withQuote(LF);
 }
Esempio n. 3
0
 @Test
 public void testWithQuoteChar() throws Exception {
   final CSVFormat formatWithQuoteChar = CSVFormat.DEFAULT.withQuote('"');
   assertEquals(Character.valueOf('"'), formatWithQuoteChar.getQuoteCharacter());
 }
Esempio n. 4
0
 @Test(expected = IllegalArgumentException.class)
 public void testQuoteCharSameAsDelimiterThrowsException() {
   CSVFormat.DEFAULT.withQuote('!').withDelimiter('!');
 }
Esempio n. 5
0
 @Test(expected = IllegalArgumentException.class)
 public void testQuoteCharSameAsCommentStartThrowsExceptionForWrapperType() {
   // Cannot assume that callers won't use different Character objects
   CSVFormat.DEFAULT.withQuote(new Character('!')).withCommentMarker('!');
 }
Esempio n. 6
0
 @Test(expected = IllegalArgumentException.class)
 public void testQuoteCharSameAsCommentStartThrowsException() {
   CSVFormat.DEFAULT.withQuote('!').withCommentMarker('!');
 }