Search in sources :

Example 1 with JmxOperation

use of org.springframework.boot.actuate.endpoint.jmx.JmxOperation 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();
    });
}
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) Test(org.junit.jupiter.api.Test)

Example 2 with JmxOperation

use of org.springframework.boot.actuate.endpoint.jmx.JmxOperation 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 3 with JmxOperation

use of org.springframework.boot.actuate.endpoint.jmx.JmxOperation 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 4 with JmxOperation

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

the class JmxEndpointDiscovererTests method getEndpointsShouldDiscoverStandardEndpoints.

@Test
void getEndpointsShouldDiscoverStandardEndpoints() {
    load(TestEndpoint.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");
        JmxOperation getAll = operationByName.get("getAll");
        assertThat(getAll.getDescription()).isEqualTo("Invoke getAll for endpoint test");
        assertThat(getAll.getOutputType()).isEqualTo(Object.class);
        assertThat(getAll.getParameters()).isEmpty();
        JmxOperation getSomething = operationByName.get("getSomething");
        assertThat(getSomething.getDescription()).isEqualTo("Invoke getSomething for endpoint test");
        assertThat(getSomething.getOutputType()).isEqualTo(String.class);
        assertThat(getSomething.getParameters()).hasSize(1);
        assertThat(getSomething.getParameters().get(0).getType()).isEqualTo(String.class);
        JmxOperation update = operationByName.get("update");
        assertThat(update.getDescription()).isEqualTo("Invoke update for endpoint test");
        assertThat(update.getOutputType()).isEqualTo(Void.TYPE);
        assertThat(update.getParameters()).hasSize(2);
        assertThat(update.getParameters().get(0).getType()).isEqualTo(String.class);
        assertThat(update.getParameters().get(1).getType()).isEqualTo(String.class);
        JmxOperation deleteSomething = operationByName.get("deleteSomething");
        assertThat(deleteSomething.getDescription()).isEqualTo("Invoke deleteSomething for endpoint test");
        assertThat(deleteSomething.getOutputType()).isEqualTo(Void.TYPE);
        assertThat(deleteSomething.getParameters()).hasSize(1);
        assertThat(deleteSomething.getParameters().get(0).getType()).isEqualTo(String.class);
    });
}
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) Test(org.junit.jupiter.api.Test)

Example 5 with JmxOperation

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

the class JmxEndpointDiscovererTests method assertJmxTestEndpoint.

private void assertJmxTestEndpoint(ExposableJmxEndpoint endpoint) {
    Map<String, JmxOperation> operationsByName = mapOperations(endpoint.getOperations());
    assertThat(operationsByName).containsOnlyKeys("getAll", "getSomething", "update", "deleteSomething");
    JmxOperation getAll = operationsByName.get("getAll");
    assertThat(getAll.getDescription()).isEqualTo("Get all the things");
    assertThat(getAll.getOutputType()).isEqualTo(Object.class);
    assertThat(getAll.getParameters()).isEmpty();
    JmxOperation getSomething = operationsByName.get("getSomething");
    assertThat(getSomething.getDescription()).isEqualTo("Get something based on a timeUnit");
    assertThat(getSomething.getOutputType()).isEqualTo(String.class);
    assertThat(getSomething.getParameters()).hasSize(1);
    hasDocumentedParameter(getSomething, 0, "unitMs", Long.class, "Number of milliseconds");
    JmxOperation update = operationsByName.get("update");
    assertThat(update.getDescription()).isEqualTo("Update something based on bar");
    assertThat(update.getOutputType()).isEqualTo(Void.TYPE);
    assertThat(update.getParameters()).hasSize(2);
    hasDocumentedParameter(update, 0, "foo", String.class, "Foo identifier");
    hasDocumentedParameter(update, 1, "bar", String.class, "Bar value");
    JmxOperation deleteSomething = operationsByName.get("deleteSomething");
    assertThat(deleteSomething.getDescription()).isEqualTo("Delete something based on a timeUnit");
    assertThat(deleteSomething.getOutputType()).isEqualTo(Void.TYPE);
    assertThat(deleteSomething.getParameters()).hasSize(1);
    hasDocumentedParameter(deleteSomething, 0, "unitMs", Long.class, "Number of milliseconds");
}
Also used : JmxOperation(org.springframework.boot.actuate.endpoint.jmx.JmxOperation)

Aggregations

JmxOperation (org.springframework.boot.actuate.endpoint.jmx.JmxOperation)5 Test (org.junit.jupiter.api.Test)4 EndpointId (org.springframework.boot.actuate.endpoint.EndpointId)4 ExposableJmxEndpoint (org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint)4 CachingOperationInvoker (org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker)2