Skip to content

Commit

Permalink
WW-3714 Update new ActionContext with new ActionInvocation
Browse files Browse the repository at this point in the history
  • Loading branch information
kusalk committed Oct 17, 2024
1 parent 272c2e7 commit e3fbe88
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions core/src/main/java/com/opensymphony/xwork2/ActionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,19 @@ public ActionContext bind() {
return this;
}

@Override
public ActionContext withActionInvocation(ActionInvocation actionInvocation) {
return withActionInvocation((org.apache.struts2.ActionInvocation) actionInvocation);
}

@Override
public ActionContext withActionInvocation(org.apache.struts2.ActionInvocation actionInvocation) {
super.withActionInvocation(actionInvocation);
return this;
}

@Override
public ActionInvocation getActionInvocation() {
return super.getActionInvocation();
return ActionInvocation.adapt(super.getActionInvocation());
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/org/apache/struts2/ActionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.struts2;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.conversion.impl.ConversionData;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.util.ValueStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ public void testActionWithoutExecuteResult_clearTagStateSet() throws Exception {

public void testExecuteButResetReturnSameInvocation() throws Exception {
Mock mockActionInv = new Mock(ActionInvocation.class);
mockActionInv.matchAndReturn("invoke", "TEST");
ActionTag tag = new ActionTag();
tag.setPageContext(pageContext);
tag.setNamespace("");
Expand All @@ -419,7 +420,7 @@ public void testExecuteButResetReturnSameInvocation() throws Exception {
ActionComponent component = (ActionComponent) tag.getComponent();

tag.doEndTag();
assertSame(oldInvocation, ActionContext.getContext().getActionInvocation());
assertEquals(oldInvocation.invoke(), ActionContext.getContext().getActionInvocation().invoke());

// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
ActionTag freshTag = new ActionTag();
Expand All @@ -432,6 +433,7 @@ public void testExecuteButResetReturnSameInvocation() throws Exception {

public void testExecuteButResetReturnSameInvocation_clearTagStateSet() throws Exception {
Mock mockActionInv = new Mock(ActionInvocation.class);
mockActionInv.matchAndReturn("invoke", "TEST");
ActionTag tag = new ActionTag();
tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing.
tag.setPageContext(pageContext);
Expand All @@ -450,7 +452,7 @@ public void testExecuteButResetReturnSameInvocation_clearTagStateSet() throws Ex
ActionComponent component = (ActionComponent) tag.getComponent();

tag.doEndTag();
assertTrue(oldInvocation == ActionContext.getContext().getActionInvocation());
assertEquals(oldInvocation.invoke(), ActionContext.getContext().getActionInvocation().invoke());

// Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag().
ActionTag freshTag = new ActionTag();
Expand Down

0 comments on commit e3fbe88

Please sign in to comment.