X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FDataChangeListenerRegistrationTest.java;h=a499ab3030a1597b66a2c3b5712e59d05570ac67;hp=23302b504ed1c63e4e4ad37d37adbfe251bc4696;hb=d594cf3be29ab746695eb5a3b0d220be89b57566;hpb=cbe83ca3074fa0182d4f079f528bb710a997ced7 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java index 23302b504e..a499ab3030 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationTest.java @@ -1,9 +1,17 @@ +/* + * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.controller.cluster.datastore; +import static org.junit.Assert.assertEquals; import akka.actor.ActorRef; import akka.actor.Props; import akka.testkit.JavaTestKit; -import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.messages.CloseDataChangeListenerRegistration; @@ -13,15 +21,11 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import static org.junit.Assert.assertEquals; - public class DataChangeListenerRegistrationTest extends AbstractActorTest { - private static ListeningExecutorService storeExecutor = MoreExecutors.listeningDecorator(MoreExecutors.sameThreadExecutor()); - - private static final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", storeExecutor); + private static final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService()); static { store.onGlobalContextUpdated(TestModel.createTestContext()); @@ -31,20 +35,22 @@ public class DataChangeListenerRegistrationTest extends AbstractActorTest { @Test public void testOnReceiveCloseListenerRegistration() throws Exception { new JavaTestKit(getSystem()) {{ - final Props props = DataChangeListenerRegistration.props(store + final Props props = DataChangeListenerRegistrationActor.props(store .registerChangeListener(TestModel.TEST_PATH, noOpDataChangeListener(), AsyncDataBroker.DataChangeScope.BASE)); final ActorRef subject = getSystem().actorOf(props, "testCloseListenerRegistration"); new Within(duration("1 seconds")) { + @Override protected void run() { - subject.tell(new CloseDataChangeListenerRegistration(), getRef()); + subject.tell(new CloseDataChangeListenerRegistration().toSerializable(), getRef()); - final String out = new ExpectMsg("match hint") { + final String out = new ExpectMsg(duration("1 seconds"), "match hint") { // do not put code outside this method, will run afterwards - protected String match(Object in) { - if (in instanceof CloseDataChangeListenerRegistrationReply) { + @Override + protected String match(final Object in) { + if (in.getClass().equals(CloseDataChangeListenerRegistrationReply.SERIALIZABLE_CLASS)) { return "match"; } else { throw noMatch(); @@ -62,10 +68,10 @@ public class DataChangeListenerRegistrationTest extends AbstractActorTest { }}; } - private AsyncDataChangeListener> noOpDataChangeListener(){ - return new AsyncDataChangeListener>() { + private static AsyncDataChangeListener> noOpDataChangeListener(){ + return new AsyncDataChangeListener>() { @Override - public void onDataChanged(AsyncDataChangeEvent> change) { + public void onDataChanged(final AsyncDataChangeEvent> change) { } };