X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FTransactionChainProxyTest.java;h=dd37371a4510c622b4ee0fdb3b5ab5cf67b5bf7f;hb=4061a49630bd90e2a4839fc5f5622e1faaebfd67;hp=93145bdd6d86360070dce5102dbd968c6ebc0629;hpb=945a63ae76181f7cda4b052fa8fcdf115da4cf2d;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java index 93145bdd6d..dd37371a45 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java @@ -10,26 +10,29 @@ package org.opendaylight.controller.cluster.datastore; -import static org.mockito.Mockito.doReturn; - +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.mockito.Mockito; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; +import org.opendaylight.controller.cluster.datastore.utils.MockActorContext; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -public class TransactionChainProxyTest { - ActorContext actorContext = Mockito.mock(ActorContext.class); - SchemaContext schemaContext = Mockito.mock(SchemaContext.class); +public class TransactionChainProxyTest extends AbstractActorTest{ + ActorContext actorContext = null; + SchemaContext schemaContext = mock(SchemaContext.class); @Before public void setUp() { - doReturn(schemaContext).when(actorContext).getSchemaContext(); + actorContext = new MockActorContext(getSystem()); + actorContext.setSchemaContext(schemaContext); } @SuppressWarnings("resource") @@ -57,8 +60,20 @@ public class TransactionChainProxyTest { } - @Test(expected=UnsupportedOperationException.class) + @Test public void testClose() throws Exception { - new TransactionChainProxy(actorContext).close(); + ActorContext context = mock(ActorContext.class); + + new TransactionChainProxy(context).close(); + + verify(context, times(1)).broadcast(anyObject()); + } + + @Test + public void testTransactionChainsHaveUniqueId(){ + TransactionChainProxy one = new TransactionChainProxy(mock(ActorContext.class)); + TransactionChainProxy two = new TransactionChainProxy(mock(ActorContext.class)); + + Assert.assertNotEquals(one.getTransactionChainId(), two.getTransactionChainId()); } }