Use Mock http objects. EasyMock and JMock are two very popular libraries. The idea is to provide a MockHttpRequest object to your unit test case so that it can continue to function as it is.
Another approach is to restrict usage of Session / Request objects to just one or two methods, and then override them in your test case. For example, if you use session to identify if the user is logged in, just create a method isUserLoggedIn() or getLoggedInUserData(), and override that in your unit test case so that it doesn't fail. --Sri On 26 April 2010 15:28, FD <[email protected]> wrote: > Hello community ;-) > > I would like to find out if it's possible to unit test a serviceImpl > class in a GWT app, where is used getThreadLocalRequest(). > > The method I'm trying to unit test with jUnit contains the line: > > HttpSession s = getThreadLocalRequest().getSession(true); > > > Is there a way around this? What's the usual approach when unit > testing this kind of stuff? > > I hope someone will hear my plea :) :) > > F. > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-web-toolkit%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
