当前位置: 首页>>代码示例>>Java>>正文


Java EasyMock.createMock方法代码示例

本文整理汇总了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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:17,代码来源:QueueExtractorTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:17,代码来源:WorkerThreadTest.java

示例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;
}
 
开发者ID:ctripcorp,项目名称:dal,代码行数:12,代码来源:AutoMarkdownTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:15,代码来源:HttpRequestHandlerAdapterTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:12,代码来源:HttpServletRequestAdapterTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:12,代码来源:HttpServletRequestAdapterTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:13,代码来源:QueueExtractorTest.java

示例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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:SMTestProxyTest.java

示例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);
 }
 
开发者ID:jyang,项目名称:google-feedserver,代码行数:10,代码来源:FeedServerClientToolTest.java

示例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());
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:10,代码来源:OrderOfferProcessorTest.java

示例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);
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:41,代码来源:CategoryBreadcrumbTagTest.java

示例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);
}
 
开发者ID:jyang,项目名称:google-feedserver,代码行数:8,代码来源:TypelessFeedServerClientTest.java

示例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);
}
 
开发者ID:akdasari,项目名称:SparkCommerce,代码行数:10,代码来源:BatchRetrieveDaoTest.java

示例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);
}
 
开发者ID:jyang,项目名称:google-feedserver,代码行数:9,代码来源:FileAdapterTest.java

示例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);
}
 
开发者ID:jyang,项目名称:google-feedserver,代码行数:8,代码来源:FeedServerClientTest.java


注:本文中的org.easymock.classextension.EasyMock.createMock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。