use of com.opensymphony.xwork2.test.ModelDrivenAction2 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);
}
use of com.opensymphony.xwork2.test.ModelDrivenAction2 in project struts by apache.
the class StrutsLocalizedTextProviderTest method testActionGetText.
public void testActionGetText() throws Exception {
ModelDrivenAction2 action = new ModelDrivenAction2();
container.inject(action);
TestBean2 bean = (TestBean2) action.getModel();
Bar bar = new Bar();
bean.setBarObj(bar);
Mock mockActionInvocation = new Mock(ActionInvocation.class);
mockActionInvocation.expectAndReturn("getAction", action);
ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy());
ActionContext.getContext().getValueStack().push(action);
ActionContext.getContext().getValueStack().push(action.getModel());
String message = action.getText("barObj.title");
assertEquals("Title:", message);
}
use of com.opensymphony.xwork2.test.ModelDrivenAction2 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.opensymphony.xwork2.test.ModelDrivenAction2 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.opensymphony.xwork2.test.ModelDrivenAction2 in project struts by apache.
the class ListAction method testFindConversionMappingForInterface.
public void testFindConversionMappingForInterface() {
ModelDrivenAction2 action = new ModelDrivenAction2();
stack.push(action);
stack.push(action.getModel());
Map<String, Object> ognlStackContext = stack.getContext();
ognlStackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
String value = "asdf:123";
Object o = converter.convertValue(ognlStackContext, action.getModel(), null, "barObj", value, Bar.class);
assertNotNull(o);
assertTrue(o instanceof Bar);
Bar b = (Bar) o;
assertEquals(value, b.getTitle() + ":" + b.getSomethingElse());
}
Aggregations