mardi 3 mars 2015

Best approach for verifying a FutureCallback effect with Jmockit



What is the preferred mechanism for verifying the effects of a callback in Jmockit?


For example, assume I have this class.



class ResultGenerator {
AsyncLauncher asyncLauncher = new AsyncLauncher();

public void getResultAsync(final ResultSignal resultSignal) {
asyncLauncher.getResult(new FutureCallback<Result>() {
@Override
public void onSuccess(@Nullable Result result) {
resultSignal.success(result);
}

@Override
public void onFailure(Throwable t) {
resultSignal.failure();
}
});
}
}


How do I verify bar.success(result) when writing a test for FooGenerator#getResultAsync?




Aucun commentaire:

Enregistrer un commentaire