1 package org.opendaylight.controller.cluster.datastore;
3 import static org.mockito.Mockito.doReturn;
4 import static org.mockito.Mockito.times;
5 import static org.mockito.Mockito.verify;
6 import org.junit.Before;
8 import org.mockito.Mock;
9 import org.mockito.MockitoAnnotations;
10 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
11 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
12 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
14 public class DistributedDataStoreTest extends AbstractActorTest {
16 private SchemaContext schemaContext;
19 private ActorContext actorContext;
22 public void setUp() throws Exception {
23 MockitoAnnotations.initMocks(this);
25 schemaContext = TestModel.createTestContext();
27 doReturn(schemaContext).when(actorContext).getSchemaContext();
31 public void testRateLimitingUsedInReadWriteTxCreation(){
32 DistributedDataStore distributedDataStore = new DistributedDataStore(actorContext);
34 distributedDataStore.newReadWriteTransaction();
36 verify(actorContext, times(1)).acquireTxCreationPermit();
40 public void testRateLimitingUsedInWriteOnlyTxCreation(){
41 DistributedDataStore distributedDataStore = new DistributedDataStore(actorContext);
43 distributedDataStore.newWriteOnlyTransaction();
45 verify(actorContext, times(1)).acquireTxCreationPermit();
50 public void testRateLimitingNotUsedInReadOnlyTxCreation(){
51 DistributedDataStore distributedDataStore = new DistributedDataStore(actorContext);
53 distributedDataStore.newReadOnlyTransaction();
54 distributedDataStore.newReadOnlyTransaction();
55 distributedDataStore.newReadOnlyTransaction();
57 verify(actorContext, times(0)).acquireTxCreationPermit();