org.easymock.EasyMock.createStrictControl()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中org.easymock.EasyMock.createStrictControl()方法的一些代码示例,展示了EasyMock.createStrictControl()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.createStrictControl()方法的具体详情如下:
包路径:org.easymock.EasyMock
类名称:EasyMock
方法名:createStrictControl

EasyMock.createStrictControl介绍

[英]Creates a control, order checking is enabled by default.
[中]创建控件,默认情况下启用订单检查。

代码示例

代码示例来源:origin: org.easymock/easymock

  1. /**
  2. * Creates a control, order checking is enabled by default.
  3. *
  4. * @return the control.
  5. */
  6. public IMocksControl createStrictControl() {
  7. IMocksControl ctrl = EasyMock.createStrictControl();
  8. controls.add(ctrl);
  9. return ctrl;
  10. }

代码示例来源:origin: org.easymock/easymock

  1. /**
  2. * Creates a mock object that implements the given interface, order checking
  3. * is enabled by default.
  4. *
  5. * @param toMock
  6. * the class or interface that should be mocked.
  7. * @param <T>
  8. * the interface that the mock object should implement. It is expected to be of
  9. * class {@code toMock}.
  10. * @return the mock object.
  11. *
  12. * @since 3.4
  13. */
  14. public static <T> T strictMock(Class<?> toMock) {
  15. return createStrictControl().mock(toMock);
  16. }

代码示例来源:origin: org.easymock/easymock

  1. /**
  2. * Creates a mock object that implements the given interface, order checking
  3. * is enabled by default.
  4. *
  5. * @param name
  6. * the name of the mock object.
  7. * @param toMock
  8. * the class or interface that should be mocked.
  9. * @param <T>
  10. * the interface that the mock object should implement. It is expected to be of
  11. * class {@code toMock}.
  12. * @return the mock object.
  13. * @throws IllegalArgumentException
  14. * if the name is not a valid Java identifier.
  15. *
  16. * @since 3.4
  17. */
  18. public static <T> T strictMock(String name, Class<?> toMock) {
  19. return createStrictControl().mock(name, toMock);
  20. }

代码示例来源:origin: org.easymock/easymock

  1. public <R> R createStrictMock(String name) {
  2. IMocksControl control = (support == null ? EasyMock.createStrictControl() : support
  3. .createStrictControl());
  4. return createMock(name, control);
  5. }

代码示例来源:origin: thinkaurelius/titan

  1. ctrl = EasyMock.createStrictControl();
  2. ctrl.checkOrder(true);

代码示例来源:origin: apache/shiro

  1. IMocksControl ctrl = createStrictControl();

代码示例来源:origin: JanusGraph/janusgraph

  1. ctrl = EasyMock.createStrictControl();
  2. ctrl.checkOrder(true);

代码示例来源:origin: apache/shiro

  1. @Test
  2. public void testDoFilter() throws Exception {
  3. IMocksControl ctrl = createStrictControl();
  4. FilterChain originalChain = ctrl.createMock(FilterChain.class);
  5. Filter filter1 = ctrl.createMock("filter1", Filter.class);
  6. Filter filter2 = ctrl.createMock("filter2", Filter.class);
  7. ServletRequest request = ctrl.createMock(ServletRequest.class);
  8. ServletResponse response = ctrl.createMock(ServletResponse.class);
  9. Capture<FilterChain> fc1 = new Capture<FilterChain>();
  10. Capture<FilterChain> fc2 = new Capture<FilterChain>();
  11. filter1.doFilter(same(request), same(response), and(anyObject(FilterChain.class), capture(fc1)));
  12. filter2.doFilter(same(request), same(response), and(anyObject(FilterChain.class), capture(fc2)));
  13. originalChain.doFilter(request, response);
  14. ctrl.replay();
  15. SimpleFilterChain underTest = new SimpleFilterChain(originalChain, Arrays.asList(filter1, filter2).iterator());
  16. // all we actually care about is that, if we keep calling the filter chain, everything is called in the right
  17. // order - we don't care what fc actually contains
  18. underTest.doFilter(request, response);
  19. fc1.getValue().doFilter(request, response);
  20. fc2.getValue().doFilter(request, response);
  21. ctrl.verify();
  22. }
  23. }

代码示例来源:origin: org.easymock/com.springsource.org.easymock

  1. /**
  2. * Creates a control, order checking is enabled by default.
  3. *
  4. * @return the control.
  5. */
  6. public IMocksControl createStrictControl() {
  7. IMocksControl ctrl = EasyMock.createStrictControl();
  8. controls.add(ctrl);
  9. return ctrl;
  10. }

代码示例来源:origin: easymock/easymock

  1. /**
  2. * Creates a mock object that implements the given interface, order checking
  3. * is enabled by default.
  4. *
  5. * @param <T>
  6. * the interface that the mock object should implement.
  7. * @param toMock
  8. * the class of the interface that the mock object should
  9. * implement.
  10. * @return the mock object.
  11. */
  12. public static <T> T createStrictMock(Class<T> toMock) {
  13. return createStrictControl().createMock(toMock);
  14. }

