- assertTrue("Expected ShardLeaderNotRespondingException cause. Actual: " + e.getCause(),
- e.getCause() instanceof ShardLeaderNotRespondingException);
- assertNotNull("Expected a nested cause", e.getCause().getCause());
- Throwables.propagateIfInstanceOf(e.getCause().getCause(), Exception.class);
- Throwables.propagate(e.getCause().getCause());
+ final String msg = "Unexpected exception: " + Throwables.getStackTraceAsString(e.getCause());
+ assertTrue(msg, Throwables.getRootCause(e) instanceof NoShardLeaderException
+ || e.getCause() instanceof ShardLeaderNotRespondingException);