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


Java PowerMock.expectPrivate方法代碼示例

本文整理匯總了Java中org.powermock.api.easymock.PowerMock.expectPrivate方法的典型用法代碼示例。如果您正苦於以下問題:Java PowerMock.expectPrivate方法的具體用法?Java PowerMock.expectPrivate怎麽用?Java PowerMock.expectPrivate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.powermock.api.easymock.PowerMock的用法示例。


在下文中一共展示了PowerMock.expectPrivate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testJoinLeaderCatchUpFails

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testJoinLeaderCatchUpFails() throws Exception {
    // Join group and as leader fail to do assignment
    EasyMock.expect(member.memberId()).andStubReturn("leader");
    expectRebalance(Collections.<String>emptyList(), Collections.<ConnectorTaskId>emptyList(),
            ConnectProtocol.Assignment.CONFIG_MISMATCH, 1, Collections.<String>emptyList(),
            Collections.<ConnectorTaskId>emptyList());
    // Reading to end of log times out
    configBackingStore.refresh(EasyMock.anyLong(), EasyMock.anyObject(TimeUnit.class));
    EasyMock.expectLastCall().andThrow(new TimeoutException());
    member.maybeLeaveGroup();
    EasyMock.expectLastCall();
    PowerMock.expectPrivate(herder, "backoff", DistributedConfig.WORKER_UNSYNC_BACKOFF_MS_DEFAULT);
    member.requestRejoin();

    // After backoff, restart the process and this time succeed
    expectRebalance(1, Arrays.asList(CONN1), Arrays.asList(TASK1));
    expectPostRebalanceCatchup(SNAPSHOT);

    worker.startConnector(EasyMock.eq(CONN1), EasyMock.<Map<String, String>>anyObject(), EasyMock.<ConnectorContext>anyObject(),
            EasyMock.eq(herder), EasyMock.eq(TargetState.STARTED));
    PowerMock.expectLastCall().andReturn(true);
    EasyMock.expect(worker.getPlugins()).andReturn(plugins);
    EasyMock.expect(worker.connectorTaskConfigs(CONN1, MAX_TASKS, null)).andReturn(TASK_CONFIGS);
    worker.startTask(EasyMock.eq(TASK1), EasyMock.<Map<String, String>>anyObject(), EasyMock.<Map<String, String>>anyObject(),
            EasyMock.eq(herder), EasyMock.eq(TargetState.STARTED));
    PowerMock.expectLastCall().andReturn(true);
    EasyMock.expect(worker.isRunning(CONN1)).andReturn(true);
    member.poll(EasyMock.anyInt());
    PowerMock.expectLastCall();

    PowerMock.replayAll();

    herder.tick();
    herder.tick();

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:39,代碼來源:DistributedHerderTest.java


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