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


Java PowerMock.resetAll方法代碼示例

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


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

示例1: testClose

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testClose() throws Exception {
    long timeoutMs = 1000;

    // Normal termination, where termination times out.
    executor.shutdown();
    PowerMock.expectLastCall();

    EasyMock.expect(executor.awaitTermination(eq(timeoutMs), eq(TimeUnit.MILLISECONDS)))
            .andReturn(false);
    mockLog.error(EasyMock.anyString());
    PowerMock.expectLastCall();
    PowerMock.replayAll();

    committer.close(timeoutMs);

    PowerMock.verifyAll();
    PowerMock.resetAll();

    // Termination interrupted
    executor.shutdown();
    PowerMock.expectLastCall();

    EasyMock.expect(executor.awaitTermination(eq(timeoutMs), eq(TimeUnit.MILLISECONDS)))
            .andThrow(new InterruptedException());
    PowerMock.replayAll();

    committer.close(timeoutMs);

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

示例2: testRemove

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testRemove() throws Exception {
    ConnectorTaskId taskId = PowerMock.createMock(ConnectorTaskId.class);
    ScheduledFuture task = PowerMock.createMock(ScheduledFuture.class);

    // Try to remove a non-existing task
    EasyMock.expect(committers.remove(taskId)).andReturn(null);
    PowerMock.replayAll();

    committer.remove(taskId);

    PowerMock.verifyAll();
    PowerMock.resetAll();

    // Try to remove an existing task
    EasyMock.expect(committers.remove(taskId)).andReturn(task);
    EasyMock.expect(task.cancel(eq(false))).andReturn(false);
    EasyMock.expect(task.isDone()).andReturn(false);
    EasyMock.expect(task.get()).andReturn(null);
    PowerMock.replayAll();

    committer.remove(taskId);

    PowerMock.verifyAll();
    PowerMock.resetAll();

    // Try to remove a cancelled task
    EasyMock.expect(committers.remove(taskId)).andReturn(task);
    EasyMock.expect(task.cancel(eq(false))).andReturn(false);
    EasyMock.expect(task.isDone()).andReturn(false);
    EasyMock.expect(task.get()).andThrow(new CancellationException());
    mockLog.trace(EasyMock.anyString(), EasyMock.<Object>anyObject());
    PowerMock.expectLastCall();
    PowerMock.replayAll();

    committer.remove(taskId);

    PowerMock.verifyAll();
    PowerMock.resetAll();

    // Try to remove an interrupted task
    EasyMock.expect(committers.remove(taskId)).andReturn(task);
    EasyMock.expect(task.cancel(eq(false))).andReturn(false);
    EasyMock.expect(task.isDone()).andReturn(false);
    EasyMock.expect(task.get()).andThrow(new InterruptedException());
    PowerMock.replayAll();

    try {
        committer.remove(taskId);
        fail("Expected ConnectException to be raised");
    } catch (ConnectException e) {
        //ignore
    }

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

示例3: tearDown

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@After
public void tearDown() throws Exception {
  helper.tearDown();
  PowerMock.resetAll();
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:6,代碼來源:OdeAuthFilterTest.java


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