use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class XMLLoggerTest method testAddError.
@Test
public void testAddError() throws IOException {
final XMLLogger logger = new XMLLogger(outStream, true);
logger.auditStarted(null);
final LocalizedMessage message = new LocalizedMessage(1, 1, "messages.properties", "key", null, SeverityLevel.ERROR, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "Test.java", message);
logger.addError(ev);
logger.auditFinished(null);
final String[] expectedLines = { "<error line=\"1\" column=\"1\" severity=\"error\" message=\"key\"" + " source=\"com.puppycrawl.tools.checkstyle.XMLLoggerTest\"/>" };
verifyLines(expectedLines);
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class XMLLoggerTest method testFileFinished.
@Test
public void testFileFinished() throws IOException {
final XMLLogger logger = new XMLLogger(outStream, true);
logger.auditStarted(null);
final AuditEvent ev = new AuditEvent(this, "Test.java");
logger.fileFinished(ev);
logger.auditFinished(null);
final String[] expectedLines = { "</file>" };
verifyLines(expectedLines);
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class XMLLoggerTest method testAddIgnored.
@Test
public void testAddIgnored() throws IOException {
final XMLLogger logger = new XMLLogger(outStream, true);
logger.auditStarted(null);
final LocalizedMessage message = new LocalizedMessage(1, 1, "messages.properties", "key", null, SeverityLevel.IGNORE, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "Test.java", message);
logger.addError(ev);
logger.auditFinished(null);
final String[] expectedLines = CommonUtils.EMPTY_STRING_ARRAY;
verifyLines(expectedLines);
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressionFilterTest method testNonExistanceSuppressionUrlWithTrueOptional.
@Test
public void testNonExistanceSuppressionUrlWithTrueOptional() throws Exception {
final String fileName = "http://checkstyle.sourceforge.net/non_existing_suppression.xml";
final boolean optional = true;
final SuppressionFilter filter = createSupressionFilter(fileName, optional);
final AuditEvent ev = new AuditEvent(this, "AnyFile.java", null);
assertTrue(filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressionFilterTest method testExistingConfigWithTrueOptionalThrowsIoErrorWhileClosing.
@Test
public void testExistingConfigWithTrueOptionalThrowsIoErrorWhileClosing() throws Exception {
final InputStream inputStream = PowerMockito.mock(InputStream.class);
Mockito.doThrow(IOException.class).when(inputStream).close();
final URL url = PowerMockito.mock(URL.class);
BDDMockito.given(url.openStream()).willReturn(inputStream);
final URI uri = PowerMockito.mock(URI.class);
BDDMockito.given(uri.toURL()).willReturn(url);
PowerMockito.mockStatic(CommonUtils.class);
final String fileName = "src/test/resources/com/puppycrawl/tools/checkstyle/filters/" + "suppressions_none.xml";
BDDMockito.given(CommonUtils.getUriByFilename(fileName)).willReturn(uri);
final boolean optional = true;
final SuppressionFilter filter = createSupressionFilter(fileName, optional);
final AuditEvent ev = new AuditEvent(this, "AnyFile.java", null);
assertTrue(filter.accept(ev));
}
Aggregations