I have a spring service method that gets an object stored in the session (using FacesContext) as follows:
(MyObject)((HttpServletRequest) FacesContext
.getCurrentInstance().getExternalContext().getRequest())
.getSession().getAttribute("myObject");
and I would like to put that object in session in unit test before invoking the method.
so i tried the solution in this post:
Spring Test session scope bean using Junit
and in my test method i put the object in session before calling the service, but the service throws an exception when trying to get the object from the session, i guess that this is because the facescontext is not available, what do you think ?
I am using Spring, Junit, JSF2, please advise, thanks.