2a9356e63d495d15d20b6be45960e5ac9a6bc697
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / DistributedDataStoreTest.java
1 package org.opendaylight.controller.cluster.datastore;
2
3 import junit.framework.Assert;
4 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
5 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
6 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
7 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
8 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
9 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
10 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
11 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
12 import org.opendaylight.yangtools.concepts.ListenerRegistration;
13 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15
16 public class DistributedDataStoreTest extends AbstractActorTest{
17
18     private DistributedDataStore distributedDataStore;
19
20     @org.junit.Before
21     public void setUp() throws Exception {
22         distributedDataStore = new DistributedDataStore(getSystem(), "config");
23         distributedDataStore.onGlobalContextUpdated(TestModel.createTestContext());
24     }
25
26     @org.junit.After
27     public void tearDown() throws Exception {
28
29     }
30
31     @org.junit.Test
32     public void testRegisterChangeListener() throws Exception {
33         ListenerRegistration registration =
34                 distributedDataStore.registerChangeListener(TestModel.TEST_PATH, new AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>() {
35             @Override
36             public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier, NormalizedNode<?, ?>> change) {
37                 throw new UnsupportedOperationException("onDataChanged");
38             }
39         }, AsyncDataBroker.DataChangeScope.BASE);
40
41         Assert.assertNotNull(registration);
42     }
43
44     @org.junit.Test
45     public void testCreateTransactionChain() throws Exception {
46         final DOMStoreTransactionChain transactionChain = distributedDataStore.createTransactionChain();
47         Assert.assertNotNull(transactionChain);
48     }
49
50     @org.junit.Test
51     public void testNewReadOnlyTransaction() throws Exception {
52         final DOMStoreReadTransaction transaction = distributedDataStore.newReadOnlyTransaction();
53         Assert.assertNotNull(transaction);
54     }
55
56     @org.junit.Test
57     public void testNewWriteOnlyTransaction() throws Exception {
58         final DOMStoreWriteTransaction transaction = distributedDataStore.newWriteOnlyTransaction();
59         Assert.assertNotNull(transaction);
60     }
61
62     @org.junit.Test
63     public void testNewReadWriteTransaction() throws Exception {
64         final DOMStoreReadWriteTransaction transaction = distributedDataStore.newReadWriteTransaction();
65         Assert.assertNotNull(transaction);
66     }
67 }