Search in sources :

Example 1 with ProcessingException

use of jakarta.ws.rs.ProcessingException in project metrics by dropwizard.

the class SingletonMetricsJerseyTest method exceptionMeteredMethodsAreExceptionMetered.

@Test
public void exceptionMeteredMethodsAreExceptionMetered() {
    final Meter meter = registry.meter(name(InstrumentedResource.class, "exceptionMetered", "exceptions"));
    assertThat(target("exception-metered").request().get(String.class)).isEqualTo("fuh");
    assertThat(meter.getCount()).isZero();
    try {
        target("exception-metered").queryParam("splode", true).request().get(String.class);
        failBecauseExceptionWasNotThrown(ProcessingException.class);
    } catch (ProcessingException e) {
        assertThat(e.getCause()).isInstanceOf(IOException.class);
    }
    assertThat(meter.getCount()).isEqualTo(1);
}
Also used : Meter(com.codahale.metrics.Meter) IOException(java.io.IOException) InstrumentedResource(com.codahale.metrics.jersey3.resources.InstrumentedResource) ProcessingException(jakarta.ws.rs.ProcessingException) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 2 with ProcessingException

use of jakarta.ws.rs.ProcessingException in project metrics by dropwizard.

the class SingletonMetricsExceptionMeteredPerClassJerseyTest method exceptionMeteredMethodsAreExceptionMetered.

@Test
public void exceptionMeteredMethodsAreExceptionMetered() {
    final Meter meter = registry.meter(name(InstrumentedResourceExceptionMeteredPerClass.class, "exceptionMetered", "exceptions"));
    assertThat(target("exception-metered").request().get(String.class)).isEqualTo("fuh");
    assertThat(meter.getCount()).isZero();
    try {
        target("exception-metered").queryParam("splode", true).request().get(String.class);
        failBecauseExceptionWasNotThrown(ProcessingException.class);
    } catch (ProcessingException e) {
        assertThat(e.getCause()).isInstanceOf(IOException.class);
    }
    assertThat(meter.getCount()).isEqualTo(1);
}
Also used : Meter(com.codahale.metrics.Meter) InstrumentedResourceExceptionMeteredPerClass(com.codahale.metrics.jersey3.resources.InstrumentedResourceExceptionMeteredPerClass) IOException(java.io.IOException) ProcessingException(jakarta.ws.rs.ProcessingException) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 3 with ProcessingException

use of jakarta.ws.rs.ProcessingException in project metrics by dropwizard.

the class SingletonMetricsExceptionMeteredPerClassJerseyTest method subresourcesFromLocatorsRegisterMetrics.

@Test
public void subresourcesFromLocatorsRegisterMetrics() {
    final Meter meter = registry.meter(name(InstrumentedSubResourceExceptionMeteredPerClass.class, "exceptionMetered", "exceptions"));
    assertThat(target("subresource/exception-metered").request().get(String.class)).isEqualTo("fuh");
    assertThat(meter.getCount()).isZero();
    try {
        target("subresource/exception-metered").queryParam("splode", true).request().get(String.class);
        failBecauseExceptionWasNotThrown(ProcessingException.class);
    } catch (ProcessingException e) {
        assertThat(e.getCause()).isInstanceOf(IOException.class);
    }
    assertThat(meter.getCount()).isEqualTo(1);
}
Also used : Meter(com.codahale.metrics.Meter) InstrumentedSubResourceExceptionMeteredPerClass(com.codahale.metrics.jersey3.resources.InstrumentedSubResourceExceptionMeteredPerClass) IOException(java.io.IOException) ProcessingException(jakarta.ws.rs.ProcessingException) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Aggregations

Meter (com.codahale.metrics.Meter)3 ProcessingException (jakarta.ws.rs.ProcessingException)3 IOException (java.io.IOException)3 JerseyTest (org.glassfish.jersey.test.JerseyTest)3 Test (org.junit.Test)3 InstrumentedResource (com.codahale.metrics.jersey3.resources.InstrumentedResource)1 InstrumentedResourceExceptionMeteredPerClass (com.codahale.metrics.jersey3.resources.InstrumentedResourceExceptionMeteredPerClass)1 InstrumentedSubResourceExceptionMeteredPerClass (com.codahale.metrics.jersey3.resources.InstrumentedSubResourceExceptionMeteredPerClass)1