### Question:
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);  }### Answer:
@Test(timeout = 90000) public void testTimedSync() { ProviderFuture future = futuresFactory.createFuture(); try { assertFalse(future.sync(1, TimeUnit.SECONDS)); } catch (Exception cause) { fail("Should throw an error"); } }
@Test(timeout = 10000) public void testSyncHandlesInterruption() 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(); } catch (Exception 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()); }
@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()); }