Saplanmış bir yöntemin sonraki çağrılarda farklı nesneler döndürmesinin bir yolu var mı? Bunu, bir alandaki belirsiz yanıtları test etmek için yapmak istiyorum ExecutorCompletionService. yani yöntemlerin dönüş sırasına bakılmaksızın sonucun sabit kaldığını test etmek.
Test etmek istediğim kod böyle görünüyor.
// Create an completion service so we can group these tasks together
ExecutorCompletionService<T> completionService =
new ExecutorCompletionService<T>(service);
// Add all these tasks to the completion service
for (Callable<T> t : ts)
completionService.submit(request);
// As an when each call finished, add it to the response set.
for (int i = 0; i < calls.size(); i ++) {
try {
T t = completionService.take().get();
// do some stuff that I want to test
} catch (...) { }
}