@Override public String toString() { return orig.toString(); } });
public void testSetSelf_toString() { SettableFuture<Object> orig = SettableFuture.create(); orig.set(orig); assertThat(orig.toString()).contains("[status=SUCCESS, result=[this future]]"); }
public void testAsyncToString() throws Exception { inputFuture.set(SLOW_OUTPUT_VALID_INPUT_DATA); assertThat(resultFuture.toString()).contains(outputFuture.toString()); }
public void testInputFutureToString() throws Throwable { assertThat(resultFuture.toString()).contains(inputFuture.toString()); }
public void testSetIndirectSelf_toString() { final SettableFuture<Object> orig = SettableFuture.create(); // unlike the above this indirection defeats the trivial cycle detection and causes a SOE orig.set( new Object() { @Override public String toString() { return orig.toString(); } }); try { orig.toString(); fail(); } catch (StackOverflowError expected) { } }
public void testSetFutureSelf_toString() { SettableFuture<String> orig = SettableFuture.create(); orig.setFuture(orig); assertThat(orig.toString()).contains("[status=PENDING, info=[setFuture=[this future]]]"); }
public void testCatchingAsync_futureToString() throws Exception { final SettableFuture<Object> toReturn = SettableFuture.create(); AsyncFunction<Object, Object> function = new AsyncFunction<Object, Object>() { @Override public ListenableFuture<Object> apply(Object input) throws Exception { return toReturn; } @Override public String toString() { return "Called my toString"; } }; ListenableFuture<?> output = Futures.catchingAsync( immediateFailedFuture(new RuntimeException()), Throwable.class, function, directExecutor()); assertThat(output.toString()).contains(toReturn.toString()); }