X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Fcheckstyle-logging%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fcheckstyle%2FCheckstyleTest.java;h=9c0342355b4c7da6239ef2ba59d42da9e7fa81fa;hb=19c2c0edae38d93402d8c3912b8dae54e07b20db;hp=df132ab6a9ce295355053908e71246932a19a556;hpb=4a575b0bf11bfd39cd0169e63983c054b3760bce;p=yangtools.git diff --git a/common/checkstyle-logging/src/test/java/org/opendaylight/yangtools/checkstyle/CheckstyleTest.java b/common/checkstyle-logging/src/test/java/org/opendaylight/yangtools/checkstyle/CheckstyleTest.java index df132ab6a9..9c0342355b 100644 --- a/common/checkstyle-logging/src/test/java/org/opendaylight/yangtools/checkstyle/CheckstyleTest.java +++ b/common/checkstyle-logging/src/test/java/org/opendaylight/yangtools/checkstyle/CheckstyleTest.java @@ -11,7 +11,9 @@ package org.opendaylight.yangtools.checkstyle; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import com.google.common.base.Charsets; import com.google.common.collect.Lists; +import com.google.common.io.Files; import com.puppycrawl.tools.checkstyle.Checker; import com.puppycrawl.tools.checkstyle.ConfigurationLoader; import com.puppycrawl.tools.checkstyle.DefaultLogger; @@ -21,6 +23,7 @@ import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.Configuration; import java.io.ByteArrayOutputStream; import java.io.File; +import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -61,10 +64,20 @@ public class CheckstyleTest { "18: Logger might be declared only once", "17: Logger must be slf4j", "27: Log message placeholders count is incorrect", - "33: Log message placeholders count is incorrect", - "42: Log message contains string concatenation"); + "36: Log message placeholders count is incorrect", + "45: Log message contains string concatenation"); } + @Test + public void testLogMessageExtractorCheck() throws Exception { + File logMessageReport = LogMessageExtractorCheck.DEFAULT_REPORT_FILE; + logMessageReport.delete(); + verify(CheckLoggingTestClass.class, false); + List reportLines = Files.readLines(logMessageReport, Charsets.UTF_8); + assertEquals(6, reportLines.size()); + assertEquals("src/test/java/org/opendaylight/yangtools/checkstyle/CheckLoggingTestClass.java:27:\"foo {} {}\"", reportLines.get(0)); + // TODO assertEquals("src/test/java/org/opendaylight/yangtools/checkstyle/CheckLoggingTestClass.java:28:\"foo {} bar {}\"", reportLines.get(1)); + } private void verify(final Class testClass, final boolean checkCount, final String... expectedMessages) throws CheckstyleException { final String filePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "java" + File.separator + testClass.getName().replaceAll("\\.", "/") + ".java";