/** * Sends the script using the given response object. * * @param res * the response to write * @param activeModules * a String listing the identifiers of the active modules. */ private void sendScript(WHttpServletResponse res, String activeModules) { // we respond with the script code res.setStatus(200); res.setContentType("application/javascript"); res.addHeader("Cache-Control", "public, max-age=" + JSAgentBuilder.JS_AGENT_CACHE_MAX_AGE_SECONDS); PrintWriter writer = res.getWriter(); writer.write(agentBuilder.buildJsFile(activeModules)); writer.flush(); }
@BeforeMethod public void initMocks() throws IOException, StorageException { eumConfig.setActiveModules("a12"); eumConfig.setEnabled(true); eumConfig.setScriptBaseUrl("/baseUrl/"); when(dummyRequest.getRequestURI()).thenReturn("/mycool/url/here"); when(config.getEndUserMonitoringConfig()).thenReturn(eumConfig); when(dummyResponse.getWriter()).thenReturn(Mockito.mock(PrintWriter.class)); when(dummyResponse.getOutputStream()).thenReturn(Mockito.mock(ServletOutputStream.class)); when(agentBuilder.buildJsFile(any(String.class))).thenReturn(AGENT_CODE); }