1 package org.opendaylight.controller.cluster.datastore;
3 import com.google.common.base.Optional;
4 import com.google.common.util.concurrent.ListenableFuture;
6 import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper;
7 import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration;
8 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
9 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
10 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
11 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
12 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
14 import static junit.framework.Assert.assertEquals;
15 import static junit.framework.Assert.assertTrue;
17 public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
20 public void integrationTest() throws Exception {
21 DistributedDataStore distributedDataStore =
22 new DistributedDataStore(getSystem(), "config", new MockClusterWrapper(), new MockConfiguration());
24 distributedDataStore.onGlobalContextUpdated(TestModel.createTestContext());
26 DOMStoreReadWriteTransaction transaction =
27 distributedDataStore.newReadWriteTransaction();
29 transaction.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
31 ListenableFuture<Optional<NormalizedNode<?, ?>>> future =
32 transaction.read(TestModel.TEST_PATH);
34 Optional<NormalizedNode<?, ?>> optional = future.get();
36 NormalizedNode<?, ?> normalizedNode = optional.get();
38 assertEquals(TestModel.TEST_QNAME, normalizedNode.getNodeType());
40 DOMStoreThreePhaseCommitCohort ready = transaction.ready();
42 ListenableFuture<Boolean> canCommit = ready.canCommit();
44 assertTrue(canCommit.get());
46 ListenableFuture<Void> preCommit = ready.preCommit();
50 ListenableFuture<Void> commit = ready.commit();