This is an automated email from the ASF dual-hosted git repository. yasserzamani pushed a commit to branch feature/more_coverage in repository https://gitbox.apache.org/repos/asf/struts.git
commit 08f1de4f96ea095201c142943efe36b8ecc692fe Author: Yasser Zamani <yasserzam...@apache.org> AuthorDate: Thu Apr 22 00:11:09 2021 +0430 more test coverages... (to be continued) --- .../java/com/opensymphony/xwork2/mock/MockResult.java | 7 ++++++- .../java/com/opensymphony/xwork2/ChainResultTest.java | 12 ++++++++++++ .../org/apache/struts2/views/jsp/ui/TextfieldTest.java | 1 + .../org/apache/struts2/views/jsp/ui/Textfield-5.txt | 2 +- core/src/test/resources/xwork-sample.xml | 15 +++++++++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/mock/MockResult.java b/core/src/main/java/com/opensymphony/xwork2/mock/MockResult.java index f85cae4..6d3debe 100644 --- a/core/src/main/java/com/opensymphony/xwork2/mock/MockResult.java +++ b/core/src/main/java/com/opensymphony/xwork2/mock/MockResult.java @@ -31,6 +31,8 @@ public class MockResult implements Result { public static final String DEFAULT_PARAM = "foo"; + private ActionInvocation invocation; + @Override public boolean equals(Object o) { if (this == o) { @@ -41,7 +43,7 @@ public class MockResult implements Result { } public void execute(ActionInvocation invocation) throws Exception { - // no op + this.invocation = invocation; } @Override @@ -53,4 +55,7 @@ public class MockResult implements Result { // no op } + public ActionInvocation getInvocation() { + return invocation; + } } diff --git a/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java b/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java index 84fa0af..22d56ef 100644 --- a/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java @@ -20,6 +20,7 @@ package com.opensymphony.xwork2; import com.mockobjects.dynamic.Mock; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; +import com.opensymphony.xwork2.mock.MockResult; import com.opensymphony.xwork2.util.ValueStack; import junit.framework.TestCase; import org.apache.struts2.StrutsException; @@ -124,6 +125,17 @@ public class ChainResultTest extends XWorkTestCase { } } + public void testNamespaceChain() throws Exception { + ActionProxy proxy = actionProxyFactory.createActionProxy(null, "chain_with_namespace", null, null); + ((SimpleAction)proxy.getAction()).setBlah("%{foo}"); + + proxy.execute(); + + assertTrue(proxy.getInvocation().getResult() instanceof MockResult); + MockResult result = (MockResult) proxy.getInvocation().getResult(); + assertEquals("%{foo}", result.getInvocation().getProxy().getNamespace()); + } + private class NamespaceActionNameTestActionProxyFactory implements ActionProxyFactory { private final ActionProxy returnVal; private final String expectedActionName; diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java index 8bbefcb..5eefb97 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java @@ -156,6 +156,7 @@ public class TextfieldTest extends AbstractUITagTest { tag.setName("myname"); tag.setValue("%{foo}"); tag.setSize("10"); + tag.setDynamicAttribute(null, "anotherAttr", "%{foo}"); tag.doStartTag(); tag.doEndTag(); diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt index 08326c7..2818476 100644 --- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt @@ -1,4 +1,4 @@ <tr> <td class="tdLabel"><label for="myname" class="label">mylabel:</label></td> - <td class="tdInput"><input type="text" name="myname" size="10" value="%{1+1}" id="myname"/></td> + <td class="tdInput"><input type="text" name="myname" size="10" value="%{1+1}" id="myname" anotherAttr="%{1+1}"/></td> </tr> diff --git a/core/src/test/resources/xwork-sample.xml b/core/src/test/resources/xwork-sample.xml index 89eb645..3e7fbac 100644 --- a/core/src/test/resources/xwork-sample.xml +++ b/core/src/test/resources/xwork-sample.xml @@ -140,6 +140,21 @@ <action name="InfiniteRecursionChain" class="com.opensymphony.xwork2.ActionSupport"> <result name="success" type="chain">InfiniteRecursionChain</result> </action> + <action name="chain_with_namespace" class="com.opensymphony.xwork2.SimpleAction"> + <result name="error" type="chain"> + <param name="actionName">chain_without_namespace</param> + <param name="namespace">%{blah}</param> + </result> + <interceptor-ref name="debugStack"/> + <interceptor-ref name="defaultStack"/> + </action> + <action name="chain_without_namespace" class="com.opensymphony.xwork2.SimpleAction"> + <result name="error" type="chain"> + <param name="actionName">Foo</param> + </result> + <interceptor-ref name="debugStack"/> + <interceptor-ref name="defaultStack"/> + </action> </package>