Anyway, to bring web @Context to JUnit (CXF + Spring)

I am trying to create a unit test environment to test RESTful services (cfx + spring) in my dev environment. To test RESTFul services I require @Context in JUnit tests. @Context should contain HttpRequest, HttpSession, ServletContext, ServletConfig and all other web server related information.

I installed JUnit for the above but when I run @Context comes up as null. It could be because there is no web server and no @Context. I just doubt if there is a way to create a web @Context sample and go to JUnit. Any other ideas can bring web @Context to JUnit test cases.

+2


a source to share


2 answers


You need to embed a web container.

Try Jetty as an inline container for example.



This article contains useful information.

0


a source


Spring has some help for mocking in a web server environment and thus testing without a real web container. To get started, take a look at these Spring Framework docs while testing . I haven't used this in your context, but it might be helpful.



0


a source







All Articles