2 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore.entityownership;
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;
28 * Unit tests for DistributedEntityOwnershipService.
30 * @author Thomas Pantelis
32 public class DistributedEntityOwnershipServiceTest extends AbstractActorTest {
33 private static int ID_COUNTER = 1;
35 private final String dataStoreType = "config" + ID_COUNTER++;
36 private DistributedEntityOwnershipService service;
37 private DistributedDataStore dataStore;
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 );
46 dataStore.onGlobalContextUpdated(TestModel.createTestContext());
48 service = new DistributedEntityOwnershipService(dataStore);
52 public void testEntityOwnershipShardCreated() throws Exception {
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);
62 public void testRegisterCandidate() {
66 public void testRegisterListener() {