开发者

How do I mock or embed an OSGi HttpService in a unit test?

I have a module that I开发者_如何学Go want to unit test, which extends HttpServlet and, in the real application is connected to an OSGi HttpService (the Jetty-based Pax Web) using registerServlet().

I'm setting up a unit test for that module and want to check whether some test HTTP requests are handled correctly. For this, I need either to embed an instance of HttpService from one of my bundle JARs or create a mock. Since I want to process an actual HTTP request, I figured I should really run a HTTP server. So far, I found tutorials on how to run a Jetty instance from within an application, but I still need to wrap the HttpService around this somehow.


I'm going to wrap a Jetty instance in a simple implementation of HttpService.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