use of org.apache.struts2.TestAction in project struts by apache.
the class ActionTagTest method testActionTagWithNamespace.
public void testActionTagWithNamespace() {
request.setupGetServletPath(TestConfigurationProvider.TEST_NAMESPACE + "/" + "foo.action");
ActionTag tag = new ActionTag();
tag.setPageContext(pageContext);
tag.setName(TestConfigurationProvider.TEST_NAMESPACE_ACTION);
tag.setVar(TestConfigurationProvider.TEST_NAMESPACE_ACTION);
try {
tag.doStartTag();
ActionComponent ac = ((ActionComponent) tag.component);
tag.doEndTag();
ActionProxy proxy = ac.getProxy();
Object o = pageContext.findAttribute(TestConfigurationProvider.TEST_NAMESPACE_ACTION);
assertTrue(o instanceof TestAction);
assertEquals(TestConfigurationProvider.TEST_NAMESPACE, proxy.getNamespace());
} 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));
}
use of org.apache.struts2.TestAction 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));
}
use of org.apache.struts2.TestAction 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));
}
use of org.apache.struts2.TestAction 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));
}
use of org.apache.struts2.TestAction 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));
}
Aggregations