@Test public void getDataWithRuntimeException() throws Exception{ ConcurrentPreloads preloads = new ConcurrentPreloads(); preloads.add(TestFuture.throwsExecution()); preloads.add(TestFuture.returnsNormal("foo")); assertEquals(2, preloads.size()); Iterator<PreloadedData> iterator = preloads.iterator(); // First item should throw an exception, a PreloadException around // a RuntimeException PreloadedData withError = iterator.next(); try { withError.toJson(); fail(); } catch (PreloadException pe) { assertSame(pe.getCause().getClass(), RuntimeException.class); } // And iteration should continue assertEquals(TestFuture.expectedResult("foo"), iterator.next().toJson()); }
@Test public void getDataWithRuntimeException() throws Exception{ ConcurrentPreloads preloads = new ConcurrentPreloads(); preloads.add(TestFuture.throwsExecution()); preloads.add(TestFuture.returnsNormal("foo")); assertEquals(2, preloads.size()); Iterator<PreloadedData> iterator = preloads.iterator(); // First item should throw an exception, a PreloadException around // a RuntimeException PreloadedData withError = iterator.next(); try { withError.toJson(); fail(); } catch (PreloadException pe) { assertSame(pe.getCause().getClass(), RuntimeException.class); } // And iteration should continue assertEquals(TestFuture.expectedResult("foo"), iterator.next().toJson()); }
@Test public void getDataWithRuntimeException() throws Exception{ ConcurrentPreloads preloads = new ConcurrentPreloads(); preloads.add(TestFuture.throwsExecution()); preloads.add(TestFuture.returnsNormal("foo")); assertEquals(2, preloads.size()); Iterator<PreloadedData> iterator = preloads.iterator(); // First item should throw an exception, a PreloadException around // a RuntimeException PreloadedData withError = iterator.next(); try { withError.toJson(); fail(); } catch (PreloadException pe) { assertSame(pe.getCause().getClass(), RuntimeException.class); } // And iteration should continue assertEquals(TestFuture.expectedResult("foo"), iterator.next().toJson()); }