|
Struts example source code file (PortletServletRequestTest.java)
The Struts PortletServletRequestTest.java source codepackage org.apache.struts2.portlet.servlet; import org.apache.struts2.ServletActionContext; import org.apache.struts2.StrutsTestCase; import org.apache.struts2.dispatcher.mapper.ActionMapping; import org.apache.struts2.portlet.PortletActionConstants; import org.apache.struts2.portlet.context.PortletActionContext; import org.springframework.mock.web.portlet.MockPortletContext; import org.springframework.mock.web.portlet.MockPortletRequest; import com.opensymphony.xwork2.ActionContext; public class PortletServletRequestTest extends StrutsTestCase { private MockPortletRequest portletRequest; private MockPortletContext portletContext; private PortletServletRequest request; protected void setUp() throws Exception { super.setUp(); portletRequest = new MockPortletRequest(); portletContext = new MockPortletContext(); request = new PortletServletRequest(portletRequest, portletContext); } public void testGetServletPathShouldHandleDefaultActionExtension() throws Exception { portletRequest.setParameter(PortletActionConstants.ACTION_PARAM, "actionName"); request.setExtension("action"); assertEquals("actionName.action", request.getServletPath()); } public void testGetServletPathShouldHandleCustomActionExtension() throws Exception { portletRequest.setParameter(PortletActionConstants.ACTION_PARAM, "actionName"); request.setExtension("custom"); assertEquals("actionName.custom", request.getServletPath()); } public void testGetServletPathShouldHandleNoExtension() throws Exception { portletRequest.setParameter(PortletActionConstants.ACTION_PARAM, "actionName"); request.setExtension(""); assertEquals("actionName", request.getServletPath()); } public void testGetServletPathShouldHandleMultipleExtensionsByUsingTheFirst() throws Exception { portletRequest.setParameter(PortletActionConstants.ACTION_PARAM, "actionName"); request.setExtension("action,,"); assertEquals("actionName.action", request.getServletPath()); } } Other Struts examples (source code examples)Here is a short list of links related to this Struts PortletServletRequestTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.