1 Reply Latest reply on Nov 30, 2009 8:49 AM by Stan Silvert

    How to pass remote user using Http request

    Naveen Noolee Newbie


      I am a newbie to JSFUnit. It's a great tool and we managed to set up with Maven and got the basic example working in few hours, but we are struggling with a small problem.

      I would like to send a HTTP request to my controller where I extract the remote user using - "request.getRemoteUser". This is currently printing as 'null' .

      Can some one help me how to set the 'remoteUser' on 'http request' and send it using JSFUnit.

      I would appreciate your help


        • 1. Re: How to pass remote user using Http request
          Stan Silvert Master

          Hi noolena,

          Thanks for the kind words.

          Note that when you are inside a JSFUnit test, ExternalContext.getRequest() can yield unexpected results. This is documented in the javadoc. The reason is because the container may recycle the HttpServletRequest object at the end of the request.

          JSFUnit will cache the remote user in the JSFUnitExternalContext. So the way to get the remote user in a JSFUnit test is to call:

          Hope that helps. If not, can you post your code so I can get a better idea of what you are trying to do?