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


Java EasyMockSupport.createMock方法代码示例

本文整理汇总了Java中org.easymock.EasyMockSupport.createMock方法的典型用法代码示例。如果您正苦于以下问题:Java EasyMockSupport.createMock方法的具体用法?Java EasyMockSupport.createMock怎么用?Java EasyMockSupport.createMock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.easymock.EasyMockSupport的用法示例。


在下文中一共展示了EasyMockSupport.createMock方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: noFilters

import org.easymock.EasyMockSupport; //导入方法依赖的package包/类
@Test
public void noFilters() throws Exception {
  EasyMockSupport ems = new EasyMockSupport();

  FilterConfig config = ems.createMock(FilterConfig.class);
  HttpServletRequest req = new FakeHttpServletRequest();
  HttpServletResponse res = new FakeHttpServletResponse();

  FilterChain chain = ems.createMock(FilterChain.class);
  chain.doFilter(req, res);

  ems.replayAll();

  AllRequestFilter.FilterProxy filterProxy = getFilterProxy();

  filterProxy.init(config);
  filterProxy.doFilter(req, res, chain);
  filterProxy.destroy();

  ems.verifyAll();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:AllRequestFilterFilterProxyTest.java

示例2: singleFilterNoBubbling

import org.easymock.EasyMockSupport; //导入方法依赖的package包/类
@Test
public void singleFilterNoBubbling() throws Exception {
  EasyMockSupport ems = new EasyMockSupport();

  FilterConfig config = ems.createMock("config", FilterConfig.class);
  HttpServletRequest req = new FakeHttpServletRequest();
  HttpServletResponse res = new FakeHttpServletResponse();

  FilterChain chain = ems.createMock("chain", FilterChain.class);

  AllRequestFilter filter = ems.createStrictMock("filter", AllRequestFilter.class);
  filter.init(config);
  filter.doFilter(eq(req), eq(res), anyObject(FilterChain.class));
  filter.destroy();

  ems.replayAll();

  AllRequestFilter.FilterProxy filterProxy = getFilterProxy();
  addFilter(filter);

  filterProxy.init(config);
  filterProxy.doFilter(req, res, chain);
  filterProxy.destroy();

  ems.verifyAll();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:AllRequestFilterFilterProxyTest.java

示例3: singleFilterBubbling

import org.easymock.EasyMockSupport; //导入方法依赖的package包/类
@Test
public void singleFilterBubbling() throws Exception {
  EasyMockSupport ems = new EasyMockSupport();

  FilterConfig config = ems.createMock(FilterConfig.class);
  HttpServletRequest req = new FakeHttpServletRequest();
  HttpServletResponse res = new FakeHttpServletResponse();

  IMocksControl mockControl = ems.createStrictControl();
  FilterChain chain = mockControl.createMock(FilterChain.class);

  Capture<FilterChain> capturedChain = new Capture<>();

  AllRequestFilter filter = mockControl.createMock(AllRequestFilter.class);
  filter.init(config);
  filter.doFilter(eq(req), eq(res), capture(capturedChain));
  chain.doFilter(req, res);
  filter.destroy();

  ems.replayAll();

  AllRequestFilter.FilterProxy filterProxy = getFilterProxy();
  addFilter(filter);

  filterProxy.init(config);
  filterProxy.doFilter(req, res, chain);
  capturedChain.getValue().doFilter(req, res);
  filterProxy.destroy();

  ems.verifyAll();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:32,代码来源:AllRequestFilterFilterProxyTest.java

示例4: twoFiltersNoBubbling

import org.easymock.EasyMockSupport; //导入方法依赖的package包/类
@Test
public void twoFiltersNoBubbling() throws Exception {
  EasyMockSupport ems = new EasyMockSupport();

  FilterConfig config = ems.createMock(FilterConfig.class);
  HttpServletRequest req = new FakeHttpServletRequest();
  HttpServletResponse res = new FakeHttpServletResponse();

  IMocksControl mockControl = ems.createStrictControl();
  FilterChain chain = mockControl.createMock(FilterChain.class);

  AllRequestFilter filterA = mockControl.createMock(AllRequestFilter.class);

  AllRequestFilter filterB = mockControl.createMock(AllRequestFilter.class);
  filterA.init(config);
  filterB.init(config);
  filterA.doFilter(eq(req), eq(res), anyObject(FilterChain.class));
  filterA.destroy();
  filterB.destroy();

  ems.replayAll();

  AllRequestFilter.FilterProxy filterProxy = getFilterProxy();
  addFilter(filterA);
  addFilter(filterB);

  filterProxy.init(config);
  filterProxy.doFilter(req, res, chain);
  filterProxy.destroy();

  ems.verifyAll();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:33,代码来源:AllRequestFilterFilterProxyTest.java

示例5: twoFiltersBubbling

import org.easymock.EasyMockSupport; //导入方法依赖的package包/类
@Test
public void twoFiltersBubbling() throws Exception {
  EasyMockSupport ems = new EasyMockSupport();

  FilterConfig config = ems.createMock(FilterConfig.class);
  HttpServletRequest req = new FakeHttpServletRequest();
  HttpServletResponse res = new FakeHttpServletResponse();

  IMocksControl mockControl = ems.createStrictControl();
  FilterChain chain = mockControl.createMock(FilterChain.class);

  Capture<FilterChain> capturedChainA = new Capture<>();
  Capture<FilterChain> capturedChainB = new Capture<>();

  AllRequestFilter filterA = mockControl.createMock(AllRequestFilter.class);
  AllRequestFilter filterB = mockControl.createMock(AllRequestFilter.class);

  filterA.init(config);
  filterB.init(config);
  filterA.doFilter(eq(req), eq(res), capture(capturedChainA));
  filterB.doFilter(eq(req), eq(res), capture(capturedChainB));
  chain.doFilter(req, res);
  filterA.destroy();
  filterB.destroy();

  ems.replayAll();

  AllRequestFilter.FilterProxy filterProxy = getFilterProxy();
  addFilter(filterA);
  addFilter(filterB);

  filterProxy.init(config);
  filterProxy.doFilter(req, res, chain);
  capturedChainA.getValue().doFilter(req, res);
  capturedChainB.getValue().doFilter(req, res);
  filterProxy.destroy();

  ems.verifyAll();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:40,代码来源:AllRequestFilterFilterProxyTest.java

示例6: postponedLoading

import org.easymock.EasyMockSupport; //导入方法依赖的package包/类
@Test
public void postponedLoading() throws Exception {
  EasyMockSupport ems = new EasyMockSupport();

  FilterConfig config = ems.createMock(FilterConfig.class);
  HttpServletRequest req1 = new FakeHttpServletRequest();
  HttpServletRequest req2 = new FakeHttpServletRequest();
  HttpServletResponse res1 = new FakeHttpServletResponse();
  HttpServletResponse res2 = new FakeHttpServletResponse();

  IMocksControl mockControl = ems.createStrictControl();
  FilterChain chain = mockControl.createMock("chain", FilterChain.class);

  Capture<FilterChain> capturedChainA1 = new Capture<>();
  Capture<FilterChain> capturedChainA2 = new Capture<>();
  Capture<FilterChain> capturedChainB = new Capture<>();

  AllRequestFilter filterA = mockControl.createMock("filterA", AllRequestFilter.class);
  AllRequestFilter filterB = mockControl.createMock("filterB", AllRequestFilter.class);

  filterA.init(config);
  filterA.doFilter(eq(req1), eq(res1), capture(capturedChainA1));
  chain.doFilter(req1, res1);

  filterA.doFilter(eq(req2), eq(res2), capture(capturedChainA2));
  filterB.init(config); // <-- This is crucial part. filterB got loaded
  // after filterProxy's init finished. Nonetheless filterB gets initialized.
  filterB.doFilter(eq(req2), eq(res2), capture(capturedChainB));
  chain.doFilter(req2, res2);

  filterA.destroy();
  filterB.destroy();

  ems.replayAll();

  AllRequestFilter.FilterProxy filterProxy = getFilterProxy();
  addFilter(filterA);

  filterProxy.init(config);
  filterProxy.doFilter(req1, res1, chain);
  capturedChainA1.getValue().doFilter(req1, res1);

  addFilter(filterB); // <-- Adds filter after filterProxy's init got called.
  filterProxy.doFilter(req2, res2, chain);
  capturedChainA2.getValue().doFilter(req2, res2);
  capturedChainB.getValue().doFilter(req2, res2);

  filterProxy.destroy();

  ems.verifyAll();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:52,代码来源:AllRequestFilterFilterProxyTest.java

示例7: dynamicUnloading

import org.easymock.EasyMockSupport; //导入方法依赖的package包/类
@Test
public void dynamicUnloading() throws Exception {
  EasyMockSupport ems = new EasyMockSupport();

  FilterConfig config = ems.createMock(FilterConfig.class);
  HttpServletRequest req1 = new FakeHttpServletRequest();
  HttpServletRequest req2 = new FakeHttpServletRequest();
  HttpServletRequest req3 = new FakeHttpServletRequest();
  HttpServletResponse res1 = new FakeHttpServletResponse();
  HttpServletResponse res2 = new FakeHttpServletResponse();
  HttpServletResponse res3 = new FakeHttpServletResponse();

  Plugin plugin = ems.createMock(Plugin.class);

  IMocksControl mockControl = ems.createStrictControl();
  FilterChain chain = mockControl.createMock("chain", FilterChain.class);

  Capture<FilterChain> capturedChainA1 = new Capture<>();
  Capture<FilterChain> capturedChainB1 = new Capture<>();
  Capture<FilterChain> capturedChainB2 = new Capture<>();

  AllRequestFilter filterA = mockControl.createMock("filterA", AllRequestFilter.class);
  AllRequestFilter filterB = mockControl.createMock("filterB", AllRequestFilter.class);

  filterA.init(config);
  filterB.init(config);

  filterA.doFilter(eq(req1), eq(res1), capture(capturedChainA1));
  filterB.doFilter(eq(req1), eq(res1), capture(capturedChainB1));
  chain.doFilter(req1, res1);

  filterA.destroy(); // Cleaning up of filterA after it got unloaded

  filterB.doFilter(eq(req2), eq(res2), capture(capturedChainB2));
  chain.doFilter(req2, res2);

  filterB.destroy(); // Cleaning up of filterA after it got unloaded

  chain.doFilter(req3, res3);

  ems.replayAll();

  AllRequestFilter.FilterProxy filterProxy = getFilterProxy();
  ReloadableRegistrationHandle<AllRequestFilter> handleFilterA = addFilter(filterA);
  ReloadableRegistrationHandle<AllRequestFilter> handleFilterB = addFilter(filterB);

  filterProxy.init(config);

  // Request #1 with filterA and filterB
  filterProxy.doFilter(req1, res1, chain);
  capturedChainA1.getValue().doFilter(req1, res1);
  capturedChainB1.getValue().doFilter(req1, res1);

  // Unloading filterA
  handleFilterA.remove();
  filterProxy.onStopPlugin(plugin);

  // Request #1 only with filterB
  filterProxy.doFilter(req2, res2, chain);
  capturedChainA1.getValue().doFilter(req2, res2);

  // Unloading filterB
  handleFilterB.remove();
  filterProxy.onStopPlugin(plugin);

  // Request #1 with no additional filters
  filterProxy.doFilter(req3, res3, chain);

  filterProxy.destroy();

  ems.verifyAll();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:73,代码来源:AllRequestFilterFilterProxyTest.java


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