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 index 6d49444ca628..afebe99b68a5 100644 --- 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 @@ -27,7 +27,7 @@ @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") +@JvmArgument("-Dprofiler.log4j.logging.pattern.full_replace.with=Log4jIT TxId:%X{PtxId} %m") public class Log4jFullReplaceIT extends Log4jTestBase { @Test @@ -38,7 +38,7 @@ public void test() { @Test public void patternUpdate() { String log = checkPatternReplace(); - Assertions.assertTrue(log.contains("IT"), "contains full-replace string IT"); + Assertions.assertTrue(log.contains("Log4jIT"), "contains full-replace string Log4jIT"); } } diff --git a/agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4J2PatternTestIT.java b/agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4J2PatternTestIT.java new file mode 100644 index 000000000000..110715c24c50 --- /dev/null +++ b/agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4J2PatternTestIT.java @@ -0,0 +1,41 @@ +/* + * Copyright 2021 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.log4j2; + +import com.navercorp.pinpoint.it.plugin.utils.AgentPath; +import com.navercorp.pinpoint.it.plugin.utils.PluginITConstants; +import com.navercorp.pinpoint.test.plugin.Dependency; +import com.navercorp.pinpoint.test.plugin.JvmArgument; +import com.navercorp.pinpoint.test.plugin.JvmVersion; +import com.navercorp.pinpoint.test.plugin.PinpointAgent; +import com.navercorp.pinpoint.test.plugin.PinpointConfig; +import com.navercorp.pinpoint.test.plugin.PluginForkedTest; +import org.junit.jupiter.api.Test; + +@PluginForkedTest +@PinpointAgent(AgentPath.PATH) +@PinpointConfig("pinpoint-spring-bean-test.config") +@JvmVersion(8) +@Dependency({"org.apache.logging.log4j:log4j-core:[2.17.1,2.20)", PluginITConstants.VERSION}) +@JvmArgument("-DtestLoggerEnable=false") +public class Log4J2PatternTestIT extends Log4j2PatternTestBase { + + @Test + public void patternUpdate() { + checkPatternUpdate(); + } + +} diff --git a/agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4j2Pattern_2_20_IT.java b/agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4J2Pattern_2_20_ITTest.java similarity index 54% rename from agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4j2Pattern_2_20_IT.java rename to agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4J2Pattern_2_20_ITTest.java index d5a6ccd196c8..278b5a38df6b 100644 --- a/agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4j2Pattern_2_20_IT.java +++ b/agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4J2Pattern_2_20_ITTest.java @@ -17,16 +17,12 @@ import com.navercorp.pinpoint.it.plugin.utils.AgentPath; import com.navercorp.pinpoint.it.plugin.utils.PluginITConstants; -import com.navercorp.pinpoint.it.plugin.utils.StdoutRecorder; import com.navercorp.pinpoint.test.plugin.Dependency; import com.navercorp.pinpoint.test.plugin.JvmArgument; import com.navercorp.pinpoint.test.plugin.JvmVersion; import com.navercorp.pinpoint.test.plugin.PinpointAgent; import com.navercorp.pinpoint.test.plugin.PinpointConfig; import com.navercorp.pinpoint.test.plugin.PluginForkedTest; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @PluginForkedTest @@ -35,32 +31,11 @@ @JvmVersion(11) @Dependency({"org.apache.logging.log4j:log4j-core:[2.20,2.22]", PluginITConstants.VERSION}) @JvmArgument("-DtestLoggerEnable=false") -public class Log4j2Pattern_2_20_IT extends Log4j2TestBase { +public class Log4J2Pattern_2_20_ITTest extends Log4j2PatternTestBase { - private String location; @Test public void patternUpdate() { - final String msg = "pattern"; - - StdoutRecorder stdoutRecorder = new StdoutRecorder(); - String log = stdoutRecorder.record(new Runnable() { - @Override - public void run() { - Logger logger = LogManager.getLogger("patternUpdateLog4j2Jvm7"); - logger.error(msg); - location = getLoggerJarLocation(logger); - } - }); - - System.out.println(log); - Assertions.assertNotNull(log, "log null"); - Assertions.assertTrue(log.contains(msg), "contains msg"); - Assertions.assertTrue(log.contains("TxId"), "contains TxId"); - - Assertions.assertNotNull(location, "location null"); - System.out.println("Log4j2 jar location:" + location); - final String testVersion = getTestVersion(); - Assertions.assertTrue(location.contains("/" + testVersion + "/"), "test version is not " + getTestVersion()); + checkPatternUpdate(); } } diff --git a/agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4j2PatternIT.java b/agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4j2PatternTestBase.java similarity index 66% rename from agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4j2PatternIT.java rename to agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4j2PatternTestBase.java index 76dc4477d17d..700d5ab30cc9 100644 --- a/agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4j2PatternIT.java +++ b/agent-module/plugins-it/log4j2-it/src/test/java/com/navercorp/pinpoint/it/plugin/log4j2/Log4j2PatternTestBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 NAVER Corp. + * 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. @@ -15,31 +15,16 @@ */ package com.navercorp.pinpoint.it.plugin.log4j2; -import com.navercorp.pinpoint.it.plugin.utils.AgentPath; -import com.navercorp.pinpoint.it.plugin.utils.PluginITConstants; import com.navercorp.pinpoint.it.plugin.utils.StdoutRecorder; -import com.navercorp.pinpoint.test.plugin.Dependency; -import com.navercorp.pinpoint.test.plugin.JvmArgument; -import com.navercorp.pinpoint.test.plugin.JvmVersion; -import com.navercorp.pinpoint.test.plugin.PinpointAgent; -import com.navercorp.pinpoint.test.plugin.PinpointConfig; -import com.navercorp.pinpoint.test.plugin.PluginForkedTest; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -@PluginForkedTest -@PinpointAgent(AgentPath.PATH) -@PinpointConfig("pinpoint-spring-bean-test.config") -@JvmVersion(8) -@Dependency({"org.apache.logging.log4j:log4j-core:[2.17.1,2.20)", PluginITConstants.VERSION}) -@JvmArgument("-DtestLoggerEnable=false") -public class Log4j2PatternIT extends Log4j2TestBase { +public class Log4j2PatternTestBase extends Log4j2TestBase { private String location; - @Test - public void patternUpdate() { + + public void checkPatternUpdate() { final String msg = "pattern"; StdoutRecorder stdoutRecorder = new StdoutRecorder();