@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();
  }
Beispiel #2
0
 @Test(expected = IllegalArgumentException.class)
 public void testWithQuoteLFThrowsException() {
   CSVFormat.DEFAULT.withQuote(LF);
 }
Beispiel #3
0
 @Test
 public void testWithQuoteChar() throws Exception {
   final CSVFormat formatWithQuoteChar = CSVFormat.DEFAULT.withQuote('"');
   assertEquals(Character.valueOf('"'), formatWithQuoteChar.getQuoteCharacter());
 }
Beispiel #4
0
 @Test(expected = IllegalArgumentException.class)
 public void testQuoteCharSameAsDelimiterThrowsException() {
   CSVFormat.DEFAULT.withQuote('!').withDelimiter('!');
 }
Beispiel #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('!');
 }
Beispiel #6
0
 @Test(expected = IllegalArgumentException.class)
 public void testQuoteCharSameAsCommentStartThrowsException() {
   CSVFormat.DEFAULT.withQuote('!').withCommentMarker('!');
 }