@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;
 }
Ejemplo n.º 3
0
 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);
   }
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 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);
   }
 }
Ejemplo n.º 6
0
 @Before
 public void setUp() {
   applicationContext = mock(ApplicationContextImpl.class);
   when(applicationContext.getEntryPointManager()).thenReturn(manager);
   when(applicationContext.getServletContext()).thenReturn(context);
 }
Ejemplo n.º 7
0
 public ClientResources(ApplicationContextImpl applicationContext) {
   this.applicationContext = applicationContext;
   resourceManager = applicationContext.getResourceManager();
   themeManager = applicationContext.getThemeManager();
 }
Ejemplo n.º 8
0
 @Override
 public void init() throws ServletException {
   ServletContext servletContext = getServletContext();
   applicationContext = ApplicationContextImpl.getFrom(servletContext);
 }
Ejemplo n.º 9
0
 private ServiceHandler getServiceHandler() {
   return applicationContext.getServiceManager().getHandler();
 }