@Test public void executeOnceTest() throws InterruptedException, ExecutionException { TestRunnable tr = new TestRunnable(); ExecuteOnGetFutureTask<?> geft = new ExecuteOnGetFutureTask<>(tr); geft.get(); geft.run(); geft.get(); // multiple get calls should not execute again either geft.run(); assertTrue(tr.ranOnce()); }
@Test public void executeInvokedByGetTest() throws InterruptedException, ExecutionException { TestRunnable tr = new TestRunnable(); ExecuteOnGetFutureTask<?> geft = new ExecuteOnGetFutureTask<>(tr); geft.get(); assertTrue(tr.ranOnce()); }