Search in sources :

Example 66 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class UIBeanTest method testGetThemeFromForm.

public void testGetThemeFromForm() {
    ValueStack stack = ActionContext.getContext().getValueStack();
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse res = new MockHttpServletResponse();
    Form form = new Form(stack, req, res);
    form.setTheme("foo");
    TextField txtFld = new TextField(stack, req, res);
    assertEquals("foo", txtFld.getTheme());
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Example 67 with Foo

use of com.opensymphony.xwork2.util.Foo 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 68 with Foo

use of com.opensymphony.xwork2.util.Foo 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 69 with Foo

use of com.opensymphony.xwork2.util.Foo 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)

Example 70 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class AnnotationValidationInterceptorTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    test = new TestAction();
    interceptor = new AnnotationValidationInterceptor();
    container.inject(interceptor);
    config = new ActionConfig.Builder("", "foo", "").build();
    mockActionInvocation = new Mock(ActionInvocation.class);
    mockActionProxy = new Mock(ActionProxy.class);
    mockActionInvocation.matchAndReturn("getProxy", (ActionProxy) mockActionProxy.proxy());
    mockActionInvocation.matchAndReturn("getAction", test);
    mockActionInvocation.expect("invoke");
    ActionContext.getContext().withActionInvocation((ActionInvocation) mockActionInvocation.proxy());
}
Also used : ActionProxy(com.opensymphony.xwork2.ActionProxy) ActionInvocation(com.opensymphony.xwork2.ActionInvocation) Mock(com.mockobjects.dynamic.Mock)

Aggregations

Foo (com.opensymphony.xwork2.util.Foo)53 HashMap (java.util.HashMap)32 ValueStack (com.opensymphony.xwork2.util.ValueStack)23 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)20 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)19 StrutsException (org.apache.struts2.StrutsException)19 OgnlException (ognl.OgnlException)18 IntrospectionException (java.beans.IntrospectionException)17 InappropriateExpressionException (ognl.InappropriateExpressionException)17 MethodFailedException (ognl.MethodFailedException)17 NoSuchPropertyException (ognl.NoSuchPropertyException)17 ActionProxy (com.opensymphony.xwork2.ActionProxy)16 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)9 ActionContext (com.opensymphony.xwork2.ActionContext)8 ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)8 Bar (com.opensymphony.xwork2.util.Bar)8 Map (java.util.Map)8 ResultConfig (com.opensymphony.xwork2.config.entities.ResultConfig)7 ConversionData (com.opensymphony.xwork2.conversion.impl.ConversionData)7 StubValueStack (com.opensymphony.xwork2.StubValueStack)6