@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException,
InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.domain", "test-domain");
environment.setProperty("endpoints.jmx.unique_names", "true");
environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().getMBeanInfo(ObjectNameManager.getInstance(
getObjectName("test-domain", "healthEndpoint", this.context).toString()
+ ",key1=value1,key2=value2"))).isNotNull();
}
java类org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration的实例源码
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 28
收藏 0
点赞 0
评论 0
IntegrationAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 34
收藏 0
点赞 0
评论 0
@Test
public void parentContext() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(JmxAutoConfiguration.class,
IntegrationAutoConfiguration.class);
this.context.refresh();
AnnotationConfigApplicationContext parent = this.context;
this.context = new AnnotationConfigApplicationContext();
this.context.setParent(parent);
this.context.register(JmxAutoConfiguration.class,
IntegrationAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(HeaderChannelRegistry.class)).isNotNull();
((ConfigurableApplicationContext) this.context.getParent()).close();
this.context.close();
}
SpringApplicationAdminJmxAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 28
收藏 0
点赞 0
评论 0
@Test
public void registerWithSimpleWebApp() throws Exception {
this.context = new SpringApplicationBuilder()
.sources(EmbeddedServletContainerAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
JmxAutoConfiguration.class,
SpringApplicationAdminJmxAutoConfiguration.class)
.run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
assertThat(this.context).isInstanceOf(EmbeddedWebApplicationContext.class);
assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
"EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
int expected = ((EmbeddedWebApplicationContext) this.context)
.getEmbeddedServletContainer().getPort();
String actual = getProperty(createDefaultObjectName(), "local.server.port");
assertThat(actual).isEqualTo(String.valueOf(expected));
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 57
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException,
InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.domain", "test-domain");
environment.setProperty("endpoints.jmx.unique_names", "true");
environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().getMBeanInfo(ObjectNameManager.getInstance(
getObjectName("test-domain", "healthEndpoint", this.context).toString()
+ ",key1=value1,key2=value2"))).isNotNull();
}
IntegrationAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 26
收藏 0
点赞 0
评论 0
@Test
public void parentContext() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(JmxAutoConfiguration.class,
IntegrationAutoConfiguration.class);
this.context.refresh();
AnnotationConfigApplicationContext parent = this.context;
this.context = new AnnotationConfigApplicationContext();
this.context.setParent(parent);
this.context.register(JmxAutoConfiguration.class,
IntegrationAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(HeaderChannelRegistry.class)).isNotNull();
((ConfigurableApplicationContext) this.context.getParent()).close();
this.context.close();
}
SpringApplicationAdminJmxAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 34
收藏 0
点赞 0
评论 0
@Test
public void registerWithSimpleWebApp() throws Exception {
this.context = new SpringApplicationBuilder()
.sources(EmbeddedServletContainerAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
JmxAutoConfiguration.class,
SpringApplicationAdminJmxAutoConfiguration.class)
.run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
assertThat(this.context).isInstanceOf(EmbeddedWebApplicationContext.class);
assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
"EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
int expected = ((EmbeddedWebApplicationContext) this.context)
.getEmbeddedServletContainer().getPort();
String actual = getProperty(createDefaultObjectName(), "local.server.port");
assertThat(actual).isEqualTo(String.valueOf(expected));
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:contestparser
阅读 31
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException,
InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.domain", "test-domain");
environment.setProperty("endpoints.jmx.unique_names", "true");
environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertNotNull(mbeanExporter.getServer()
.getMBeanInfo(ObjectNameManager.getInstance(
getObjectName("test-domain", "healthEndpoint", this.context)
.toString() + ",key1=value1,key2=value2")));
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:contestparser
阅读 36
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterInParentChild() throws IntrospectionException,
InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
this.context = new AnnotationConfigApplicationContext();
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
parent.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.setParent(parent);
parent.refresh();
this.context.refresh();
parent.close();
}
SpringApplicationAdminJmxAutoConfigurationTests.java 文件源码
项目:contestparser
阅读 35
收藏 0
点赞 0
评论 0
@Test
public void registerWithSimpleWebApp() throws Exception {
this.context = new SpringApplicationBuilder()
.sources(EmbeddedServletContainerAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
JmxAutoConfiguration.class,
SpringApplicationAdminJmxAutoConfiguration.class)
.run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
assertTrue(this.context instanceof EmbeddedWebApplicationContext);
assertEquals(true, this.mBeanServer.getAttribute(createDefaultObjectName(),
"EmbeddedWebApplication"));
int expected = ((EmbeddedWebApplicationContext) this.context)
.getEmbeddedServletContainer().getPort();
String actual = getProperty(createDefaultObjectName(), "local.server.port");
assertEquals(String.valueOf(expected), actual);
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterIsInstalled() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer()
.queryNames(getObjectName("*", "*,*", this.context), null)).isNotEmpty();
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 34
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterIsNotInstalledIfManagedResource()
throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
ManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer()
.queryNames(getObjectName("*", "*,*", this.context), null)).isEmpty();
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 32
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterIsNotInstalledIfNestedInManagedResource()
throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
NestedInManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer()
.queryNames(getObjectName("*", "*,*", this.context), null)).isEmpty();
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 38
收藏 0
点赞 0
评论 0
@Test(expected = NoSuchBeanDefinitionException.class)
public void testEndpointMBeanExporterIsNotInstalled() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.enabled", "false");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 34
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterInParentChild() throws IntrospectionException,
InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
this.context = new AnnotationConfigApplicationContext();
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
parent.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.setParent(parent);
parent.refresh();
this.context.refresh();
parent.close();
}
IntegrationAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 34
收藏 0
点赞 0
评论 0
private void load(Class<?> config, String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
if (config != null) {
ctx.register(config);
}
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(ctx, environment);
ctx.register(JmxAutoConfiguration.class, IntegrationAutoConfiguration.class);
ctx.refresh();
this.context = ctx;
}
SpringApplicationAdminJmxAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 32
收藏 0
点赞 0
评论 0
private void load(String... environment) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(applicationContext, environment);
applicationContext.register(JmxAutoConfiguration.class,
SpringApplicationAdminJmxAutoConfiguration.class);
applicationContext.refresh();
this.context = applicationContext;
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 33
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterIsInstalled() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer()
.queryNames(getObjectName("*", "*,*", this.context), null)).isNotEmpty();
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 31
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterIsNotInstalledIfManagedResource()
throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
ManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer()
.queryNames(getObjectName("*", "*,*", this.context), null)).isEmpty();
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 33
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterIsNotInstalledIfNestedInManagedResource()
throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
NestedInManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer()
.queryNames(getObjectName("*", "*,*", this.context), null)).isEmpty();
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 32
收藏 0
点赞 0
评论 0
@Test(expected = NoSuchBeanDefinitionException.class)
public void testEndpointMBeanExporterIsNotInstalled() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.enabled", "false");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 33
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterInParentChild() throws IntrospectionException,
InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
this.context = new AnnotationConfigApplicationContext();
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
parent.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.setParent(parent);
parent.refresh();
this.context.refresh();
parent.close();
}
IntegrationAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 33
收藏 0
点赞 0
评论 0
private void load(String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(ctx, environment);
ctx.register(JmxAutoConfiguration.class, IntegrationAutoConfiguration.class);
ctx.refresh();
this.context = ctx;
}
SpringApplicationAdminJmxAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 37
收藏 0
点赞 0
评论 0
private void load(String... environment) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(applicationContext, environment);
applicationContext.register(JmxAutoConfiguration.class,
SpringApplicationAdminJmxAutoConfiguration.class);
applicationContext.refresh();
this.context = applicationContext;
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:contestparser
阅读 36
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterIsInstalled() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(EndpointMBeanExporter.class));
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertFalse(mbeanExporter.getServer()
.queryNames(getObjectName("*", "*,*", this.context), null).isEmpty());
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:contestparser
阅读 33
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterIsNotInstalledIfManagedResource()
throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
ManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(EndpointMBeanExporter.class));
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertTrue(mbeanExporter.getServer()
.queryNames(getObjectName("*", "*,*", this.context), null).isEmpty());
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:contestparser
阅读 35
收藏 0
点赞 0
评论 0
@Test
public void testEndpointMBeanExporterIsNotInstalledIfNestedInManagedResource()
throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
NestedInManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(EndpointMBeanExporter.class));
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertTrue(mbeanExporter.getServer()
.queryNames(getObjectName("*", "*,*", this.context), null).isEmpty());
}
EndpointMBeanExportAutoConfigurationTests.java 文件源码
项目:contestparser
阅读 27
收藏 0
点赞 0
评论 0
@Test(expected = NoSuchBeanDefinitionException.class)
public void testEndpointMBeanExporterIsNotInstalled() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.enabled", "false");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
fail();
}
IntegrationAutoConfigurationTests.java 文件源码
项目:contestparser
阅读 37
收藏 0
点赞 0
评论 0
@Test
public void addJmxAuto() {
this.context.register(JmxAutoConfiguration.class,
IntegrationAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(HeaderChannelRegistry.class));
this.context.close();
}
SpringApplicationAdminJmxAutoConfigurationTests.java 文件源码
项目:contestparser
阅读 35
收藏 0
点赞 0
评论 0
private void load(String... environment) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(applicationContext, environment);
applicationContext.register(JmxAutoConfiguration.class,
SpringApplicationAdminJmxAutoConfiguration.class);
applicationContext.refresh();
this.context = applicationContext;
}
EndpointMBeanExportAutoConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 33
收藏 0
点赞 0
评论 0
@Bean
@ConditionalOnMissingBean(MBeanServer.class)
public MBeanServer mbeanServer() {
return new JmxAutoConfiguration().mbeanServer();
}