MockHttpSession session = new MockHttpSession();
servletContext = new MockServletContext();
session.setServletContext(servletContext);
IdentityServer server = this.getIdentityServer(session);
servletContext.setAttribute("IDENTITY_SERVER", server);
MockServletConfig servletConfig = new MockServletConfig(servletContext);
MockContextClassLoader mclIDP = setupTCL(profile + "/idp");
Thread.currentThread().setContextClassLoader(mclIDP);
MockHttpServletRequest request = new MockHttpServletRequest(session, "POST");
request.addHeader("Referer", "http://localhost:8080/employee/");
request.addParameter(GeneralConstants.USERNAME_FIELD, "anil");
request.addParameter(GeneralConstants.PASS_FIELD, "anil");
MockHttpServletResponse response = new MockHttpServletResponse();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.setOutputStream(baos);
IDPLoginServlet login = new IDPLoginServlet();
login.init(servletConfig);
String samlAuth = DocumentUtil.getDocumentAsString(saml2Request.convert(art));
String samlMessage = Base64.encodeBytes(samlAuth.getBytes());
session.setAttribute("SAMLRequest", samlMessage);
login.testPost(request, response);
IDPServlet idp = new IDPServlet();
// No signing outgoing messages
servletConfig.addInitParameter(GeneralConstants.SIGN_OUTGOING_MESSAGES, "false");
// Initialize the servlet
idp.init(servletConfig);
// Lets start the workflow with post