当前位置: 首页>>代码示例>>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;未经允许,请勿转载。