* Ensure that the namespace of the current executing action is used when no
* namespace is specified. (WW-1875)
*/
public void testShouldIncludeCurrentNamespaceIfNoNamespaceSpecifiedForRenderUrl()
throws Exception {
final MockPortletURL portletUrl = new MockPortletURL(
new MockPortalContext(), "render");
MockRenderRequest request = new MockRenderRequest();
MockRenderResponse response = new MockRenderResponse() {
@Override
public PortletURL createRenderURL() {
return portletUrl;
}
};
ActionContext ctx = ActionContext.getContext();
ctx.put(PortletActionConstants.PHASE,
PortletActionConstants.RENDER_PHASE);
ctx.put(PortletActionConstants.REQUEST, request);
ctx.put(PortletActionConstants.RESPONSE, response);
Map<PortletMode, String> modeMap = new HashMap<PortletMode, String>();
modeMap.put(PortletMode.VIEW, "/view");
ctx.put(PortletActionConstants.MODE_NAMESPACE_MAP, modeMap);
ValueStack stack = ctx.getValueStack();
URL url = new URL(stack, new PortletServletRequest(request, null),
new PortletServletResponse(response));
MockActionInvocation ai = new MockActionInvocation();
MockActionProxy ap = new MockActionProxy();
ap.setActionName("testAction");
ap.setNamespace("/current_namespace");
ai.setProxy(ap);
ai.setStack(stack);
ai.setAction(new Object());
ctx.setActionInvocation(ai);
StringWriter renderOutput = new StringWriter();
renderer.renderUrl(renderOutput, url);
String action = portletUrl
.getParameter(PortletActionConstants.ACTION_PARAM);
assertEquals("/view/current_namespace/testAction", action);
}