use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class XMLLoggerTest method testAddErrorOnZeroColumns.
@Test
public void testAddErrorOnZeroColumns() throws Exception {
final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE);
logger.auditStarted(null);
final Violation violation = new Violation(1, 0, "messages.properties", "key", null, SeverityLevel.ERROR, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "Test.java", violation);
logger.fileStarted(ev);
logger.addError(ev);
logger.fileFinished(ev);
logger.auditFinished(null);
verifyXml(getPath("ExpectedXMLLoggerErrorZeroColumn.xml"), outStream, violation.getViolation());
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class XMLLoggerTest method testAddExceptionAfterFileStarted.
@Test
public void testAddExceptionAfterFileStarted() throws Exception {
final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE);
logger.auditStarted(null);
final AuditEvent fileStartedEvent = new AuditEvent(this, "Test.java");
logger.fileStarted(fileStartedEvent);
final Violation violation = new Violation(1, 1, "messages.properties", null, null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "Test.java", violation);
logger.addException(ev, new TestException("msg", new RuntimeException("msg")));
logger.fileFinished(ev);
logger.auditFinished(null);
verifyXml(getPath("ExpectedXMLLoggerException2.xml"), outStream);
assertWithMessage("Invalid close count").that(outStream.getCloseCount()).isEqualTo(1);
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class XMLLoggerTest method testAddErrorModuleId.
@Test
public void testAddErrorModuleId() throws Exception {
final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE);
logger.auditStarted(null);
final Violation violation = new Violation(1, 1, "messages.properties", "key", null, SeverityLevel.ERROR, "module", getClass(), null);
final AuditEvent ev = new AuditEvent(this, "Test.java", violation);
logger.addError(ev);
logger.auditFinished(null);
verifyXml(getPath("ExpectedXMLLoggerErrorModuleId.xml"), outStream, violation.getViolation());
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class XMLLoggerTest method testAddExceptionWithNullFileName.
@Test
public void testAddExceptionWithNullFileName() throws Exception {
final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE);
logger.auditStarted(null);
final Violation violation = new Violation(1, 1, "messages.properties", null, null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, null, violation);
logger.addException(ev, new TestException("msg", new RuntimeException("msg")));
logger.auditFinished(null);
verifyXml(getPath("ExpectedXMLLoggerExceptionNullFileName.xml"), outStream);
assertWithMessage("Invalid close count").that(outStream.getCloseCount()).isEqualTo(1);
}
use of com.puppycrawl.tools.checkstyle.api.Violation in project checkstyle by checkstyle.
the class XpathFileGeneratorAuditListenerTest method testAddException.
@Test
public void testAddException() {
final OutputStream out = new ByteArrayOutputStream();
final XpathFileGeneratorAuditListener logger = new XpathFileGeneratorAuditListener(out, AutomaticBean.OutputStreamOptions.CLOSE);
logger.auditStarted(null);
final Violation violation = new Violation(1, 1, "messages.properties", null, null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "Test.java", violation);
try {
logger.addException(ev, null);
assertWithMessage("Exception is excepted").fail();
} catch (UnsupportedOperationException ex) {
assertWithMessage("Invalid exception message").that(ex.getMessage()).isEqualTo("Operation is not supported");
}
}
Aggregations