diff --git a/agent-module/plugins-it/log4j-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j/Log4jFullReplaceIT.java b/agent-module/plugins-it/log4j-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j/Log4jFullReplaceIT.java new file mode 100644 index 000000000000..6d49444ca628 --- /dev/null +++ b/agent-module/plugins-it/log4j-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j/Log4jFullReplaceIT.java @@ -0,0 +1,44 @@ +/* + * Copyright 2024 NAVER Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.navercorp.pinpoint.it.plugin.log4j; + +import com.navercorp.pinpoint.it.plugin.utils.AgentPath; +import com.navercorp.pinpoint.it.plugin.utils.PluginITConstants; +import com.navercorp.pinpoint.test.plugin.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +@PluginForkedTest +@PinpointAgent(AgentPath.PATH) +@Dependency({"log4j:log4j:[1.2.16,)", PluginITConstants.VERSION}) +@ImportPlugin({"com.navercorp.pinpoint:pinpoint-log4j-plugin"}) +@PinpointConfig("pinpoint-spring-bean-test.config") +@TransformInclude("org.apache.log4j.") +@JvmArgument("-Dprofiler.log4j.logging.pattern.full_replace.with=IT TxId:%X{PtxId} %m") +public class Log4jFullReplaceIT extends Log4jTestBase { + + @Test + public void test() { + checkMDC(); + } + + @Test + public void patternUpdate() { + String log = checkPatternReplace(); + Assertions.assertTrue(log.contains("IT"), "contains full-replace string IT"); + } + +} diff --git a/agent-module/plugins-it/log4j-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j/Log4jTestBase.java b/agent-module/plugins-it/log4j-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j/Log4jTestBase.java index 5337abeeee9d..ece857b3a0e0 100644 --- a/agent-module/plugins-it/log4j-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j/Log4jTestBase.java +++ b/agent-module/plugins-it/log4j-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j/Log4jTestBase.java @@ -34,7 +34,7 @@ protected void checkMDC() { Assertions.assertNotNull(MDC.get("PspanId"), "spanId"); } - protected void checkPatternReplace() { + protected String checkPatternReplace() { final String msg = "pattern"; @@ -54,6 +54,7 @@ public void run() { Assertions.assertNotNull(logger, "logger null"); checkVersion(logger); + return log; } private void checkVersion(Logger logger) {