Skip to content

Commit 4d19672

Browse files
committed
[pinpoint-apm#11290] log4j2-it, add test for full-pattern replacement
1 parent 092d5f4 commit 4d19672

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.log4j2;
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+
@PinpointConfig("pinpoint-spring-bean-test.config")
27+
@JvmVersion(8)
28+
@Dependency({"org.apache.logging.log4j:log4j-core:[2.17.1,2.20)", PluginITConstants.VERSION})
29+
@JvmArgument({"-DtestLoggerEnable=false", "-Dprofiler.log4j2.logging.pattern.full_replace.with=Log4j2IT TxId:%X{PtxId} %message"})
30+
public class Log4J2PatternFullReplaceTestIT extends Log4j2PatternTestBase {
31+
32+
@Test
33+
public void patternUpdate() {
34+
String log = checkPatternUpdate();
35+
Assertions.assertTrue(log.contains("Log4j2IT"), "contains full-replace string Log4j2IT");
36+
}
37+
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.log4j2;
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+
@PinpointConfig("pinpoint-spring-bean-test.config")
27+
@JvmVersion(11)
28+
@Dependency({"org.apache.logging.log4j:log4j-core:[2.20,2.22]", PluginITConstants.VERSION})
29+
@JvmArgument({"-DtestLoggerEnable=false", "-Dprofiler.log4j2.logging.pattern.full_replace.with=Log4j2IT TxId:%X{PtxId} %message"})
30+
public class Log4J2PatternFullReplace_2_20_ITTest extends Log4j2PatternTestBase {
31+
32+
@Test
33+
public void patternUpdate() {
34+
String log = checkPatternUpdate();
35+
Assertions.assertTrue(log.contains("Log4j2IT"), "contains full-replace string Log4j2IT");
36+
}
37+
38+
}

agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4j2PatternTestBase.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class Log4j2PatternTestBase extends Log4j2TestBase {
2424

2525
private String location;
2626

27-
public void checkPatternUpdate() {
27+
protected String checkPatternUpdate() {
2828
final String msg = "pattern";
2929

3030
StdoutRecorder stdoutRecorder = new StdoutRecorder();
@@ -46,6 +46,7 @@ public void run() {
4646
System.out.println("Log4j2 jar location:" + location);
4747
final String testVersion = getTestVersion();
4848
Assertions.assertTrue(location.contains("/" + testVersion + "/"), "test version is not " + getTestVersion());
49+
return log;
4950
}
5051

5152
}

0 commit comments

Comments
 (0)