use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ChainingInterceptorTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
stack = ActionContext.getContext().getValueStack();
mockInvocation = new Mock(ActionInvocation.class);
mockInvocation.expectAndReturn("getStack", stack);
mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
mockInvocation.expectAndReturn("getInvocationContext", ActionContext.of(new HashMap<>()).bind());
mockInvocation.expectAndReturn("getResult", new ActionChainResult());
invocation = (ActionInvocation) mockInvocation.proxy();
interceptor = new ChainingInterceptor();
container.inject(interceptor);
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ConversionErrorInterceptorTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
interceptor = new ConversionErrorInterceptor();
mockInvocation = new Mock(ActionInvocation.class);
invocation = (ActionInvocation) mockInvocation.proxy();
stack = ActionContext.getContext().getValueStack();
conversionErrors = new HashMap<>();
context = ActionContext.of(stack.getContext()).withConversionErrors(conversionErrors).bind();
mockInvocation.matchAndReturn("getInvocationContext", context);
mockInvocation.expect("addPreResultListener", C.isA(PreResultListener.class));
mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ExceptionMappingInterceptorTest method testThrownExceptionNoMatchLogging.
public void testThrownExceptionNoMatchLogging() {
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.intercept(invocation);
fail("Should not have reached this point.");
} catch (Exception e) {
assertEquals(e, exception);
}
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ExceptionMappingInterceptorTest method testThrownExceptionNoMatchLoggingUnknownLevel.
public void testThrownExceptionNoMatchLoggingUnknownLevel() throws Exception {
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.setLogLevel("xxx");
interceptor.intercept(invocation);
fail("Should not have reached this point.");
} catch (IllegalArgumentException e) {
// success
}
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ExceptionMappingInterceptorTest method testThrownExceptionNoMatchLoggingCategoryLevelTrace.
public void testThrownExceptionNoMatchLoggingCategoryLevelTrace() {
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("trace");
interceptor.intercept(invocation);
fail("Should not have reached this point.");
} catch (Exception e) {
assertEquals(e, exception);
}
}
Aggregations