Search in sources :

Example 1 with CachingOperationInvoker

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);
    });
}
Also used : JmxOperation(org.springframework.boot.actuate.endpoint.jmx.JmxOperation) ExposableJmxEndpoint(org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint) EndpointId(org.springframework.boot.actuate.endpoint.EndpointId) CachingOperationInvoker(org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker) Test(org.junit.jupiter.api.Test)

Example 2 with CachingOperationInvoker

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);
    });
}
Also used : JmxOperation(org.springframework.boot.actuate.endpoint.jmx.JmxOperation) ExposableJmxEndpoint(org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint) EndpointId(org.springframework.boot.actuate.endpoint.EndpointId) CachingOperationInvoker(org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker) Test(org.junit.jupiter.api.Test)

Example 3 with CachingOperationInvoker

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);
    });
}
Also used : WebOperation(org.springframework.boot.actuate.endpoint.web.WebOperation) ExposableWebEndpoint(org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint) EndpointId(org.springframework.boot.actuate.endpoint.EndpointId) CachingOperationInvoker(org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 EndpointId (org.springframework.boot.actuate.endpoint.EndpointId)3 CachingOperationInvoker (org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker)3 ExposableJmxEndpoint (org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint)2 JmxOperation (org.springframework.boot.actuate.endpoint.jmx.JmxOperation)2 ExposableWebEndpoint (org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint)1 WebOperation (org.springframework.boot.actuate.endpoint.web.WebOperation)1