@Test(timeout = 10000) public void testTimedSyncHandlesInterruption() throws InterruptedException { ProviderFuture future = futuresFactory.createFuture(); final CountDownLatch syncing = new CountDownLatch(1); final CountDownLatch done = new CountDownLatch(1); final AtomicBoolean interrupted = new AtomicBoolean(false); Thread runner = new Thread(new Runnable() { @Override public void run() { try { syncing.countDown(); future.sync(20, TimeUnit.SECONDS); } catch (ProviderException cause) { if (cause.getCause() instanceof InterruptedException) { interrupted.set(true); } } finally { done.countDown(); } } }); runner.start(); assertTrue(syncing.await(5, TimeUnit.SECONDS)); runner.interrupt(); assertTrue(done.await(5, TimeUnit.SECONDS)); assertTrue(interrupted.get()); }
public abstract void sync() throws ProviderException;
ProviderFuture implements AsyncResult { public abstract void sync() throws ProviderException; }
ProviderFuture implements AsyncResult { public abstract void sync() throws ProviderException; ProviderFuture();  ProviderFuture(ProviderSynchronization synchronization); }
ProviderFuture implements AsyncResult { public abstract void sync() throws ProviderException; ProviderFuture();  ProviderFuture(ProviderSynchronization synchronization); @Override boolean isComplete(); @Override void onFailure(ProviderException result); @Override void onSuccess(); abstract void sync(); abstract boolean sync(long amount, TimeUnit unit); }
ProviderFuture implements AsyncResult { public abstract void sync() throws ProviderException; ProviderFuture();  ProviderFuture(ProviderSynchronization synchronization); @Override boolean isComplete(); @Override void onFailure(ProviderException result); @Override void onSuccess(); abstract void sync(); abstract boolean sync(long amount, TimeUnit unit);  }