How to unit test case on GWT server side class methods and how mock up the session inside the methods.

2011-05-23 Thread Rupesh
Can anybody please suggest how to write unit test case on GWT server
side class methods and mainly how to mock up the session inside the
methods. I getting NullPointerException with the statment like :
 final HttpSession session = this.getHttpSession();

- As I m not able create the Object of same session inside my test
case.

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: How to unit test case on GWT server side class methods and how mock up the session inside the methods.

2011-05-23 Thread Ben Imp
I do all of my server side work in little action objects.  This allows you 
to remove your dependency on RemoteServiceServlet, and test only your code.

So basically all of your server methods would look like:

return new MyAction(getThreadLocalRequest(), 
clientArgumentBundle).perform();

Then you can mock out the request, session, etc, in your unit test, since 
they will just be arguments instead of class methods.

-Ben

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.