hi,
in my spring mvc controller, I need to get username from acegi security
context and pass this username to my service manager. but bcos of this
acegi dependency, I have difficulty to do unit test for my mvc
controller.
may I know what is the best practice?
should I refactor the mvc controller, injecting denpendency of
acegi security context to my Controller via spring from
setAcegiContext(), then use Jmock to mock a acegi security context in
my MyControllerTest ?
i am a bit puzzled on this. pls advise. thanks so much.
~thinkboy.
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
User currentUser = (User) SecurityContextHolder.getContext()
.getAuthentication().getPrincipal();
String username = currentUser.getUsername()
return new ModelAndView("serviceList", Constants.SERVICE_LIST,
mgr
.lookupServicesByUsername(username));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]