use of org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker 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.invoker.cache.CachingOperationInvoker 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);
});
}
use of org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker in project spring-boot by spring-projects.
the class WebEndpointDiscovererTests method getEndpointsWhenHasCacheWithTtlShouldCacheReadOperationWithTtlValue.
@Test
void getEndpointsWhenHasCacheWithTtlShouldCacheReadOperationWithTtlValue() {
load((id) -> 500L, EndpointId::toString, TestEndpointConfiguration.class, (discoverer) -> {
Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"));
ExposableWebEndpoint endpoint = endpoints.get(EndpointId.of("test"));
assertThat(endpoint.getOperations()).hasSize(1);
WebOperation operation = endpoint.getOperations().iterator().next();
Object invoker = ReflectionTestUtils.getField(operation, "invoker");
assertThat(invoker).isInstanceOf(CachingOperationInvoker.class);
assertThat(((CachingOperationInvoker) invoker).getTimeToLive()).isEqualTo(500);
});
}
Aggregations