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) {
}
}
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) {
}
}
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) {
}
}
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);
}
Aggregations