Search in sources :

Example 1 with EndpointObjectNameFactory

use of org.springframework.boot.actuate.endpoint.jmx.EndpointObjectNameFactory in project spring-boot by spring-projects.

the class JmxEndpointAutoConfigurationTests method jmxEndpointWithCustomEndpointObjectNameFactory.

@Test
void jmxEndpointWithCustomEndpointObjectNameFactory() {
    EndpointObjectNameFactory factory = mock(EndpointObjectNameFactory.class);
    this.contextRunner.withPropertyValues("spring.jmx.enabled=true").with(mockMBeanServer()).withBean(EndpointObjectNameFactory.class, () -> factory).run((context) -> {
        ArgumentCaptor<ExposableJmxEndpoint> argumentCaptor = ArgumentCaptor.forClass(ExposableJmxEndpoint.class);
        then(factory).should().getObjectName(argumentCaptor.capture());
        ExposableJmxEndpoint jmxEndpoint = argumentCaptor.getValue();
        assertThat(jmxEndpoint.getEndpointId().toLowerCaseString()).isEqualTo("test");
    });
}
Also used : ExposableJmxEndpoint(org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint) EndpointObjectNameFactory(org.springframework.boot.actuate.endpoint.jmx.EndpointObjectNameFactory) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 EndpointObjectNameFactory (org.springframework.boot.actuate.endpoint.jmx.EndpointObjectNameFactory)1 ExposableJmxEndpoint (org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint)1