本文整理汇总了Java中org.easymock.classextension.EasyMock.createMock方法的典型用法代码示例。如果您正苦于以下问题:Java EasyMock.createMock方法的具体用法?Java EasyMock.createMock怎么用?Java EasyMock.createMock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.easymock.classextension.EasyMock
的用法示例。
在下文中一共展示了EasyMock.createMock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRunCallsQueuedRunnables
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
public void testRunCallsQueuedRunnables() throws Exception {
RunnableQueue q = EasyMock.createMock(RunnableQueue.class);
Runnable task1 = EasyMock.createMock(Runnable.class);
Runnable task2 = EasyMock.createMock(Runnable.class);
EasyMock.expect(q.remove()).andReturn(task1);
task1.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andReturn(task2);
task2.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andThrow(new InterruptedException());
EasyMock.replay(q, task1, task2);
QueueExtractor extractor = new QueueExtractor(q);
extractor.run();
EasyMock.verify(q, task1, task2);
}
示例2: testRun
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
public void testRun() throws Exception {
RunnableQueue q = EasyMock.createMock(RunnableQueue.class);
Runnable task1 = EasyMock.createMock(Runnable.class);
Runnable task2 = EasyMock.createMock(Runnable.class);
EasyMock.expect(q.remove()).andReturn(task1);
task1.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andReturn(task2);
task2.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andThrow(new InterruptedException());
EasyMock.replay(q, task1, task2);
WorkerThread worker = new WorkerThread(q, "test thread");
worker.run();
EasyMock.verify(q, task1, task2);
}
示例3: mockDalConnection
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
public DalConnection mockDalConnection(){
DalConnection conn = EasyMock.createMock(DalConnection.class);
DbMeta meta = EasyMock.createMock(DbMeta.class);
EasyMock.expect(meta.getDataBaseKeyName()).andReturn(dbName).times(1);
EasyMock.expect(meta.getDatabaseCategory()).andReturn(DatabaseCategory.MySql).times(1);
EasyMock.expect(conn.getMeta()).andReturn(meta).times(3);
EasyMock.replay(meta, conn);
return conn;
}
示例4: testHandleRequest
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testHandleRequest() throws Exception {
FilterChain chain = EasyMock.createMock(FilterChain.class);
HttpRequest request = EasyMock.createMock(HttpRequest.class);
HttpResponse response = EasyMock.createMock(HttpResponse.class);
HttpRequestHandlerAdapter adapter = new HttpRequestHandlerAdapter(chain);
chain.doFilter(EasyMock.isA(HttpServletRequestAdapter.class),
EasyMock.isA(HttpServletResponseAdapter.class));
EasyMock.expectLastCall();
EasyMock.expect(request.getConnectionInformation()).andReturn(null);
EasyMock.replay(chain, request, response);
adapter.handleRequest(request, response);
EasyMock.verify(chain, request, response);
}
示例5: testGetInputStream_passesBackStream
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testGetInputStream_passesBackStream() throws IOException {
final ServletInputStream mockSis
= EasyMock.createMock(ServletInputStream.class);
EasyMock.expect(mockSubset.getInputStream()).andReturn(mockSis);
EasyMock.replay(mockSubset);
EasyMock.replay(mockSis);
assertThat(adapter.getInputStream(), sameInstance(mockSis));
EasyMock.verify(mockSubset);
EasyMock.verify(mockSis);
}
示例6: testGetReader_passesBackValueFromSubset
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testGetReader_passesBackValueFromSubset()
throws IOException {
final BufferedReader mockReader = EasyMock.createMock(BufferedReader.class);
EasyMock.expect(mockSubset.getReader()).andReturn(mockReader);
EasyMock.replay(mockSubset);
EasyMock.replay(mockReader);
assertThat(adapter.getReader(), sameInstance(mockReader));
EasyMock.verify(mockSubset);
EasyMock.verify(mockReader);
}
示例7: testRunThrowsNullPointerExceptionIfQueueReturnsNull
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
public void testRunThrowsNullPointerExceptionIfQueueReturnsNull()
throws Exception {
RunnableQueue q = EasyMock.createMock(RunnableQueue.class);
EasyMock.expect(q.remove()).andReturn(null);
EasyMock.replay(q);
QueueExtractor extractor = new QueueExtractor(q);
try {
extractor.run();
fail("NullPointerException expected");
} catch (NullPointerException e) { /* expected */ }
EasyMock.verify(q);
}
示例8: testNavigatable
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
public void testNavigatable() {
TestConsoleProperties properties = EasyMock.createMock(TestConsoleProperties.class);
assertNull(mySuite.getDescriptor(null, properties));
mySuite.addChild(mySimpleTest);
assertNull(mySuite.getDescriptor(null, properties));
assertNull(mySimpleTest.getDescriptor(null, properties));
}
示例9: setUp
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
testUtil = new FeedServerClientTestUtil();
mockFeedServerClient = EasyMock.createMock(TypelessFeedServerClient.class);
feedServerClientTool = new FeedServerClientTool(mockFeedServerClient);
}
示例10: setUp
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
offerDaoMock = EasyMock.createMock(OfferDao.class);
offerTimeZoneProcessorMock = EasyMock.createMock(OfferTimeZoneProcessor.class);
orderProcessor = new OrderOfferProcessorImpl();
orderProcessor.setOfferDao(offerDaoMock);
orderProcessor.setOfferTimeZoneProcessor(offerTimeZoneProcessorMock);
orderProcessor.setPromotableItemFactory(new PromotableItemFactoryImpl());
}
示例11: test_Breadcrumb
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
public void test_Breadcrumb() throws JspException, IOException {
List<Category> categoryList = new ArrayList<Category>();
Category defaultParentCategory = EasyMock.createMock(Category.class);
categoryList.add(category);
categoryList.add(defaultParentCategory);
//pageContext.setAttribute("crumbVar", categoryList);
categoryBreadcrumbTag.setCategoryId(0L);
EasyMock.expect(catalogService.findCategoryById(0L)).andReturn(category);
EasyMock.expect(category.getDefaultParentCategory()).andReturn(defaultParentCategory);
EasyMock.expect(defaultParentCategory.getDefaultParentCategory()).andReturn(null);
EasyMock.expect(pageContext.getRequest()).andReturn(request).anyTimes();
EasyMock.expect(pageContext.getOut()).andReturn(writer).anyTimes();
EasyMock.expect(request.isSecure()).andReturn(false).anyTimes();
EasyMock.expect(request.getServerName()).andReturn("test").anyTimes();
EasyMock.expect(request.getLocalPort()).andReturn(80).anyTimes();
EasyMock.expect(request.getContextPath()).andReturn("myApp").anyTimes();
EasyMock.expect(category.getGeneratedUrl()).andReturn("url").anyTimes();
EasyMock.expect(category.getName()).andReturn("name").anyTimes();
EasyMock.expect(defaultParentCategory.getGeneratedUrl()).andReturn("url").anyTimes();
EasyMock.expect(defaultParentCategory.getName()).andReturn("name").anyTimes();
categoryBreadcrumbTag.setCategoryList(categoryList);
categoryBreadcrumbTag.setJspContext(pageContext);
categoryBreadcrumbTag.setCatalogService(catalogService);
super.replayAdditionalMockObjects(category, defaultParentCategory);
assert(categoryList.get(1).equals(defaultParentCategory));
assert(categoryList.get(0).equals(category));
categoryBreadcrumbTag.doTag();
assert(categoryList.get(0).equals(defaultParentCategory));
assert(categoryList.get(1).equals(category));
super.verifyBaseMockObjects(category, defaultParentCategory);
}
示例12: setUp
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
testUtil = new FeedServerClientTestUtil();
mockService = EasyMock.createMock(GoogleService.class);
feedServerClient = new TypelessFeedServerClient(mockService);
}
示例13: setUp
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
dao = new BatchRetrieveDao();
queryMock = EasyMock.createMock(Query.class);
List<String> response = new ArrayList<String>();
response.add("test");
EasyMock.expect(queryMock.getResultList()).andReturn(response).times(2);
EasyMock.expect(queryMock.setParameter(EasyMock.eq("test"), EasyMock.isA(List.class))).andReturn(queryMock).times(2);
}
示例14: setUp
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
fileUtilMock = EasyMock.createMock(FileUtil.class);
FeedConfiguration feedConfig = new FeedConfiguration(FEED_ID, null, null, null, serverConfig);
FileAdapterConfig fileAdapterConfig = new FileAdapterConfig(ROOT_DIR);
adapter = new FileAdapter(
new XmlUtil(), fileUtilMock, new Abdera(), feedConfig, fileAdapterConfig);
}
示例15: setUp
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
testUtil = new FeedServerClientTestUtil();
mockService = EasyMock.createMock(GoogleService.class);
feedServerClient = new FeedServerClient<VehicleBean>(mockService, VehicleBean.class);
}