2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.datastore;
10 import akka.actor.ActorRef;
11 import akka.actor.Props;
12 import akka.testkit.JavaTestKit;
13 import com.google.common.util.concurrent.MoreExecutors;
14 import org.junit.Test;
15 import org.mockito.Mockito;
16 import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeChangeListenerRegistration;
17 import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeChangeListenerRegistrationReply;
18 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
19 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
20 import org.opendaylight.yangtools.concepts.ListenerRegistration;
22 public class DataTreeChangeListenerRegistrationActorTest extends AbstractActorTest {
23 private static final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
26 store.onGlobalContextUpdated(TestModel.createTestContext());
29 @SuppressWarnings("rawtypes")
31 public void testOnReceiveCloseListenerRegistration() throws Exception {
32 new JavaTestKit(getSystem()) {{
33 final ListenerRegistration mockListenerReg = Mockito.mock(ListenerRegistration.class);
34 final Props props = DataTreeChangeListenerRegistrationActor.props(mockListenerReg);
35 final ActorRef subject = getSystem().actorOf(props, "testCloseListenerRegistration");
37 subject.tell(CloseDataTreeChangeListenerRegistration.getInstance(), getRef());
39 expectMsgClass(duration("1 second"), CloseDataTreeChangeListenerRegistrationReply.class);
41 Mockito.verify(mockListenerReg).close();