예제 #1
0
 private void assertNextLine(String[] line, CharSeeker seeker, Mark mark, Extractors extractors)
     throws IOException {
   for (String value : line) {
     assertTrue(seeker.seek(mark, delimiter));
     assertEquals(value, seeker.extract(mark, extractors.string()).value());
   }
   assertTrue(mark.isEndOfLine());
 }
예제 #2
0
  @Test
  public void shouldReadFromMultipleReaders() throws Exception {
    // GIVEN
    String[][] data =
        new String[][] {
          {"this is", "the first line"},
          {"where this", "is the second line"},
          {"and here comes", "the third line"}
        };
    RawIterator<Reader, IOException> readers = readerIteratorFromStrings(data, null);
    CharSeeker seeker = CharSeekers.charSeeker(new MultiReadable(readers), 200, true, '"');

    // WHEN/THEN
    for (String[] line : data) {
      assertNextLine(line, seeker, mark, extractors);
    }
    assertFalse(seeker.seek(mark, delimiter));
    seeker.close();
  }
예제 #3
0
  @Test
  public void shouldHandleSourcesEndingWithNewLine() throws Exception {
    // GIVEN
    String[][] data =
        new String[][] {
          {"this is", "the first line"},
          {"where this", "is the second line"},
        };

    // WHEN
    RawIterator<Reader, IOException> readers = readerIteratorFromStrings(data, '\n');
    CharSeeker seeker = CharSeekers.charSeeker(Readables.sources(readers), 200, true, '"');

    // WHEN/THEN
    for (String[] line : data) {
      assertNextLine(line, seeker, mark, extractors);
    }
    assertFalse(seeker.seek(mark, delimiter));
    seeker.close();
  }