+ return addActor(actorRef, false);
+ }
+
+ /**
+ * Create a test actor with the passed in name.
+ *
+ * @param props the actor Props
+ * @param actorId name of actor
+ * @param <T> the actor type
+ * @return the ActorRef
+ */
+ @SuppressWarnings("unchecked")
+ public <T extends Actor> TestActorRef<T> createTestActor(Props props, String actorId) {
+ InvalidActorNameException lastError = null;
+ for (int i = 0; i < 10; i++) {
+ try {
+ TestActorRef<T> actorRef = TestActorRef.create(system, props, actorId);
+ return (TestActorRef<T>) addActor(actorRef, true);
+ } catch (InvalidActorNameException e) {
+ lastError = e;
+ Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ }
+ }
+
+ throw lastError;