代码示例来源:origin: easymock/easymock

  1. /**
  2. * Creates a mock control object for the specified interface. The
  3. * <code>MockControl</code> and its associated mock object will check the
  4. * order of expected method calls. An unexpected method call on the mock
  5. * object will lead to an <code>AssertionError</code>.
  6. *
  7. * @param toMock
  8. * the class of the interface to mock.
  9. * @return the mock control.
  10. */
  11. public static <T> MockControl<T> createStrictControl(Class<T> toMock) {
  12. return new MockControl<T>(
  13. (MocksControl) EasyMock.createStrictControl(), toMock);
  14. }

代码示例来源:origin: org.easymock/com.springsource.org.easymock

  1. /**
  2. * Creates a mock object that implements the given interface, order checking
  3. * is enabled by default.
  4. *
  5. * @param <T>
  6. * the interface that the mock object should implement.
  7. * @param toMock
  8. * the class of the interface that the mock object should
  9. * implement.
  10. * @return the mock object.
  11. */
  12. public static <T> T createStrictMock(Class<T> toMock) {
  13. return createStrictControl().createMock(toMock);
  14. }

代码示例来源:origin: org.easymock/com.springsource.org.easymock

  1. /**
  2. * Creates a mock control object for the specified interface. The
  3. * <code>MockControl</code> and its associated mock object will check the
  4. * order of expected method calls. An unexpected method call on the mock
  5. * object will lead to an <code>AssertionError</code>.
  6. *
  7. * @param <T> type of the mock controlled
  8. * @param toMock
  9. * the class of the interface to mock.
  10. * @return the mock control.
  11. */
  12. public static <T> MockControl<T> createStrictControl(Class<T> toMock) {
  13. return new MockControl<T>(
  14. (MocksControl) EasyMock.createStrictControl(), toMock);
  15. }

代码示例来源:origin: org.easymock/com.springsource.org.easymock

  1. /**
  2. * Creates a mock object that implements the given interface, order checking
  3. * is enabled by default.
  4. * @param name the name of the mock object.
  5. * @param toMock
  6. * the class of the interface that the mock object should
  7. * implement.
  8. * @param <T>
  9. * the interface that the mock object should implement.
  10. * @return the mock object.
  11. * @throws IllegalArgumentException if the name is not a valid Java identifier.
  12. */
  13. public static <T> T createStrictMock(String name, Class<T> toMock) {
  14. return createStrictControl().createMock(name, toMock);
  15. }

代码示例来源:origin: org.apache.shindig/shindig-gadgets

  1. @Before
  2. public void setUp() throws Exception {
  3. control = EasyMock.createStrictControl();
  4. preloader = control.createMock(PipelinedDataPreloader.class);
  5. preloaderService = new ConcurrentPreloaderService(Executors.newSingleThreadExecutor(), null);
  6. executor = new PipelineExecutor(preloader, preloaderService, Expressions.forTesting());
  7. context = new GadgetContext(){};
  8. }

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-gadgets

  1. @Before
  2. public void setUp() throws Exception {
  3. control = EasyMock.createStrictControl();
  4. preloader = control.createMock(PipelinedDataPreloader.class);
  5. preloaderService = new ConcurrentPreloaderService(Executors.newSingleThreadExecutor(), null);
  6. executor = new PipelineExecutor(preloader, preloaderService, Expressions.forTesting());
  7. context = new GadgetContext(){};
  8. }

代码示例来源:origin: com.lmco.shindig/shindig-gadgets

  1. @Before
  2. public void setUp() throws Exception {
  3. control = EasyMock.createStrictControl();
  4. preloader = control.createMock(PipelinedDataPreloader.class);
  5. preloaderService = new ConcurrentPreloaderService(Executors.newSingleThreadExecutor(), null);
  6. executor = new PipelineExecutor(preloader, preloaderService, Expressions.forTesting());
  7. context = new GadgetContext(){};
  8. }

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-gadgets

  1. @Before
  2. public void setUp() throws Exception {
  3. control = EasyMock.createStrictControl();
  4. preloader = control.createMock(PipelinedDataPreloader.class);
  5. preloaderService = new ConcurrentPreloaderService(Executors.newSingleThreadExecutor(), null);
  6. rewriter = new PipelineDataGadgetRewriter(new PipelineExecutor(preloader, preloaderService,
  7. Expressions.forTesting()));
  8. }

代码示例来源:origin: com.lmco.shindig/shindig-gadgets

  1. @Before
  2. public void setUp() throws Exception {
  3. control = EasyMock.createStrictControl();
  4. preloader = control.createMock(PipelinedDataPreloader.class);
  5. preloaderService = new ConcurrentPreloaderService(Executors.newSingleThreadExecutor(), null);
  6. rewriter = new PipelineDataGadgetRewriter(new PipelineExecutor(preloader, preloaderService,
  7. Expressions.forTesting()));
  8. }

代码示例来源:origin: org.apache.shindig/shindig-gadgets

  1. @Before
  2. public void setUp() throws Exception {
  3. control = EasyMock.createStrictControl();
  4. preloader = control.createMock(PipelinedDataPreloader.class);
  5. preloaderService = new ConcurrentPreloaderService(Executors.newSingleThreadExecutor(), null);
  6. rewriter = new PipelineDataGadgetRewriter(new PipelineExecutor(preloader, preloaderService,
  7. Expressions.forTesting()));
  8. }

相关文章