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",
24 MoreExecutors.newDirectExecutorService());
27 STORE.onGlobalContextUpdated(TestModel.createTestContext());
30 @SuppressWarnings({ "rawtypes", "unchecked" })
32 public void testOnReceiveCloseListenerRegistration() throws Exception {
33 new JavaTestKit(getSystem()) {
35 final ListenerRegistration mockListenerReg = Mockito.mock(ListenerRegistration.class);
36 final Props props = DataTreeChangeListenerRegistrationActor.props(mockListenerReg);
37 final ActorRef subject = getSystem().actorOf(props, "testCloseListenerRegistration");
39 subject.tell(CloseDataTreeChangeListenerRegistration.getInstance(), getRef());
41 expectMsgClass(duration("1 second"), CloseDataTreeChangeListenerRegistrationReply.class);
43 Mockito.verify(mockListenerReg).close();