本文整理匯總了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());
}
示例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);
}