use of com.opensymphony.xwork2.util.Bar in project struts by apache.
the class PropertyTest method testTopValueShouldReturnTopOfValueStack.
public void testTopValueShouldReturnTopOfValueStack() {
final ValueStack stack = ActionContext.getContext().getValueStack();
stack.push(new FooBar("foo-value", "bar-value"));
final Property property = new Property(stack);
property.setDefault("default");
property.setValue("top");
assertPropertyOutput("foo-value/bar-value", property);
}
use of com.opensymphony.xwork2.util.Bar in project struts by apache.
the class PropertyTest method testTypeConverterShouldBeUsed.
public void testTypeConverterShouldBeUsed() {
final ValueStack stack = ActionContext.getContext().getValueStack();
converter.registerConverter("org.apache.struts2.components.PropertyTest$FooBar", new FooBarConverter());
stack.push(new FooBar("foo-value", "bar-value"));
final Property property = new Property(stack);
property.setDefault("default");
property.setValue("top");
assertPropertyOutput("*foo-value + bar-value*", property);
}
use of com.opensymphony.xwork2.util.Bar in project struts by apache.
the class UIBeanTest method testEscapeId.
public void testEscapeId() {
ValueStack stack = ActionContext.getContext().getValueStack();
MockHttpServletRequest req = new MockHttpServletRequest();
MockHttpServletResponse res = new MockHttpServletResponse();
Form form = new Form(stack, req, res);
form.getParameters().put("id", "formId");
TextField txtFld = new TextField(stack, req, res);
txtFld.setName("foo/bar");
txtFld.populateComponentHtmlId(form);
assertEquals("formId_foo_bar", txtFld.getParameters().get("id"));
}
use of com.opensymphony.xwork2.util.Bar in project struts by apache.
the class StrutsConversionErrorInterceptorTest method testFieldErrorAdded.
public void testFieldErrorAdded() throws Exception {
conversionErrors.put("foo", new ConversionData("bar", Integer.class));
ActionSupport action = new ActionSupport();
mockInvocation.expectAndReturn("getAction", action);
stack.push(action);
mockInvocation.matchAndReturn("getAction", action);
assertNull(action.getFieldErrors().get("foo"));
interceptor.doIntercept(invocation);
assertTrue(action.hasFieldErrors());
assertNotNull(action.getFieldErrors().get("foo"));
}
use of com.opensymphony.xwork2.util.Bar in project struts by apache.
the class StrutsConversionErrorInterceptorTest method testEmptyValuesDoNotSetFieldErrors.
public void testEmptyValuesDoNotSetFieldErrors() throws Exception {
conversionErrors.put("foo", new ConversionData("bar", Integer.class));
conversionErrors.put("bar", new ConversionData("", Integer.class));
conversionErrors.put("baz", new ConversionData(new String[] { "" }, Integer.class));
ActionSupport action = new ActionSupport();
mockInvocation.expectAndReturn("getAction", action);
stack.push(action);
mockInvocation.matchAndReturn("getAction", action);
assertNull(action.getFieldErrors().get("foo"));
assertNull(action.getFieldErrors().get("bar"));
assertNull(action.getFieldErrors().get("baz"));
interceptor.doIntercept(invocation);
assertTrue(action.hasFieldErrors());
assertNotNull(action.getFieldErrors().get("foo"));
assertNull(action.getFieldErrors().get("bar"));
assertNull(action.getFieldErrors().get("baz"));
}
Aggregations