本文整理汇总了Java中org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration类的典型用法代码示例。如果您正苦于以下问题:Java EntityOwnershipListenerRegistration类的具体用法?Java EntityOwnershipListenerRegistration怎么用?Java EntityOwnershipListenerRegistration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityOwnershipListenerRegistration类属于org.opendaylight.controller.md.sal.common.api.clustering包,在下文中一共展示了EntityOwnershipListenerRegistration类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRegisterListener
import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration; //导入依赖的package包/类
@Test
public void testRegisterListener() {
DOMEntityOwnershipListenerRegistration mockDOMReg = mock(DOMEntityOwnershipListenerRegistration.class);
doNothing().when(mockDOMReg).close();
doReturn(mockDOMReg).when(mockDOMService).registerListener(eq(DOM_ENTITY.getType()),
any(DOMEntityOwnershipListener.class));
EntityOwnershipListener mockListener = mock(EntityOwnershipListener.class);
doNothing().when(mockListener).ownershipChanged(any(EntityOwnershipChange.class));
EntityOwnershipListenerRegistration reg = adapter.registerListener(LEGACY_ENTITY.getType(), mockListener);
assertNotNull("registerListener returned null", reg);
assertEquals("getInstance", mockListener, reg.getInstance());
assertEquals("getEntityType", LEGACY_ENTITY.getType(), reg.getEntityType());
ArgumentCaptor<DOMEntityOwnershipListener> domListenerCaptor = ArgumentCaptor.forClass(DOMEntityOwnershipListener.class);
verify(mockDOMService).registerListener(eq(DOM_ENTITY.getType()), domListenerCaptor.capture());
DOMEntityOwnershipChange domOwnershipChange = new DOMEntityOwnershipChange(DOM_ENTITY,
EntityOwnershipChangeState.LOCAL_OWNERSHIP_GRANTED);
domListenerCaptor.getValue().ownershipChanged(domOwnershipChange );
ArgumentCaptor<EntityOwnershipChange> ownershipChangeCaptor = ArgumentCaptor.forClass(EntityOwnershipChange.class);
verify(mockListener).ownershipChanged(ownershipChangeCaptor.capture());
EntityOwnershipChange change = ownershipChangeCaptor.getValue();
assertEquals("getEntity", LEGACY_ENTITY, change.getEntity());
assertEquals("wasOwner", false, change.wasOwner());
assertEquals("isOwner", true, change.isOwner());
assertEquals("hasOwner", true, change.hasOwner());
reg.close();
verify(mockDOMReg).close();
}
示例2: setUp
import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration; //导入依赖的package包/类
@Before
public void setUp() throws CandidateAlreadyRegisteredException {
entityOwnershipService = mock(EntityOwnershipService.class);
when(entityOwnershipService.registerListener(anyString(), any(EntityOwnershipListener.class))).thenReturn(
mock(EntityOwnershipListenerRegistration.class));
when(entityOwnershipService.registerCandidate(any(Entity.class))).thenReturn(mock(
EntityOwnershipCandidateRegistration.class));
}
示例3: registerListener
import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration; //导入依赖的package包/类
@Override
public EntityOwnershipListenerRegistration registerListener(String entityType, EntityOwnershipListener listener) {
return new EntityOwnershipListenerRegistrationAdapter(entityType, listener,
domService.registerListener(entityType, new DOMEntityOwnershipListenerAdapter(listener)));
}
示例4: registerListener
import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration; //导入依赖的package包/类
@Override
public EntityOwnershipListenerRegistration registerListener(String entityType, EntityOwnershipListener listener) {
return Mockito.mock(EntityOwnershipListenerRegistration.class, realOrException());
}