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();
28 doReturn(DatastoreContext.newBuilder().build()).when(actorContext).getDatastoreContext();
32 public void testRateLimitingUsedInReadWriteTxCreation(){
33 DistributedDataStore distributedDataStore = new DistributedDataStore(actorContext);
35 distributedDataStore.newReadWriteTransaction();
37 verify(actorContext, times(1)).acquireTxCreationPermit();
41 public void testRateLimitingUsedInWriteOnlyTxCreation(){
42 DistributedDataStore distributedDataStore = new DistributedDataStore(actorContext);
44 distributedDataStore.newWriteOnlyTransaction();
46 verify(actorContext, times(1)).acquireTxCreationPermit();
51 public void testRateLimitingNotUsedInReadOnlyTxCreation(){
52 DistributedDataStore distributedDataStore = new DistributedDataStore(actorContext);
54 distributedDataStore.newReadOnlyTransaction();
55 distributedDataStore.newReadOnlyTransaction();
56 distributedDataStore.newReadOnlyTransaction();
58 verify(actorContext, times(0)).acquireTxCreationPermit();