Trouble creating DWR WebContext for Test class

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Trouble creating DWR WebContext for Test class

Sanjay Patil
The author has deleted this message.
Reply | Threaded
Open this post in threaded view

Re: Trouble creating DWR WebContext for Test class

Mike Wilson
Hi Satil,
In the simplest case you can supply your own mock implementation of the Container interface. The Container represents a generic dependency injection container that knows about all registered parts of DWR, f ex there is a SpringContainer implementation that interfaces to Spring.
Once your test cases start to ask for objects in the container it might be easier to fire up the real DWR classes that fully initialize the Container. Have a look at:
to see how this may be done, and either use it directly or take inspiration from it.
Note that DWR is an open-source project so I encourage you to take the opportunity to look in the source code for answers.
Best regards

From: Sanjay Patil [mailto:[hidden email]]
Sent: den 6 juni 2014 10:26
To: [hidden email]
Subject: [dwr-users] Trouble creating DWR WebContext for Test class

Hi all,


I am in the process migrating a web application from DWR 2.0 and Spring 2.5 to DWR 3.0 and Spring 4. I have got the application working thanks to this forum and DWR Support team.

I am now facing problem changing my DWR Test classes. In DWR 2.0, I was able to pass the mocked request and response objects to DefaultWebContextBuilder and set this to WebContextFactory and my test used to work.


But looks like we need to pass a DWR Container to DefaultWebContextBuilder. So my question is how do I get hold of this container in my test classes as I need to attach it to WebContextFactory too.  I am using Junit and Spring 4 test framework. I appreciate your time on this. Thanks.



                DWR 2.0 and Spring 2.5

response = new MockHttpServletResponse();

request = new MockHttpServletRequest();

DefaultWebContextBuilder builder = new DefaultWebContextBuilder();

             builder.set(request, response, null, null, null);



                DWR 3.0 and Spring 4

                DefaultWebContextBuilder builder = new DefaultWebContextBuilder();

builder.engageThread(null, request, response);;




Sanjay Patil

This e-mail and any attached files are intended for the named addressee only. It contains information which may be confidential and legally privileged, and also protected by copyright. Unless you are the named addressee (or authorised to receive for the addressee) you may not copy, use or disclose it to anyone else. If you received it in error please notify the sender immediately and then delete it from your system. The views and opinions expressed in this e-mail may not reflect the views and opinions of Wowcher Limited or any of its subsidiary companies. We make every effort to keep our network free from viruses. However, you need to check this e-mail and any attachments for viruses as we take no responsibility for any virus which may be transferred by this e-mail.
Wowcher Ltd. Registered Office: Northcliffe House, 2 Derry St, Kensington, London, W8 5TT. Registered No 04264984 England.