public void testFailingIteratorFails() { Exception ex = new Exception("for testing"); ExceptionalIterator<?, Exception> failing = ExceptionalIterator.Failing.create(ex); try { failing.hasNext(); fail("Expected an exception"); } catch (Exception e) { assertSame(ex, e); } }
public void testFailingIteratorFails() { Exception ex = new Exception("for testing"); ExceptionalIterator<?, Exception> failing = ExceptionalIterator.Failing.create(ex); try { failing.hasNext(); fail("Expected an exception"); } catch (Exception e) { assertSame(ex, e); } }
public void testFromIteratorWithException() throws Exception { Exception ex = new Exception("for testing"); ExceptionalIterator<Integer, Exception> itr = ExceptionalIterator.FromIterator.create(items.iterator(), ex); assertTrue(itr.hasNext()); assertEquals(Integer.valueOf(1), itr.next()); assertEquals(Integer.valueOf(2), itr.next()); assertEquals(Integer.valueOf(3), itr.next()); try { itr.hasNext(); fail("Expected an exception"); } catch (Exception e) { assertSame(ex, e); } } }
public void testFromIteratorWithException() throws Exception { Exception ex = new Exception("for testing"); ExceptionalIterator<Integer, Exception> itr = ExceptionalIterator.FromIterator.create(items.iterator(), ex); assertTrue(itr.hasNext()); assertEquals(Integer.valueOf(1), itr.next()); assertEquals(Integer.valueOf(2), itr.next()); assertEquals(Integer.valueOf(3), itr.next()); try { itr.hasNext(); fail("Expected an exception"); } catch (Exception e) { assertSame(ex, e); } } }