Skip to content

Commit

Permalink
more test coverages...
Browse files Browse the repository at this point in the history
(to be continued)
  • Loading branch information
yasserzamani committed Apr 21, 2021
1 parent 2ba1a3e commit 08f1de4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
Expand Up @@ -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) {
Expand All @@ -41,7 +43,7 @@ public boolean equals(Object o) {
}

public void execute(ActionInvocation invocation) throws Exception {
// no op
this.invocation = invocation;
}

@Override
Expand All @@ -53,4 +55,7 @@ public void setFoo(String foo) {
// no op
}

public ActionInvocation getInvocation() {
return invocation;
}
}
12 changes: 12 additions & 0 deletions core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java
Expand Up @@ -20,6 +20,7 @@

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;
Expand Down Expand Up @@ -124,6 +125,17 @@ public void testRecursiveChain() throws Exception {
}
}

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;
Expand Down
Expand Up @@ -156,6 +156,7 @@ public void testSimple_recursionTest() throws Exception {
tag.setName("myname");
tag.setValue("%{foo}");
tag.setSize("10");
tag.setDynamicAttribute(null, "anotherAttr", "%{foo}");

tag.doStartTag();
tag.doEndTag();
Expand Down
@@ -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>
15 changes: 15 additions & 0 deletions core/src/test/resources/xwork-sample.xml
Expand Up @@ -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>

Expand Down

0 comments on commit 08f1de4

Please sign in to comment.