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


Java EasyMock.checkOrder方法代碼示例

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


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

示例1: exceptionExecutingPolicy

import org.easymock.EasyMock; //導入方法依賴的package包/類
@Test
public void exceptionExecutingPolicy() throws InterruptedException, IOException, IllegalAccessException {
    Map<String, String> props = new HashMap<>(taskConfig);
    task.start(props);

    Policy policy = EasyMock.createNiceMock(Policy.class);
    EasyMock.expect(policy.hasEnded()).andReturn(Boolean.FALSE);
    EasyMock.expect(policy.execute()).andThrow(new ConnectException("Exception from mock"));
    EasyMock.expect(policy.getURIs()).andReturn(null);
    EasyMock.checkOrder(policy, false);
    EasyMock.replay(policy);
    MemberModifier.field(FsSourceTask.class, "policy").set(task, policy);

    assertEquals(0, task.poll().size());
}
 
開發者ID:mmolimar,項目名稱:kafka-connect-fs,代碼行數:16,代碼來源:FsSourceTaskTestBase.java

示例2: initTask

import org.easymock.EasyMock; //導入方法依賴的package包/類
@Before
public void initTask() {
    task = new FsSourceTask();
    taskConfig = new HashMap<String, String>() {{
        String uris[] = directories.stream().map(dir -> dir.toString())
                .toArray(size -> new String[size]);
        put(FsSourceTaskConfig.FS_URIS, String.join(",", uris));
        put(FsSourceTaskConfig.TOPIC, "topic_test");
        put(FsSourceTaskConfig.POLICY_CLASS, SimplePolicy.class.getName());
        put(FsSourceTaskConfig.FILE_READER_CLASS, TextFileReader.class.getName());
        put(FsSourceTaskConfig.POLICY_REGEXP, "^[0-9]*\\.txt$");
    }};

    //Mock initialization
    taskContext = PowerMock.createMock(SourceTaskContext.class);
    offsetStorageReader = PowerMock.createMock(OffsetStorageReader.class);

    EasyMock.expect(taskContext.offsetStorageReader())
            .andReturn(offsetStorageReader);

    EasyMock.expect(taskContext.offsetStorageReader())
            .andReturn(offsetStorageReader);

    EasyMock.expect(offsetStorageReader.offset(EasyMock.anyObject()))
            .andReturn(new HashMap<String, Object>() {{
                put("offset", 5L);
            }});
    EasyMock.expect(offsetStorageReader.offset(EasyMock.anyObject()))
            .andReturn(new HashMap<String, Object>() {{
                put("offset", 5L);
            }});

    EasyMock.checkOrder(taskContext, false);
    EasyMock.replay(taskContext);

    EasyMock.checkOrder(offsetStorageReader, false);
    EasyMock.replay(offsetStorageReader);

    task.initialize(taskContext);

}
 
開發者ID:mmolimar,項目名稱:kafka-connect-fs,代碼行數:42,代碼來源:FsSourceTaskTestBase.java


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