public void testTransformAsync_listenerThrowsError() throws Exception { SettableFuture<Object> input = SettableFuture.create(); ListenableFuture<Object> output = transformAsync(input, asyncIdentity(), directExecutor()); output.addListener( new Runnable() { @Override public void run() { throw new MyError(); } }, directExecutor()); try { input.set("foo"); fail(); } catch (MyError expected) { } }
public void testTransformAsync_rejectionPropagatesToOutput() throws Exception { SettableFuture<Foo> input = SettableFuture.create(); AsyncFunction<Foo, Foo> asyncIdentity = asyncIdentity(); ListenableFuture<Foo> transformed = transformAsync(input, asyncIdentity, REJECTING_EXECUTOR); input.set(new Foo()); try { getDone(transformed); fail(); } catch (ExecutionException expected) { assertThat(expected.getCause()).isInstanceOf(RejectedExecutionException.class); } }
@AndroidIncompatible @GwtIncompatible // StackOverflowError public void testTransformAsync_StackOverflow() throws Exception { { /* * Initialize all relevant classes before running the test, which may otherwise poison any * classes it is trying to load during its stack overflow. */ SettableFuture<Object> root = SettableFuture.create(); ListenableFuture<Object> unused = transformAsync(root, asyncIdentity(), directExecutor()); root.set("foo"); } SettableFuture<Object> root = SettableFuture.create(); ListenableFuture<Object> output = root; for (int i = 0; i < 10000; i++) { output = transformAsync(output, asyncIdentity(), directExecutor()); } try { root.set("foo"); fail(); } catch (StackOverflowError expected) { } }
public void testCatchingAsync_listenerThrowsError() throws Exception { SettableFuture<Object> input = SettableFuture.create(); ListenableFuture<Object> output = catchingAsync(input, Throwable.class, asyncIdentity(), directExecutor()); output.addListener( new Runnable() { @Override public void run() { throw new MyError(); } }, directExecutor()); try { input.setException(new MyException()); fail(); } catch (MyError expected) { } }
@GwtIncompatible // StackOverflowError public void testCatchingAsync_StackOverflow() throws Exception { { /* * Initialize all relevant classes before running the test, which may otherwise poison any * classes it is trying to load during its stack overflow. */ SettableFuture<Object> root = SettableFuture.create(); ListenableFuture<Object> unused = catchingAsync(root, MyException.class, asyncIdentity(), directExecutor()); root.setException(new MyException()); } SettableFuture<Object> root = SettableFuture.create(); ListenableFuture<Object> output = root; for (int i = 0; i < 10000; i++) { output = catchingAsync(output, MyException.class, asyncIdentity(), directExecutor()); } try { root.setException(new MyException()); fail(); } catch (StackOverflowError expected) { } }
public void testCatchingAsync_getThrowsError() throws Exception { ListenableFuture<Object> input = UncheckedThrowingFuture.throwingError(new MyError()); // We'd catch only MyError.class here, but then the test won't compile under GWT. ListenableFuture<Object> output = catchingAsync(input, Throwable.class, asyncIdentity(), directExecutor()); assertThat(getDone(output)).isInstanceOf(MyError.class); }
public void testTransformAsync_getThrowsRuntimeException() throws Exception { ListenableFuture<Object> input = UncheckedThrowingFuture.throwingRuntimeException(new MyRuntimeException()); ListenableFuture<Object> output = transformAsync(input, asyncIdentity(), directExecutor()); try { getDone(output); fail(); } catch (ExecutionException expected) { assertThat(expected.getCause()).isInstanceOf(MyRuntimeException.class); } }
public void testTransformAsync_getThrowsError() throws Exception { ListenableFuture<Object> input = UncheckedThrowingFuture.throwingError(new MyError()); ListenableFuture<Object> output = transformAsync(input, asyncIdentity(), directExecutor()); try { getDone(output); fail(); } catch (ExecutionException expected) { assertThat(expected.getCause()).isInstanceOf(MyError.class); } }
public void testCatchingAsync_getThrowsRuntimeException() throws Exception { ListenableFuture<Object> input = UncheckedThrowingFuture.throwingRuntimeException(new MyRuntimeException()); // We'd catch only MyRuntimeException.class here, but then the test won't compile under GWT. ListenableFuture<Object> output = catchingAsync(input, Throwable.class, asyncIdentity(), directExecutor()); assertThat(getDone(output)).isInstanceOf(MyRuntimeException.class); }
public void testTransformAsync_listenerThrowsError() throws Exception { SettableFuture<Object> input = SettableFuture.create(); ListenableFuture<Object> output = transformAsync(input, asyncIdentity(), directExecutor()); output.addListener( new Runnable() { @Override public void run() { throw new MyError(); } }, directExecutor()); try { input.set("foo"); fail(); } catch (MyError expected) { } }
@AndroidIncompatible @GwtIncompatible // StackOverflowError public void testTransformAsync_StackOverflow() throws Exception { { /* * Initialize all relevant classes before running the test, which may otherwise poison any * classes it is trying to load during its stack overflow. */ SettableFuture<Object> root = SettableFuture.create(); ListenableFuture<Object> unused = transformAsync(root, asyncIdentity(), directExecutor()); root.set("foo"); } SettableFuture<Object> root = SettableFuture.create(); ListenableFuture<Object> output = root; for (int i = 0; i < 10000; i++) { output = transformAsync(output, asyncIdentity(), directExecutor()); } try { root.set("foo"); fail(); } catch (StackOverflowError expected) { } }
public void testTransformAsync_rejectionPropagatesToOutput() throws Exception { SettableFuture<Foo> input = SettableFuture.create(); AsyncFunction<Foo, Foo> asyncIdentity = asyncIdentity(); ListenableFuture<Foo> transformed = transformAsync(input, asyncIdentity, REJECTING_EXECUTOR); input.set(new Foo()); try { getDone(transformed); fail(); } catch (ExecutionException expected) { assertThat(expected.getCause()).isInstanceOf(RejectedExecutionException.class); } }
@GwtIncompatible // StackOverflowError public void testCatchingAsync_StackOverflow() throws Exception { { /* * Initialize all relevant classes before running the test, which may otherwise poison any * classes it is trying to load during its stack overflow. */ SettableFuture<Object> root = SettableFuture.create(); ListenableFuture<Object> unused = catchingAsync(root, MyException.class, asyncIdentity(), directExecutor()); root.setException(new MyException()); } SettableFuture<Object> root = SettableFuture.create(); ListenableFuture<Object> output = root; for (int i = 0; i < 10000; i++) { output = catchingAsync(output, MyException.class, asyncIdentity(), directExecutor()); } try { root.setException(new MyException()); fail(); } catch (StackOverflowError expected) { } }
public void testCatchingAsync_listenerThrowsError() throws Exception { SettableFuture<Object> input = SettableFuture.create(); ListenableFuture<Object> output = catchingAsync(input, Throwable.class, asyncIdentity(), directExecutor()); output.addListener( new Runnable() { @Override public void run() { throw new MyError(); } }, directExecutor()); try { input.setException(new MyException()); fail(); } catch (MyError expected) { } }
public void testTransformAsync_getThrowsRuntimeException() throws Exception { ListenableFuture<Object> input = UncheckedThrowingFuture.throwingRuntimeException(new MyRuntimeException()); ListenableFuture<Object> output = transformAsync(input, asyncIdentity(), directExecutor()); try { getDone(output); fail(); } catch (ExecutionException expected) { assertThat(expected.getCause()).isInstanceOf(MyRuntimeException.class); } }
public void testCatchingAsync_getThrowsRuntimeException() throws Exception { ListenableFuture<Object> input = UncheckedThrowingFuture.throwingRuntimeException(new MyRuntimeException()); // We'd catch only MyRuntimeException.class here, but then the test won't compile under GWT. ListenableFuture<Object> output = catchingAsync(input, Throwable.class, asyncIdentity(), directExecutor()); assertThat(getDone(output)).isInstanceOf(MyRuntimeException.class); }
public void testCatchingAsync_getThrowsError() throws Exception { ListenableFuture<Object> input = UncheckedThrowingFuture.throwingError(new MyError()); // We'd catch only MyError.class here, but then the test won't compile under GWT. ListenableFuture<Object> output = catchingAsync(input, Throwable.class, asyncIdentity(), directExecutor()); assertThat(getDone(output)).isInstanceOf(MyError.class); }
public void testTransformAsync_getThrowsError() throws Exception { ListenableFuture<Object> input = UncheckedThrowingFuture.throwingError(new MyError()); ListenableFuture<Object> output = transformAsync(input, asyncIdentity(), directExecutor()); try { getDone(output); fail(); } catch (ExecutionException expected) { assertThat(expected.getCause()).isInstanceOf(MyError.class); } }