use of com.puppycrawl.tools.checkstyle.internal.testmodules.DebugFilter in project checkstyle by checkstyle.
the class CheckerTest method testAddFilter.
@Test
public void testAddFilter() {
final Checker checker = new Checker();
final DebugFilter filter = new DebugFilter();
checker.addFilter(filter);
filter.resetFilter();
final SortedSet<Violation> violations = new TreeSet<>();
violations.add(new Violation(1, 0, "a Bundle", "message.key", new Object[] { "arg" }, null, getClass(), null));
checker.fireErrors("Some File Name", violations);
assertWithMessage("Checker.fireErrors() doesn't call filter").that(filter.wasCalled()).isTrue();
}
use of com.puppycrawl.tools.checkstyle.internal.testmodules.DebugFilter in project checkstyle by checkstyle.
the class CheckerTest method testDestroy.
@Test
public void testDestroy() throws Exception {
final Checker checker = new Checker();
final DebugAuditAdapter auditAdapter = new DebugAuditAdapter();
checker.addListener(auditAdapter);
final TestFileSetCheck fileSet = new TestFileSetCheck();
checker.addFileSetCheck(fileSet);
final DebugFilter filter = new DebugFilter();
checker.addFilter(filter);
final TestBeforeExecutionFileFilter fileFilter = new TestBeforeExecutionFileFilter();
checker.addBeforeExecutionFileFilter(fileFilter);
// should remove all listeners, file sets, and filters
checker.destroy();
final File tempFile = File.createTempFile("junit", null, temporaryFolder);
checker.process(Collections.singletonList(tempFile));
final SortedSet<Violation> violations = new TreeSet<>();
violations.add(new Violation(1, 0, "a Bundle", "message.key", new Object[] { "arg" }, null, getClass(), null));
checker.fireErrors("Some File Name", violations);
assertWithMessage("Checker.destroy() doesn't remove listeners.").that(auditAdapter.wasCalled()).isFalse();
assertWithMessage("Checker.destroy() doesn't remove file sets.").that(fileSet.wasCalled()).isFalse();
assertWithMessage("Checker.destroy() doesn't remove filters.").that(filter.wasCalled()).isFalse();
assertWithMessage("Checker.destroy() doesn't remove file filters.").that(fileFilter.wasCalled()).isFalse();
}
use of com.puppycrawl.tools.checkstyle.internal.testmodules.DebugFilter in project checkstyle by checkstyle.
the class CheckerTest method testRemoveFilter.
@Test
public void testRemoveFilter() {
final Checker checker = new Checker();
final DebugFilter filter = new DebugFilter();
final DebugFilter f2 = new DebugFilter();
checker.addFilter(filter);
checker.addFilter(f2);
checker.removeFilter(filter);
f2.resetFilter();
final SortedSet<Violation> violations = new TreeSet<>();
violations.add(new Violation(1, 0, "a Bundle", "message.key", new Object[] { "arg" }, null, getClass(), null));
checker.fireErrors("Some File Name", violations);
assertWithMessage("Checker.fireErrors() doesn't call filter").that(f2.wasCalled()).isTrue();
assertWithMessage("Checker.fireErrors() does call removed filter").that(filter.wasCalled()).isFalse();
}
Aggregations