@Test public void testRegistersTabrisLoaderWithId() { ApplicationImpl application = mockConfiguration(); ApplicationContextImpl applicationContext = application.getApplicationContext(); TabrisClientInstaller.install(application, "foo"); verify(applicationContext.getResourceRegistry()) .add(eq("index.json"), any(TabrisResourceLoader.class)); }
private ApplicationImpl mockConfiguration() { ApplicationImpl application = mock(ApplicationImpl.class); ApplicationContextImpl context = mock(ApplicationContextImpl.class); ThemeManager themeManager = mock(ThemeManager.class); when(context.getThemeManager()).thenReturn(themeManager); when(context.getServletContext()).thenReturn(mock(ServletContext.class)); when(application.getApplicationContext()).thenReturn(context); ResourceRegistry resourceRegistry = mock(ResourceRegistry.class); when(context.getResourceRegistry()).thenReturn(resourceRegistry); return application; }
private void sendStartupContent(HttpServletRequest request, HttpServletResponse response) throws IOException { String accept = request.getHeader(HTTP.HEADER_ACCEPT); if (accept != null && accept.contains(HTTP.CONTENT_TYPE_JSON)) { StartupJson.send(response); } else { applicationContext.getStartupPage().send(response); } }
private void registerJavascriptResource(ContentBuffer buffer, String name) throws IOException { InputStream inputStream = buffer.getContentAsStream(); try { resourceManager.register(name, inputStream); } finally { inputStream.close(); } String location = resourceManager.getLocation(name); applicationContext.getStartupPage().setClientJsLibrary(location); }
private void handleRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (!applicationContext.allowsRequests()) { response.sendError(SC_SERVICE_UNAVAILABLE); } else if (request.getPathInfo() == null) { // /context/servlet: no extra path info after servlet name handleValidRequest(request, response); } else if ("/".equals(request.getPathInfo()) && "".equals(request.getServletPath())) { // /context/: root servlet, in this case path info "/" is ok handleValidRequest(request, response); } else { response.sendError(SC_NOT_FOUND); } }
@Before public void setUp() { applicationContext = mock(ApplicationContextImpl.class); when(applicationContext.getEntryPointManager()).thenReturn(manager); when(applicationContext.getServletContext()).thenReturn(context); }
public ClientResources(ApplicationContextImpl applicationContext) { this.applicationContext = applicationContext; resourceManager = applicationContext.getResourceManager(); themeManager = applicationContext.getThemeManager(); }
@Override public void init() throws ServletException { ServletContext servletContext = getServletContext(); applicationContext = ApplicationContextImpl.getFrom(servletContext); }
private ServiceHandler getServiceHandler() { return applicationContext.getServiceManager().getHandler(); }