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