śr., 4 lis 2020 o 17:29 Paul Zepernick
<Paul.Zepernick@healthsmart.com.invalid> napisał(a):
> I have posted an example project that reproduces the error in the junit test
>
> https://github.com/zepernick/struts25-rest-junit
I think I have found the problem, mapping is not set in
getActionProxy(), you can fix it by overriding it like this:
protected ActionProxy getActionProxy(String uri) {
request.setRequestURI(uri);
ActionMapping mapping = getActionMapping(request);
String namespace = mapping.getNamespace();
String name = mapping.getName();
String method = mapping.getMethod();
Configuration config = configurationManager.getConfiguration();
ActionProxy proxy =
config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy(
namespace, name, method, new HashMap<String,
Object>(), true, false);
initActionContext(proxy.getInvocation().getInvocationContext());
// this is normally done in onSetUp(), but we are using Struts internal
// objects (proxy and action invocation)
// so we have to hack around so it works
ServletActionContext.setServletContext(servletContext);
ServletActionContext.setRequest(request);
ServletActionContext.setResponse(response);
ServletActionContext.getContext().put(ServletActionContext.ACTION_MAPPING,
mapping);
return proxy;
}
Fee free to open a JIRA ticket and as I'm going to prepare yet another
2.5.x release I can address this issue
Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
|