Search in sources :

Example 1 with RrdMetricsRetriever

use of ddf.metrics.reporting.internal.rrd4j.RrdMetricsRetriever in project ddf by codice.

the class MetricsEndpointTest method testGetMetricsGraphWithMetricsGraphException.

// NOTE: "expected" annotation does not work when test case extends XMLTestCase,
// hence the usage of the try/catch/fail approach for the expected exception
@Test
public // (expected = MetricsEndpointException.class)
void testGetMetricsGraphWithMetricsGraphException() throws Exception {
    UriInfo uriInfo = createUriInfo();
    RrdMetricsRetriever metricsRetriever = mock(RrdMetricsRetriever.class);
    when(metricsRetriever.createGraph(anyString(), anyString(), anyLong(), anyLong(), anyString(), anyString())).thenThrow(MetricsGraphException.class);
    MetricsEndpoint endpoint = getEndpoint();
    endpoint.setMetricsDir(TEST_DIR);
    endpoint.setMetricsRetriever(metricsRetriever);
    try {
        endpoint.getMetricsData("uptime", "png", "2013-03-25T06:00:00-07:00", "2013-03-25T07:10:00-07:00", null, "my label", "my title", uriInfo);
        fail();
    } catch (MetricsEndpointException e) {
    }
}
Also used : RrdMetricsRetriever(ddf.metrics.reporting.internal.rrd4j.RrdMetricsRetriever) MetricsEndpointException(ddf.metrics.reporting.internal.MetricsEndpointException) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 2 with RrdMetricsRetriever

use of ddf.metrics.reporting.internal.rrd4j.RrdMetricsRetriever in project ddf by codice.

the class MetricsEndpointTest method verifyException.

private void verifyException(String format, Class exceptionClass) throws Exception {
    UriInfo uriInfo = createUriInfo();
    RrdMetricsRetriever metricsRetriever = mock(RrdMetricsRetriever.class);
    when(metricsRetriever.createJsonData(anyString(), anyString(), anyLong(), anyLong())).thenThrow(exceptionClass);
    when(metricsRetriever.createCsvData(anyString(), anyLong(), anyLong())).thenThrow(exceptionClass);
    when(metricsRetriever.createXlsData(anyString(), anyString(), anyLong(), anyLong())).thenThrow(exceptionClass);
    when(metricsRetriever.createXmlData(anyString(), anyString(), anyLong(), anyLong())).thenThrow(exceptionClass);
    // Get the metrics data from the endpoint
    MetricsEndpoint endpoint = getEndpoint();
    endpoint.setMetricsDir(TEST_DIR);
    endpoint.setMetricsRetriever(metricsRetriever);
    try {
        Response response = endpoint.getMetricsData("uptime", format, null, null, "900", "my label", "my title", uriInfo);
        fail();
    } catch (MetricsEndpointException e) {
    }
}
Also used : Response(javax.ws.rs.core.Response) RrdMetricsRetriever(ddf.metrics.reporting.internal.rrd4j.RrdMetricsRetriever) MetricsEndpointException(ddf.metrics.reporting.internal.MetricsEndpointException) UriInfo(javax.ws.rs.core.UriInfo)

Example 3 with RrdMetricsRetriever

use of ddf.metrics.reporting.internal.rrd4j.RrdMetricsRetriever in project ddf by codice.

the class MetricsEndpointTest method testGetMetricsGraphWithIOException.

// NOTE: "expected" annotation does not work when test case extends XMLTestCase,
// hence the usage of the try/catch/fail approach for the expected exception
@Test
public // (expected = MetricsEndpointException.class)
void testGetMetricsGraphWithIOException() throws Exception {
    UriInfo uriInfo = createUriInfo();
    RrdMetricsRetriever metricsRetriever = mock(RrdMetricsRetriever.class);
    when(metricsRetriever.createGraph(anyString(), anyString(), anyLong(), anyLong(), anyString(), anyString())).thenThrow(IOException.class);
    MetricsEndpoint endpoint = getEndpoint();
    endpoint.setMetricsDir(TEST_DIR);
    endpoint.setMetricsRetriever(metricsRetriever);
    try {
        endpoint.getMetricsData("uptime", "png", "2013-03-25T06:00:00-07:00", "2013-03-25T07:10:00-07:00", null, "my label", "my title", uriInfo);
        fail();
    } catch (MetricsEndpointException e) {
    }
}
Also used : RrdMetricsRetriever(ddf.metrics.reporting.internal.rrd4j.RrdMetricsRetriever) MetricsEndpointException(ddf.metrics.reporting.internal.MetricsEndpointException) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 4 with RrdMetricsRetriever

use of ddf.metrics.reporting.internal.rrd4j.RrdMetricsRetriever in project ddf by codice.

the class MetricsEndpoint method setMetricsMaxThreshold.

public void setMetricsMaxThreshold(double metricsMaxThreshold) {
    LOGGER.debug("Creating new RrdMetricsRetriever with metricsMaxThreshold = {}", metricsMaxThreshold);
    this.metricsMaxThreshold = metricsMaxThreshold;
    metricsRetriever = new RrdMetricsRetriever(metricsMaxThreshold);
}
Also used : RrdMetricsRetriever(ddf.metrics.reporting.internal.rrd4j.RrdMetricsRetriever)

Aggregations

RrdMetricsRetriever (ddf.metrics.reporting.internal.rrd4j.RrdMetricsRetriever)4 MetricsEndpointException (ddf.metrics.reporting.internal.MetricsEndpointException)3 UriInfo (javax.ws.rs.core.UriInfo)3 Test (org.junit.Test)2 Response (javax.ws.rs.core.Response)1