コード例 #1
0
  @Test
  public void shouldConfigurePadding() {
    UniVocityFixedWidthDataFormat dataFormat =
        new UniVocityFixedWidthDataFormat().setFieldLengths(new int[] {1, 2, 3}).setPadding('p');

    assertEquals(Character.valueOf('p'), dataFormat.getPadding());
    assertEquals('p', dataFormat.createAndConfigureWriterSettings().getFormat().getPadding());
    assertEquals('p', dataFormat.createAndConfigureParserSettings().getFormat().getPadding());
  }
コード例 #2
0
  @Test
  public void shouldConfigureRecordEndsOnNewline() {
    UniVocityFixedWidthDataFormat dataFormat =
        new UniVocityFixedWidthDataFormat()
            .setFieldLengths(new int[] {1, 2, 3})
            .setRecordEndsOnNewline(true);

    assertTrue(dataFormat.getRecordEndsOnNewline());
    assertTrue(dataFormat.createAndConfigureParserSettings().getRecordEndsOnNewline());
  }
コード例 #3
0
  @Test
  public void shouldConfigureNumberOfRecordsToRead() {
    UniVocityFixedWidthDataFormat dataFormat =
        new UniVocityFixedWidthDataFormat()
            .setFieldLengths(new int[] {1, 2, 3})
            .setNumberOfRecordsToRead(42);

    assertEquals(Integer.valueOf(42), dataFormat.getNumberOfRecordsToRead());
    assertEquals(42, dataFormat.createAndConfigureParserSettings().getNumberOfRecordsToRead());
  }
コード例 #4
0
  @Test
  public void shouldConfigureHeaderExtractionEnabled() {
    UniVocityFixedWidthDataFormat dataFormat =
        new UniVocityFixedWidthDataFormat()
            .setFieldLengths(new int[] {1, 2, 3})
            .setHeaderExtractionEnabled(true);

    assertTrue(dataFormat.getHeaderExtractionEnabled());
    assertTrue(dataFormat.createAndConfigureParserSettings().isHeaderExtractionEnabled());
  }
コード例 #5
0
  @Test
  public void shouldConfigureIgnoreLeadingWhitespaces() {
    UniVocityFixedWidthDataFormat dataFormat =
        new UniVocityFixedWidthDataFormat()
            .setFieldLengths(new int[] {1, 2, 3})
            .setIgnoreLeadingWhitespaces(true);

    assertTrue(dataFormat.getIgnoreLeadingWhitespaces());
    assertTrue(dataFormat.createAndConfigureWriterSettings().getIgnoreLeadingWhitespaces());
    assertTrue(dataFormat.createAndConfigureParserSettings().getIgnoreLeadingWhitespaces());
  }
コード例 #6
0
  @Test
  public void shouldConfigureNullValue() {
    UniVocityFixedWidthDataFormat dataFormat =
        new UniVocityFixedWidthDataFormat()
            .setFieldLengths(new int[] {1, 2, 3})
            .setNullValue("N/A");

    assertEquals("N/A", dataFormat.getNullValue());
    assertEquals("N/A", dataFormat.createAndConfigureWriterSettings().getNullValue());
    assertEquals("N/A", dataFormat.createAndConfigureParserSettings().getNullValue());
  }
コード例 #7
0
  @Test
  public void shouldConfigureHeaders() {
    UniVocityFixedWidthDataFormat dataFormat =
        new UniVocityFixedWidthDataFormat()
            .setFieldLengths(new int[] {1, 2, 3})
            .setHeaders(new String[] {"A", "B", "C"});

    assertArrayEquals(new String[] {"A", "B", "C"}, dataFormat.getHeaders());
    assertArrayEquals(
        new String[] {"A", "B", "C"}, dataFormat.createAndConfigureWriterSettings().getHeaders());
    assertArrayEquals(
        new String[] {"A", "B", "C"}, dataFormat.createAndConfigureParserSettings().getHeaders());
  }
コード例 #8
0
  @Test
  public void shouldConfigureNormalizedLineSeparator() {
    UniVocityFixedWidthDataFormat dataFormat =
        new UniVocityFixedWidthDataFormat()
            .setFieldLengths(new int[] {1, 2, 3})
            .setNormalizedLineSeparator('n');

    assertEquals(Character.valueOf('n'), dataFormat.getNormalizedLineSeparator());
    assertEquals(
        'n', dataFormat.createAndConfigureWriterSettings().getFormat().getNormalizedNewline());
    assertEquals(
        'n', dataFormat.createAndConfigureParserSettings().getFormat().getNormalizedNewline());
  }
コード例 #9
0
  @Test
  public void shouldConfigureLineSeparator() {
    UniVocityFixedWidthDataFormat dataFormat =
        new UniVocityFixedWidthDataFormat()
            .setFieldLengths(new int[] {1, 2, 3})
            .setLineSeparator("ls");

    assertEquals("ls", dataFormat.getLineSeparator());
    assertEquals(
        "ls", dataFormat.createAndConfigureWriterSettings().getFormat().getLineSeparatorString());
    assertEquals(
        "ls", dataFormat.createAndConfigureParserSettings().getFormat().getLineSeparatorString());
  }