Search in sources :

Example 6 with MetricsEndpointException

use of ddf.metrics.reporting.internal.MetricsEndpointException in project ddf by codice.

the class MetricsEndpointTest method testGetMetricsGraphWithDateOffsetAndDates.

// 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 testGetMetricsGraphWithDateOffsetAndDates() throws Exception {
    UriInfo uriInfo = createUriInfo();
    MetricsEndpoint endpoint = getEndpoint();
    endpoint.setMetricsDir(TEST_DIR);
    try {
        endpoint.getMetricsData("uptime", "png", "2013-03-25T06:00:00-07:00", "2013-03-25T07:10:00-07:00", "3600", "my label", "my title", uriInfo);
        fail();
    } catch (MetricsEndpointException e) {
    }
}
Also used : MetricsEndpointException(ddf.metrics.reporting.internal.MetricsEndpointException) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 7 with MetricsEndpointException

use of ddf.metrics.reporting.internal.MetricsEndpointException 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)

Aggregations

MetricsEndpointException (ddf.metrics.reporting.internal.MetricsEndpointException)7 Response (javax.ws.rs.core.Response)4 UriInfo (javax.ws.rs.core.UriInfo)4 Test (org.junit.Test)4 RrdMetricsRetriever (ddf.metrics.reporting.internal.rrd4j.RrdMetricsRetriever)3 MetricsGraphException (ddf.metrics.reporting.internal.MetricsGraphException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 Calendar (java.util.Calendar)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)2