Skip to content

Commit 32c7d37

Browse files
authored
[ISSUE #5205]Enable checkstyle for test code (rocketmq-logging) (#5258)
1 parent 294e263 commit 32c7d37

File tree

7 files changed

+30
-14
lines changed

7 files changed

+30
-14
lines changed

logging/pom.xml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
limitations under the License.
1616
-->
1717

18-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1920
<parent>
2021
<groupId>org.apache.rocketmq</groupId>
2122
<artifactId>rocketmq-all</artifactId>
@@ -44,4 +45,29 @@
4445
</dependency>
4546
</dependencies>
4647

48+
<build>
49+
<plugins>
50+
<plugin>
51+
<artifactId>maven-checkstyle-plugin</artifactId>
52+
<version>${maven-checkstyle-plugin.version}</version>
53+
<executions>
54+
<execution>
55+
<id>validate</id>
56+
<phase>validate</phase>
57+
<configuration>
58+
<configLocation>${project.parent.basedir}/style/rmq_checkstyle.xml</configLocation>
59+
<inputEncoding>UTF-8</inputEncoding>
60+
<consoleOutput>true</consoleOutput>
61+
<failsOnError>true</failsOnError>
62+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
63+
</configuration>
64+
<goals>
65+
<goal>check</goal>
66+
</goals>
67+
</execution>
68+
</executions>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
4773
</project>

logging/src/test/java/org/apache/rocketmq/logging/InnerLoggerFactoryTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public void testInnerLoggerFactory() {
8282
logger3.debug("debug {}", "hahahah");
8383

8484
String content = new String(byteArrayOutputStream.toByteArray());
85-
System.out.println(content);
8685

8786
Assert.assertTrue(content.contains("InnerLoggerFactoryTest"));
8887
Assert.assertTrue(content.contains("info"));

logging/src/test/java/org/apache/rocketmq/logging/inner/AppenderTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ public void testInnerFile() throws IOException {
9191

9292
String content = readFile(file);
9393

94-
System.out.println(content);
95-
9694
Assert.assertTrue(content.contains("info"));
9795
Assert.assertTrue(content.contains("RuntimeException"));
9896
Assert.assertTrue(!content.contains("debug"));

logging/src/test/java/org/apache/rocketmq/logging/inner/LayoutTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,5 @@ public void testLogFormat() {
4848
LoggingEvent loggingEvent = new LoggingEvent(Logger.class.getName(), logger, org.apache.rocketmq.logging.inner.Level.INFO,
4949
"junit test error", null);
5050
String format = innerLayout.format(loggingEvent);
51-
52-
System.out.println(format);
5351
}
5452
}

logging/src/test/java/org/apache/rocketmq/logging/inner/LevelTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public void levelTest() {
3030
}
3131

3232
@Test
33-
public void loggerLevel(){
33+
public void loggerLevel() {
3434
Level level = Logger.getRootLogger().getLevel();
35-
Assert.assertTrue(level!=null);
35+
Assert.assertTrue(level != null);
3636
}
3737
}

logging/src/test/java/org/apache/rocketmq/logging/inner/LoggerTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ public void testInnerConsoleLogger() throws IOException {
6666

6767
String result = new String(byteArrayOutputStream.toByteArray());
6868

69-
System.out.println(result);
70-
7169
Assert.assertTrue(result.contains("info"));
7270
Assert.assertTrue(result.contains("RuntimeException"));
7371
Assert.assertTrue(result.contains("WATERMARK"));
@@ -101,8 +99,6 @@ public void testInnerFileLogger() throws IOException {
10199

102100
String content = readFile(file);
103101

104-
System.out.println(content);
105-
106102
Assert.assertTrue(content.contains("info"));
107103
Assert.assertTrue(content.contains("RuntimeException"));
108104
Assert.assertTrue(!content.contains("debug"));

logging/src/test/java/org/apache/rocketmq/logging/inner/MessageFormatterTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525
public class MessageFormatterTest {
2626

2727
@Test
28-
public void formatTest(){
28+
public void formatTest() {
2929
InnerLoggerFactory.FormattingTuple logging = InnerLoggerFactory.MessageFormatter.format("this is {},and {}", "logging", 6546);
3030
String message = logging.getMessage();
3131
Assert.assertTrue(message.contains("logging"));
3232

3333
InnerLoggerFactory.FormattingTuple format = InnerLoggerFactory.MessageFormatter.format("cause exception {}", 143545, new RuntimeException());
3434
String message1 = format.getMessage();
3535
Throwable throwable = format.getThrowable();
36-
System.out.println(message1);
3736
Assert.assertTrue(throwable != null);
3837
}
3938

0 commit comments

Comments
 (0)