use of org.glassfish.jersey.jetty.JettyHttpContainer in project jersey by jersey.
the class JettyContainerTest method testParentServiceLocator.
/**
* Test that defined ServiceLocator becomes a parent of the newly created service locator.
*/
@Test
public void testParentServiceLocator() {
final ServiceLocator locator = new ServiceLocatorImpl("MyServiceLocator", null);
final Server server = JettyHttpContainerFactory.createServer(URI.create("http://localhost:9876"), new ResourceConfig(Resource.class), false, locator);
JettyHttpContainer container = (JettyHttpContainer) server.getHandler();
InjectionManager injectionManager = container.getApplicationHandler().getInjectionManager();
HK2InjectionManager hk2InjectionManager = (HK2InjectionManager) injectionManager;
ServiceLocator serviceLocator = hk2InjectionManager.getServiceLocator();
assertTrue("Application injection manager was expected to have defined parent locator", serviceLocator.getParent() == locator);
}
Aggregations