use of com.mockobjects.dynamic.Mock in project struts by apache.
the class StrutsLocalizedTextProviderTest method testFindTextInInterface.
public void testFindTextInInterface() throws Exception {
Action action = new ModelDrivenAction2();
Mock mockActionInvocation = new Mock(ActionInvocation.class);
mockActionInvocation.expectAndReturn("getAction", action);
ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy());
String message = localizedTextProvider.findText(ModelDrivenAction2.class, "test.foo", Locale.getDefault());
assertEquals("Foo!", message);
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class StrutsLocalizedTextProviderTest method testFindTextInPackage.
public void testFindTextInPackage() throws Exception {
ModelDriven action = new ModelDrivenAction2();
Mock mockActionInvocation = new Mock(ActionInvocation.class);
mockActionInvocation.expectAndReturn("getAction", action);
ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy());
String message = localizedTextProvider.findText(ModelDrivenAction2.class, "package.properties", Locale.getDefault());
assertEquals("It works!", message);
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class StrutsLocalizedTextProviderTest method testActionGetTextWithNullObject.
public void testActionGetTextWithNullObject() throws Exception {
MyAction action = new MyAction();
container.inject(action);
Mock mockActionInvocation = new Mock(ActionInvocation.class);
mockActionInvocation.expectAndReturn("getAction", action);
ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy()).getValueStack().push(action);
String message = action.getText("barObj.title");
assertEquals("Title:", message);
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class StrutsLocalizedTextProviderTest method testActionGetTextXXX.
public void testActionGetTextXXX() throws Exception {
localizedTextProvider.addDefaultResourceBundle("com/opensymphony/xwork2/util/FindMe");
SimpleAction action = new SimpleAction();
container.inject(action);
Mock mockActionInvocation = new Mock(ActionInvocation.class);
mockActionInvocation.expectAndReturn("getAction", action);
ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy()).getValueStack().push(action);
String message = action.getText("bean.name");
String foundBean2 = action.getText("bean2.name");
assertEquals("Okay! You found Me!", foundBean2);
assertEquals("Haha you cant FindMe!", message);
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class StrutsConversionErrorInterceptorTest method setUp.
protected void setUp() throws Exception {
super.setUp();
interceptor = new StrutsConversionErrorInterceptor();
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.expectAndReturn("invoke", Action.SUCCESS);
mockInvocation.expectAndReturn("getStack", stack);
mockInvocation.expect("addPreResultListener", C.ANY_ARGS);
}
Aggregations