use of com.mockobjects.dynamic.Mock in project struts by apache.
the class ExceptionMappingInterceptorTest method testThrownExceptionNoMatchLoggingCategoryLevelError.
public void testThrownExceptionNoMatchLoggingCategoryLevelError() {
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("error");
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 setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
stack = ActionContext.getContext().getValueStack();
mockInvocation = new Mock(ActionInvocation.class);
mockInvocation.expectAndReturn("getStack", stack);
mockInvocation.expectAndReturn("getInvocationContext", ActionContext.of(new HashMap<>()).bind());
interceptor = new ExceptionMappingInterceptor();
interceptor.init();
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class DefaultActionValidatorManagerTest method setUp.
@Override
protected void setUp() throws Exception {
actionValidatorManager = new DefaultActionValidatorManager();
super.setUp();
mockValidatorFileParser = new Mock(ValidatorFileParser.class);
actionValidatorManager.setValidatorFileParser((ValidatorFileParser) mockValidatorFileParser.proxy());
mockValidatorFactory = new Mock(ValidatorFactory.class);
actionValidatorManager.setValidatorFactory((ValidatorFactory) mockValidatorFactory.proxy());
stubValueStack = new StubValueStack();
ActionContext.of(new HashMap<>()).withValueStack(stubValueStack).bind();
DefaultFileManagerFactory factory = new DefaultFileManagerFactory();
factory.setContainer(container);
factory.setFileManager(new DefaultFileManager());
actionValidatorManager.setFileManagerFactory(factory);
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class DefaultValidatorFactoryTest method testParseValidators.
public void testParseValidators() {
Mock mockValidatorFileParser = new Mock(ValidatorFileParser.class);
mockValidatorFileParser.expect("parseValidatorDefinitions", C.args(C.IS_NOT_NULL, C.IS_NOT_NULL, C.eq("com/opensymphony/xwork2/validator/validators/default.xml")));
mockValidatorFileParser.expect("parseValidatorDefinitions", C.args(C.IS_NOT_NULL, C.IS_NOT_NULL, C.eq("validators.xml")));
mockValidatorFileParser.expect("parseValidatorDefinitions", C.args(C.IS_NOT_NULL, C.IS_NOT_NULL, C.eq("myOther-validators.xml")));
mockValidatorFileParser.expect("parseValidatorDefinitions", C.args(C.IS_NOT_NULL, C.IS_NOT_NULL, C.eq("my-validators.xml")));
DefaultValidatorFactory factory = new DefaultValidatorFactory(null, (ValidatorFileParser) mockValidatorFileParser.proxy());
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class StrutsLocalizedTextProviderTest method testFindTextInChildProperty.
public void testFindTextInChildProperty() throws Exception {
ModelDriven action = new ModelDrivenAction2();
TestBean2 bean = (TestBean2) action.getModel();
Bar bar = new Bar();
bean.setBarObj(bar);
Mock mockActionInvocation = new Mock(ActionInvocation.class);
mockActionInvocation.expectAndReturn("hashCode", 0);
mockActionInvocation.expectAndReturn("getAction", action);
ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy());
ActionContext.getContext().getValueStack().push(action);
ActionContext.getContext().getValueStack().push(action.getModel());
String message = localizedTextProvider.findText(ModelDrivenAction2.class, "invalid.fieldvalue.barObj.title", Locale.getDefault());
assertEquals("Title is invalid!", message);
}
Aggregations