@Override public Void then(Task<Object> task) { if (task.isFaulted()) { synchronized (errorLock) { errors.add(task.getError()); } } if (task.isCancelled()) { isCancelled.set(true); } if (count.decrementAndGet() == 0) { if (errors.size() != 0) { if (errors.size() == 1) { allFinished.setError(errors.get(0)); } else { allFinished.setError(new AggregateException(errors)); } } else if (isCancelled.get()) { allFinished.setCancelled(); } else { allFinished.setResult(null); } } return null; } });
@Test(expected = TimeoutException.class) public void readDeviceInfoTimeout() throws Throwable { connectToBoard(); junitPlatform.delayReadDevInfo = true; Task<DeviceInformation> task = mwBoard.readDeviceInformationAsync(); task.waitForCompletion(); AggregateException exception = (AggregateException) task.getError(); assertEquals(2, exception.getInnerThrowables().size()); throw exception.getInnerThrowables().get(1); }