use of org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint in project spring-boot by spring-projects.
the class DefaultEndpointObjectNameFactoryTests method assertUniqueObjectName.
private void assertUniqueObjectName() {
ExposableJmxEndpoint endpoint = endpoint(EndpointId.of("test"));
String id = ObjectUtils.getIdentityHexString(endpoint);
ObjectName objectName = generateObjectName(endpoint);
assertThat(objectName.toString()).isEqualTo("org.springframework.boot:type=Endpoint,name=Test,identity=" + id);
}
use of org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint 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");
});
}
use of org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint in project spring-boot by spring-projects.
the class JmxEndpointDiscovererTests method getEndpointsWhenHasJmxExtensionWithNewOperationAddsExtraOperation.
@Test
void getEndpointsWhenHasJmxExtensionWithNewOperationAddsExtraOperation() {
load(AdditionalOperationJmxEndpointConfiguration.class, (discoverer) -> {
Map<EndpointId, ExposableJmxEndpoint> endpoints = discover(discoverer);
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
Map<String, JmxOperation> operationByName = mapOperations(endpoints.get(EndpointId.of("test")).getOperations());
assertThat(operationByName).containsOnlyKeys("getAll", "getSomething", "update", "deleteSomething", "getAnother");
JmxOperation getAnother = operationByName.get("getAnother");
assertThat(getAnother.getDescription()).isEqualTo("Get another thing");
assertThat(getAnother.getOutputType()).isEqualTo(Object.class);
assertThat(getAnother.getParameters()).isEmpty();
});
}
use of org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint in project spring-boot by spring-projects.
the class JmxEndpointDiscovererTests method getEndpointsWhenHasCacheWithTtlShouldCacheReadOperationWithTtlValue.
@Test
void getEndpointsWhenHasCacheWithTtlShouldCacheReadOperationWithTtlValue() {
load(TestEndpoint.class, (id) -> 500L, (discoverer) -> {
Map<EndpointId, ExposableJmxEndpoint> endpoints = discover(discoverer);
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
Map<String, JmxOperation> operationByName = mapOperations(endpoints.get(EndpointId.of("test")).getOperations());
assertThat(operationByName).containsOnlyKeys("getAll", "getSomething", "update", "deleteSomething");
JmxOperation getAll = operationByName.get("getAll");
assertThat(getInvoker(getAll)).isInstanceOf(CachingOperationInvoker.class);
assertThat(((CachingOperationInvoker) getInvoker(getAll)).getTimeToLive()).isEqualTo(500);
});
}
use of org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint in project spring-boot by spring-projects.
the class JmxEndpointDiscovererTests method getEndpointsShouldCacheReadOperations.
@Test
void getEndpointsShouldCacheReadOperations() {
load(AdditionalOperationJmxEndpointConfiguration.class, (id) -> 500L, (discoverer) -> {
Map<EndpointId, ExposableJmxEndpoint> endpoints = discover(discoverer);
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
Map<String, JmxOperation> operationByName = mapOperations(endpoints.get(EndpointId.of("test")).getOperations());
assertThat(operationByName).containsOnlyKeys("getAll", "getSomething", "update", "deleteSomething", "getAnother");
JmxOperation getAll = operationByName.get("getAll");
assertThat(getInvoker(getAll)).isInstanceOf(CachingOperationInvoker.class);
assertThat(((CachingOperationInvoker) getInvoker(getAll)).getTimeToLive()).isEqualTo(500);
JmxOperation getAnother = operationByName.get("getAnother");
assertThat(getInvoker(getAnother)).isInstanceOf(CachingOperationInvoker.class);
assertThat(((CachingOperationInvoker) getInvoker(getAnother)).getTimeToLive()).isEqualTo(500);
});
}
Aggregations