Search in sources :

Example 31 with Bar

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);
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack)

Example 32 with Bar

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);
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack)

Example 33 with Bar

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"));
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Example 34 with Bar

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"));
}
Also used : ActionSupport(com.opensymphony.xwork2.ActionSupport) ConversionData(com.opensymphony.xwork2.conversion.impl.ConversionData)

Example 35 with Bar

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"));
}
Also used : ActionSupport(com.opensymphony.xwork2.ActionSupport) ConversionData(com.opensymphony.xwork2.conversion.impl.ConversionData)

Aggregations

HashMap (java.util.HashMap)17 Bar (com.opensymphony.xwork2.util.Bar)14 Foo (com.opensymphony.xwork2.util.Foo)13 ValueStack (com.opensymphony.xwork2.util.ValueStack)12 ActionProxy (com.opensymphony.xwork2.ActionProxy)9 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)9 ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)7 ValidationAware (com.opensymphony.xwork2.interceptor.ValidationAware)7 List (java.util.List)6 Map (java.util.Map)6 ConversionData (com.opensymphony.xwork2.conversion.impl.ConversionData)5 Mock (com.mockobjects.dynamic.Mock)4 ActionContext (com.opensymphony.xwork2.ActionContext)4 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)4 ResultConfig (com.opensymphony.xwork2.config.entities.ResultConfig)3 ContainerBuilder (com.opensymphony.xwork2.inject.ContainerBuilder)3 MockResult (com.opensymphony.xwork2.mock.MockResult)3 ModelDrivenAction2 (com.opensymphony.xwork2.test.ModelDrivenAction2)3 LocatableProperties (com.opensymphony.xwork2.util.location.LocatableProperties)3 ActionSupport (com.opensymphony.xwork2.ActionSupport)2