本文整理匯總了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());
}