Search in sources :

Example 1 with ExpectedErrorConfigImpl

use of com.newrelic.agent.config.ExpectedErrorConfigImpl in project newrelic-java-agent by newrelic.

the class ErrorAnalyzerImplTest method nullErrorsAreNotExpected.

@Test
public void nullErrorsAreNotExpected() {
    ErrorCollectorConfig config = new TestErrorCollectorConfig().setExpectedErrors(new ExpectedErrorConfigImpl(MyThrowable.class.getName(), null), new ExpectedErrorConfigImpl(RuntimeException.class.getName(), "ignore_token"));
    ErrorAnalyzer target = new ErrorAnalyzerImpl(config);
    assertFalse(target.isExpectedError(HTTP_OK, null));
    assertFalse(target.isExpectedError(HTTP_OK, wrap(null)));
}
Also used : ErrorCollectorConfig(com.newrelic.agent.config.ErrorCollectorConfig) ExpectedErrorConfigImpl(com.newrelic.agent.config.ExpectedErrorConfigImpl) Test(org.junit.Test)

Example 2 with ExpectedErrorConfigImpl

use of com.newrelic.agent.config.ExpectedErrorConfigImpl in project newrelic-java-agent by newrelic.

the class ErrorAnalyzerImplTest method expectedThrowableFollowsAnyCause.

@Test
public void expectedThrowableFollowsAnyCause() {
    ErrorCollectorConfig config = new TestErrorCollectorConfig().setExpectedErrors(new ExpectedErrorConfigImpl(MyThrowable.class.getName(), null));
    ErrorAnalyzer target = new ErrorAnalyzerImpl(config);
    assertTrue(target.isExpectedError(HTTP_OK, wrap(new MyThrowable("message"))));
    assertTrue(target.isExpectedError(HTTP_OK, wrap(new Exception("other", new MyThrowable("message")))));
    assertFalse(target.isExpectedError(HTTP_OK, wrap(new Exception("other"))));
}
Also used : ErrorCollectorConfig(com.newrelic.agent.config.ErrorCollectorConfig) ExpectedErrorConfigImpl(com.newrelic.agent.config.ExpectedErrorConfigImpl) Test(org.junit.Test)

Example 3 with ExpectedErrorConfigImpl

use of com.newrelic.agent.config.ExpectedErrorConfigImpl in project newrelic-java-agent by newrelic.

the class ErrorAnalyzerImplTest method expectStatusCodeOrThrowable.

@Test
public void expectStatusCodeOrThrowable() {
    ErrorCollectorConfig config = new TestErrorCollectorConfig().setExpectedStatusCodes(HTTP_BAD_REQUEST, HTTP_ACCEPTED).setExpectedErrors(new ExpectedErrorConfigImpl(MyThrowable.class.getName(), null), new ExpectedErrorConfigImpl(RuntimeException.class.getName(), "ignore_token"));
    ErrorAnalyzer target = new ErrorAnalyzerImpl(config);
    // neither status nor throwable are ignored.
    assertFalse(target.isExpectedError(HTTP_OK, null));
    assertFalse(target.isExpectedError(HTTP_OK, wrap(new RuntimeException("not ignored"))));
    assertFalse(target.isExpectedError(HTTP_OK, wrap(new RuntimeException((String) null))));
    // only the throwable is ignored.
    assertTrue(target.isExpectedError(HTTP_OK, wrap(new MyThrowable("message"))));
    assertTrue(target.isExpectedError(HTTP_OK, wrap(new MyThrowable(null))));
    assertTrue(target.isExpectedError(HTTP_OK, wrap(new RuntimeException("ignore_token"))));
    // only the status is ignored
    assertTrue(target.isExpectedError(HTTP_BAD_REQUEST, null));
    assertTrue(target.isExpectedError(HTTP_BAD_REQUEST, wrap(new RuntimeException("not ignored"))));
    assertTrue(target.isExpectedError(HTTP_BAD_REQUEST, wrap(new RuntimeException((String) null))));
    // both status and throwable are ignored
    assertTrue(target.isExpectedError(HTTP_BAD_REQUEST, wrap(new MyThrowable("message"))));
    assertTrue(target.isExpectedError(HTTP_BAD_REQUEST, wrap(new MyThrowable(null))));
    assertTrue(target.isExpectedError(HTTP_BAD_REQUEST, wrap(new RuntimeException("ignore_token"))));
}
Also used : ErrorCollectorConfig(com.newrelic.agent.config.ErrorCollectorConfig) ExpectedErrorConfigImpl(com.newrelic.agent.config.ExpectedErrorConfigImpl) Test(org.junit.Test)

Aggregations

ErrorCollectorConfig (com.newrelic.agent.config.ErrorCollectorConfig)3 ExpectedErrorConfigImpl (com.newrelic.agent.config.ExpectedErrorConfigImpl)3 Test (org.junit.Test)3