title: Mocking FacesContext
body: <p>I am trying to add some unit tests to a JSF application. This application didnt rely heavily on any best practices, so many service methods use the <code>FacesContext</code> to pull data from managed session beans like so:</p>
  
  <p>(this is inside a util class)</p>
  
  <pre><code>  public static Object getPageBean(String beanReference) {
        FacesContext fc = FacesContext.getCurrentInstance();
        VariableResolver vr = fc.getApplication().getVariableResolver();
        return vr.resolveVariable(fc, beanReference);
    }
  </code></pre>
  
  <p>What would be the best way to mock this? I am using groovy so i have a few more options for creating classes that i cant normally create.</p>