コード例 #1
0
  @Test(expected = IllegalArgumentException.class)
  public void shouldNotAllowHeadersWithSameName() {
    UniVocityFixedWidthDataFormat dataFormat =
        new UniVocityFixedWidthDataFormat()
            .setFieldLengths(new int[] {1, 2, 3})
            .setHeaders(new String[] {"A", "B", "A"});

    assertArrayEquals(new int[] {1, 2, 3}, dataFormat.getFieldLengths());
    assertArrayEquals(new String[] {"A", "B", "A"}, dataFormat.getHeaders());

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

    assertArrayEquals(new int[] {1, 2, 3}, dataFormat.getFieldLengths());
    assertArrayEquals(new String[] {"A", "B", "C"}, dataFormat.getHeaders());

    dataFormat.createAndConfigureWriterSettings();
  }