use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ExceptionMappingInterceptorTest method testThrownExceptionNoMatchLoggingCategoryLevelFatal.
public void testThrownExceptionNoMatchLoggingCategoryLevelFatal() {
this.setupWithoutExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.setLogEnabled(true);
interceptor.setLogCategory("showcase.unhandled");
interceptor.setLogLevel("fatal");
interceptor.intercept(invocation);
fail("Should not have reached this point.");
} catch (Exception e) {
assertEquals(e, exception);
}
assertEquals("fatal", interceptor.getLogLevel());
assertTrue(interceptor.isLogEnabled());
assertEquals("showcase.unhandled", interceptor.getLogCategory());
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ModelDrivenInterceptorTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mockActionInvocation = new Mock(ActionInvocation.class);
modelDrivenInterceptor = new ModelDrivenInterceptor();
stack = ActionContext.getContext().getValueStack();
// any object will do
model = new Date();
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ParameterFilterInterceptorTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
stack = ActionContext.getContext().getValueStack();
mockInvocation = new Mock(ActionInvocation.class);
mockInvocation.expectAndReturn("getInvocationContext", ActionContext.getContext());
mockInvocation.expectAndReturn("getStack", stack);
mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
mockInvocation.expectAndReturn("getInvocationContext", ActionContext.getContext());
mockInvocation.matchAndReturn("getAction", new SimpleAction());
invocation = (ActionInvocation) mockInvocation.proxy();
interceptor = new ParameterFilterInterceptor();
interceptor.init();
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class PreResultListenerTest method testPreResultListenersAreCalled.
public void testPreResultListenersAreCalled() throws Exception {
ActionProxy proxy = actionProxyFactory.createActionProxy("package", "action", null, new HashMap<String, Object>(), false, true);
ActionInvocation invocation = proxy.getInvocation();
Mock preResultListenerMock1 = new Mock(PreResultListener.class);
preResultListenerMock1.expect("beforeResult", C.args(C.eq(invocation), C.eq(Action.SUCCESS)));
invocation.addPreResultListener((PreResultListener) preResultListenerMock1.proxy());
proxy.execute();
preResultListenerMock1.verify();
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class PrepareInterceptorTest method setUp.
@Override
protected void setUp() throws Exception {
mock = new Mock(ActionInterface.class);
interceptor = new PrepareInterceptor();
mockAction = (ActionInterface) createMock(ActionInterface.class);
}
Aggregations