@Test public void agentServletWithCustomPath() throws Exception { this.context = new AnnotationConfigEmbeddedWebApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "endpoints.jolokia.path=/foo/bar"); this.context.register(EndpointsConfig.class, WebMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, ManagementServerPropertiesAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, JolokiaAutoConfiguration.class); this.context.refresh(); assertThat(this.context.getBeanNamesForType(JolokiaMvcEndpoint.class)).hasSize(1); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build(); mockMvc.perform(MockMvcRequestBuilders.get("/foo/bar")) .andExpect(MockMvcResultMatchers.content() .string(Matchers.containsString("\"request\":{\"type\""))); }
@Parameters(name = "{0}") public static Object[] parameters() { return new Object[] { new Object[] { "actuator", HalJsonMvcEndpoint.class }, new Object[] { "autoconfig", AutoConfigurationReportEndpoint.class }, new Object[] { "beans", BeansEndpoint.class }, new Object[] { "configprops", ConfigurationPropertiesReportEndpoint.class }, new Object[] { "docs", DocsMvcEndpoint.class }, new Object[] { "dump", DumpEndpoint.class }, new Object[] { "env", EnvironmentMvcEndpoint.class }, new Object[] { "flyway", FlywayEndpoint.class }, new Object[] { "health", HealthMvcEndpoint.class }, new Object[] { "info", InfoEndpoint.class }, new Object[] { "jolokia", JolokiaMvcEndpoint.class }, new Object[] { "liquibase", LiquibaseEndpoint.class }, new Object[] { "logfile", LogFileMvcEndpoint.class }, new Object[] { "mappings", RequestMappingEndpoint.class }, new Object[] { "metrics", MetricsMvcEndpoint.class }, new Object[] { "shutdown", ShutdownEndpoint.class }, new Object[] { "trace", TraceEndpoint.class } }; }
@Test public void agentServletWithCustomPath() throws Exception { this.context = new AnnotationConfigEmbeddedWebApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "endpoints.jolokia.path=/foo/bar"); this.context.register(EndpointsConfig.class, WebMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, ManagementServerPropertiesAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, JolokiaAutoConfiguration.class); this.context.refresh(); assertEquals(1, this.context.getBeanNamesForType(JolokiaMvcEndpoint.class).length); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build(); mockMvc.perform(MockMvcRequestBuilders.get("/foo/bar")) .andExpect(MockMvcResultMatchers.content() .string(Matchers.containsString("\"request\":{\"type\""))); }
@Bean @ConditionalOnMissingBean public JolokiaMvcEndpoint jolokiaEndpoint() { JolokiaMvcEndpoint endpoint = new JolokiaMvcEndpoint(); endpoint.setInitParameters(getInitParameters()); return endpoint; }
@Test public void agentServletRegisteredWithAppContext() throws Exception { this.context = new AnnotationConfigEmbeddedWebApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "jolokia.config[key1]:value1", "jolokia.config[key2]:value2"); this.context.register(Config.class, WebMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, ManagementServerPropertiesAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, JolokiaAutoConfiguration.class); this.context.refresh(); assertThat(this.context.getBeanNamesForType(JolokiaMvcEndpoint.class)).hasSize(1); }
private void assertEndpointDisabled(String... pairs) { this.context = new AnnotationConfigEmbeddedWebApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, pairs); this.context.register(Config.class, WebMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, ManagementServerPropertiesAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, JolokiaAutoConfiguration.class); this.context.refresh(); assertThat(this.context.getBeanNamesForType(JolokiaMvcEndpoint.class)).isEmpty(); }
private void assertEndpointEnabled(String... pairs) { this.context = new AnnotationConfigEmbeddedWebApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, pairs); this.context.register(Config.class, WebMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, ManagementServerPropertiesAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, JolokiaAutoConfiguration.class); this.context.refresh(); assertThat(this.context.getBeanNamesForType(JolokiaMvcEndpoint.class)).hasSize(1); }
@Test public void agentServletRegisteredWithAppContext() throws Exception { this.context = new AnnotationConfigEmbeddedWebApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, "jolokia.config[key1]:value1", "jolokia.config[key2]:value2"); this.context.register(Config.class, WebMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, ManagementServerPropertiesAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, JolokiaAutoConfiguration.class); this.context.refresh(); assertEquals(1, this.context.getBeanNamesForType(JolokiaMvcEndpoint.class).length); }
private void assertEndpointDisabled(String... pairs) { this.context = new AnnotationConfigEmbeddedWebApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, pairs); this.context.register(Config.class, WebMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, ManagementServerPropertiesAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, JolokiaAutoConfiguration.class); this.context.refresh(); assertEquals(0, this.context.getBeanNamesForType(JolokiaMvcEndpoint.class).length); }
private void assertEndpointEnabled(String... pairs) { this.context = new AnnotationConfigEmbeddedWebApplicationContext(); EnvironmentTestUtils.addEnvironment(this.context, pairs); this.context.register(Config.class, WebMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, ManagementServerPropertiesAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, JolokiaAutoConfiguration.class); this.context.refresh(); assertEquals(1, this.context.getBeanNamesForType(JolokiaMvcEndpoint.class).length); }