@GwtIncompatible // threads public void testSubmitAsync_asyncCallable_returnsInterruptedFuture() throws InterruptedException { assertThat(Thread.interrupted()).isFalse(); SettableFuture<Integer> cancelledFuture = SettableFuture.create(); cancelledFuture.cancel(true); assertThat(Thread.interrupted()).isFalse(); ListenableFuture<Integer> future = submitAsync(constantAsyncCallable(cancelledFuture), directExecutor()); assertThat(future.isDone()).isTrue(); assertThat(Thread.interrupted()).isFalse(); }
public void testSubmitAsync_asyncCallable_nullInsteadOfFuture() throws Exception { ListenableFuture<?> chainedFuture = submitAsync(constantAsyncCallable(null), directExecutor()); try { getDone(chainedFuture); fail(); } catch (ExecutionException expected) { NullPointerException cause = (NullPointerException) expected.getCause(); assertThat(cause) .hasMessageThat() .contains( "AsyncCallable.call returned null instead of a Future. " + "Did you mean to return immediateFuture(null)?"); } }
@GwtIncompatible // threads public void testScheduleAsync_asyncCallable_nullInsteadOfFuture() throws Exception { ListenableFuture<?> chainedFuture = scheduleAsync( constantAsyncCallable(null), 1, TimeUnit.NANOSECONDS, newSingleThreadScheduledExecutor()); try { chainedFuture.get(); fail(); } catch (ExecutionException expected) { NullPointerException cause = (NullPointerException) expected.getCause(); assertThat(cause) .hasMessageThat() .contains( "AsyncCallable.call returned null instead of a Future. " + "Did you mean to return immediateFuture(null)?"); } }
public void testSubmitAsync_asyncCallable_nullInsteadOfFuture() throws Exception { ListenableFuture<?> chainedFuture = submitAsync(constantAsyncCallable(null), directExecutor()); try { getDone(chainedFuture); fail(); } catch (ExecutionException expected) { NullPointerException cause = (NullPointerException) expected.getCause(); assertThat(cause) .hasMessage( "AsyncCallable.call returned null instead of a Future. " + "Did you mean to return immediateFuture(null)?"); } }
@GwtIncompatible // threads public void testSubmitAsync_asyncCallable_returnsInterruptedFuture() throws InterruptedException { assertThat(Thread.interrupted()).isFalse(); SettableFuture<Integer> cancelledFuture = SettableFuture.create(); cancelledFuture.cancel(true); assertThat(Thread.interrupted()).isFalse(); ListenableFuture<Integer> future = submitAsync(constantAsyncCallable(cancelledFuture), directExecutor()); assertThat(future.isDone()).isTrue(); assertThat(Thread.interrupted()).isFalse(); }
@GwtIncompatible // threads public void testScheduleAsync_asyncCallable_nullInsteadOfFuture() throws Exception { ListenableFuture<?> chainedFuture = scheduleAsync( constantAsyncCallable(null), 1, TimeUnit.NANOSECONDS, newSingleThreadScheduledExecutor()); try { chainedFuture.get(); fail(); } catch (ExecutionException expected) { NullPointerException cause = (NullPointerException) expected.getCause(); assertThat(cause) .hasMessage( "AsyncCallable.call returned null instead of a Future. " + "Did you mean to return immediateFuture(null)?"); } }