import akka.actor.ActorContext;
import akka.actor.ActorRef;
import akka.actor.Props;
-import akka.testkit.JavaTestKit;
import akka.testkit.TestActorRef;
+import akka.testkit.javadsl.TestKit;
import com.google.common.util.concurrent.Uninterruptibles;
import java.util.ArrayList;
import java.util.List;
// Unregister all listeners and verify their listener actors are destroyed.
- List<JavaTestKit> watchers = new ArrayList<>();
+ List<TestKit> watchers = new ArrayList<>();
for (Iterator<ActorRef> iter = listenerActors.iterator(); iter.hasNext();) {
- JavaTestKit kit = new JavaTestKit(getSystem());
+ TestKit kit = new TestKit(getSystem());
kit.watch(iter.next());
watchers.add(kit);
}
support.removeEntityOwnershipListener(entityType2, mockListener2);
Iterator<ActorRef> iter = listenerActors.iterator();
- for (JavaTestKit kit: watchers) {
- kit.expectTerminated(JavaTestKit.duration("3 seconds"), iter.next());
+ for (TestKit kit: watchers) {
+ kit.expectTerminated(kit.duration("3 seconds"), iter.next());
}
assertEquals("# of listener actors", 0, actorContext.children().size());
support.addEntityOwnershipListener(entityType1, mockListener2);
support.removeEntityOwnershipListener(entityType1, mockListener2);
}
-
- @Test
- public void testHasCandidateForEntity() {
- EntityOwnershipListenerSupport support = new EntityOwnershipListenerSupport(actorContext, "test");
- DOMEntity entity = new DOMEntity("type", YangInstanceIdentifier.of(QName.create("test", "id")));
-
- assertEquals("hasCandidateForEntity", false, support.hasCandidateForEntity(entity));
-
- support.setHasCandidateForEntity(entity);
- support.setHasCandidateForEntity(entity); // set again - should be noop
- assertEquals("hasCandidateForEntity", true, support.hasCandidateForEntity(entity));
-
- support.unsetHasCandidateForEntity(entity);
- assertEquals("hasCandidateForEntity", false, support.hasCandidateForEntity(entity));
-
- support.unsetHasCandidateForEntity(entity); // unset again - should be noop
- assertEquals("hasCandidateForEntity", false, support.hasCandidateForEntity(entity));
-
- support.setHasCandidateForEntity(entity);
- assertEquals("hasCandidateForEntity", true, support.hasCandidateForEntity(entity));
- }
}