public class SaveOriginalPostRequestTestCase {
@BeforeClass
public static void setup() throws ServletException {
final PathHandler path = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
ServletInfo securedRequestDumper = new ServletInfo("SecuredRequestDumperServlet", RequestDumper.class)
.setServletSecurityInfo(new ServletSecurityInfo()
.addRoleAllowed("role1"))
.addMapping("/secured/dumpRequest");
ServletInfo unsecuredRequestDumper = new ServletInfo("UnsecuredRequestDumperServlet", RequestDumper.class)
.addMapping("/dumpRequest");
ServletInfo loginFormServlet = new ServletInfo("loginPage", FormLoginServlet.class)
.setServletSecurityInfo(new ServletSecurityInfo()
.addRoleAllowed("group1"))
.addMapping("/FormLoginServlet");
ServletIdentityManager identityManager = new ServletIdentityManager();
identityManager.addUser("user1", "password1", "role1");
DeploymentInfo builder = new DeploymentInfo()
.setClassLoader(SimpleServletTestCase.class.getClassLoader())
.setContextPath("/servletContext")
.setClassIntrospecter(TestClassIntrospector.INSTANCE)
.setDeploymentName("servletContext.war")
.setIdentityManager(identityManager)
.setLoginConfig(new LoginConfig("FORM", "Test Realm", "/FormLoginServlet", "/error.html"))
.addServlets(securedRequestDumper, unsecuredRequestDumper, loginFormServlet);
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
path.addPrefixPath(builder.getContextPath(), manager.start());