@GwtIncompatible public void testImmediateCancelledFutureStack() throws Exception { ListenableFuture<String> future = CallerClass1.makeImmediateCancelledFuture(); assertTrue(future.isCancelled()); try { CallerClass2.get(future); fail(); } catch (CancellationException expected) { // There should be two CancellationException chained together. The outer one should have the // stack trace of where the get() call was made, and the inner should have the stack trace of // where the immediateCancelledFuture() call was made. List<StackTraceElement> stackTrace = ImmutableList.copyOf(expected.getStackTrace()); assertFalse(Iterables.any(stackTrace, hasClassName(CallerClass1.class))); assertTrue(Iterables.any(stackTrace, hasClassName(CallerClass2.class))); // See AbstractFutureCancellationCauseTest for how to set causes. assertThat(expected.getCause()).isNull(); } }
@GwtIncompatible public void testImmediateCancelledFutureStack() throws Exception { ListenableFuture<String> future = CallerClass1.makeImmediateCancelledFuture(); assertTrue(future.isCancelled()); try { CallerClass2.get(future); fail(); } catch (CancellationException expected) { // There should be two CancellationException chained together. The outer one should have the // stack trace of where the get() call was made, and the inner should have the stack trace of // where the immediateCancelledFuture() call was made. List<StackTraceElement> stackTrace = ImmutableList.copyOf(expected.getStackTrace()); assertFalse(Iterables.any(stackTrace, hasClassName(CallerClass1.class))); assertTrue(Iterables.any(stackTrace, hasClassName(CallerClass2.class))); // See AbstractFutureCancellationCauseTest for how to set causes. assertThat(expected.getCause()).isNull(); } }