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.shardstrategy.ShardStrategyFactory;
7 import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper;
8 import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration;
9 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
10 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
11 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
12 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
13 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
15 import static junit.framework.Assert.assertEquals;
16 import static junit.framework.Assert.assertTrue;
18 public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
21 public void integrationTest() throws Exception {
22 ShardStrategyFactory.setConfiguration(new MockConfiguration());
23 DistributedDataStore distributedDataStore =
24 new DistributedDataStore(getSystem(), "config", new MockClusterWrapper(), new MockConfiguration());
26 distributedDataStore.onGlobalContextUpdated(TestModel.createTestContext());
28 DOMStoreReadWriteTransaction transaction =
29 distributedDataStore.newReadWriteTransaction();
31 transaction.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
33 ListenableFuture<Optional<NormalizedNode<?, ?>>> future =
34 transaction.read(TestModel.TEST_PATH);
36 Optional<NormalizedNode<?, ?>> optional = future.get();
38 NormalizedNode<?, ?> normalizedNode = optional.get();
40 assertEquals(TestModel.TEST_QNAME, normalizedNode.getNodeType());
42 DOMStoreThreePhaseCommitCohort ready = transaction.ready();
44 ListenableFuture<Boolean> canCommit = ready.canCommit();
46 assertTrue(canCommit.get());
48 ListenableFuture<Void> preCommit = ready.preCommit();
52 ListenableFuture<Void> commit = ready.commit();