views:

134

answers:

2

I am trying to create unit test environment to test RESTFul services (cfx+spring) in my dev environemnt. To test RESTFul Services, I require @Context within JUnit test cases. @Context should contain HttpRequest, HttpSession, ServletContext, ServletConfig and all other webserver related information.

I have setup the JUnit for the above, but when I run, @Context is coming as null. This could be because there is no webserver running and there is no @Context. I am just doubting whether there is a way to created sample web @Context and pass to JUnit. Any other ideas are welcome to bring web @Context into JUnit test cases.

Thank you, Sudheer

A: 

You need to embed a web container.

Try for example Jetty as an embedded container.

This article contains useful information.

Espen
Thank you. I will try the option.
Sudheer
A: 

Spring has some help for mocking the web server environment and thus testing without a real web container. See these Spring Framework docs on testing to get started. I haven't used this in your context, but it may be helpful.

Don Roby