use of com.newrelic.agent.config.IgnoreErrorConfigImpl in project newrelic-java-agent by newrelic.
the class ErrorAnalyzerImplTest method ignoredThrowableFollowsAnyCause.
@Test
public void ignoredThrowableFollowsAnyCause() {
ErrorCollectorConfig config = new TestErrorCollectorConfig().setIgnoreErrors(new IgnoreErrorConfigImpl(MyThrowable.class.getName(), null));
ErrorAnalyzer target = new ErrorAnalyzerImpl(config);
assertTrue(target.isIgnoredThrowable(new MyThrowable("message")));
assertTrue(target.isIgnoredThrowable(new Exception("other", new MyThrowable("message"))));
assertFalse(target.isIgnoredThrowable(new Exception("other")));
}
use of com.newrelic.agent.config.IgnoreErrorConfigImpl in project newrelic-java-agent by newrelic.
the class ErrorAnalyzerImplTest method ignoredThrowableFollowsConfig.
@Test
public void ignoredThrowableFollowsConfig() {
ErrorCollectorConfig config = new TestErrorCollectorConfig().setIgnoreErrors(new IgnoreErrorConfigImpl(MyThrowable.class.getName(), null), new IgnoreErrorConfigImpl(RuntimeException.class.getName(), "ignore_token"));
ErrorAnalyzer target = new ErrorAnalyzerImpl(config);
assertTrue(target.isIgnoredThrowable(new MyThrowable("message")));
assertTrue(target.isIgnoredThrowable(new MyThrowable(null)));
assertTrue(target.isIgnoredThrowable(new RuntimeException("ignore_token")));
assertFalse(target.isIgnoredThrowable(new RuntimeException("not ignored")));
assertFalse(target.isIgnoredThrowable(new RuntimeException((String) null)));
}
use of com.newrelic.agent.config.IgnoreErrorConfigImpl in project newrelic-java-agent by newrelic.
the class ErrorAnalyzerImplTest method ignoreStatusCodeOrThrowable.
@Test
public void ignoreStatusCodeOrThrowable() {
ErrorCollectorConfig config = new TestErrorCollectorConfig().setIgnoreStatusCodes(HTTP_BAD_REQUEST, HTTP_ACCEPTED).setIgnoreErrors(new IgnoreErrorConfigImpl(MyThrowable.class.getName(), null), new IgnoreErrorConfigImpl(RuntimeException.class.getName(), "ignore_token"));
ErrorAnalyzer target = new ErrorAnalyzerImpl(config);
// neither status nor throwable are ignored.
assertFalse(target.isIgnoredError(HTTP_OK, null));
assertFalse(target.isIgnoredError(HTTP_OK, new RuntimeException("not ignored")));
assertFalse(target.isIgnoredError(HTTP_OK, new RuntimeException((String) null)));
// only the throwable is ignored.
assertTrue(target.isIgnoredError(HTTP_OK, new MyThrowable("message")));
assertTrue(target.isIgnoredError(HTTP_OK, new MyThrowable(null)));
assertTrue(target.isIgnoredError(HTTP_OK, new RuntimeException("ignore_token")));
// only the status is ignored
assertTrue(target.isIgnoredError(HTTP_BAD_REQUEST, null));
assertTrue(target.isIgnoredError(HTTP_BAD_REQUEST, new RuntimeException("not ignored")));
assertTrue(target.isIgnoredError(HTTP_BAD_REQUEST, new RuntimeException((String) null)));
// both status and throwable are ignored
assertTrue(target.isIgnoredError(HTTP_BAD_REQUEST, new MyThrowable("message")));
assertTrue(target.isIgnoredError(HTTP_BAD_REQUEST, new MyThrowable(null)));
assertTrue(target.isIgnoredError(HTTP_BAD_REQUEST, new RuntimeException("ignore_token")));
}
Aggregations