Ensure endpoints.jolokia.enabled=false switches off jolokia

This commit is contained in:
Dave Syer
2013-11-26 13:22:17 +00:00
parent 564475556e
commit 94e2f90793
3 changed files with 24 additions and 1 deletions

View File

@@ -22,12 +22,14 @@ import javax.servlet.ServletRegistration;
import org.jolokia.http.AgentServlet;
import org.junit.After;
import org.junit.Test;
import org.springframework.boot.TestUtils;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory.RegisteredServlet;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -62,6 +64,16 @@ public class JolokiaAutoConfigurationTests {
assertEquals(1, this.context.getBeanNamesForType(AgentServlet.class).length);
}
@Test
public void agentDisabled() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
TestUtils.addEnviroment(this.context, "endpoints.jolokia.enabled:false");
this.context.register(Config.class, WebMvcAutoConfiguration.class,
JolokiaAutoConfiguration.class);
this.context.refresh();
assertEquals(0, this.context.getBeanNamesForType(AgentServlet.class).length);
}
@Test
public void agentServletRegisteredWithServletContainer() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
@@ -83,6 +95,7 @@ public class JolokiaAutoConfigurationTests {
}
@Configuration
@EnableConfigurationProperties
protected static class Config {
protected static MockEmbeddedServletContainerFactory containerFactory = null;