@Test public void testCancel() { ZigBeeTransaction transaction = Mockito.mock(ZigBeeTransaction.class); ZigBeeTransactionFuture future = new ZigBeeTransactionFuture(transaction); assertFalse(future.isCancelled()); assertTrue(future.cancel(true)); Mockito.verify(transaction, Mockito.timeout(TIMEOUT).times(1)).cancel(); assertFalse(future.cancel(true)); Mockito.verify(transaction, Mockito.timeout(TIMEOUT).times(1)).cancel(); assertTrue(future.isCancelled()); }
@Override public synchronized boolean cancel(boolean mayInterruptIfRunning) { if (result != null || cancelled) { return false; } cancelled = true; transaction.cancel(); notifyAll(); return true; }
ZigBeeTransactionFuture implements Future<CommandResult> { @Override public synchronized boolean cancel(boolean mayInterruptIfRunning) { if (result != null || cancelled) { return false; } cancelled = true; transaction.cancel(); notifyAll(); return true; } }
ZigBeeTransactionFuture implements Future<CommandResult> { @Override public synchronized boolean cancel(boolean mayInterruptIfRunning) { if (result != null || cancelled) { return false; } cancelled = true; transaction.cancel(); notifyAll(); return true; } ZigBeeTransactionFuture(ZigBeeTransaction transaction); }
ZigBeeTransactionFuture implements Future<CommandResult> { @Override public synchronized boolean cancel(boolean mayInterruptIfRunning) { if (result != null || cancelled) { return false; } cancelled = true; transaction.cancel(); notifyAll(); return true; } ZigBeeTransactionFuture(ZigBeeTransaction transaction); synchronized void set(final CommandResult result); @Override synchronized boolean cancel(boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override synchronized boolean isDone(); @Override CommandResult get(); @Override CommandResult get(long timeout, TimeUnit unit); @Override String toString(); }
ZigBeeTransactionFuture implements Future<CommandResult> { @Override public synchronized boolean cancel(boolean mayInterruptIfRunning) { if (result != null || cancelled) { return false; } cancelled = true; transaction.cancel(); notifyAll(); return true; } ZigBeeTransactionFuture(ZigBeeTransaction transaction); synchronized void set(final CommandResult result); @Override synchronized boolean cancel(boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override synchronized boolean isDone(); @Override CommandResult get(); @Override CommandResult get(long timeout, TimeUnit unit); @Override String toString();  }