![JAR search and dependency download from the Maven repository](/logo.png)
com.mockrunner.example.struts.LogoutAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockrunner-jdk1.6-j2ee1.3 Show documentation
Show all versions of mockrunner-jdk1.6-j2ee1.3 Show documentation
Mockrunner is a lightweight framework for unit testing applications
in the J2EE environment. It supports servlets, filters, tag classes
and Struts actions. It includes a JDBC a JMS and a JCA test
framework and can be used to test EJB based applications.
The newest version!
package com.mockrunner.example.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
* This example action does the same as
* {@link com.mockrunner.example.servlet.LogoutServlet}.
* It is used to demonstrate the testing of actions with
* specified filters since {@link com.mockrunner.struts.ActionTestModule}
* does not provide any filter methods. Please note that usually it's not
* necessary to test actions in conjunction with filters. You can
* add the filtered values directly to the request.
* This action uses the custom action mapping {@link LogoutActionMapping}
* to get the request parameter name.
*/
public class LogoutAction extends Action
{
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception
{
LogoutActionMapping logoutMapping = (LogoutActionMapping)mapping;
String logout = request.getParameter(logoutMapping.getRequestParameterName());
if(null != logout)
{
request.getSession().invalidate();
request.getRequestDispatcher("/html/goodbye.html").forward(request, response);
}
return mapping.findForward("success");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy