I have posted the answer 2 days ago from my gmail account. For some
strange reason it does not appear here.

http://code.google.com/p/tadedon/

New module in the library is called tadedon-guice-servlet-mock

Here are unit tests:

http://code.google.com/p/tadedon/source/browse/tadedon-guice-servlet-mock/src/test/java/com/xemantic/tadedon/guice/servlet/mock/UriReturningServletTest.java

http://code.google.com/p/tadedon/source/browse/tadedon-guice-servlet-mock/src/test/java/com/xemantic/tadedon/guice/servlet/mock/SessionIdReturningServletTest.java

The code for testing Filter would be quite similar, though it could
require another interceptor. I will try to write such code in a spare
moment.

On Jul 1, 11:21 pm, charles gay <[email protected]> wrote:
> Hi Kazimierz,
> can you post an example of unit testing an httpservlet or
> servletFilter, called by the GuiceFilter, like implied in your prevous
> post?
>
> best regards,
>
> Charles.
>
> On 19 juin, 22:51, Kazimierz Pogoda <[email protected]> wrote:
>
>
>
> > On Thu, Jun 17, 2010 at 1:21 PM, yaniv kessler <[email protected]> wrote:
> > > I wanted to know if anyone tried to artificially induce scopes like 
> > > Request
> > > or Session in unit tests and what is the best way to go about it.
>
> > I tried with success, though my solution is specific to GWT RCP
> > testing. I have built abstraction around GuiceFilter which is
> > initialized on @BeforeClass together with Injector instance, and
> > destroyed on @AfterClass. The idea is to simply call doFilter on
> > GuiceFilter instance in every test, and pass FilterChain instance
> > which will call servlet's doGet or doPost method. I mock
> > ServletContext, HttpSession, HttpServletRequest, HttpServletResponse
> > with the help of spring-test library. In case of GWT RPC instead of
> > calling servlet's doPost method I just wrap service instance with
> > dynamic proxy which ensures that any method invocation is performed
> > inside GuiceFilter.doFilter method. This way I can test RPC service
> > and avoid any processing in the HTTP stack.
>
> > > This question is being asked within the context of wicket pages testing.
>
> > In case of wicket you would have to call WicketFilter instance in the
> > FilterChain in addition to GuiceFilter and construct appropriate
> > HttpServletRequest mock pointing to specific wicket page.
>
> > --
> > "Meaning is differential not referential"
>
> > kazik 'morisil' pogodahttp://www.xemantic.com/http://blog.xemantic.com/

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" 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-guice?hl=en.

Reply via email to