- assertEquals("getReadyOperationFutures size", expReplies.length,
- proxy.getCohortFutures().size());
-
- int i = 0;
- for( Future<ActorSelection> future: proxy.getCohortFutures()) {
- assertNotNull("Ready operation Future is null", future);
-
- Object expReply = expReplies[i++];
- if(expReply instanceof ActorSelection) {
- ActorSelection actual = Await.result(future, Duration.create(5, TimeUnit.SECONDS));
- assertEquals("Cohort actor path", expReply, actual);
- } else {
- try {
- Await.result(future, Duration.create(5, TimeUnit.SECONDS));
- fail("Expected exception from ready operation Future");
- } catch(Exception e) {
- assertTrue(String.format("Expected exception type %s. Actual %s",
- expReply, e.getClass()), ((Class<?>)expReply).isInstance(e));
- }
+ assertEquals("getReadyOperationFutures size", expReplies.length,
+ proxy.getCohortFutures().size());
+
+ List<Object> futureResults = new ArrayList<>();
+ for (Future<?> future : proxy.getCohortFutures()) {
+ assertNotNull("Ready operation Future is null", future);
+ try {
+ futureResults.add(Await.result(future, Duration.create(5, TimeUnit.SECONDS)));
+ } catch (Exception e) {
+ futureResults.add(e);
+ }
+ }
+
+ for (Object expReply : expReplies) {
+ boolean found = false;
+ Iterator<?> iter = futureResults.iterator();
+ while (iter.hasNext()) {
+ Object actual = iter.next();
+ if (CommitTransactionReply.isSerializedType(expReply)
+ && CommitTransactionReply.isSerializedType(actual)) {
+ found = true;
+ } else if (expReply instanceof ActorSelection && Objects.equals(expReply, actual)) {
+ found = true;
+ } else if (expReply instanceof Class && ((Class<?>) expReply).isInstance(actual)) {
+ found = true;