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));
}
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));
}
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));
}
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));
}
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;
}
Aggregations