use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ExceptionMappingInterceptorTest method setupWithoutExceptionMappings.
private void setupWithoutExceptionMappings() {
ActionConfig actionConfig = new ActionConfig.Builder("", "", "").build();
Mock actionProxy = new Mock(ActionProxy.class);
actionProxy.expectAndReturn("getConfig", actionConfig);
mockInvocation.expectAndReturn("getProxy", actionProxy.proxy());
invocation = (ActionInvocation) mockInvocation.proxy();
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ExceptionMappingInterceptorTest method testThrownExceptionNoMatchLoggingCategoryLevelDebug.
public void testThrownExceptionNoMatchLoggingCategoryLevelDebug() {
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("debug");
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 testThrownExceptionNoMatchLoggingCategoryLevelWarn.
public void testThrownExceptionNoMatchLoggingCategoryLevelWarn() {
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("warn");
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 testThrownExceptionMatching2.
public void testThrownExceptionMatching2() throws Exception {
this.setUpWithExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new ValidationException("test");
mockInvocation.expectAndThrow("invoke", exception);
mockInvocation.matchAndReturn("getAction", action.proxy());
String result = interceptor.intercept(invocation);
assertNotNull(stack.findValue("exception"));
assertEquals(stack.findValue("exception"), exception);
assertEquals(result, "throwable");
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ExceptionMappingInterceptorTest method testThrownExceptionNoMatch.
public void testThrownExceptionNoMatch() {
this.setupWithoutExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.intercept(invocation);
fail("Should not have reached this point.");
} catch (Exception e) {
assertEquals(e, exception);
}
}
Aggregations