EverrestServletContextInitializer { public DependencySupplier getDependencySupplier() { DependencySupplier dependencySupplier = (DependencySupplier)servletContext.getAttribute(DependencySupplier.class.getName()); if (dependencySupplier == null) { dependencySupplier = new ServletContextDependencySupplier(servletContext); } return dependencySupplier; } EverrestServletContextInitializer(ServletContext servletContext); Application getApplication(); EverrestConfiguration createConfiguration(); RequestHandler createRequestHandler(); RequestDispatcher createRequestDispatcher(); ResourceBinder createResourceBinder(); DependencySupplier getDependencySupplier(); ProviderBinder createProviderBinder(); EverrestProcessor createEverrestProcessor(); static final String EVERREST_SCAN_COMPONENTS; static final String EVERREST_SCAN_SKIP_PACKAGES; static final String JAXRS_APPLICATION; }
@Test public void createsDependencySupplier() { EverrestServletContextInitializer everrestServletContextInitializer = new EverrestServletContextInitializer(servletContext); DependencySupplier dependencySupplier = everrestServletContextInitializer.getDependencySupplier(); assertTrue(String.format("ServletContextDependencySupplier is expected to be created but %s found", dependencySupplier), dependencySupplier instanceof ServletContextDependencySupplier); }
@Test public void usesDependencySupplierConfiguredInServletContext() { DependencySupplier configuredDependencySupplier = new DependencySupplierImpl(); when(servletContext.getAttribute(DependencySupplier.class.getName())).thenReturn(configuredDependencySupplier); EverrestServletContextInitializer everrestServletContextInitializer = new EverrestServletContextInitializer(servletContext); DependencySupplier dependencySupplier = everrestServletContextInitializer.getDependencySupplier(); assertSame(String.format("ServletContextDependencySupplier is expected to be created but %s found", dependencySupplier), dependencySupplier, configuredDependencySupplier); }