Search in sources :

Example 1 with Foo

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

the class ActionTagTest method testSimpleWithctionMethodInOriginalURI_clearTagStateSet.

public void testSimpleWithctionMethodInOriginalURI_clearTagStateSet() {
    request.setupGetServletPath("/foo!foo.action");
    ActionConfig config = configuration.getRuntimeConfiguration().getActionConfig("", "testAction");
    container.inject(config.getInterceptors().get(0).getInterceptor());
    ActionTag tag = new ActionTag();
    // Explicitly request tag state clearing.
    tag.setPerformClearTagStateForTagPoolingServers(true);
    tag.setPageContext(pageContext);
    tag.setName("testAction");
    tag.setVar("testAction");
    int stackSize = stack.size();
    try {
        tag.doStartTag();
        // Ensure component tag state clearing is set true (to match tag).
        setComponentTagClearTagState(tag, true);
        tag.addParameter("foo", "myFoo");
        tag.doEndTag();
        assertEquals(stack.size(), ActionContext.getContext().getValueStack().size());
        assertEquals("myFoo", stack.findValue("#testAction.foo"));
        assertEquals(stackSize, stack.size());
        Object o = pageContext.findAttribute("testAction");
        assertTrue(o instanceof TestAction);
        assertEquals("myFoo", ((TestAction) o).getFoo());
        assertEquals(Action.SUCCESS, ((TestAction) o).getResult());
    } catch (JspException ex) {
        ex.printStackTrace();
        fail();
    }
    // Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
    ActionTag freshTag = new ActionTag();
    freshTag.setPerformClearTagStateForTagPoolingServers(true);
    freshTag.setPageContext(pageContext);
    assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set.  " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", strutsBodyTagsAreReflectionEqual(tag, freshTag));
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) JspException(javax.servlet.jsp.JspException) TestAction(org.apache.struts2.TestAction)

Example 2 with Foo

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

the class ActionTagTest method testSimple.

public void testSimple() {
    request.setupGetServletPath("/foo.action");
    ActionConfig config = configuration.getRuntimeConfiguration().getActionConfig("", "testAction");
    container.inject(config.getInterceptors().get(0).getInterceptor());
    ActionTag tag = new ActionTag();
    tag.setPageContext(pageContext);
    tag.setName("testAction");
    tag.setVar("testAction");
    int stackSize = stack.size();
    try {
        tag.doStartTag();
        tag.addParameter("foo", "myFoo");
        tag.doEndTag();
        assertEquals(stack.size(), ActionContext.getContext().getValueStack().size());
        assertEquals("myFoo", stack.findValue("#testAction.foo"));
        assertEquals(stackSize, stack.size());
        Object o = pageContext.findAttribute("testAction");
        assertTrue(o instanceof TestAction);
        assertEquals("myFoo", ((TestAction) o).getFoo());
        assertEquals(Action.SUCCESS, ((TestAction) o).getResult());
    } catch (JspException ex) {
        ex.printStackTrace();
        fail();
    }
    // Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
    ActionTag freshTag = new ActionTag();
    freshTag.setPageContext(pageContext);
    assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set.  " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", strutsBodyTagsAreReflectionEqual(tag, freshTag));
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) JspException(javax.servlet.jsp.JspException) TestAction(org.apache.struts2.TestAction)

Example 3 with Foo

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

the class ActionTagTest method testSimple_clearTagStateSet.

public void testSimple_clearTagStateSet() {
    request.setupGetServletPath("/foo.action");
    ActionConfig config = configuration.getRuntimeConfiguration().getActionConfig("", "testAction");
    container.inject(config.getInterceptors().get(0).getInterceptor());
    ActionTag tag = new ActionTag();
    // Explicitly request tag state clearing.
    tag.setPerformClearTagStateForTagPoolingServers(true);
    tag.setPageContext(pageContext);
    tag.setName("testAction");
    tag.setVar("testAction");
    int stackSize = stack.size();
    try {
        tag.doStartTag();
        // Ensure component tag state clearing is set true (to match tag).
        setComponentTagClearTagState(tag, true);
        tag.addParameter("foo", "myFoo");
        tag.doEndTag();
        assertEquals(stack.size(), ActionContext.getContext().getValueStack().size());
        assertEquals("myFoo", stack.findValue("#testAction.foo"));
        assertEquals(stackSize, stack.size());
        Object o = pageContext.findAttribute("testAction");
        assertTrue(o instanceof TestAction);
        assertEquals("myFoo", ((TestAction) o).getFoo());
        assertEquals(Action.SUCCESS, ((TestAction) o).getResult());
    } catch (JspException ex) {
        ex.printStackTrace();
        fail();
    }
    // Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
    ActionTag freshTag = new ActionTag();
    freshTag.setPerformClearTagStateForTagPoolingServers(true);
    freshTag.setPageContext(pageContext);
    assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set.  " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", strutsBodyTagsAreReflectionEqual(tag, freshTag));
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) JspException(javax.servlet.jsp.JspException) TestAction(org.apache.struts2.TestAction)

Example 4 with Foo

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

the class ActionTagTest method testSimpleWithActionMethodInOriginalURI.

public void testSimpleWithActionMethodInOriginalURI() {
    request.setupGetServletPath("/foo!foo.action");
    ActionConfig config = configuration.getRuntimeConfiguration().getActionConfig("", "testAction");
    container.inject(config.getInterceptors().get(0).getInterceptor());
    ActionTag tag = new ActionTag();
    tag.setPageContext(pageContext);
    tag.setName("testAction");
    tag.setVar("testAction");
    int stackSize = stack.size();
    try {
        tag.doStartTag();
        tag.addParameter("foo", "myFoo");
        tag.doEndTag();
        assertEquals(stack.size(), ActionContext.getContext().getValueStack().size());
        assertEquals("myFoo", stack.findValue("#testAction.foo"));
        assertEquals(stackSize, stack.size());
        Object o = pageContext.findAttribute("testAction");
        assertTrue(o instanceof TestAction);
        assertEquals("myFoo", ((TestAction) o).getFoo());
        assertEquals(Action.SUCCESS, ((TestAction) o).getResult());
    } catch (JspException ex) {
        ex.printStackTrace();
        fail();
    }
    // Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
    ActionTag freshTag = new ActionTag();
    freshTag.setPageContext(pageContext);
    assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set.  " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", strutsBodyTagsAreReflectionEqual(tag, freshTag));
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) JspException(javax.servlet.jsp.JspException) TestAction(org.apache.struts2.TestAction)

Example 5 with Foo

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

the class I18n method start.

public boolean start(Writer writer) {
    boolean result = super.start(writer);
    try {
        String name = this.findString(this.name, "name", "Resource bundle name is required. Example: foo or foo_en");
        ResourceBundle bundle = defaultTextProvider.getTexts(name);
        if (bundle == null) {
            LocaleProvider localeProvider = localeProviderFactory.createLocaleProvider();
            bundle = localizedTextProvider.findResourceBundle(name, localeProvider.getLocale());
        }
        if (bundle != null) {
            textProvider = textProviderFactory.createInstance(bundle);
            getStack().push(textProvider);
            pushed = true;
        }
    } catch (Exception e) {
        throw new StrutsException("Could not find the bundle " + name, e);
    }
    return result;
}
Also used : StrutsException(org.apache.struts2.StrutsException) LocaleProvider(com.opensymphony.xwork2.LocaleProvider) ResourceBundle(java.util.ResourceBundle) StrutsException(org.apache.struts2.StrutsException)

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