+ throw new AssertionError(String.format("Expected specific message of type %s. Last message received was: %s",
+ clazz, lastMessage), lastEx);
+ }
+
+ public static <T> void assertNoneMatching(final ActorRef actor, final Class<T> clazz) {
+ assertNoneMatching(actor, clazz, 5000);
+ }
+
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ public static <T> void assertNoneMatching(final ActorRef actor, final Class<T> clazz, final long timeout) {
+ Exception lastEx = null;
+ int count = (int) (timeout / 50);
+ for (int i = 0; i < count; i++) {
+ try {
+ T message = getFirstMatching(actor, clazz);
+ if (message != null) {
+ Assert.fail("Unexpected message received" + message.toString());
+ return;
+ }
+
+ lastEx = null;
+ } catch (Exception e) {
+ lastEx = e;
+ }
+
+ Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
+ }
+
+ if (lastEx != null) {
+ Throwables.throwIfUnchecked(lastEx);
+ throw new RuntimeException(lastEx);
+ }
+
+ return;