public void testReadLines_toList() throws IOException { TestCharSource lines = new TestCharSource(LINES); assertEquals(ImmutableList.of("foo", "bar", "baz", "something"), lines.readLines()); assertTrue(lines.wasStreamOpened() && lines.wasStreamClosed()); }
public void testReadLines_withProcessor() throws IOException { TestCharSource lines = new TestCharSource(LINES); List<String> list = lines.readLines( new LineProcessor<List<String>>() { List<String> list = Lists.newArrayList(); @Override public boolean processLine(String line) throws IOException { list.add(line); return true; } @Override public List<String> getResult() { return list; } }); assertEquals(ImmutableList.of("foo", "bar", "baz", "something"), list); assertTrue(lines.wasStreamOpened() && lines.wasStreamClosed()); }
public void testReadLines_withProcessor_stopsOnFalse() throws IOException { TestCharSource lines = new TestCharSource(LINES); List<String> list = lines.readLines( new LineProcessor<List<String>>() { List<String> list = Lists.newArrayList(); @Override public boolean processLine(String line) throws IOException { list.add(line); return false; } @Override public List<String> getResult() { return list; } }); assertEquals(ImmutableList.of("foo"), list); assertTrue(lines.wasStreamOpened() && lines.wasStreamClosed()); }
public void testReadLines_toList() throws IOException { TestCharSource lines = new TestCharSource(LINES); assertEquals(ImmutableList.of("foo", "bar", "baz", "something"), lines.readLines()); assertTrue(lines.wasStreamOpened() && lines.wasStreamClosed()); }
public void testReadLines_withProcessor_stopsOnFalse() throws IOException { TestCharSource lines = new TestCharSource(LINES); List<String> list = lines.readLines(new LineProcessor<List<String>>() { List<String> list = Lists.newArrayList(); @Override public boolean processLine(String line) throws IOException { list.add(line); return false; } @Override public List<String> getResult() { return list; } }); assertEquals(ImmutableList.of("foo"), list); assertTrue(lines.wasStreamOpened() && lines.wasStreamClosed()); }
public void testReadLines_withProcessor() throws IOException { TestCharSource lines = new TestCharSource(LINES); List<String> list = lines.readLines(new LineProcessor<List<String>>() { List<String> list = Lists.newArrayList(); @Override public boolean processLine(String line) throws IOException { list.add(line); return true; } @Override public List<String> getResult() { return list; } }); assertEquals(ImmutableList.of("foo", "bar", "baz", "something"), list); assertTrue(lines.wasStreamOpened() && lines.wasStreamClosed()); }