Hi all,
I am having hard time in findind a solution to test the spring security.
Always my test case returns null authentication. Please see the attachement for my full junit code and testsecurity.xml.
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST");
request.setServletPath("/adjudication.html");
request.setScheme("https");
MockHttpServletResponse response = new MockHttpServletResponse();
XmlWebApplicationContext ctx = new XmlWebApplicationContext();
ctx.setConfigLocations(new String[] { "file:war/WEB-INF/testadjudication-security.xml","file:war/WEB-INF/adjudication-dao.xml" ,"file:war/WEB-INF/adjudication-base.xml","file:war/WEB-INF/adjudication-datasource.xml"});
ctx.refresh();
Filter f = (Filter) ctx.getBean("springSecurityFilterChain", Filter.class);
try {
f.doFilter(request, response,new MockFilterChain());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertEquals("/adjudication.html",response.getRedirectedUrl());
And i am always getting reponse.getRedirectedUrl() as null. Please help me in resolving this issue.


