X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fentityownership%2FDistributedEntityOwnershipServiceTest.java;h=83056bae3a02a520766cfc804b2cc28a44b94660;hb=12fcdfe39aa26dcba7fd3bb4d4c68e3d02e65c51;hp=52adc5af42c3fa3d0911055cf2d69b24f3df8d2a;hpb=a47dd7a5d21ca68804a6d0e2e3ca765f223c2ef4;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipServiceTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipServiceTest.java index 52adc5af42..83056bae3a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipServiceTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipServiceTest.java @@ -27,6 +27,7 @@ import static org.opendaylight.controller.cluster.datastore.entityownership.Enti import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.entityOwnersWithEntityTypeEntry; import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.entityPath; import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.entityTypeEntryWithEntityEntry; + import akka.actor.ActorRef; import com.google.common.base.Optional; import com.google.common.collect.Sets; @@ -38,6 +39,7 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.opendaylight.controller.cluster.access.concepts.MemberName; +import org.opendaylight.controller.cluster.datastore.AbstractDataStore; import org.opendaylight.controller.cluster.datastore.DatastoreContext; import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory; import org.opendaylight.controller.cluster.datastore.DistributedDataStore; @@ -72,19 +74,19 @@ import scala.concurrent.duration.Duration; * * @author Thomas Pantelis */ -public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnershipTest { +public class DistributedEntityOwnershipServiceTest extends AbstractClusterRefEntityOwnershipTest { static final String ENTITY_TYPE = "test"; static final String ENTITY_TYPE2 = "test2"; static final QName QNAME = QName.create("test", "2015-08-11", "foo"); static int ID_COUNTER = 1; private final String dataStoreName = "config" + ID_COUNTER++; - private DistributedDataStore dataStore; + private AbstractDataStore dataStore; @Before public void setUp() { - DatastoreContext datastoreContext = DatastoreContext.newBuilder().dataStoreName(dataStoreName). - shardInitializationTimeout(10, TimeUnit.SECONDS).build(); + DatastoreContext datastoreContext = DatastoreContext.newBuilder().dataStoreName(dataStoreName) + .shardInitializationTimeout(10, TimeUnit.SECONDS).build(); Configuration configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider()) { @Override @@ -97,7 +99,8 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh Mockito.doReturn(datastoreContext).when(mockContextFactory).getBaseDatastoreContext(); Mockito.doReturn(datastoreContext).when(mockContextFactory).getShardDatastoreContext(Mockito.anyString()); - dataStore = new DistributedDataStore(getSystem(), new MockClusterWrapper(), configuration, mockContextFactory, null); + dataStore = new DistributedDataStore(getSystem(), new MockClusterWrapper(), configuration, + mockContextFactory, null); dataStore.onGlobalContextUpdated(SchemaContextHelper.entityOwners()); } @@ -145,7 +148,7 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh try { service.registerCandidate(entity); fail("Expected CandidateAlreadyRegisteredException"); - } catch(CandidateAlreadyRegisteredException e) { + } catch (CandidateAlreadyRegisteredException e) { // expected assertEquals("getEntity", entity, e.getEntity()); } @@ -228,7 +231,8 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh when(service.getLocalEntityOwnershipShardDataTree()).thenReturn(shardDataTree.getDataTree()); DOMEntity entity1 = new DOMEntity(ENTITY_TYPE, "one"); - writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, entity1.getIdentifier(), "member-1"), shardDataTree); + writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, entity1.getIdentifier(), "member-1"), + shardDataTree); writeNode(ENTITY_OWNERS_PATH, entityOwnersWithEntityTypeEntry(entityTypeEntryWithEntityEntry(entity1.getType(), entityEntryWithOwner(entity1.getIdentifier(), "member-1"))), shardDataTree); verifyGetOwnershipState(service, entity1, EntityOwnershipState.IS_OWNER); @@ -239,8 +243,8 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh entityEntryWithOwner(entity1.getIdentifier(), "member-2"), shardDataTree); verifyGetOwnershipState(service, entity1, EntityOwnershipState.OWNED_BY_OTHER); - writeNode(entityPath(entity1.getType(), entity1.getIdentifier()), entityEntryWithOwner(entity1.getIdentifier(), ""), - shardDataTree); + writeNode(entityPath(entity1.getType(), entity1.getIdentifier()), entityEntryWithOwner(entity1.getIdentifier(), + ""), shardDataTree); verifyGetOwnershipState(service, entity1, EntityOwnershipState.NO_OWNER); DOMEntity entity2 = new DOMEntity(ENTITY_TYPE, "two"); @@ -282,19 +286,20 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh assertEquals("EntityOwnershipState", expState, state.get()); } + @SuppressWarnings("checkstyle:IllegalCatch") private void verifyEntityCandidate(final ActorRef entityOwnershipShard, final String entityType, final YangInstanceIdentifier entityId, final String candidateName) { - verifyEntityCandidate(entityType, entityId, candidateName, - path -> { - try { - return dataStore.newReadOnlyTransaction().read(path).get(5, TimeUnit.SECONDS).get(); - } catch (Exception e) { - return null; - } - }); + verifyEntityCandidate(entityType, entityId, candidateName, path -> { + try { + return dataStore.newReadOnlyTransaction().read(path).get(5, TimeUnit.SECONDS).get(); + } catch (Exception e) { + return null; + } + }); } - private static void verifyRegisterCandidateLocal(final DistributedEntityOwnershipService service, final DOMEntity entity) { + private static void verifyRegisterCandidateLocal(final DistributedEntityOwnershipService service, + final DOMEntity entity) { RegisterCandidateLocal regCandidate = verifyMessage(service, RegisterCandidateLocal.class); assertEquals("getEntity", entity, regCandidate.getEntity()); }