Bug 4105: Add EntityOwnershipShard
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / entityownership / DistributedEntityOwnershipServiceTest.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.datastore.entityownership;
9
10 import static org.junit.Assert.assertNotNull;
11 import akka.actor.ActorRef;
12 import java.util.Collections;
13 import java.util.List;
14 import java.util.concurrent.TimeUnit;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.controller.cluster.datastore.AbstractActorTest;
18 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
19 import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
20 import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper;
21 import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration;
22 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
23 import scala.concurrent.Await;
24 import scala.concurrent.Future;
25 import scala.concurrent.duration.Duration;
26
27 /**
28  * Unit tests for DistributedEntityOwnershipService.
29  *
30  * @author Thomas Pantelis
31  */
32 public class DistributedEntityOwnershipServiceTest extends AbstractActorTest {
33     private static int ID_COUNTER = 1;
34
35     private final String dataStoreType = "config" + ID_COUNTER++;
36     private DistributedEntityOwnershipService service;
37     private DistributedDataStore dataStore;
38
39     @Before
40     public void setUp() throws Exception {
41         DatastoreContext datastoreContext = DatastoreContext.newBuilder().dataStoreType(dataStoreType).
42                 shardInitializationTimeout(10, TimeUnit.SECONDS).build();
43         dataStore = new DistributedDataStore(getSystem(), new MockClusterWrapper(),
44                 new MockConfiguration(Collections.<String, List<String>>emptyMap()), datastoreContext );
45
46         dataStore.onGlobalContextUpdated(TestModel.createTestContext());
47
48         service = new DistributedEntityOwnershipService(dataStore);
49     }
50
51     @Test
52     public void testEntityOwnershipShardCreated() throws Exception {
53         service.start();
54
55         Future<ActorRef> future = dataStore.getActorContext().findLocalShardAsync(
56                 DistributedEntityOwnershipService.ENTITY_OWNERSHIP_SHARD_NAME);
57         ActorRef shardActor = Await.result(future, Duration.create(10, TimeUnit.SECONDS));
58         assertNotNull(DistributedEntityOwnershipService.ENTITY_OWNERSHIP_SHARD_NAME + " not found", shardActor);
59     }
60
61     @Test
62     public void testRegisterCandidate() {
63     }
64
65     @Test
66     public void testRegisterListener() {
67     }
68 }