-
1. Re: FacesContext is not active?
vineet.reynolds Mar 6, 2012 3:54 AM (in response to membersound)Well the answer depends on what class you are testing, how the FacesContext is referenced by this class, and how the FacesContext instance is provided to this class.
You could use JSFUnit if your test fixture involves the issuance of a HTTP request to the server; in the case of JSFUnit, HtmlUnit is used to issue requests. Using JSFUnit will allow you to obtain a reference to the FacesContext instance, in the context of a request.
Alternatively, if your test fixture does not issue a HTTP request, you can create your own FacesContext implementation. As part of your test fixture, you can set the FacesContext instance for the current thread to an instance of this custom FacesContext class; the FacesContext.setCurrentInstance(...) API method allows you to do this.
-
2. Re: FacesContext is not active?
membersound Mar 6, 2012 4:07 AM (in response to vineet.reynolds)I'm using FacesContext to obtain the locale in the bean I'm testing.
Will have a look at JSFUnit. ty!