Skip to content

Commit 860feae

Browse files
committed
[#11290] logback-it, add test for full-pattern replacement
1 parent 2e311a8 commit 860feae

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2024 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.it.plugin.logback;
17+
18+
import com.navercorp.pinpoint.it.plugin.utils.AgentPath;
19+
import com.navercorp.pinpoint.it.plugin.utils.PluginITConstants;
20+
import com.navercorp.pinpoint.test.plugin.*;
21+
import org.junit.jupiter.api.Assertions;
22+
import org.junit.jupiter.api.Test;
23+
24+
@PluginForkedTest
25+
@PinpointAgent(AgentPath.PATH)
26+
@Dependency({"ch.qos.logback:logback-classic:[1.0.13],[1.1.0,1.1.11],[1.2.0,1.2.6]", "org.slf4j:slf4j-api:1.7.12", PluginITConstants.VERSION})
27+
@ImportPlugin({"com.navercorp.pinpoint:pinpoint-logback-plugin"})
28+
@PinpointConfig("pinpoint-spring-bean-test.config")
29+
@JvmArgument({"-DtestLoggerEnable=false", "-Dprofiler.logback.logging.pattern.full_replace.with=%d{yyyy-MM-dd HH:mm:ss} [%p] [%t] %c [TxId:%X{PtxId} ReqId:%X{PreqId}] -LogbackIT- %m%n"})
30+
@TransformInclude("org.slf4j.")
31+
public class LogbackPatternFullReplaceIT extends LogbackTestBase {
32+
33+
@Test
34+
public void test() {
35+
checkMDC();
36+
}
37+
38+
@Test
39+
public void patternUpdate() {
40+
String log = checkPatternUpdate();
41+
Assertions.assertTrue(log.contains("-LogbackIT-"), "contains full-replace string LogbackIT");
42+
}
43+
44+
}

agent-module/plugins-it/logback-it/src/test/java/com/navercorp/pinpoint/it/plugin/logback/LogbackTestBase.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected void checkMDC() {
3737

3838
private Logger logger;
3939

40-
protected void checkPatternUpdate() {
40+
protected String checkPatternUpdate() {
4141

4242
final String msg = "pattern";
4343
StdoutRecorder stdoutRecorder = new StdoutRecorder();
@@ -58,6 +58,7 @@ public void run() {
5858

5959
Assertions.assertNotNull(logger, "logger null");
6060
checkVersion(logger);
61+
return log;
6162
}
6263

6364
private void checkVersion(Logger logger) {

0 commit comments

Comments
 (0)