use of com.puppycrawl.tools.checkstyle.api.LocalizedMessage in project checkstyle by checkstyle.
the class SuppressElementTest method testDecideByFileNameAndModuleMatchingModuleNull.
@Test
public void testDecideByFileNameAndModuleMatchingModuleNull() {
final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, "MyModule", getClass(), null);
final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
filter.setModuleId(null);
assertFalse(filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.LocalizedMessage in project checkstyle by checkstyle.
the class SuppressElementTest method testDecideByFileNameAndModuleMatchingFileNameNull.
@Test
public void testDecideByFileNameAndModuleMatchingFileNameNull() {
final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, null, message);
assertTrue(filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.LocalizedMessage in project checkstyle by checkstyle.
the class XMLLoggerTest method testAddException.
@Test
public void testAddException() throws IOException {
final XMLLogger logger = new XMLLogger(outStream, true);
logger.auditStarted(null);
final LocalizedMessage message = new LocalizedMessage(1, 1, "messages.properties", null, null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "Test.java", message);
logger.addException(ev, new TestException("msg", new RuntimeException("msg")));
logger.auditFinished(null);
final String[] expectedLines = { "<exception>", "<![CDATA[", "stackTrace]]>", "</exception>", "" };
verifyLines(expectedLines);
}
use of com.puppycrawl.tools.checkstyle.api.LocalizedMessage in project checkstyle by checkstyle.
the class XMLLoggerTest method testAddErrorOnZeroColumns.
@Test
public void testAddErrorOnZeroColumns() throws IOException {
final XMLLogger logger = new XMLLogger(outStream, true);
logger.auditStarted(null);
final LocalizedMessage message = new LocalizedMessage(1, 0, "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\" severity=\"error\" message=\"key\"" + " source=\"com.puppycrawl.tools.checkstyle.XMLLoggerTest\"/>" };
verifyLines(expectedLines);
}
use of com.puppycrawl.tools.checkstyle.api.LocalizedMessage in project checkstyle by checkstyle.
the class PackageObjectFactory method createModule.
/**
* Creates a new instance of a class from a given name, or that name
* concatenated with "Check". If the name is
* a class name, creates an instance of the named class. Otherwise, creates
* an instance of a class name obtained by concatenating the given name
* to a package name from a given list of package names.
* @param name the name of a class.
* @return the {@code Object} created by loader.
* @throws CheckstyleException if an error occurs.
*/
@Override
public Object createModule(String name) throws CheckstyleException {
Object instance = createObjectFromMap(name);
if (instance == null) {
instance = createObjectWithIgnoringProblems(name, getAllPossibleNames(name));
}
if (instance == null) {
final String nameCheck = name + CHECK_SUFFIX;
instance = createObjectWithIgnoringProblems(nameCheck, getAllPossibleNames(nameCheck));
if (instance == null) {
final String attemptedNames = joinPackageNamesWithClassName(name, packages) + STRING_SEPARATOR + nameCheck + STRING_SEPARATOR + joinPackageNamesWithClassName(nameCheck, packages);
final LocalizedMessage exceptionMessage = new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, UNABLE_TO_INSTANTIATE_EXCEPTION_MESSAGE, new String[] { name, attemptedNames }, null, getClass(), null);
throw new CheckstyleException(exceptionMessage.getMessage());
}
}
return instance;
}
Aggregations