![JAR search and dependency download from the Maven repository](/logo.png)
com.mockrunner.example.servlet.LogoutServletTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockrunner-jdk1.3-j2ee1.3 Show documentation
Show all versions of mockrunner-jdk1.3-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.servlet;
import javax.servlet.http.HttpServletRequest;
import com.mockrunner.servlet.BasicServletTestCaseAdapter;
/**
* Example test for {@link LogoutServlet}.
* Demonstrates the usage of {@link com.mockrunner.servlet.ServletTestModule}
* and {@link com.mockrunner.servlet.BasicServletTestCaseAdapter}
* with and without a filter.
*/
public class LogoutServletTest extends BasicServletTestCaseAdapter
{
protected void setUp() throws Exception
{
super.setUp();
createServlet(LogoutServlet.class);
}
public void testDoLogout() throws Exception
{
addRequestParameter("logout", "true");
doPost();
assertFalse(getWebMockObjectFactory().getMockSession().isValid());
}
public void testDoLogoutWithFilteredImageButton() throws Exception
{
addRequestParameter("logout.x", "11");
addRequestParameter("logout.y", "11");
doPost();
assertTrue(getWebMockObjectFactory().getMockSession().isValid());
createFilter(ImageButtonFilter.class);
setDoChain(true);
doPost();
assertFalse(getWebMockObjectFactory().getMockSession().isValid());
HttpServletRequest filteredRequest = (HttpServletRequest)getFilteredRequest();
assertEquals("11", filteredRequest.getParameter("logout"));
assertNull(filteredRequest.getParameter("logout.x"));
assertNull(filteredRequest.getParameter("logout.y"));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy