use of com.puppycrawl.tools.checkstyle.internal.testmodules.TestLoggingReporter in project checkstyle by checkstyle.
the class RegexpMultilineCheckTest method testStateIsBeingReset.
/**
* Done as a UT cause new instance of Detector is created each time 'verify' executed.
*
* @throws Exception some Exception
*/
@Test
public void testStateIsBeingReset() throws Exception {
final TestLoggingReporter reporter = new TestLoggingReporter();
final DetectorOptions detectorOptions = DetectorOptions.newBuilder().reporter(reporter).format("\\r").maximum(1).build();
final MultilineDetector detector = new MultilineDetector(detectorOptions);
final File file = File.createTempFile("junit", null, temporaryFolder);
Files.write(file.toPath(), "first line \r\n second line \n\r third line".getBytes(StandardCharsets.UTF_8));
detector.processLines(new FileText(file, StandardCharsets.UTF_8.name()));
detector.processLines(new FileText(file, StandardCharsets.UTF_8.name()));
assertWithMessage("Logged unexpected amount of issues").that(reporter.getLogCount()).isEqualTo(2);
}
use of com.puppycrawl.tools.checkstyle.internal.testmodules.TestLoggingReporter in project checkstyle by checkstyle.
the class RegexpSinglelineCheckTest method testStateIsBeingReset.
/**
* Done as a UT cause new instance of Detector is created each time 'verify' executed.
*
* @throws Exception some Exception
*/
@Test
public void testStateIsBeingReset() throws Exception {
final String illegal = "System\\.(out)|(err)\\.print(ln)?\\(";
final TestLoggingReporter reporter = new TestLoggingReporter();
final DetectorOptions detectorOptions = DetectorOptions.newBuilder().reporter(reporter).format(illegal).maximum(1).build();
final SinglelineDetector detector = new SinglelineDetector(detectorOptions);
final File file = new File(getPath("InputRegexpSinglelineSemantic8.java"));
detector.processLines(new FileText(file, StandardCharsets.UTF_8.name()));
detector.processLines(new FileText(file, StandardCharsets.UTF_8.name()));
assertWithMessage("Logged unexpected amount of issues").that(reporter.getLogCount()).isEqualTo(0);
}
Aggregations