return new ClusterException(exceptions);
/** @see #create(Collection) */ public static RuntimeException create(Throwable... exceptions) { ArrayList<Throwable> temp = new ArrayList<>(Arrays.asList(exceptions)); return create(temp); }
public void testThrowingTearDown() throws Exception { final TearDownStack stack = buildTearDownStack(); final ThrowingTearDown tearDownOne = new ThrowingTearDown("one"); stack.addTearDown(tearDownOne); final ThrowingTearDown tearDownTwo = new ThrowingTearDown("two"); stack.addTearDown(tearDownTwo); assertEquals(false, tearDownOne.ran); assertEquals(false, tearDownTwo.ran); try { stack.runTearDown(); fail("runTearDown should have thrown an exception"); } catch (ClusterException expected) { assertThat(expected.getCause()).hasMessage("two"); } catch (RuntimeException e) { throw new RuntimeException( "A ClusterException should have been thrown, rather than a " + e.getClass().getName(), e); } assertEquals(true, tearDownOne.ran); assertEquals(true, tearDownTwo.ran); }
public void testThrowingTearDown() throws Exception { final TearDownStack stack = buildTearDownStack(); final ThrowingTearDown tearDownOne = new ThrowingTearDown("one"); stack.addTearDown(tearDownOne); final ThrowingTearDown tearDownTwo = new ThrowingTearDown("two"); stack.addTearDown(tearDownTwo); assertEquals(false, tearDownOne.ran); assertEquals(false, tearDownTwo.ran); try { stack.runTearDown(); fail("runTearDown should have thrown an exception"); } catch (ClusterException expected) { assertEquals("two", expected.getCause().getMessage()); } catch (RuntimeException e) { throw new RuntimeException( "A ClusterException should have been thrown, rather than a " + e.getClass().getName(), e); } assertEquals(true, tearDownOne.ran); assertEquals(true, tearDownTwo.ran); }
/** Causes teardown to execute. */ public final void runTearDown() { List<Throwable> exceptions = new ArrayList<>(); List<TearDown> stackCopy; synchronized (stack) { stackCopy = Lists.newArrayList(stack); stack.clear(); } for (TearDown tearDown : stackCopy) { try { tearDown.tearDown(); } catch (Throwable t) { if (suppressThrows) { logger.log(Level.INFO, "exception thrown during tearDown", t); } else { exceptions.add(t); } } } if (!suppressThrows && (exceptions.size() > 0)) { throw ClusterException.create(exceptions); } } }
return new ClusterException(exceptions);
/** * @see #create(Collection) */ public static RuntimeException create(Throwable... exceptions) { ArrayList<Throwable> temp = new ArrayList<Throwable>(); for (Throwable exception : exceptions) { temp.add(exception); } return create(temp); }
return new ClusterException(exceptions);
/** @see #create(Collection) */ public static RuntimeException create(Throwable... exceptions) { ArrayList<Throwable> temp = new ArrayList<>(Arrays.asList(exceptions)); return create(temp); }
/** Causes teardown to execute. */ public final void runTearDown() { List<Throwable> exceptions = new ArrayList<>(); List<TearDown> stackCopy; synchronized (stack) { stackCopy = Lists.newArrayList(stack); stack.clear(); } for (TearDown tearDown : stackCopy) { try { tearDown.tearDown(); } catch (Throwable t) { if (suppressThrows) { logger.log(Level.INFO, "exception thrown during tearDown", t); } else { exceptions.add(t); } } } if (!suppressThrows && (exceptions.size() > 0)) { throw ClusterException.create(exceptions); } } }
/** * Causes teardown to execute. */ public final void runTearDown() { List<Throwable> exceptions = new ArrayList<Throwable>(); for (TearDown tearDown : stack) { try { tearDown.tearDown(); } catch (Throwable t) { if (suppressThrows) { logger.log(Level.INFO, "exception thrown during tearDown", t); } else { exceptions.add(t); } } } stack.clear(); if ((!suppressThrows) && (exceptions.size() > 0)) { throw ClusterException.create(exceptions); } } }