@Test public void runAllProvidedTest() { List<TestRunnable> list = new ArrayList<TestRunnable>(RUNNABLE_COUNT); for (int i = 0; i < RUNNABLE_COUNT; i++) { list.add(new ChainRunnable(i == FAIL_INDEX)); } RunnableChain chain = new RunnableChain(false, list); try { chain.run(); } catch (RuntimeException expected) { // ignore expected exception } for (int i = 0; i < RUNNABLE_COUNT; i++) { TestRunnable tr = list.get(i); assertEquals(1, tr.getRunCount()); } }
@Test public void runWithLockFactoryTest() { List<ChainRunnable> list = new ArrayList<ChainRunnable>(RUNNABLE_COUNT); for (int i = 0; i < RUNNABLE_COUNT; i++) { list.add(new ChainRunnable(i == FAIL_INDEX)); } LockFactory lf = new NativeLockFactory(); RunnableChain chain = new RunnableChain(false, list); try { chain.run(lf); } catch (RuntimeException expected) { // ignore expected exception } for (int i = 0; i < RUNNABLE_COUNT; i++) { ChainRunnable cr = list.get(i); assertEquals(1, cr.getRunCount()); assertTrue(cr.factorySetAtRuntime); } }