AbstractGtfsDataProcessor implements ItemProcessor<I, O> { @SuppressWarnings("unchecked") protected static <O> List<O> readAll(ItemStreamReader<O> reader) { List<O> result = (List<O>) cache.get(reader); if (result == null) { result = doReadAll(reader); cache.put(reader, result); } return result; }    }
@Test public void testReadAll() throws Exception { reader.open(EasyMock.anyObject()); EasyMock.expectLastCall(); expect(reader.read()).andReturn(new Object()); expect(reader.read()).andReturn(new Object()); expect(reader.read()).andReturn(new Object()); expect(reader.read()).andReturn(null); reader.close(); EasyMock.expectLastCall(); replay(reader); assertNotNull(AbstractGtfsDataProcessor.readAll(reader)); }
@Test(expected = IllegalStateException.class) public void testReadAllWithException() throws Exception { reader.open(EasyMock.anyObject()); EasyMock.expectLastCall(); expect(reader.read()).andThrow(new Exception()); reader.close(); EasyMock.expectLastCall(); replay(reader); AbstractGtfsDataProcessor.readAll(reader); }