use of com.puppycrawl.tools.checkstyle.internal.testmodules.TestFileSetCheck 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();
}
Aggregations