HttpService

The HttpServiceTestCase deploys a Service that registeres a servlet and a resource with the HttpService .

ServiceTracker tracker = new ServiceTracker(context, HttpService.class.getName(), null);
tracker.open();

HttpService httpService = (HttpService)tracker.getService();
if (httpService == null)
   throw new IllegalStateException("HttpService not registered");

Properties initParams = new Properties();
initParams.setProperty("initProp", "SomeValue");
httpService.registerServlet("/servlet", new EndpointServlet(context), initParams, null);
httpService.registerResources("/file", "/res", null);

The test then verifies that the registered servlet context and the registered resource can be accessed.

HttpService support in AS7

This test uses the OSGi Repository functionality to provision the runtime with the required support functionality like this

HttpServiceSupport.provideHttpService(context, bundle);

To enable HttpService support in AS7 you would configure this capability

<capability name="org.ops4j.pax.web:pax-web-jetty-bundle:1.1.2"/>