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