本文整理了Java中org.easymock.EasyMock.createControl()
方法的一些代码示例,展示了EasyMock.createControl()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.createControl()
方法的具体详情如下:
包路径:org.easymock.EasyMock
类名称:EasyMock
方法名:createControl
[英]Creates a control, order checking is disabled by default.
[中]创建控件,默认情况下禁用顺序检查。
代码示例来源:origin: org.easymock/easymock
/**
* Creates a control, order checking is enabled by default.
*
* @return the control.
*/
public static IMocksControl createStrictControl() {
return createControl(MockType.STRICT);
}
代码示例来源:origin: org.easymock/easymock
/**
* Creates a control, order checking is disabled by default.
*
* @return the control.
*/
public static IMocksControl createControl() {
return createControl(MockType.DEFAULT);
}
代码示例来源:origin: org.easymock/easymock
/**
* Creates a control, order checking is disabled by default, and the mock
* objects created by this control will return {@code 0},
* {@code null} or {@code false} for unexpected invocations.
*
* @return the control.
*/
public static IMocksControl createNiceControl() {
return createControl(MockType.NICE);
}
代码示例来源:origin: org.easymock/easymock
/**
* Creates a control of the given type.
*
* @param type the mock type.
* @return the control.
* @since 3.2
*/
public IMocksControl createControl(MockType type) {
IMocksControl ctrl = EasyMock.createControl(type);
controls.add(ctrl);
return ctrl;
}
代码示例来源:origin: org.easymock/easymock
/**
* Creates a mock object that implements the given interface, order checking
* is disabled by default.
*
* @param toMock
* the class or interface that should be mocked.
* @param <T>
* the interface that the mock object should implement. It is expected to be of
* class {@code toMock}.
* @return the mock object.
*
* @since 3.4
*/
public static <T> T mock(Class<?> toMock) {
return createControl().mock(toMock);
}
代码示例来源:origin: org.easymock/easymock
/**
* Creates a mock object, of the requested type, that implements the given interface
* or extends the given class
*
* @param type
* the type of the mock to be created.
* @param toMock
* the class or interface that should be mocked.
* @param <T>
* the interface that the mock object should implement. It is expected to be of
* class {@code toMock}.
* @return the mock object
*
* @since 3.4
*/
public static <T> T mock(MockType type, Class<?> toMock) {
return createControl(type).mock(toMock);
}
代码示例来源:origin: org.easymock/easymock
/**
* Creates a mock object that implements the given interface, order checking
* is disabled by default.
*
* @param name
* the name of the mock object.
* @param toMock
* the class or interface that should be mocked.
* @param <T>
* the interface that the mock object should implement. It is expected to be of
* class {@code toMock}.
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*
* @since 3.4
*/
public static <T> T mock(String name, Class<?> toMock) {
return createControl().mock(name, toMock);
}
代码示例来源:origin: org.easymock/easymock
/**
* Creates a mock object, of the requested type and name, that implements the given interface
* or extends the given class
*
* @param name
* the name of the mock object.
* @param type
* the type of the mock to be created.
* @param toMock
* the class or interface that should be mocked.
* @param <T>
* the interface that the mock object should implement. It is expected to be of
* class {@code toMock}.
* @return the mock object.
*
* @since 3.4
*/
public static <T> T mock(String name, MockType type, Class<?> toMock) {
return createControl(type).mock(name, toMock);
}
代码示例来源:origin: org.easymock/easymock
public <R> R createMock(String name, MockType type) {
IMocksControl control = (support == null ? EasyMock.createControl(type) : support
.createControl(type));
return createMock(name, control);
}
代码示例来源:origin: org.easymock/easymock
public <R> R createMock(MockType type) {
IMocksControl control = (support == null ? EasyMock.createControl(type) : support
.createControl(type));
return createMock(null, control);
}
代码示例来源:origin: org.easymock/easymock
public <R> R createMock(String name) {
IMocksControl control = (support == null ? EasyMock.createControl() : support.createControl());
return createMock(name, control);
}
代码示例来源:origin: apache/shiro
@Test
public void testPropertySetting() throws Exception {
IMocksControl control = createControl();
TypeEncounter<SomeInjectableBean> encounter = control.createMock(TypeEncounter.class);
Provider<Injector> injectorProvider = control.createMock(Provider.class);
Injector injector = control.createMock(Injector.class);
expect(encounter.getProvider(Injector.class)).andReturn(injectorProvider);
expect(injectorProvider.get()).andReturn(injector).anyTimes();
Capture<MembersInjector<SomeInjectableBean>> capture = new Capture<MembersInjector<SomeInjectableBean>>();
encounter.register(and(anyObject(MembersInjector.class), capture(capture)));
SecurityManager securityManager = control.createMock(SecurityManager.class);
String property = "myPropertyValue";
expect(injector.getInstance(Key.get(SecurityManager.class))).andReturn(securityManager);
expect(injector.getInstance(Key.get(String.class, Names.named("shiro.myProperty")))).andReturn(property);
expect(injector.getInstance(Key.get(String.class, Names.named("shiro.unavailableProperty"))))
.andThrow(new ConfigurationException(Collections.singleton(new Message("Not Available!"))));
expect((Map)injector.getInstance(BeanTypeListener.MAP_KEY)).andReturn(Collections.EMPTY_MAP).anyTimes();
control.replay();
BeanTypeListener underTest = new BeanTypeListener();
underTest.hear(TypeLiteral.get(SomeInjectableBean.class), encounter);
SomeInjectableBean bean = new SomeInjectableBean();
capture.getValue().injectMembers(bean);
assertSame(securityManager, bean.securityManager);
assertSame(property, bean.myProperty);
assertNull(bean.unavailableProperty);
control.verify();
}
代码示例来源:origin: com.google.inject.extensions/guice-servlet
@Override
public final void setUp() {
inits = 0;
doFilters = 0;
destroys = 0;
control = EasyMock.createControl();
GuiceFilter.reset();
}
代码示例来源:origin: com.google.inject.extensions/guice-servlet
public void testSimple() throws Exception {
IMocksControl testControl = createControl();
TestFilterChain testFilterChain = new TestFilterChain();
HttpServletRequest req = testControl.createMock(HttpServletRequest.class);
HttpServletResponse res = testControl.createMock(HttpServletResponse.class);
expect(req.getMethod()).andReturn("GET").anyTimes();
expect(req.getRequestURI()).andReturn("/bar/foo").anyTimes();
expect(req.getServletPath()).andReturn("/bar/foo").anyTimes();
expect(req.getContextPath()).andReturn("").anyTimes();
testControl.replay();
guiceFilter.doFilter(req, res, testFilterChain);
assertFalse(testFilterChain.isTriggered());
assertFalse(fooServlet.isTriggered());
assertTrue(barServlet.isTriggered());
testControl.verify();
}
代码示例来源:origin: org.apache.tapestry/tapestry-test
@Override
protected IMocksControl initialValue()
{
return EasyMock.createControl();
}
}
代码示例来源:origin: com.google.inject.extensions/guice-servlet
assertNotSame(fooServlet, barServlet);
globalControl = createControl();
servletContext = globalControl.createMock(ServletContext.class);
filterConfig = globalControl.createMock(FilterConfig.class);
代码示例来源:origin: com.google.inject.extensions/guice-servlet
private void runTest(
final String requestURI,
final String servletPath,
final String contextPath,
final boolean filterResult,
final boolean fooResult,
final boolean barResult)
throws Exception {
IMocksControl testControl = createControl();
barServlet.clear();
fooServlet.clear();
TestFilterChain testFilterChain = new TestFilterChain();
HttpServletRequest req = testControl.createMock(HttpServletRequest.class);
HttpServletResponse res = testControl.createMock(HttpServletResponse.class);
expect(req.getMethod()).andReturn("GET").anyTimes();
expect(req.getRequestURI()).andReturn(requestURI).anyTimes();
expect(req.getServletPath()).andReturn(servletPath).anyTimes();
expect(req.getContextPath()).andReturn(contextPath).anyTimes();
testControl.replay();
guiceFilter.doFilter(req, res, testFilterChain);
assertEquals(filterResult, testFilterChain.isTriggered());
assertEquals(fooResult, fooServlet.isTriggered());
assertEquals(barResult, barServlet.isTriggered());
testControl.verify();
}
代码示例来源:origin: org.easymock/com.springsource.org.easymock
/**
* Creates a control, order checking is disabled by default.
*
* @return the control.
*/
public IMocksControl createControl() {
IMocksControl ctrl = EasyMock.createControl();
controls.add(ctrl);
return ctrl;
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void removeNonMandatoryProperty() throws CommitFailedException {
EffectiveType effective = createControl().createMock(EffectiveType.class);
expect(effective.isMandatoryProperty("mandatory")).andReturn(false);
replay(effective);
TypeEditor editor = new TypeEditor(effective);
editor.propertyDeleted(PropertyStates.createProperty("mandatory", ""));
}
代码示例来源:origin: org.apache.shindig/shindig-gadgets
@Before
public void setUp() {
control = EasyMock.createControl();
jsUri = control.createMock(JsUri.class);
request = control.createMock(JsRequest.class);
response = new JsResponseBuilder();
processor = new AddOnloadFunctionProcessor();
EasyMock.expect(request.getJsUri()).andReturn(jsUri);
}
内容来源于网络,如有侵权,请联系作者删除!