當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityOwnershipListenerRegistration類代碼示例

本文整理匯總了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();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:35,代碼來源:LegacyEntityOwnershipServiceAdapterTest.java

示例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));
}
 
開發者ID:opendaylight,項目名稱:ovsdb,代碼行數:9,代碼來源:SouthboundProviderTest.java

示例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)));
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:6,代碼來源:LegacyEntityOwnershipServiceAdapter.java

示例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());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:5,代碼來源:TestEntityOwnershipService.java


注:本文中的org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。