use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExporterTests method jsonListConversion.
@Test
public void jsonListConversion() throws Exception {
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition("endpointMbeanExporter", new RootBeanDefinition(EndpointMBeanExporter.class));
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(JsonListConversionEndpoint.class));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
Object response = mbeanExporter.getServer().invoke(getObjectName("endpoint1", this.context), "getData", new Object[0], new String[0]);
assertThat(response).isInstanceOf(List.class);
assertThat(((List<?>) response).get(0)).isInstanceOf(Long.class);
}
use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExporterTests method loggerEndpointUnknownLogLevel.
@Test
public void loggerEndpointUnknownLogLevel() throws Exception {
MBeanExporter mbeanExporter = registerLoggersEndpoint();
this.thrown.expect(MBeanException.class);
this.thrown.expectCause(hasMessage(containsString("No enum constant")));
this.thrown.expectCause(hasMessage(containsString("LogLevel.INVALID")));
mbeanExporter.getServer().invoke(getObjectName("loggersEndpoint", this.context), "setLogLevel", new Object[] { "com.example", "invalid" }, new String[] { String.class.getName(), String.class.getName() });
}
use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExporterTests method testRegistrationWithParentContext.
@Test
public void testRegistrationWithParentContext() throws Exception {
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition("endpointMbeanExporter", new RootBeanDefinition(EndpointMBeanExporter.class));
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(TestEndpoint.class));
GenericApplicationContext parent = new GenericApplicationContext();
this.context.setParent(parent);
parent.refresh();
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().getMBeanInfo(getObjectName("endpoint1", this.context))).isNotNull();
parent.close();
}
use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExporterTests method jsonMapConversionWithDefaultObjectMapper.
@Test
public void jsonMapConversionWithDefaultObjectMapper() throws Exception {
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition("endpointMbeanExporter", new RootBeanDefinition(EndpointMBeanExporter.class));
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(JsonMapConversionEndpoint.class));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
Object response = mbeanExporter.getServer().invoke(getObjectName("endpoint1", this.context), "getData", new Object[0], new String[0]);
assertThat(response).isInstanceOf(Map.class);
assertThat(((Map<?, ?>) response).get("date")).isInstanceOf(Long.class);
}
use of org.springframework.jmx.export.MBeanExporter in project spring-boot by spring-projects.
the class EndpointMBeanExporterTests method testRegistrationOfEnabledEndpoint.
@Test
public void testRegistrationOfEnabledEndpoint() throws Exception {
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition("endpointMbeanExporter", new RootBeanDefinition(EndpointMBeanExporter.class));
MutablePropertyValues mpv = new MutablePropertyValues();
mpv.add("enabled", Boolean.TRUE);
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(TestEndpoint.class, null, mpv));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().isRegistered(getObjectName("endpoint1", this.context))).isTrue();
}
Aggregations