Search in sources :

Example 1 with DataTreeChangedReply

use of org.opendaylight.controller.cluster.datastore.messages.DataTreeChangedReply 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)

Aggregations

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