scriptSrcURL.append(base).append(JSAgentModule.JAVASCRIPT_URL_PREFIX); scriptSrcURL.append(JSAgentModule.JS_AGENT_REVISION).append('_'); scriptSrcURL.append(configurationStorage.getEndUserMonitoringConfig().getActiveModules()); scriptSrcURL.append(".js");
@Test public void testScriptInterception() throws IOException { hook = new EUMInstrumentationHook(linker, tracer, dataHandler, config, agentBuilder); String scriptUrl = eumConfig.getScriptBaseUrl() + JSAgentModule.JAVASCRIPT_URL_PREFIX + "32488_" + eumConfig.getActiveModules() + ".JS"; when(dummyRequest.getRequestURI()).thenReturn(scriptUrl); StringWriter response = new StringWriter(); PrintWriter pw = new PrintWriter(response); when(dummyResponse.getWriter()).thenReturn(pw); boolean intercepted = null != hook.beforeBody(METHOD_ID, dummyServlet, new Object[] { dummyRequest, dummyResponse }, ssc); assertThat(intercepted, equalTo(true)); assertThat(response.toString(), equalTo(AGENT_CODE)); }
@Test public void eumConfig() throws Exception { EndUserMonitoringConfig config = mock(EndUserMonitoringConfig.class); when(config.isEumEnabled()).thenReturn(true); String url = "/base/url"; when(config.getScriptBaseUrl()).thenReturn(url); String modules = "12a"; when(config.getActiveModules()).thenReturn(modules); when(config.isListenerInstrumentationAllowed()).thenReturn(false); when(config.isAgentMinificationEnabled()).thenReturn(false); when(environment.getEumConfig()).thenReturn(config); AgentConfig agentConfiguration = creator.environmentToConfiguration(environment, 0); AgentEndUserMonitoringConfig eumConfig = agentConfiguration.getEumConfig(); assertThat(eumConfig.isEnabled(), is(true)); assertThat(eumConfig.getActiveModules(), is(modules)); assertThat(eumConfig.getScriptBaseUrl(), is(url)); assertThat(eumConfig.isListenerInstrumentationAllowed(), is(false)); assertThat(eumConfig.isAgentMinificationEnabled(), is(false)); }