DelegatedListenableExecutor extends ForwardingListeningExecutorService { @Override protected ListeningExecutorService delegate() { return delegateExecutor; } DelegatedListenableExecutor( final ExecutorService delegateExecutor ); @Override ListenableFuture<T> submit( final Callable<T> callable );  }
@Test public void delegate() throws Exception { final ExecutorService exec = mock( ExecutorService.class ); final DelegatedListenableExecutor delegatedListenableExecutor = new DelegatedListenableExecutor( exec ); final ListeningExecutorService delegate = delegatedListenableExecutor.delegate(); final Callable callable = mock( Callable.class ); delegate.submit( callable ); verify( exec, times( 1 ) ).execute( any( Runnable.class ) ); }