Search in sources :

Example 1 with DeadLetter

use of akka.actor.DeadLetter in project controller by opendaylight.

the class DataTreeChangeListenerActorTest method testDataChangedWithNoSender.

@Test
public void testDataChangedWithNoSender() {
    new TestKit(getSystem()) {

        {
            final DataTreeCandidate mockTreeCandidate = Mockito.mock(DataTreeCandidate.class);
            final ImmutableList<DataTreeCandidate> mockCandidates = ImmutableList.of(mockTreeCandidate);
            final DOMDataTreeChangeListener mockListener = Mockito.mock(DOMDataTreeChangeListener.class);
            final Props props = DataTreeChangeListenerActor.props(mockListener, TEST_PATH);
            final ActorRef subject = getSystem().actorOf(props, "testDataTreeChangedWithNoSender");
            getSystem().eventStream().subscribe(getRef(), DeadLetter.class);
            subject.tell(new DataTreeChanged(mockCandidates), ActorRef.noSender());
            // Make sure no DataChangedReply is sent to DeadLetters.
            while (true) {
                DeadLetter deadLetter;
                try {
                    deadLetter = expectMsgClass(duration("1 seconds"), DeadLetter.class);
                } catch (AssertionError e) {
                    // Timed out - got no DeadLetter - this is good
                    break;
                }
                // We may get DeadLetters for other messages we don't care
                // about.
                Assert.assertFalse("Unexpected DataTreeChangedReply", deadLetter.message() instanceof DataTreeChangedReply);
            }
        }
    };
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate) DeadLetter(akka.actor.DeadLetter) DataTreeChanged(org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged) DOMDataTreeChangeListener(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener) ActorRef(akka.actor.ActorRef) TestKit(akka.testkit.javadsl.TestKit) Props(akka.actor.Props) DataTreeChangedReply(org.opendaylight.controller.cluster.datastore.messages.DataTreeChangedReply) Test(org.junit.Test)

Example 2 with DeadLetter

use of akka.actor.DeadLetter in project controller by opendaylight.

the class DataChangeListenerTest method testDataChangedWithNoSender.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testDataChangedWithNoSender() {
    new TestKit(getSystem()) {

        {
            final AsyncDataChangeEvent mockChangeEvent = Mockito.mock(AsyncDataChangeEvent.class);
            final AsyncDataChangeListener mockListener = Mockito.mock(AsyncDataChangeListener.class);
            final Props props = DataChangeListener.props(mockListener, TEST_PATH);
            final ActorRef subject = getSystem().actorOf(props, "testDataChangedWithNoSender");
            getSystem().eventStream().subscribe(getRef(), DeadLetter.class);
            subject.tell(new DataChanged(mockChangeEvent), ActorRef.noSender());
            // Make sure no DataChangedReply is sent to DeadLetters.
            while (true) {
                DeadLetter deadLetter;
                try {
                    deadLetter = expectMsgClass(duration("1 seconds"), DeadLetter.class);
                } catch (AssertionError e) {
                    // Timed out - got no DeadLetter - this is good
                    break;
                }
                // We may get DeadLetters for other messages we don't care
                // about.
                Assert.assertFalse("Unexpected DataChangedReply", deadLetter.message() instanceof DataChangedReply);
            }
        }
    };
}
Also used : DataChanged(org.opendaylight.controller.cluster.datastore.messages.DataChanged) DeadLetter(akka.actor.DeadLetter) AsyncDataChangeListener(org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener) ActorRef(akka.actor.ActorRef) TestKit(akka.testkit.javadsl.TestKit) Props(akka.actor.Props) AsyncDataChangeEvent(org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent) DataChangedReply(org.opendaylight.controller.cluster.datastore.messages.DataChangedReply) Test(org.junit.Test)

Aggregations

ActorRef (akka.actor.ActorRef)2 DeadLetter (akka.actor.DeadLetter)2 Props (akka.actor.Props)2 TestKit (akka.testkit.javadsl.TestKit)2 Test (org.junit.Test)2 DataChanged (org.opendaylight.controller.cluster.datastore.messages.DataChanged)1 DataChangedReply (org.opendaylight.controller.cluster.datastore.messages.DataChangedReply)1 DataTreeChanged (org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged)1 DataTreeChangedReply (org.opendaylight.controller.cluster.datastore.messages.DataTreeChangedReply)1 AsyncDataChangeEvent (org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent)1 AsyncDataChangeListener (org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener)1 DOMDataTreeChangeListener (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener)1 DataTreeCandidate (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate)1